Skip to main content

FastscanMaster

Struct FastscanMaster 

Source
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

Source

pub const fn new() -> Self

Start a fresh Fastscan.

Source

pub fn next_request(&self) -> Option<LssFrame>

The next Fastscan frame to transmit on LSS_MASTER_COB_ID, or None once discovery has finished.

Source

pub fn on_response(&mut self, responded: bool)

Report whether the last next_request drew an identify-slave response, advancing the scan.

Source

pub const fn found(&self) -> bool

Whether an unconfigured node answered the initial probe.

Source

pub const fn is_complete(&self) -> bool

Whether the scan has run to completion.

Source

pub const fn address(&self) -> LssAddress

The discovered address — meaningful once is_complete and found are both true.

Trait Implementations§

Source§

impl Debug for FastscanMaster

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FastscanMaster

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.