Scoprire il Micro Framework
con C#
Twitter: @raffaeler
Email: [email protected]
Articoli e codice: http://www.iamraf.net
Blog: http://blogs.ugidotnet.org/raffaele
Profilo MVP: https://mvp.support.microsoft.com/profile/raffaele
Il mondo dei device
• Ieri
–
–
–
–
PC  Full Windows
Apparati industriali  Windows Embedded / CE
PDA, Cellulari  Windows CE
Piccole schede  Micro Framework
• Domani
–
–
–
–
PC  Full Windows
Apparati industriali  Windows Embedded / CE
PDA, Cellulari  Full Windows vNext (SoC)
Piccole schede  Micro Framework
Caratteristiche dell'hardware
• Circa 256K di RAM, 512K di ROM
– WinCE è intorno ai 10MB RAM / 10MB ROM
• CPU 32 bit tipicamente tra 27 e 100MHz
– ARM 7 in poi,
– Memory Management Unit non necessaria
Caratteristiche del MF
• Nasce nel 2001 dal progetto "Smart Personal Object
Technology" (SPOT) usata per gli orologi MSN
• Codebase indipendente da CF o fx.net
– Open source http://netmf.codeplex.com
•
•
•
•
Subset del full fx.net
Il runtime del CLR interpreta il codice IL
Pieno controllo delle periferiche hardware
Supportato da VS2010 (anche express)
– Wizard, emulatore, esempi, help
– Tool diagnostici e conversione font truetype
Architettura
Managed Application
Application Services
DPWS
HTTP(S)
Advanced Graphics
Touch Panel
SDK
Managed Libraries
Threading
Collections
Reflection
I/O: USB,
UART, SPI, I2C
Porting Kit (PK)
Security
USB client
File System
Sockets
Basic
Graphics
SSL
XML Parser
Managed Run-Time
CLR, Interpreter, Executive, and Interop
PAL – Platform Abstraction Layer
approximately 40 functions
(preferred)
HAL - Hardware Abstraction Layer
approximately 60 functions
Hardware
(optional) Host OS
AMBIENTE DI SVILUPPO
Librerie – Supporto Base
• Suddivise tra i namespace System.* e SPOT.*
–
–
–
–
–
–
–
ArrayList (unica collection), Hashtable, Queue, Stack
XmlWriter, XmlReader, XmlTextReader
Thread, Timer, AutoResetEvent, …
Reflection
IO: File, streams, SerialPort
Crypto API
GC, delegate, AppDomain, String, Uri, WeakReference, …
Librerie - Hardware
• Microsoft.SPOT.Hardware
–
–
–
–
–
–
Battery, PowerState, PowerEvent, SleepEvent
Cpu
I2CDevice
Port, InputPort, OutputPort, InterruptPort, TristatePort
SPI
Watchdog, WatchdogEvent
• Microsoft.SPOT.Hardware.UsbClient
• SDK Specifici dei produttori OEM. Per es. GHI Electronics:
– CAN, PWM, RealtimeClock, OneWire
– USB client (mouse, kbd, …), USB host (mouse, kbd, …)
– …
Librerie – User Interface
• Implementa WPF! (versione super-ridotta)
– Niente XAML o binding, solo API essenziali
– Microsoft.SPOT.Presentation
• Controlli
– Border, Canvas, Image, ListBox, Panel, ScrollViewer, StackPanel, Text, …
– No Button:
http://www.nielsderdaele.be/post/2010/10/12/WPF-Based-Touch-Button-for-NET-Micro-Framework-41.aspx
• Disegno
– Brush, Color, Pen, ImageBrush, DrawingContext, …
– Ellipse , Line, Polygon, Rectangle, Shape
• Touch
– Ink, Touch, TouchEvent, TouchPanel, InkCanvas
Librerie - Network
• Network:
– Socket
– SSL con certificati
• Transport:
Librerie - DPWS
• Implementa WCF (Device Profile for Web Services)!
– Può essere client o server
– Implementa WS-Discovery
– Generazione proxy con MFSvcUtil
• Implementazione ridotta:
– http://msdn.microsoft.com/en-us/library/ee435399.aspx
– Solo Http binding
C# nel Micro Framework
• Non implementati:
– Generics
– Linq
• Workaround:
http://blogs.oberon.ch/tamberg/2009-02-06/implementing-linq-on-the-dotnet-mf.html
–
–
–
–
–
–
Expression trees
anonymous types
partial classes
nullable types
tipi puntatori (e.g. IntPtr)
supporto limitato per unsafe code blocks
• Solo unsafe/fixed in un numero di casi limitati e su array
– custom attributes
Real-world samples
• http://www.tinyclr.com/ by GHI
• http://www.netduino.com/projects/ by Netduino
• Micro Framework sources (+ contributions) by
NetMF team
– http://netmf.codeplex.com/documentation
Votate le feature per
la prossima release!
1.
2.
3.
4.
http://netmf.codeplex.com/
Login via LiveId
Issue Tracker
Votate!
–
–
–
•
REST: http://netmf.codeplex.com/workitem/751
Generics: http://netmf.codeplex.com/workitem/750
Video Streaming: http://netmf.codeplex.com/workitem/749
Il team del Micro Framework legge tutte le richieste
–
È possibile collaborare al source tree ufficiale (direttamente sul
TFS di codeplex)
Domande ?
Uno grazie speciale a Lorenzo Tessiore e Zach Libby del
team di Micro Framework per la disponibilità e i
suggerimenti
Scarica

Scoprire il Micro Framework con C