pub struct FastscanMaster { /* private fields */ }Expand description
A sans-I/O LSS master that discovers an unconfigured node’s 128-bit
LssAddress by Fastscan, when the master does not know it up front.
It walks the four identity values, bisecting each from the most significant
bit: for every bit it emits a next_request
frame, the caller transmits it and reports — via
on_response — whether an
is_identify_slave_response arrived on LSS_SLAVE_COB_ID within the
LSS timeout. After is_complete, the matched
node is in the configuration state and its address
is known — ready for encode_configure_node_id.
use canopen_rs::lss::{FastscanMaster, LssAddress, LssSlave, UNCONFIGURED_NODE_ID};
let address = LssAddress { vendor_id: 0x1F, product_code: 0x2A, revision_number: 1, serial_number: 0x1234 };
let mut slave = LssSlave::new(address, UNCONFIGURED_NODE_ID);
let mut master = FastscanMaster::new();
while let Some(req) = master.next_request() {
let answered = slave.handle(&req).is_some(); // stand-in for the bus round-trip
master.on_response(answered);
}
assert!(master.found());
assert_eq!(master.address(), address);Implementations§
Source§impl FastscanMaster
impl FastscanMaster
Sourcepub fn next_request(&self) -> Option<LssFrame>
pub fn next_request(&self) -> Option<LssFrame>
The next Fastscan frame to transmit on LSS_MASTER_COB_ID, or None
once discovery has finished.
Sourcepub fn on_response(&mut self, responded: bool)
pub fn on_response(&mut self, responded: bool)
Report whether the last next_request
drew an identify-slave response, advancing the scan.
Sourcepub const fn is_complete(&self) -> bool
pub const fn is_complete(&self) -> bool
Whether the scan has run to completion.
Sourcepub const fn address(&self) -> LssAddress
pub const fn address(&self) -> LssAddress
The discovered address — meaningful once is_complete
and found are both true.