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

This is an alias for upload_f64 for a more intuitive API

Source

pub async fn upload_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 on the SDO server

This is an alias for download_f64 for a more intuitive API

Source

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

Read 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

This is an alias for upload_f32 for a more intuitive API

Source

pub async fn upload_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 on the SDO server

This is an alias for download_f32 for a more intuitive API

Source

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

Read 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

This is an alias for upload_u64 for a more intuitive API

Source

pub async fn upload_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 on the SDO server

This is an alias for download_u64 for a more intuitive API

Source

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

Read 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

This is an alias for upload_u32 for a more intuitive API

Source

pub async fn upload_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 on the SDO server

This is an alias for download_u32 for a more intuitive API

Source

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

Read a u32 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

This is an alias for upload_u16 for a more intuitive API

Source

pub async fn upload_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 on the SDO server

This is an alias for download_u16 for a more intuitive API

Source

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

Read 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

This is an alias for upload_u8 for a more intuitive API

Source

pub async fn upload_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 on the SDO server

This is an alias for download_u8 for a more intuitive API

Source

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

Read 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

This is an alias for upload_i64 for a more intuitive API

Source

pub async fn upload_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 on the SDO server

This is an alias for download_i64 for a more intuitive API

Source

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

Read 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

This is an alias for upload_i32 for a more intuitive API

Source

pub async fn upload_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 on the SDO server

This is an alias for download_i32 for a more intuitive API

Source

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

Read a i32 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

This is an alias for upload_i16 for a more intuitive API

Source

pub async fn upload_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 on the SDO server

This is an alias for download_i16 for a more intuitive API

Source

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

Read 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

This is an alias for upload_i8 for a more intuitive API

Source

pub async fn upload_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 on the SDO server

This is an alias for download_i8 for a more intuitive API

Source

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

Read a i8 sub object from the SDO server

Source

pub async fn download_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_of_day( &mut self, index: u16, sub: u8, data: TimeOfDay, ) -> Result<(), SdoClientError>

Write to a TimeOfDay object on the SDO server

Alias for download_time_of_day. This is a convenience function to allow for a more intuitive API.

Source

pub async fn download_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 write_time_difference( &mut self, index: u16, sub: u8, data: TimeDifference, ) -> Result<(), SdoClientError>

Write to a TimeDifference object on the SDO server

Alias for download_time_difference. This is a convenience function to allow for a more intuitive API.

Source

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

Read a string from the SDO server

Source

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

Alias for upload_utf8

Source

pub async fn upload_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_of_day( &mut self, index: u16, sub: u8, ) -> Result<TimeOfDay, SdoClientError>

Read a TimeOfDay object from the SDO server

Alias for upload_time_of_day. This is a convenience function to allow for a more intuitive API.

Source

pub async fn upload_time_difference( &mut self, index: u16, sub: u8, ) -> Result<TimeDifference, 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

Alias for upload_time_of_day. This is a convenience function to allow for a more intuitive API.

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_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 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> 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 = 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.