1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! # canopen-rs
//!
//! A `no_std`-first [CANopen] (CiA 301) protocol stack in Rust.
//!
//! This core crate is transport-agnostic and allocation-free: it models the
//! object dictionary, encodes/decodes SDO and PDO messages, and drives the
//! NMT state machine. It is designed to run unchanged on a bare-metal MCU
//! node and on a host (Linux/SocketCAN) via the companion `canopen-host`
//! crate.
//!
//! CAN frames are represented through the [`embedded_can`] traits, so any
//! controller or socket that implements them can carry CANopen traffic.
//!
//! # Example: an SDO read, transport-free
//!
//! A device exposes an [`ObjectDictionary`]; a [client](sdo::SdoClient) reads it
//! from a [server](sdo::SdoServer) one frame at a time — no bus required, so the
//! same logic runs on a host or an MCU.
//!
//! ```
//! use canopen_rs::sdo::{SdoClient, SdoEvent, SdoServer};
//! use canopen_rs::{Address, DataType, Entry, NodeId, ObjectDictionary, Value};
//!
//! let node = NodeId::new(0x10).unwrap();
//!
//! // The device's object dictionary, served by an SDO server.
//! let mut od = ObjectDictionary::<8>::new();
//! od.insert(Address::new(0x1000, 0), Entry::constant(Value::Unsigned32(0x1234))).unwrap();
//! let mut server = SdoServer::new(node);
//!
//! // The client drives the transaction; expedited vs segmented is automatic.
//! let mut client = SdoClient::new(node);
//! let mut frame = client.read(Address::new(0x1000, 0), DataType::Unsigned32);
//! let value = loop {
//! let response = server.handle(&mut od, &frame).expect("server replies");
//! match client.on_response(&response) {
//! SdoEvent::Send(next) => frame = next,
//! SdoEvent::Complete(v) => break v.unwrap(),
//! SdoEvent::Aborted(code) => panic!("aborted {code:#010x}"),
//! }
//! };
//! assert_eq!(value, Value::Unsigned32(0x1234));
//! ```
//!
//! ## Status
//!
//! Early development. The API will change. See the roadmap in the workspace
//! `README.md`.
//!
//! [CANopen]: https://www.can-cia.org/canopen/
// Enable once the public API stabilises:
// #![warn(missing_docs)]
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use SyncCounter;
pub use ;