Slide 1

Slide 1 text

Internet of Streams: IoT with Rust Florian Gilcher Linuxing in London April 2019 CEO and Rust Trainer Ferrous Systems GmbH 1

Slide 2

Slide 2 text

Whoami • Florian Gilcher • CEO https://asquera.de, https://ferrous-systems.com • Rust Programmer and Trainer: https://rust-experts.com • Leadership Rust (Community Team, Rust Core, Rust Events Team) • Organizing events and meetups • Previously 10 years of Ruby community work 2

Slide 3

Slide 3 text

A short overview of Rust • Built by Mozilla to improve the safety of systems programming • Statically typed, compiled language • Memory-safe with all memory management static • No Runtime/VM • Semantically lands somewhere between C and C++ • With the speed of both • but safer 3

Slide 4

Slide 4 text

You can’t spell trust without Rust • Convenience of a modern high-level language • Allows for safe manual memory management • Doesn’t need a heap • Eliminates multiple classes of bugs at compile time • One of the rare languages with language level checks for concurrency • Released in 2015 • Since 2018 stable for development on bare metal devices 4

Slide 5

Slide 5 text

Who care about (memory) safety? • Writing memory safe code in unsafe languages is an effort • Bugs are often subtle and sometimes hard to debug • Patching of remote devices is expensive • Memory bugs are regularly security bugs • Is considered required in a lot of places 5

Slide 6

Slide 6 text

Ownership use std::fs::File; use std::io::Read; fn main() -> Result<(), std::io::Error> { let mut contents = String::new(); let mut file = File::open("hello_world.rs")?; file.read_to_string(&mut contents)?; println!("{}", contents); Ok(()) } 6

Slide 7

Slide 7 text

Project • 5 decawaves • 4 software components • A REST application with Display • A gateway • A modem device • 4 devices acting as senders • All built in a consistent environment 7

Slide 8

Slide 8 text

DWM1001 Module and Board • Nordic nrf52 + DWM 1000 Module • Ultra Wideband & Bluetooth capable • Can be used for location • Raspberry-Pi compatible header 8

Slide 9

Slide 9 text

Demo and code reading time! Code by: • James Munns: https://github.com/jamesmunns/ • Mirabellensaft: https://github.com/mirabellensaft 9

Slide 10

Slide 10 text

Embedded development usecases • ”loop in main” development • We have a lightweight scheduler available (RTFM - Realtime for the Masses) • Also available: full realtime operating systems (like TOCK) 10

Slide 11

Slide 11 text

Embedded development aspects • A FOSS ecosystem maintained by the community • Integration into the standard toolchain of the language • Debuggable using the tools you know and use • Abstracting and supplying the annoying parts to make you care about the important problems • At low to zero cost 11

Slide 12

Slide 12 text

Cross-cutting concerns: Serialization • Uses the same serialisiation framework everywhere (ser/de) • Using different protocol implementations • No custom serialization code • Choose the optimal serialization for every layer 12

Slide 13

Slide 13 text

Pragmatism • Rust can tied into C at no cost • Rust can be embedded in everything that can deal native libraries • Rust has an special sublanguage for unsafe things 13

Slide 14

Slide 14 text

Read up on Rust • 9 books on our website: https://www.rust-lang.org/learn • ”The Rust Programming Language” • ”The Embedded Book” 14

Slide 15

Slide 15 text

Roadmap • Rust for embedded went 1.0 in 2018 • If you are used to build you own components, you’ll feel right at home • If you are heavily using components, it’s already worth trying • 2019 will make the ecosystem 1.0, goal is stability and maturity • 2020 wants to be as convenient as desktop Rust 15

Slide 16

Slide 16 text

How convenient is Rust? • Much more then 3 years ago • StackOverflows most loved language 4 times in a row! • 2.41:1 ratio of preference:expertise ratio in Go’s 2019 survey. • Our compiler error messages are a current industry standard • We write books! Tons of them! 16

Slide 17

Slide 17 text

Conclusion: Access all areas • Rust is useable in all IoT-relevant areas • Hardware support is growing fast • ARM targets are great • RISC-V and others are coming • It can be used throughout the stack 17

Slide 18

Slide 18 text

Where is embedded Rust used? • NZ Firefighters • logistics/tracking • Robotics • Doors and Locks 18

Slide 19

Slide 19 text

Internet of Streams • https://github.com/ferrous-systems/internet-of-streams/ • https://github.com/ferrous-systems/embedded-trainings/ 19

Slide 20

Slide 20 text

Thank you! • https://twitter.com/argorak • https://github.com/skade • https://speakerdeck.com/skade • florian.gilcher@ferrous-systems.com • https://ferrous-systems.com • https://rust-experts.com 20