Upload
dotnetmarche
View
1.536
Download
6
Embed Size (px)
DESCRIPTION
Il Micro Framework è una versione ultra-ridotta del Framework.NET per piccole CPU a 32 bit dove è lo stesso CLR a fungere da pseudo sistema operativo. La chiave di svolta del Micro Framework è di poter utilizzare C# per scrivere applicazioni che girano su un hardware totalmente indipendente, di bassa potenza e dalle funzionalità molto elevate. Basti solo pensare alla possibilità di pubblicare un servizio WCF, oppure chiamare un servizio WCF esterno, o ancora scrivere la UI con una mini versione di WPF (priva di xaml) o ancora accedere liberamente alle periferiche hardware senza bisogno di driver. Il mondo delle periferiche è tutto sotto controllo: USB (client e host), RS232, Schede SD, monitor, CanBus, ZigBee, etc. etc.Durante la sessione scopriremo quanto l'hardware non faccia più paura in questo mondo, e sia abbordabile da chiunque provenga della programmazione software.
Citation preview
Raffaele Rialdi
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
Scoprire il Micro Frameworkcon C#
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, Analog Devices Blackfin, Renesas SH2/SH2A– Memory Management Unit non necessaria– … Porting Kit!
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
XML Parser
DPWS
SSL
Advanced Graphics
USB client
Touch Panel
Managed Application
Application Services
Managed Libraries
Managed Run-TimeCLR, Interpreter, Executive, and Interop
PAL – Platform Abstraction Layerapproximately 40 functions
(preferred) HAL - Hardware Abstraction Layerapproximately 60 functions (optional) Host
OS
Hardware
I/O: USB, UART, SPI, I2C
Threading
BasicGraphics
Collections
Security
Sockets
Port
ing
Kit
(PK
)
SD
K
File System
Reflection
HTTP(S)
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
• Event routing e input providers
Librerie - Network
• Network:– Socket– HttpWebRequest, HttpWebResponse and HttpListener
• Esistono esempi di Webserver pronti all'uso
– HTTP/1.1 compreso chunking e keep-alive– SSL con certificati X.509!
• Transport:– 802.11 [WiFi] supportato (necessita di supporto sdk OEM)– 802.15.4 [ZigBee] implementato ma ancora non
documentato
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– WSDL 1.1, SOAP 1.2, WS-Addressing, WS-
MetadataExchange, WS-Transfer, WS-Discovery, WS-Eventing
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 perla prossima release!
1. http://netmf.codeplex.com/2. Login via LiveId3. Issue Tracker4. 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