Skip to main content

Module node

Module node 

Source
Expand description

A CANopen device node — object dictionary + SDO server + NMT state in one frame-driven type.

Node bundles the pieces a device needs and, like the rest of the stack, is sans-I/O: hand each incoming CAN frame to Node::on_frame and transmit the TxFrame it returns (if any). It serves SDO requests against its object dictionary, tracks NMT state from node-control commands, and produces boot-up and heartbeat frames — the same logic on a host or an MCU.

let mut od = ObjectDictionary::<16>::new();
od.insert(Address::new(0x1000, 0), Entry::constant(Value::Unsigned32(0x0004_0192))).unwrap();
let mut node = Node::new(NodeId::new(0x10).unwrap(), od);

let boot = node.boot();            // enter pre-operational, announce boot-up
bus_send(boot.cob_id, boot.data());

loop {
    let (cob_id, data) = bus_recv();
    if let Some(tx) = node.on_frame(cob_id, &data) {
        bus_send(tx.cob_id, tx.data());
    }
}

Structs§

Node
A CANopen device node: an object dictionary served over SDO, with NMT state, heartbeat/boot-up production, and PDO exchange.
TxFrame
A frame to transmit: an 11-bit COB-ID and up to eight data bytes.

Constants§

MAX_PDOS
The maximum number of transmit (or receive) PDOs a Node holds — the four of the predefined connection set.
MAX_PDO_MAPPING
The maximum objects mapped into one PDO: a full eight-byte frame of one-byte objects.