INTRODUZIONE A MICRO FRAMEWORK
Smart Personal Objects Technology (SPOT)
Dario AiroldiDeveloper & Platform Evangelism Italy
[email protected]://blogs.msdn.com/darioa
http://blogs.msdn.com/darioait
MissionFavorire la conoscenza e la diffusione delle tecnologie innovative, creare casi di utilizzo che rendano evidente il valore della piattaforma Microsoft.
Iniziative e attività: La redazione dei contenuti sul sito MSDN Italy. Newsletter e Webcast registrati Seminari e conferenze Incontri presso le aziende
http://www.microsoft.com/italy/msdn/contattaci/default.mspx
TEAM DEVELOPER & PLATFORM
Piccoli dispositivi elettronici controllati da microprocessori sono sempre più diffusi ma: Pochi tool ne supportano lo sviluppo Richiedono forti skill per fare cose semplici Sono realizzati con codice unmanaged
Microframework si propone per il mondo embedded come VB6 per lo sviluppo delle vecchie applicazioni desktop.
LA VISION DI MICRO FRAMEWORK
POSIZIONAMENTO DI MICRO FRAMEWORK
MF è un .Net Runtime piccolo per processori embedded 32bit, economici e a basso consuno
Ha Memory footprint ridotto (~256K RAM) Non richiede Memory Management Unit
Permette lo sviluppo embedded con Visual Studio 2005
L’ambiente Include un emulatore completo e funzionale
Permette lo sviluppo con linguaggio C# e .Net framework
Esegue codice managed controllato e sicuro
LE PIATTAFORME EMBEDDED DI MICROSOFT
Set-top boxes
Windows CE Windows XP Embedded
Windows Mobile Smartphone
Pocket PC Phone
WindowsAutomotive
Portable Media Center
VoIP phones
Mobile handhelds
Gateways
Retail Point-of-SaleWindows-based
Terminals
Medical devices Entertainment devices
.NET Micro Framework
Health Monitoring
Wearable Devices
Auxiliary Displays
Remote Controls
Sensor Networks
LE PIATTAFORME EMBEDDED A CONFRONTO
.NET Micro Framework Windows CE Windows XPe
Example Devices
Sensor Nodes, Aux displays, Health
Monitoring, Remote Controls, Robotics
GPS Handhelds, PDAs,Automotive, Set Top
BoxesThin Clients, ATMs, Kiosks
Features Connected, Small, Wearable, Graphical UI
Connected, Graphical UI, Server, Browser, RAS,
DirectX
PCclass performance,PC networking
Footprint250-500KB managed
codeFull featured
300KB+ without managed code
12MB with managed code
40MB + Depending on features
Power Very low power Low power Mains power
CPU ARM7, ARM9, No MMUX86, MIPS, SH4, ARM,
with MMUX86
Real-time Not Real-time Hard Real-timeReal-time capable through 3rd party
extensions
Managed vs. Native Code
Managed via .NET Micro Framework,
native code through interop only.
Supports both,managed code
requires .NET Compact Framework
Supports both, managed code
requires .NET Framework
UN PO’ DI STORIA2001 •Nasce Smart Personal Object Technology (SPOT)
•Nasce TinyCLR per supportare SPOT.
2004 •Escono gli SmartWatches con MSN Direct
2005 •Rilasciata Microsoft TV
2006 •Sumo Robot Kit alla Microsoft Mobile Embedded DevCon (MEDC)
2007 •Windows Vista Side Show
Microframework è: Bootable
Può eseguire boot autonomamente Può essere ospitato su sistemi operativi esistenti
Safe L’accesso alle risorse avviene tramite oggetti
Secure Utilizza assemblies firmati
Extensible A livello software ed Hardware
Portable Il Porting Kit permette di portarlo su HW non supportato
CARATTERISTICHE DI MICRO FRAMEWORK
RUNTIME FEATURES
Runtime grafico Windows Presentation Foundation (WPF): Graphics primitives BMP and JPG image support Text manipulation Unified Programming model covering All devices
Runtime engine: Thread support Garbage collection Globalized language support
Funzioni di interazione con l’hardware Managed drivers for LCDs Universal Asynchronous Receiver/Transmitter (USART) I2C™ General-purpose I/O (GPIO) Pulse-Width modulation (PWM)
TOOL DI SVILUPPO Microsoft Visual Studio 2005
Project System/templates PostBuild processing Intellisense support Deployment to device (seriale, usb o
emulatore) Debugging interattivo dall’IDE
(Breakpoints, tracing, variable inspection)
Device Emulator Personalizzabile per simulare la
configurazione delle periferiche
SCHEMA ARCHITETTURALE
Come bootable runtime supporta: ARM7TDMI @ 27MHz (384K RAM, 1M Flash) ARM7TDMI @ 50MHz (4M RAM, 2M Flash) ARM920T @ 96MHz (4M RAM, 2M Flash) ARM Cortex M3 Motorola 68K (implementazioni custom) …
Come hosted runtime supporta: Dual ARM7TDMI @100Mhz (32M RAM, 1G Flash)
NetOS/ThreadX per CONNECTME , WinCE Intel x86
Windows XP …
Il Porting a nuovi devices: Porting to new HW richiede 80-100 APIs Porting to new Platform richiede 20-40 APIs
PIATTAFORME SUPPORTATE
Web Site: “www.aboutnetmf.com”
Slide 13
ATTENDING PARTNERS
Create a new application and the graphical componentsDEMO: TRIPCOMPUTER SAMPLE
FRAMEWORK .NETSystem.web System.Windows.Forms
System.Drawing
System.XmlSystem.Data
System
Services• Description• Discovery• protocol
UI• HTML Controls• Web Controls
Cache
Configuration
Security
Session State
Design Component Model
Drawing 2D
Imaging
Printing
Text
ADO.Net
Design
SQL Client
SQL Server CE
XML Document
XslT/XPath
Serialization
Reader/Writers
Collections
Security
Text
Globalization
IO
Net
Reflection
Resources
Configuration
Service process
Diagnostics
Threading
Runtime• Interop Services• Remoting• Serialization
COMPACT FRAMEWORKSystem.web System.Windows.Forms
System.Drawing
System.XmlSystem.Data
System
Services• Description• Discovery• protocol
UI• HTML Controls• Web Controls
Cache
Configuration
Security
Session State
Design Component Model
Drawing 2D
Imaging
Printing
Text
ADO.Net
Design
SQL Client
SQL Server CE
XML Document
XslT/XPath
Serialization
Reader/Writers
Collections
Security
Text
Globalization
IO
Net
Reflection
Resources
Configuration
Service process
Diagnostics
Threading
Runtime• Interop Services• Remoting• Serialization
MICRO FRAMEWORKSystem.web System.Windows.Forms
System.Drawing
System.XmlSystem.Data
System
Services• Description• Discovery• protocol
UI• HTML Controls• Web Controls
Cache
Configuration
Security
Session State
Design Component Model
Drawing 2D
Imaging
Printing
Text
ADO.Net
Design
SQL Client
SQL Server CE
XML Document
XslT/XPath
Serialization
Reader/Writers
Collections
Security
Text
Globalization
IO
Net
Reflection
Resources
Configuration
Service process
Diagnostics
Threading
Runtime• Interop Services• Remoting• Serialization
Implementa un sottoinsieme delle core libraries
Permette diversi linguaggi di programmazione Rispetta Common Language Specification (CLS) Derivato da Common Language Infrastructure
(CLI) v1.0
Supporta Common Intermediate Language (CIL) Execution.
MICRO FRAMEWORK È UNA IMPLEMENTAZIONE .NET!
Serialization: Implementazione specifica per mf 60% più efficiente in spazio rispetto a .Net Framework
Remote Procedure Call (RPC) Implementazione specifica per mf Permette di invocare metodi su oggetti remoti
Encryption: Supporta RSA algorithm (Asymmetrico) tramite la classe Key_RSA. supporta Extedned Tiny Encryption Algorithm (XTEA, symmetric)
tramite la classe Key_TinyEncryptionAlgorithm. Permette algoritmi custom derivando dalla classe Key.
Delegates: permette programmazione ad eventi invece che per polling.
Exception handling Reflection
NOTE SULLA IMPLEMENTAZIONE DEL RUNTIME
RUNTIME FEATURES – DETTAGLIO
Funzioni disponibili includono:
•Numeric types, class types, value types, arrays (one-dimensional only), delegates, events, references, and weak references •Synchronization, threads, and timers •Reflection •Serialization•Garbage collection •Exception handling •Time classes, including DateTime and TimeSpan (using INT64 arithmetic) •Time-sliced thread management
Funzioni progettate per
microframework:•Execution constraints that limit call durations and prevent failures. •Strings represented internally as UTF-8 and exposed as Unicode. •A global, shared string table for well-known values (types, methods, and fields) that reduces RAM and ROM and reduces the number of cross-references among assemblies. •method resolution no virtual tables. •A WeakDelegate class to handle dangling references to delegates. •Support for extending the hardware chipset by programming its drivers directly in C#, using the Managed Drivers Framework. Hardware devices compatible with industry communication standards — such as GPIO, serial, SPI, or I2C — can be added to the chipset and used by a managed C# application.
DEMO THE TRIPCOMPUTER SAMPLEAdd the clock and other trip control features to the
TripComputer
Object model Basato su Windows Presentation foundation (WPF) Supporta routed events e context
properties Supporta layout system (content
sizing, text flow, nested controls) Supporta bitmap fonts Gestisce Images Gestisce Pens, brushes, colors Gestisce Vector primitives Gestisce Alpha blending
RUNTIME GRAFICO
Permette il boot del runtime Permette una astrazione delle risorse Gestisce gli interrupts Supporta asynchronous cooperative
multi-tasking. È realizzato tramite queued Workitems È compatto (Occupa 40K inclusi i base drivers)
HARDWARE ABSTRACTION LAYER
Assembly loader esegue validazione al caricamento degli
assemblies. registra i tipi con il type system (in tabella globale
dei tipi) Microsoft Intermediate Language (MSIL)
interpreter Supporta TUTTE le msil instructions (tranne le
istruzioni unsafe) È ottimizzato per minimizzare la latenza Permette esecuzione “virtuale pura”
LOADER ED INTERPRETER
Execution engine: No native thread scheduler Manages native work queues Invokes native code Permette non traditional interoperability
Garbage collector Non incremental Mark and Sweep. Colleziona 50ms per 1M, variabile a seconda del numero di
oggetti Supporto per storage non volatile. dispone di un meccanismo di persistenza di oggetti
EXECUTION ENGINE AND GARBAGE COLLECTOR
ROM/Flash footprint Runtime: ~120K Runtime + framework minimale: ~250K Runtime + framework completo: ~500K
RAM requirements ~70K system overhead ~256K per full-featured application
MICRO FRAMEWORK FOOTPRINT
Permette di gestire da codice managed (Managed drivers): General-purpose I/O (GPIO) pins Serial peripheral interface (SPI) bus Serial ports Universal Asynchronous Receiver/Transmitter (USART) I2C™ Pulse-Width modulation (PWM)
GPIO Interrupts sono dispatched alla applicazione managed in forma di eventi.
DEVICE ESTERNI
QUALI DEVICE SI POSSONO GESTIRE?
External device Protocol to communicate API to control
Bottoni GPIO Microsft.SPOT.Hardware.InterruptPort (o Port family e classi drivate in generale)
Potenziometri/Attuatori GPIO (PWM non e’ disponibile al momento)
Microsft.SPOT.Hardware.InterruptPort (o Port family e classi drivate in generale)
Accelerometri SPI o I2C (tipicamente)
Microsft.SPOT.Hardware.SPI e Microsft.SPOT.Hardware.I2CDevice
Outputs booleani (backlight, vibrator)
GPIO Microsoft.SPOT.hardware.Backlight o Microsoft.SPT.Hardware.OutputPort
Monochrome LCD SPI o I2C o driver nativo (tipicamente)
Microsft.SPOT.Hardware.SPI e Microsft.SPOT.Hardware.I2Cdevice. LCD (display) API (LCD_BitBlt e LCD_BitBltEx)
OEM-specific (heart rate monitor, air pressure sensor,
touch screen)
SPI o I2C o Seriale(Tipicamente, Dipende dal device)
Microsft.SPOT.Hardware.SPI, Microsft.SPOT.Hardware.I2Cdevice e Microsft.SPOT.Hardware.SerialPort
Battery monitoring Battery API Microsft.SPOT.Hardware.Battery e Battery and Charger HAL API
Flash memoryMicrosoft.SPOT.ExtendedWeakReferences Microsoft.SPOT.Logging (solo per debug)HAL FLASH API
Bluetooth Seriale o SPI(dipende dal controllore, vedi Promi-SD o BlueCore)
Microsoft.SPOT.hardware.SerialPort o Microsoft.SPOT.Hardware.SPI
802.15.4 SPI (Tipicamente, vedi Ember or Chipcon CC2420)
Microsoft.SPOT.Hardware.SPI
EEPROM memory Unsupported Legacy n/a
Calibrated accurate time Dell’apposito codice e’ provvisto nel porting kit ma deve essere abilitato manualmente
CODICE DI UN MANAGED DRIVER
using System.Threading; using Microsoft.SPOT.Hardware;
…InterruptPort myButton = new InterruptPort(
(Cpu.Pin)12, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow
);
MyButton.OnInterrupt +=new GPIOInterruptEventHandler( this.MyInterruptHandler );
…}
public void MyInterruptHandler(Cpu.Pin id, bool edge, TimeSpan time) { // handle the interrupt event here}
L’emulatore è una windows application che esegue codice micro framework
Una collezione di classi che permette di comporre epersonalizzare l’emulatore
Un file di configurazione (XML) che permette di configurare ed inizializzare tutti i componenti
EMULATORE
Windows application che esegue codice Micro Framework
Una collezione di classi permette di comporre e personalizzare i componenti da emulare
Un file di configurazione (XML) permette di configurare ed inizializzare tutti i componenti
ARCHITETTURA DELL’EMULATORE
DEMO THE TRIPCOMPUTER SAMPLECustomize the emulator to simulate buttons and IO on the
TripComputer
Sito microframework: http://msdn.microsoft.com/embedded/netmf.
Sito embedded development: http://msdn2.microsoft.com/embedded.
Sito per download http://www.microsoft.com/downloads.
Webcasts• http://Www.microsoft.com/Webcasts • http://www.microsoft.com/italy/eventi/webcast/
MAGGIORI INFORMAZIONI