Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Internet of Streams - IoT in Rust

Internet of Streams - IoT in Rust

Florian Gilcher

April 17, 2019
Tweet

More Decks by Florian Gilcher

Other Decks in Programming

Transcript

  1. Internet of Streams: IoT with Rust Florian Gilcher Linuxing in

    London April 2019 CEO and Rust Trainer Ferrous Systems GmbH 1
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. DWM1001 Module and Board • Nordic nrf52 + DWM 1000

    Module • Ultra Wideband & Bluetooth capable • Can be used for location • Raspberry-Pi compatible header 8
  9. Demo and code reading time! Code by: • James Munns:

    https://github.com/jamesmunns/ • Mirabellensaft: https://github.com/mirabellensaft 9
  10. 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
  11. 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
  12. 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
  13. 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
  14. Read up on Rust • 9 books on our website:

    https://www.rust-lang.org/learn • ”The Rust Programming Language” • ”The Embedded Book” 14
  15. 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
  16. 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
  17. 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