Skip to main content

SdoClient

Struct SdoClient 

Source
pub struct SdoClient<S, R> { /* private fields */ }
Expand description

A client for accessing a node’s SDO server

A single server can talk to a single client at a time.

Implementations§

Source§

impl<S: AsyncCanSender, R: AsyncCanReceiver> SdoClient<S, R>

Source

pub fn new_std(server_node_id: u8, sender: S, receiver: R) -> Self

Create a new SdoClient using a node ID

Nodes have a default SDO server, which uses a COB ID based on the node ID. This is a shortcut to create a client that that default SDO server.

It is possible for nodes to have other SDO servers on other COB IDs, and clients for these can be created using Self::new()

Source

pub fn new( req_cob_id: CanId, resp_cob_id: CanId, sender: S, receiver: R, ) -> Self

Create a new SdoClient from request and response COB IDs

Source

pub fn set_timeout(&mut self, timeout: Duration)

Set the timeout for waiting on SDO server responses

Source

pub fn get_timeout(&self) -> Duration

Get the current timeout for waiting on SDO server responses

Source

pub async fn download( &mut self, index: u16, sub: u8, data: &[u8], ) -> Result<(), SdoClientError>

Write data to a sub-object on the SDO server

Source

pub async fn upload( &mut self, index: u16, sub: u8, ) -> Result<Vec<u8>, SdoClientError>

Read a sub-object on the SDO server

Source

pub async fn block_download( &mut self, index: u16, sub: u8, data: &[u8], ) -> Result<(), SdoClientError>

Perform a block download to transfer data to an object

Block downloads are more efficient for large amounts of data, but may not be supported by all devices.

Source

pub async fn block_upload( &mut self, index: u16, sub: u8, ) -> Result<Vec<u8>, SdoClientError>

Perform a block upload of data from the node

Source

pub async fn read_f64( &mut self, index: u16, sub: u8, ) -> Result<f64, SdoClientError>

Read a f64 sub object from the SDO server

Source

pub async fn write_f64( &mut self, index: u16, sub: u8, value: f64, ) -> Result<(), SdoClientError>

Write a f64 sub object from the SDO server

Source

pub async fn read_f32( &mut self, index: u16, sub: u8, ) -> Result<f32, SdoClientError>

Read a f32 sub object from the SDO server

Source

pub async fn write_f32( &mut self, index: u16, sub: u8, value: f32, ) -> Result<(), SdoClientError>

Write a f32 sub object from the SDO server

Source

pub async fn read_u64( &mut self, index: u16, sub: u8, ) -> Result<u64, SdoClientError>

Read a u64 sub object from the SDO server

Source

pub async fn write_u64( &mut self, index: u16, sub: u8, value: u64, ) -> Result<(), SdoClientError>

Write a u64 sub object from the SDO server

Source

pub async fn read_u32( &mut self, index: u16, sub: u8, ) -> Result<u32, SdoClientError>

Read a u32 sub object from the SDO server

Source

pub async fn write_u32( &mut self, index: u16, sub: u8, value: u32, ) -> Result<(), SdoClientError>

Write a u32 sub object from the SDO server

Source

pub async fn read_u24( &mut self, index: u16, sub: u8, ) -> Result<u24, SdoClientError>

Read a u24 sub object from the SDO server

Source

pub async fn write_u24( &mut self, index: u16, sub: u8, value: u24, ) -> Result<(), SdoClientError>

Write a u24 sub object from the SDO server

Source

pub async fn read_u16( &mut self, index: u16, sub: u8, ) -> Result<u16, SdoClientError>

Read a u16 sub object from the SDO server

Source

pub async fn write_u16( &mut self, index: u16, sub: u8, value: u16, ) -> Result<(), SdoClientError>

Write a u16 sub object from the SDO server

Source

pub async fn read_u8( &mut self, index: u16, sub: u8, ) -> Result<u8, SdoClientError>

Read a u8 sub object from the SDO server

Source

pub async fn write_u8( &mut self, index: u16, sub: u8, value: u8, ) -> Result<(), SdoClientError>

Write a u8 sub object from the SDO server

Source

pub async fn read_i64( &mut self, index: u16, sub: u8, ) -> Result<i64, SdoClientError>

Read a i64 sub object from the SDO server

Source

pub async fn write_i64( &mut self, index: u16, sub: u8, value: i64, ) -> Result<(), SdoClientError>

Write a i64 sub object from the SDO server

Source

pub async fn read_i32( &mut self, index: u16, sub: u8, ) -> Result<i32, SdoClientError>

Read a i32 sub object from the SDO server

Source

pub async fn write_i32( &mut self, index: u16, sub: u8, value: i32, ) -> Result<(), SdoClientError>

Write a i32 sub object from the SDO server

Source

pub async fn read_i24( &mut self, index: u16, sub: u8, ) -> Result<i24, SdoClientError>

Read a i24 sub object from the SDO server

Source

pub async fn write_i24( &mut self, index: u16, sub: u8, value: i24, ) -> Result<(), SdoClientError>

Write a i24 sub object from the SDO server

Source

pub async fn read_i16( &mut self, index: u16, sub: u8, ) -> Result<i16, SdoClientError>

Read a i16 sub object from the SDO server

Source

pub async fn write_i16( &mut self, index: u16, sub: u8, value: i16, ) -> Result<(), SdoClientError>

Write a i16 sub object from the SDO server

Source

pub async fn read_i8( &mut self, index: u16, sub: u8, ) -> Result<i8, SdoClientError>

Read a i8 sub object from the SDO server

Source

pub async fn write_i8( &mut self, index: u16, sub: u8, value: i8, ) -> Result<(), SdoClientError>

Write a i8 sub object from the SDO server

Source

pub async fn write_time_of_day( &mut self, index: u16, sub: u8, data: TimeOfDay, ) -> Result<(), SdoClientError>

Write to a TimeOfDay object on the SDO server

Source

pub async fn write_time_difference( &mut self, index: u16, sub: u8, data: TimeDifference, ) -> Result<(), SdoClientError>

Write to a TimeDifference object on the SDO server

Source

pub async fn read_utf8( &mut self, index: u16, sub: u8, ) -> Result<String, SdoClientError>

Read a string from the SDO server

Source

pub async fn read_time_of_day( &mut self, index: u16, sub: u8, ) -> Result<TimeOfDay, SdoClientError>

Read a TimeOfDay object from the SDO server

Source

pub async fn read_time_difference( &mut self, index: u16, sub: u8, ) -> Result<TimeDifference, SdoClientError>

Read a TimeOfDay object from the SDO server

Source

pub async fn read_visible_string( &mut self, index: u16, sub: u8, ) -> Result<String, SdoClientError>

Read an object as a visible string

It will be read and assumed to contain valid UTF8 characters

Source

pub async fn read_bool( &mut self, index: u16, sub: u8, ) -> Result<bool, SdoClientError>

Read an object as a boolean

Source

pub async fn write_bool( &mut self, index: u16, sub: u8, value: bool, ) -> Result<(), SdoClientError>

Write an object as a boolean

Source

pub async fn read_identity(&mut self) -> Result<LssIdentity, SdoClientError>

Read the identity object

All nodes should implement this object

Source

pub async fn save_objects(&mut self) -> Result<(), SdoClientError>

Write object 0x1010sub1 to command all objects be saved

Source

pub async fn read_device_name(&mut self) -> Result<String, SdoClientError>

Read the device name object

All nodes should implement this object

Source

pub async fn read_software_version(&mut self) -> Result<String, SdoClientError>

Read the software version object

All nodes should implement this object

Source

pub async fn read_hardware_version(&mut self) -> Result<String, SdoClientError>

Read the hardware version object

All nodes should implement this object

Source

pub async fn configure_tpdo( &mut self, pdo_num: usize, cfg: &PdoConfig, ) -> Result<(), SdoClientError>

Configure a transmit PDO on the device

This is a convenience function to write the PDO comm and mapping objects based on a PdoConfig.

Source

pub async fn configure_rpdo( &mut self, pdo_num: usize, cfg: &PdoConfig, ) -> Result<(), SdoClientError>

Configure a receive PDO on the device

This is a convenience function to write the PDO comm and mapping objects based on a PdoConfig.

Source

pub async fn set_rpdo_cob_id( &mut self, pdo_num: usize, cob_id: CanId, valid: bool, rtr_disabled: bool, ) -> Result<(), SdoClientError>

Set the COB_ID config for an RPDO

Can be used to enable/disable, or change COB ID for a PDO without changing other settings

Source

pub async fn set_tpdo_cob_id( &mut self, pdo_num: usize, cob_id: CanId, valid: bool, rtr_disabled: bool, ) -> Result<(), SdoClientError>

Set the COB_ID config for an RPDO

Can be used to enable/disable, or change COB ID for a PDO without changing other settings

Source

pub async fn read_rpdo_config( &mut self, pdo_num: usize, ) -> Result<PdoConfig, SdoClientError>

Read the configuration of an RPDO from the node

Source

pub async fn read_tpdo_config( &mut self, pdo_num: usize, ) -> Result<PdoConfig, SdoClientError>

Read the configuration of a TPDO from the node

Trait Implementations§

Source§

impl<S: Debug, R: Debug> Debug for SdoClient<S, R>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S, R> Freeze for SdoClient<S, R>
where S: Freeze, R: Freeze,

§

impl<S, R> RefUnwindSafe for SdoClient<S, R>

§

impl<S, R> Send for SdoClient<S, R>
where S: Send, R: Send,

§

impl<S, R> Sync for SdoClient<S, R>
where S: Sync, R: Sync,

§

impl<S, R> Unpin for SdoClient<S, R>
where S: Unpin, R: Unpin,

§

impl<S, R> UnsafeUnpin for SdoClient<S, R>
where S: UnsafeUnpin, R: UnsafeUnpin,

§

impl<S, R> UnwindSafe for SdoClient<S, R>
where S: UnwindSafe, R: UnwindSafe,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.