most crucial security equipment you can have while diving • Constantly tracks your depth and your (calculated) absorption of Nitrogen • Absorbed Nitrogen is the cause of divers' sickness • Continues tracking the release of Nitrogen during surface times • Calculates the time you can spend at depth • Checks a safe ascent speed • Usually provides a tracking function for later
dive computer is always in waiting mode • It provides a simple configuration interface • Gas mixture • Timer and warning settings • It does not allow to switch off safety features • After a dive, stays in “No Fly mode” for 24 hours • Cannot be switched off • Provides dive history • Marks dives where you ascended too quickly
is activated on first contact with water • Tracks every tick • Depth • Temperature • Remaining “No Deco(mpression)”-Time • If “0”, decompression depth • Saves those data points regularly • Calculates your modelled Nitrogen absorption on every tick • Presents you with: • Remaining time at current depth • Ascent/Descent speed • Separate “stop” mode
Dive computers are security equipment, don’t mess with it • Buy a cable (60 EUR for a 200 EUR computer) • Figure out it doesn’t connect properly • Try to figure out what the dive computer actually exposes • Hint: it’s rarely documented • Use libdivecomputer as a reference
• Memory layout type • Works mostly by listing • Page sizes on the computer • Address models • USB/Serial differentiation • Fully Iterator-Based • Fully dynamic dispatch based
= serialport::open(&computer.port_name) ?; let cmd: &[u8] = &[0x84, 0x00]; let res = port.write(cmd); This will trigger the computer to respond with its name. "AQUAI300 \0\0 512K“
= read_cf_pointers(port)?; let mut rdr = Cursor::new(&pointers[4..]); let rb_logbook_first = rdr.read_u16::<LittleEndian>().unwrap(); let rb_logbook_last = rdr.read_u16::<LittleEndian>().unwrap(); These two are pointers into a ringbuffer, giving us the first and last logbook locations. The logbook just contains general dive data and is of fixed size. The ringbuffer size is known.
in idiomatic encoding • Pointers vs. Values • Differences in Algorithm abstraction • Cursor type for reading instead of a function • Rust favors indexing, C favours pointer calculations • Dynamic dispatch is common in C, avoided in Rust
have awesome users documentation! • Lingo is the hardest to learn • A good C codebase is good to read up on, but a mediocre architecture reference • Implementing off a data sheet would be easier • The page based memory model is actually nice to learn on • \0\0 seems to be a separator people use
to compete with libdivecomputer • At least without hundreds of computer models • Iterator model is easy to interface with using Rust • Dynamic dispatch model is easy to interface with using Rust • I got my fun out of it!