book.derekmolloy.ie
Interactive Textbook

Edge Programming
with C/C++ and Rust

Master physical AI, memory safety, and hardware constraints. A modern guide to bridging the gap between high-level logic and low-level sensor interfaces.

By Prof. Derek Molloy
Dublin City University
src/sensor_node.rs
// Derek's annotation:
// Ensure safe memory access at the edge
pub fn read_sensor_data(address: u16) -> Result<f32, Error> {
    let mut buffer = [0u8; 4];
    
    match hardware_bus.read(address, &mut buffer) {
        Ok(_) => Ok(f32::from_le_bytes(buffer)),
        Err(e) => {
            log_error!("I2C failure at node");
            Err(e)
        }
    }
}

Core Concepts

This book bridges the gap between traditional embedded C/C++ development and modern, memory-safe paradigms using Rust.

Low-Level Hardware

Master the fundamentals of interacting with physical hardware. Understand GPIO, I2C, SPI, and UART protocols through hands-on examples using standard C++.

🔒

Memory Safety

Learn why memory safety is critical at the edge. Transition into Rust to build robust, thread-safe applications without sacrificing the performance of bare-metal C.

🦀

Physical AI

Deploy machine learning models directly onto constrained edge devices. Manage thermal limits, power consumption, and real-time sensor latency.

Real-time Constraints

Design architectures that guarantee deterministic execution. Explore real-time operating systems (RTOS) and interrupt-driven paradigms.

From the Lab

⚠ Lab Tip

Always verify logic level voltage (3.3V vs 5V) before connecting sensor arrays to GPIO to prevent catastrophic board failure.

ℹ Professor's Note

Notice how Rust's strict compiler eliminates the classic null-pointer dereference bugs we encountered in Chapter 2.

Built for Interactive Learning

This book isn't just static text. Built on top of the Starlight framework, it features interactive code blocks, integrated terminal environments, and rich visual marginalia to recreate the experience of a guided laboratory session.

Terminal Emulator:

user@edge-node:~/aiot-lab$ cargo build --release