SlideShare a Scribd company logo
mruby/c and data-flow
programming for small devices
Kazuaki Tanaka
mruby/c and data-flow programming for small devices
About me
• Kazuaki Tanaka
• Kyushu Institute of Technology
• Lectures:
Data Structure, Image Processing
• Research:
Embedded Systems, IoT, Wireless
communication
Activities
• Ruby Association, mruby Forum, Ruby
Business Council(Ruby協)
• mruby, mruby/c committer
Research on Wireless Communication
• LPWA (Low Power Wide Area network)
– Ultra-narrow band communication
– Protocol design, Firmware
– Application, Pilot experiment
– Low-cost network for local government
Disaster Prevention
Land slides in Fukuoka
2020
Pilot experiment
• Rain/Wind measurement
– Flood alert, land slide alert
Topic today
• Programming environment for small devices
– Using mruby/c
– For IoT applications
DEMO
DEMO
• Blinking two LEDs
• Talk about backside of this DEMO
– What’s mruby/c ?
– Data-flow programming
– Integrating mruby/c and data-flow
mruby/c
Ruby for small devices
• Programming language Ruby
– Object oriented programming language
• mruby, mruby/c
– Apply Ruby features for embedded software
– Small memory footprint
Concept of mruby
• Reduce memory footprint in execution
– mruby Compiler + mruby VM
– Compile source code in PC
– Execute compiled code in target device
• Extensible libraries “mrbgems”
– Easy to add new features to mruby
Ruby, mruby, mruby/c
Ruby
1 MB~ 128KB~ 20KB~
Memory
Language
Target
device
Targeting: Small devices
• Low power, Low cost
• Long-time operation
• mruby/c provides,
– Memory management, object reference counter
– Power management
– (Semi-) real-time operation
RBoard
• mruby/c ready microcontroller board
– PIC32MX170F256B
SRAM 64KB
Flash 256KB
– I/O
Digital In, Out
ADC, PWM, UART, I2C
You can order @ chip1stop
島根情報処理センター
mruby VM
ary = [2, 4.1, 0.5, 3]
ary.sort.each do |data|
puts data
end
00000000: 52 49 54 45 30 33 30 30 00 00 00 d6 4d 41 54 5a RITE0300....MATZ
00000010: 30 30 30 30 49 52 45 50 00 00 00 98 30 33 30 30 0000IREP....0300
00000020: 00 00 00 64 00 03 00 08 00 01 00 00 00 00 00 2f ...d.........../
00000030: 0b 01 51 04 00 01 05 01 09 06 40 05 52 04 2d 03 ..Q.......@.R.-.
00000040: 00 01 08 03 0a 04 07 05 09 06 48 02 03 04 01 03 ..........H.....
00000050: 02 2f 03 01 00 57 04 00 30 03 02 00 38 03 69 00 ./...W..0...8.i.
00000060: 01 00 00 08 61 20 2a 20 33 20 3d 20 00 00 03 00 ....a * 3 = ....
00000070: 04 70 75 74 73 00 00 04 73 6f 72 74 00 00 04 65 .puts...sort...e
00000080: 61 63 68 00 00 00 00 28 00 03 00 06 00 00 00 00 ach....(........
00000090: 00 00 00 0d 34 04 00 00 01 04 01 2d 03 00 01 38 ....4......-...8
000000a0: 03 00 00 00 01 00 04 70 75 74 73 00 4c 56 41 52 .......puts.LVAR
000000b0: 00 00 00 22 00 00 00 03 00 01 61 00 03 61 72 79 ..."......a..ary
000000c0: 00 04 64 61 74 61 00 00 00 01 00 02 ff ff 45 4e ..data........EN
000000d0: 44 00 00 00 00 08 D.....
Ruby source code
Compile
mruby bytecode
mruby VM
on target device
Execute
mruby compiler
Inside RBoard microcontroller
RBoard Hardware
HAL: Hardware Abstraction Layer
mruby/c VM
Application Bytecode
Transfer from PC
Firmware
mruby/c on github
• VM
• HAL
– ESP32
– PIC24
– POSIX
– PSoC5LP
– RP2040 (Raspberry Pi Pico)
– STM32
https://github.com/mrubyc/mrubyc
Data-flow programming
Visual Programming
Block Programming
Data-flow Programming
Block Programming
Smalruby
• Education
• Entry to procedural programming
loop do
puts( "mruby" )
sleep(1)
end
Block Programming
Node-RED
• IoT
?
Inject node
Process nodes
Nodes
Wires
Inject and Process
QUEUE
Inject: Create a packet, store into Queue
Process: Retrieve a packet from Queue, process, store into Queue
Packet = {
destination node,
payload
}
Integrating mruby/c and data-flow
How to ?
nodered2mruby
• Input= Data-flow description
– Node-RED JSON
• Output= mruby/c
– Bytecode (or mruby source)
[
{
"id": "ef2b6bb33e489cef",
"type": "inject",
"z": "f6f2187d.f17ca8",
"name": "",
"props": [],
"repeat": "1",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 130,
"y": 100,
"wires": [
[
"7438f9109319b2e9"
]
]
},
・・・・・
]
DEMO Program
Injection 1.0 [s]
Injection 2.5 [s]
Green LED
Red LED
$queue = []
# main loop
while true do
# inject
injects.each_index do |idx|
inject_node injects[idx]
end
# process queue
msg = $queue.first
if msg then
$queue.delete_at 0
idx = find_target(nodes, msg)
if idx then
process_node nodes[idx], msg
else
puts "node not found: #{msg[:id]}"
end
end
# next
sleep LoopInterval
end
Pseudo code
Conclusion
• This work is continuing,
• Future work (or just idea)
– Dispatching performance
– Distributed system, IoT
– Deploying
Acknowledgements
• murby/c developers
• itoc 「しまねソフト研究開発センター」
• Kyutech students
• National Institute of Technology Matsue
College students
References
• https://github.com/mrubyc/
• https://github.com/nodered-mrubyc/
• K. Tanaka, S. Ogura and R. Krishnamoorthy,
"Hybrid IoT Programming with Data Flow
Diagrams and mruby," 2024 IEEE Conference on
Dependable, Autonomic and Secure Computing
(DASC), Boracay Island, Philippines, 2024, pp. 78-
82, doi: 10.1109/DASC64200.2024.00017.

More Related Content

Similar to mruby/c and data-flow programming for small devices (20)

What lies beneath the beautiful code?
What lies beneath the beautiful code?What lies beneath the beautiful code?
What lies beneath the beautiful code?
Niranjan Sarade
 
MacRuby, an introduction
MacRuby, an introductionMacRuby, an introduction
MacRuby, an introduction
Olivier Gutknecht
 
Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in Ruby
John Vlachoyiannis
 
Charla ruby nscodermad
Charla ruby nscodermadCharla ruby nscodermad
Charla ruby nscodermad
nscoder_mad
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?
Joshua Ballanco
 
MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoa
Thilo Utke
 
C言語静的解析ツールと Ruby 1.9 trunk
C言語静的解析ツールと Ruby 1.9 trunkC言語静的解析ツールと Ruby 1.9 trunk
C言語静的解析ツールと Ruby 1.9 trunk
ikegami__
 
Accelerating Ruby with LLVM
Accelerating Ruby with LLVMAccelerating Ruby with LLVM
Accelerating Ruby with LLVM
evanphx
 
DZone%20-%20Essential%20Ruby
DZone%20-%20Essential%20RubyDZone%20-%20Essential%20Ruby
DZone%20-%20Essential%20Ruby
tutorialsruby
 
DZone%20-%20Essential%20Ruby
DZone%20-%20Essential%20RubyDZone%20-%20Essential%20Ruby
DZone%20-%20Essential%20Ruby
tutorialsruby
 
IJTC%202009%20JRuby
IJTC%202009%20JRubyIJTC%202009%20JRuby
IJTC%202009%20JRuby
tutorialsruby
 
IJTC%202009%20JRuby
IJTC%202009%20JRubyIJTC%202009%20JRuby
IJTC%202009%20JRuby
tutorialsruby
 
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar BatsovRuby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Michael Kimathi
 
MacRuby on Rails
MacRuby on RailsMacRuby on Rails
MacRuby on Rails
宏治 高尾
 
MacRuby For Ruby Developers
MacRuby For Ruby DevelopersMacRuby For Ruby Developers
MacRuby For Ruby Developers
Renzo Borgatti
 
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Jan Wedekind
 
Transcendental Programming in Ruby
Transcendental Programming in RubyTranscendental Programming in Ruby
Transcendental Programming in Ruby
mametter
 
Esoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in RubyEsoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in Ruby
mametter
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
rivierarb
 
Why MacRuby Matters
Why MacRuby MattersWhy MacRuby Matters
Why MacRuby Matters
importantshock
 
What lies beneath the beautiful code?
What lies beneath the beautiful code?What lies beneath the beautiful code?
What lies beneath the beautiful code?
Niranjan Sarade
 
Charla ruby nscodermad
Charla ruby nscodermadCharla ruby nscodermad
Charla ruby nscodermad
nscoder_mad
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?
Joshua Ballanco
 
MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoa
Thilo Utke
 
C言語静的解析ツールと Ruby 1.9 trunk
C言語静的解析ツールと Ruby 1.9 trunkC言語静的解析ツールと Ruby 1.9 trunk
C言語静的解析ツールと Ruby 1.9 trunk
ikegami__
 
Accelerating Ruby with LLVM
Accelerating Ruby with LLVMAccelerating Ruby with LLVM
Accelerating Ruby with LLVM
evanphx
 
DZone%20-%20Essential%20Ruby
DZone%20-%20Essential%20RubyDZone%20-%20Essential%20Ruby
DZone%20-%20Essential%20Ruby
tutorialsruby
 
DZone%20-%20Essential%20Ruby
DZone%20-%20Essential%20RubyDZone%20-%20Essential%20Ruby
DZone%20-%20Essential%20Ruby
tutorialsruby
 
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar BatsovRuby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Michael Kimathi
 
MacRuby For Ruby Developers
MacRuby For Ruby DevelopersMacRuby For Ruby Developers
MacRuby For Ruby Developers
Renzo Borgatti
 
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Ruby & Machine Vision - Talk at Sheffield Hallam University Feb 2009
Jan Wedekind
 
Transcendental Programming in Ruby
Transcendental Programming in RubyTranscendental Programming in Ruby
Transcendental Programming in Ruby
mametter
 
Esoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in RubyEsoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in Ruby
mametter
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
rivierarb
 

More from Kazuaki Tanaka (7)

workshop slide.pdf
workshop slide.pdfworkshop slide.pdf
workshop slide.pdf
Kazuaki Tanaka
 
workshop slide.pdf
workshop slide.pdfworkshop slide.pdf
workshop slide.pdf
Kazuaki Tanaka
 
下関中等教育学校 出前講義の資料(2023/8/18)
下関中等教育学校 出前講義の資料(2023/8/18)下関中等教育学校 出前講義の資料(2023/8/18)
下関中等教育学校 出前講義の資料(2023/8/18)
Kazuaki Tanaka
 
組込みシステムの高効率開発を可能とする開発フレームワークの研究開発
組込みシステムの高効率開発を可能とする開発フレームワークの研究開発組込みシステムの高効率開発を可能とする開発フレームワークの研究開発
組込みシステムの高効率開発を可能とする開発フレームワークの研究開発
Kazuaki Tanaka
 
mruby/c in TokyoRubyKaigi#11
mruby/c in TokyoRubyKaigi#11mruby/c in TokyoRubyKaigi#11
mruby/c in TokyoRubyKaigi#11
Kazuaki Tanaka
 
Ruby東京プレゼン 資料
Ruby東京プレゼン 資料Ruby東京プレゼン 資料
Ruby東京プレゼン 資料
Kazuaki Tanaka
 
ET2014資料: mruby プログラム言語Rubyによる組込みソト開発
ET2014資料: mruby プログラム言語Rubyによる組込みソト開発ET2014資料: mruby プログラム言語Rubyによる組込みソト開発
ET2014資料: mruby プログラム言語Rubyによる組込みソト開発
Kazuaki Tanaka
 
下関中等教育学校 出前講義の資料(2023/8/18)
下関中等教育学校 出前講義の資料(2023/8/18)下関中等教育学校 出前講義の資料(2023/8/18)
下関中等教育学校 出前講義の資料(2023/8/18)
Kazuaki Tanaka
 
組込みシステムの高効率開発を可能とする開発フレームワークの研究開発
組込みシステムの高効率開発を可能とする開発フレームワークの研究開発組込みシステムの高効率開発を可能とする開発フレームワークの研究開発
組込みシステムの高効率開発を可能とする開発フレームワークの研究開発
Kazuaki Tanaka
 
mruby/c in TokyoRubyKaigi#11
mruby/c in TokyoRubyKaigi#11mruby/c in TokyoRubyKaigi#11
mruby/c in TokyoRubyKaigi#11
Kazuaki Tanaka
 
Ruby東京プレゼン 資料
Ruby東京プレゼン 資料Ruby東京プレゼン 資料
Ruby東京プレゼン 資料
Kazuaki Tanaka
 
ET2014資料: mruby プログラム言語Rubyによる組込みソト開発
ET2014資料: mruby プログラム言語Rubyによる組込みソト開発ET2014資料: mruby プログラム言語Rubyによる組込みソト開発
ET2014資料: mruby プログラム言語Rubyによる組込みソト開発
Kazuaki Tanaka
 
Ad

Recently uploaded (20)

IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdfHow to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
QuickBooks Training
 
Agile Software Engineering Methodologies
Agile Software Engineering MethodologiesAgile Software Engineering Methodologies
Agile Software Engineering Methodologies
Gaurav Sharma
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Best Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small BusinessesBest Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small Businesses
TheTelephony
 
Micro-Metrics Every Performance Engineer Should Validate Before Sign-Off
Micro-Metrics Every Performance Engineer Should Validate Before Sign-OffMicro-Metrics Every Performance Engineer Should Validate Before Sign-Off
Micro-Metrics Every Performance Engineer Should Validate Before Sign-Off
Tier1 app
 
Leveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer IntentsLeveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer Intents
Keheliya Gallaba
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework
Angelo Theodorou
 
Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...
Rishab Acharya
 
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps CyclesFrom Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
Marjukka Niinioja
 
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
Nacho Cougil
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
How to purchase, license and subscribe to Microsoft Azure_PDF.pdf
How to purchase, license and subscribe to Microsoft Azure_PDF.pdfHow to purchase, license and subscribe to Microsoft Azure_PDF.pdf
How to purchase, license and subscribe to Microsoft Azure_PDF.pdf
victordsane
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdfTop 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Trackobit
 
Providing Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better DataProviding Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better Data
Safe Software
 
Revolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management SoftwareRevolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management Software
Insurance Tech Services
 
Design by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First DevelopmentDesign by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First Development
Par-Tec S.p.A.
 
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
WSO2
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdfHow to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
QuickBooks Training
 
Agile Software Engineering Methodologies
Agile Software Engineering MethodologiesAgile Software Engineering Methodologies
Agile Software Engineering Methodologies
Gaurav Sharma
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Best Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small BusinessesBest Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small Businesses
TheTelephony
 
Micro-Metrics Every Performance Engineer Should Validate Before Sign-Off
Micro-Metrics Every Performance Engineer Should Validate Before Sign-OffMicro-Metrics Every Performance Engineer Should Validate Before Sign-Off
Micro-Metrics Every Performance Engineer Should Validate Before Sign-Off
Tier1 app
 
Leveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer IntentsLeveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer Intents
Keheliya Gallaba
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework
Angelo Theodorou
 
Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...
Rishab Acharya
 
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps CyclesFrom Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
Marjukka Niinioja
 
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
How John started to like TDD (instead of hating it) (ViennaJUG, June'25)
Nacho Cougil
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
How to purchase, license and subscribe to Microsoft Azure_PDF.pdf
How to purchase, license and subscribe to Microsoft Azure_PDF.pdfHow to purchase, license and subscribe to Microsoft Azure_PDF.pdf
How to purchase, license and subscribe to Microsoft Azure_PDF.pdf
victordsane
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdfTop 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Trackobit
 
Providing Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better DataProviding Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better Data
Safe Software
 
Revolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management SoftwareRevolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management Software
Insurance Tech Services
 
Design by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First DevelopmentDesign by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First Development
Par-Tec S.p.A.
 
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
WSO2
 
Ad

mruby/c and data-flow programming for small devices

  • 1. mruby/c and data-flow programming for small devices Kazuaki Tanaka
  • 3. About me • Kazuaki Tanaka • Kyushu Institute of Technology • Lectures: Data Structure, Image Processing • Research: Embedded Systems, IoT, Wireless communication
  • 4. Activities • Ruby Association, mruby Forum, Ruby Business Council(Ruby協) • mruby, mruby/c committer
  • 5. Research on Wireless Communication • LPWA (Low Power Wide Area network) – Ultra-narrow band communication – Protocol design, Firmware – Application, Pilot experiment – Low-cost network for local government
  • 7. Pilot experiment • Rain/Wind measurement – Flood alert, land slide alert
  • 8. Topic today • Programming environment for small devices – Using mruby/c – For IoT applications
  • 10. DEMO • Blinking two LEDs • Talk about backside of this DEMO – What’s mruby/c ? – Data-flow programming – Integrating mruby/c and data-flow
  • 12. Ruby for small devices • Programming language Ruby – Object oriented programming language • mruby, mruby/c – Apply Ruby features for embedded software – Small memory footprint
  • 13. Concept of mruby • Reduce memory footprint in execution – mruby Compiler + mruby VM – Compile source code in PC – Execute compiled code in target device • Extensible libraries “mrbgems” – Easy to add new features to mruby
  • 14. Ruby, mruby, mruby/c Ruby 1 MB~ 128KB~ 20KB~ Memory Language Target device
  • 15. Targeting: Small devices • Low power, Low cost • Long-time operation • mruby/c provides, – Memory management, object reference counter – Power management – (Semi-) real-time operation
  • 16. RBoard • mruby/c ready microcontroller board – PIC32MX170F256B SRAM 64KB Flash 256KB – I/O Digital In, Out ADC, PWM, UART, I2C You can order @ chip1stop 島根情報処理センター
  • 17. mruby VM ary = [2, 4.1, 0.5, 3] ary.sort.each do |data| puts data end 00000000: 52 49 54 45 30 33 30 30 00 00 00 d6 4d 41 54 5a RITE0300....MATZ 00000010: 30 30 30 30 49 52 45 50 00 00 00 98 30 33 30 30 0000IREP....0300 00000020: 00 00 00 64 00 03 00 08 00 01 00 00 00 00 00 2f ...d.........../ 00000030: 0b 01 51 04 00 01 05 01 09 06 40 05 52 04 2d 03 [email protected]. 00000040: 00 01 08 03 0a 04 07 05 09 06 48 02 03 04 01 03 ..........H..... 00000050: 02 2f 03 01 00 57 04 00 30 03 02 00 38 03 69 00 ./...W..0...8.i. 00000060: 01 00 00 08 61 20 2a 20 33 20 3d 20 00 00 03 00 ....a * 3 = .... 00000070: 04 70 75 74 73 00 00 04 73 6f 72 74 00 00 04 65 .puts...sort...e 00000080: 61 63 68 00 00 00 00 28 00 03 00 06 00 00 00 00 ach....(........ 00000090: 00 00 00 0d 34 04 00 00 01 04 01 2d 03 00 01 38 ....4......-...8 000000a0: 03 00 00 00 01 00 04 70 75 74 73 00 4c 56 41 52 .......puts.LVAR 000000b0: 00 00 00 22 00 00 00 03 00 01 61 00 03 61 72 79 ..."......a..ary 000000c0: 00 04 64 61 74 61 00 00 00 01 00 02 ff ff 45 4e ..data........EN 000000d0: 44 00 00 00 00 08 D..... Ruby source code Compile mruby bytecode mruby VM on target device Execute mruby compiler
  • 18. Inside RBoard microcontroller RBoard Hardware HAL: Hardware Abstraction Layer mruby/c VM Application Bytecode Transfer from PC Firmware
  • 19. mruby/c on github • VM • HAL – ESP32 – PIC24 – POSIX – PSoC5LP – RP2040 (Raspberry Pi Pico) – STM32 https://github.com/mrubyc/mrubyc
  • 22. Block Programming Smalruby • Education • Entry to procedural programming loop do puts( "mruby" ) sleep(1) end
  • 25. Inject and Process QUEUE Inject: Create a packet, store into Queue Process: Retrieve a packet from Queue, process, store into Queue Packet = { destination node, payload }
  • 28. nodered2mruby • Input= Data-flow description – Node-RED JSON • Output= mruby/c – Bytecode (or mruby source)
  • 29. [ { "id": "ef2b6bb33e489cef", "type": "inject", "z": "f6f2187d.f17ca8", "name": "", "props": [], "repeat": "1", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "x": 130, "y": 100, "wires": [ [ "7438f9109319b2e9" ] ] }, ・・・・・ ]
  • 30. DEMO Program Injection 1.0 [s] Injection 2.5 [s] Green LED Red LED
  • 31. $queue = [] # main loop while true do # inject injects.each_index do |idx| inject_node injects[idx] end # process queue msg = $queue.first if msg then $queue.delete_at 0 idx = find_target(nodes, msg) if idx then process_node nodes[idx], msg else puts "node not found: #{msg[:id]}" end end # next sleep LoopInterval end Pseudo code
  • 32. Conclusion • This work is continuing, • Future work (or just idea) – Dispatching performance – Distributed system, IoT – Deploying
  • 33. Acknowledgements • murby/c developers • itoc 「しまねソフト研究開発センター」 • Kyutech students • National Institute of Technology Matsue College students
  • 34. References • https://github.com/mrubyc/ • https://github.com/nodered-mrubyc/ • K. Tanaka, S. Ogura and R. Krishnamoorthy, "Hybrid IoT Programming with Data Flow Diagrams and mruby," 2024 IEEE Conference on Dependable, Autonomic and Secure Computing (DASC), Boracay Island, Philippines, 2024, pp. 78- 82, doi: 10.1109/DASC64200.2024.00017.