SlideShare a Scribd company logo
1 of 13
Lorenzo Maiorfi

Modern OOP embedded development with
.NET Micro Framework
maiorfi@innovactive.it – www.innovactive.it www.tinyclr.it
What does «embedded development» actually mean?
Lorenzo Maiorfi

maiorfi@innovactive.it – www.innovactive.it
www.tinyclr.it

• Small Hardware components…
•

Microcontrollers (microprocessor cores driving
electrical analog/digital peripherals)
•
•
•

small (about 1 square cm)
cheap (€1-10 each)
low-power (about 50-100 uA per MHz)

• External boards/modules/IC
•
•

running specific tasks (i.e. sensors, actuators)
bound via some communication channel (network,
serial port, CAN, I2C, SPI, etc)
What does «embedded development» actually mean?
Lorenzo Maiorfi

maiorfi@innovactive.it – www.innovactive.it
www.tinyclr.it

• …running small software «modules»
•

Native firmware
•
•
•

•

Hard to write/debug/maintain
Vendor/platform specific (not portable)
Uses «old» languages/paradigms (C, assembler, core
registers access, memory-based actions, etc)

Managed firmware
•
•
•
•

Easy to write/debug/maintain
Portable
Uses OOP/OOD concepts
Abstracts both «machine model» and interactions
with other «actors» of whole solution
Introducing .NET Micro Framework
Lorenzo Maiorfi

maiorfi@innovactive.it – www.innovactive.it
www.tinyclr.it

An open-source platform (runtime/libraries , toolchain
and IDE) that excels in:
• Productivity
– Visual Studio IDE, C#/VB.NET compilers, debugger and
emulator make up the most productive suite on the embedded
market

•

Reliability
– managed runtime keeps under control all application layers

•

Portability
– could be ported to all known technologies, at this time covers
most microcontrollers whose core is based on 32 bit ARM™

•

Support
– open-source under Apache 2.0 license, contains many
community-provided resources
How to write applications with .NET Micro Framework
Lorenzo Maiorfi

maiorfi@innovactive.it – www.innovactive.it
www.tinyclr.it

1. Developer writes code by mean of high-level languages
such as C# or VB.NET
2. Compiler generates one or more «assemblies»
3. Assemblies binary images are stored in device flash (i.e.
non-volatile) memory
4. Once reset, device runs a bootloader, that on its turn
fires managed runtime (TinyCLR)
5. TinyCLR loads both framework and «user» assemblies,
and soon after it runs entry-point method, i.e. the
«Main()»
Demo #1 – Getting Started
Lorenzo Maiorfi

DEMO
Hello,world
(with 3 different patterns)
white led

button
OOP/OOD with .NET Micro Framework
Lorenzo Maiorfi

maiorfi@innovactive.it – www.innovactive.it
www.tinyclr.it

• OOP/OOD is very suitable for embedded development,
since it naturally maps physical objects to software
models, by mean of classes, objects and interfaces
• Encapsulation allows for better component isolation
(black-box model)
• Inheritance allows for better code reuse when using
several «variants/flavors» of same component
• Polymorphism allows for a better way to connect objects,
by mean of «outlet» abstraction, i.e. interfaces
OOP/OOD with .NET Micro Framework
Lorenzo Maiorfi

maiorfi@innovactive.it – www.innovactive.it
www.tinyclr.it

We’re going to apply this paradigm on a simple “devicedriver” for a small integrated-circuit (IC): MCP3201 ADC
1. Do some “lab” (quick & dirty demos, test SPIcommunication with a scope, etc)
2. Encapsulate functionalities into a class
3. Add features (such as async events in our case) via
inheritance
4. Extract “Interfaces” (i.e. abstract behavior)
5. Re-implement Interfaces differently
Demo #2 – OOP/OOD Demo
Lorenzo Maiorfi

DEMO
ADC Driver
This is a POT to change voltage

+
This is MCP3201!
IoT/M2M as the killer app for .NET Micro Framework
Lorenzo Maiorfi

maiorfi@innovactive.it – www.innovactive.it
www.tinyclr.it

.NET Micro Framework killer applications are IoT/M2M
systems, since:
• It has a rich TCP/IP network stack
• There are many libraries implementing both IoT
protocols (first and foremost HTTP REST, both client and
server) and M2M protocols (primarily MQTT & CoAP)
• There are many libraries that allow for «bridging» across
other technologies, such as ZigBee, Bluetooth, BLE,
vendor-specific 2.4GHz/433MHz radio modules (we’re
developing Z-Wave stack, too)
• OOP features are great for building systems made of
devices that interact in an abstract way!
IoT/M2M with mqtt & node-red
Lorenzo Maiorfi

maiorfi@innovactive.it – www.innovactive.it
www.tinyclr.it

• Mqtt is a lightweight pub/sub protocol whose primary
focus is communication in IoT/M2M applications
• Mqtt client libs are available for all platforms/languages
• Node-Red is an open software (based on Node.js) whose
purpose is to design and run “flows”
• Flows are made of “nodes” targeted to specific functions
• Among built-in nodes: tcp-in/out, udp-in/out, httpin/out, mqtt-in/out, twitter, mail, files, mongodb, etc.
• Many “logic” node blocks (function, template, switch)
• You can write (and debug, via node-inspector) your own
nodes, too!
Demo #3 – IoT/M2M Demo
Lorenzo Maiorfi

APIs

Node-Red

http
“javascript”
Remote #1

mqtt
Mqtt Broker

Remote #2

mqtt

mqtt

Radio
Bridge

radio
websockets
Robot
Thank you!
Lorenzo Maiorfi
maiorfi@innovactive.it – www.innovactive.it - @innovactive
Tech Blog: www.tinyclr.it - @tinyclr

More Related Content

Similar to Codemotion 2013 Madrid - Modern OOP embedded development with .NET Micro Framework

Null mumbai-iot-workshop
Null mumbai-iot-workshopNull mumbai-iot-workshop
Null mumbai-iot-workshopNitesh Malviya
 
IoT Studio #1: Protocols introduction and connected jukebox
IoT Studio #1: Protocols introduction and connected jukeboxIoT Studio #1: Protocols introduction and connected jukebox
IoT Studio #1: Protocols introduction and connected jukeboxMickaël Rémond
 
Using Eclipse and Lua for the Internet of Things with Eclipse Koneki, Mihini ...
Using Eclipse and Lua for the Internet of Things with Eclipse Koneki, Mihini ...Using Eclipse and Lua for the Internet of Things with Eclipse Koneki, Mihini ...
Using Eclipse and Lua for the Internet of Things with Eclipse Koneki, Mihini ...Benjamin Cabé
 
Open source building blocks for the Internet of Things - Jfokus 2013
Open source building blocks for the Internet of Things - Jfokus 2013Open source building blocks for the Internet of Things - Jfokus 2013
Open source building blocks for the Internet of Things - Jfokus 2013Benjamin Cabé
 
Using Eclipse and Lua for the Internet of Things - EclipseDay Googleplex 2012
Using Eclipse and Lua for the Internet of Things - EclipseDay Googleplex 2012Using Eclipse and Lua for the Internet of Things - EclipseDay Googleplex 2012
Using Eclipse and Lua for the Internet of Things - EclipseDay Googleplex 2012Benjamin Cabé
 
RIOT: towards open source, secure DevOps on microcontroller-based IoT
RIOT: towards open source, secure DevOps on microcontroller-based IoTRIOT: towards open source, secure DevOps on microcontroller-based IoT
RIOT: towards open source, secure DevOps on microcontroller-based IoTAlexandre Abadie
 
#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...
#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...
#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...Paris Open Source Summit
 
Contiki IoT simulation
Contiki IoT simulationContiki IoT simulation
Contiki IoT simulationnabati
 
Internet of Things – Contiki.pdf
Internet of Things – Contiki.pdfInternet of Things – Contiki.pdf
Internet of Things – Contiki.pdfSudhanshiBakre1
 
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019Codemotion
 
Smart home and smartfactory intelligent systems
Smart home and smartfactory intelligent systemsSmart home and smartfactory intelligent systems
Smart home and smartfactory intelligent systemsLorenzo Maiorfi
 
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteUnit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteTushar B Kute
 
Italian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch SessionItalian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch SessionChris Hardy
 
Building IoT devices with ARM mbed - RISE Manchester
Building IoT devices with ARM mbed - RISE ManchesterBuilding IoT devices with ARM mbed - RISE Manchester
Building IoT devices with ARM mbed - RISE ManchesterJan Jongboom
 
Developers’ mDay u Banjoj Luci - Janko Isidorović, Mainflux – Unified IoT Pl...
Developers’ mDay u Banjoj Luci - Janko Isidorović, Mainflux –  Unified IoT Pl...Developers’ mDay u Banjoj Luci - Janko Isidorović, Mainflux –  Unified IoT Pl...
Developers’ mDay u Banjoj Luci - Janko Isidorović, Mainflux – Unified IoT Pl...mCloud
 
Introduction to Embedded Systems and Microcontrollers
Introduction to Embedded Systems and MicrocontrollersIntroduction to Embedded Systems and Microcontrollers
Introduction to Embedded Systems and MicrocontrollersIslam Samir
 
node.js is made for IoT - node.hh 07/16, Hamburg by Michael Kuehne
node.js is made for IoT - node.hh 07/16, Hamburg by Michael Kuehnenode.js is made for IoT - node.hh 07/16, Hamburg by Michael Kuehne
node.js is made for IoT - node.hh 07/16, Hamburg by Michael KuehneMichael Kuehne-Schlinkert
 

Similar to Codemotion 2013 Madrid - Modern OOP embedded development with .NET Micro Framework (20)

Null mumbai-iot-workshop
Null mumbai-iot-workshopNull mumbai-iot-workshop
Null mumbai-iot-workshop
 
IoT Studio #1: Protocols introduction and connected jukebox
IoT Studio #1: Protocols introduction and connected jukeboxIoT Studio #1: Protocols introduction and connected jukebox
IoT Studio #1: Protocols introduction and connected jukebox
 
Using Eclipse and Lua for the Internet of Things with Eclipse Koneki, Mihini ...
Using Eclipse and Lua for the Internet of Things with Eclipse Koneki, Mihini ...Using Eclipse and Lua for the Internet of Things with Eclipse Koneki, Mihini ...
Using Eclipse and Lua for the Internet of Things with Eclipse Koneki, Mihini ...
 
Open source building blocks for the Internet of Things - Jfokus 2013
Open source building blocks for the Internet of Things - Jfokus 2013Open source building blocks for the Internet of Things - Jfokus 2013
Open source building blocks for the Internet of Things - Jfokus 2013
 
Using Eclipse and Lua for the Internet of Things - EclipseDay Googleplex 2012
Using Eclipse and Lua for the Internet of Things - EclipseDay Googleplex 2012Using Eclipse and Lua for the Internet of Things - EclipseDay Googleplex 2012
Using Eclipse and Lua for the Internet of Things - EclipseDay Googleplex 2012
 
RIOT: towards open source, secure DevOps on microcontroller-based IoT
RIOT: towards open source, secure DevOps on microcontroller-based IoTRIOT: towards open source, secure DevOps on microcontroller-based IoT
RIOT: towards open source, secure DevOps on microcontroller-based IoT
 
#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...
#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...
#OSSPARIS19 : RIOT: towards open source, secure DevOps on microcontroller-bas...
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Contiki IoT simulation
Contiki IoT simulationContiki IoT simulation
Contiki IoT simulation
 
Internet of Things – Contiki.pdf
Internet of Things – Contiki.pdfInternet of Things – Contiki.pdf
Internet of Things – Contiki.pdf
 
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019
 
Smart home and smartfactory intelligent systems
Smart home and smartfactory intelligent systemsSmart home and smartfactory intelligent systems
Smart home and smartfactory intelligent systems
 
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteUnit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
 
Midori ppt
Midori pptMidori ppt
Midori ppt
 
Italian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch SessionItalian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch Session
 
Building IoT devices with ARM mbed - RISE Manchester
Building IoT devices with ARM mbed - RISE ManchesterBuilding IoT devices with ARM mbed - RISE Manchester
Building IoT devices with ARM mbed - RISE Manchester
 
Developers’ mDay u Banjoj Luci - Janko Isidorović, Mainflux – Unified IoT Pl...
Developers’ mDay u Banjoj Luci - Janko Isidorović, Mainflux –  Unified IoT Pl...Developers’ mDay u Banjoj Luci - Janko Isidorović, Mainflux –  Unified IoT Pl...
Developers’ mDay u Banjoj Luci - Janko Isidorović, Mainflux – Unified IoT Pl...
 
Introduction to Embedded Systems and Microcontrollers
Introduction to Embedded Systems and MicrocontrollersIntroduction to Embedded Systems and Microcontrollers
Introduction to Embedded Systems and Microcontrollers
 
Construct an Efficient and Secure Microkernel for IoT
Construct an Efficient and Secure Microkernel for IoTConstruct an Efficient and Secure Microkernel for IoT
Construct an Efficient and Secure Microkernel for IoT
 
node.js is made for IoT - node.hh 07/16, Hamburg by Michael Kuehne
node.js is made for IoT - node.hh 07/16, Hamburg by Michael Kuehnenode.js is made for IoT - node.hh 07/16, Hamburg by Michael Kuehne
node.js is made for IoT - node.hh 07/16, Hamburg by Michael Kuehne
 

Recently uploaded

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Recently uploaded (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

Codemotion 2013 Madrid - Modern OOP embedded development with .NET Micro Framework

  • 1. Lorenzo Maiorfi Modern OOP embedded development with .NET Micro Framework maiorfi@innovactive.it – www.innovactive.it www.tinyclr.it
  • 2. What does «embedded development» actually mean? Lorenzo Maiorfi maiorfi@innovactive.it – www.innovactive.it www.tinyclr.it • Small Hardware components… • Microcontrollers (microprocessor cores driving electrical analog/digital peripherals) • • • small (about 1 square cm) cheap (€1-10 each) low-power (about 50-100 uA per MHz) • External boards/modules/IC • • running specific tasks (i.e. sensors, actuators) bound via some communication channel (network, serial port, CAN, I2C, SPI, etc)
  • 3. What does «embedded development» actually mean? Lorenzo Maiorfi maiorfi@innovactive.it – www.innovactive.it www.tinyclr.it • …running small software «modules» • Native firmware • • • • Hard to write/debug/maintain Vendor/platform specific (not portable) Uses «old» languages/paradigms (C, assembler, core registers access, memory-based actions, etc) Managed firmware • • • • Easy to write/debug/maintain Portable Uses OOP/OOD concepts Abstracts both «machine model» and interactions with other «actors» of whole solution
  • 4. Introducing .NET Micro Framework Lorenzo Maiorfi maiorfi@innovactive.it – www.innovactive.it www.tinyclr.it An open-source platform (runtime/libraries , toolchain and IDE) that excels in: • Productivity – Visual Studio IDE, C#/VB.NET compilers, debugger and emulator make up the most productive suite on the embedded market • Reliability – managed runtime keeps under control all application layers • Portability – could be ported to all known technologies, at this time covers most microcontrollers whose core is based on 32 bit ARM™ • Support – open-source under Apache 2.0 license, contains many community-provided resources
  • 5. How to write applications with .NET Micro Framework Lorenzo Maiorfi maiorfi@innovactive.it – www.innovactive.it www.tinyclr.it 1. Developer writes code by mean of high-level languages such as C# or VB.NET 2. Compiler generates one or more «assemblies» 3. Assemblies binary images are stored in device flash (i.e. non-volatile) memory 4. Once reset, device runs a bootloader, that on its turn fires managed runtime (TinyCLR) 5. TinyCLR loads both framework and «user» assemblies, and soon after it runs entry-point method, i.e. the «Main()»
  • 6. Demo #1 – Getting Started Lorenzo Maiorfi DEMO Hello,world (with 3 different patterns) white led button
  • 7. OOP/OOD with .NET Micro Framework Lorenzo Maiorfi maiorfi@innovactive.it – www.innovactive.it www.tinyclr.it • OOP/OOD is very suitable for embedded development, since it naturally maps physical objects to software models, by mean of classes, objects and interfaces • Encapsulation allows for better component isolation (black-box model) • Inheritance allows for better code reuse when using several «variants/flavors» of same component • Polymorphism allows for a better way to connect objects, by mean of «outlet» abstraction, i.e. interfaces
  • 8. OOP/OOD with .NET Micro Framework Lorenzo Maiorfi maiorfi@innovactive.it – www.innovactive.it www.tinyclr.it We’re going to apply this paradigm on a simple “devicedriver” for a small integrated-circuit (IC): MCP3201 ADC 1. Do some “lab” (quick & dirty demos, test SPIcommunication with a scope, etc) 2. Encapsulate functionalities into a class 3. Add features (such as async events in our case) via inheritance 4. Extract “Interfaces” (i.e. abstract behavior) 5. Re-implement Interfaces differently
  • 9. Demo #2 – OOP/OOD Demo Lorenzo Maiorfi DEMO ADC Driver This is a POT to change voltage + This is MCP3201!
  • 10. IoT/M2M as the killer app for .NET Micro Framework Lorenzo Maiorfi maiorfi@innovactive.it – www.innovactive.it www.tinyclr.it .NET Micro Framework killer applications are IoT/M2M systems, since: • It has a rich TCP/IP network stack • There are many libraries implementing both IoT protocols (first and foremost HTTP REST, both client and server) and M2M protocols (primarily MQTT & CoAP) • There are many libraries that allow for «bridging» across other technologies, such as ZigBee, Bluetooth, BLE, vendor-specific 2.4GHz/433MHz radio modules (we’re developing Z-Wave stack, too) • OOP features are great for building systems made of devices that interact in an abstract way!
  • 11. IoT/M2M with mqtt & node-red Lorenzo Maiorfi maiorfi@innovactive.it – www.innovactive.it www.tinyclr.it • Mqtt is a lightweight pub/sub protocol whose primary focus is communication in IoT/M2M applications • Mqtt client libs are available for all platforms/languages • Node-Red is an open software (based on Node.js) whose purpose is to design and run “flows” • Flows are made of “nodes” targeted to specific functions • Among built-in nodes: tcp-in/out, udp-in/out, httpin/out, mqtt-in/out, twitter, mail, files, mongodb, etc. • Many “logic” node blocks (function, template, switch) • You can write (and debug, via node-inspector) your own nodes, too!
  • 12. Demo #3 – IoT/M2M Demo Lorenzo Maiorfi APIs Node-Red http “javascript” Remote #1 mqtt Mqtt Broker Remote #2 mqtt mqtt Radio Bridge radio websockets Robot
  • 13. Thank you! Lorenzo Maiorfi maiorfi@innovactive.it – www.innovactive.it - @innovactive Tech Blog: www.tinyclr.it - @tinyclr