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 download_u32( &mut self, index: u16, sub: u8, data: u32, ) -> Result<(), SdoClientError>

Write to a u32 object on the SDO server

Source

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

Alias for download_u32

This is a convenience function to allow for a more intuitive API

Source

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

Write to a u16 object on the SDO server

Source

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

Alias for download_u16

This is a convenience function to allow for a more intuitive API

Source

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

Write to a u16 object on the SDO server

Source

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

Alias for download_u8

This is a convenience function to allow for a more intuitive API

Source

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

Write to an i32 object on the SDO server

Source

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

Alias for download_i32

This is a convenience function to allow for a more intuitive API

Source

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

Write to an i16 object on the SDO server

Source

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

Alias for download_i16

This is a convenience function to allow for a more intuitive API

Source

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

Write to an i8 object on the SDO server

Source

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

Alias for download_i8

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_u8( &mut self, index: u16, sub: u8, ) -> Result<u8, SdoClientError>

Read a sub-object from the SDO server, assuming it is an u8

Source

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

Alias for upload_u8

This is a convenience function to allow for a more intuitive API

Source

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

Read a sub-object from the SDO server, assuming it is an u16

Source

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

Alias for upload_u16

This is a convenience function to allow for a more intuitive API

Source

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

Read a sub-object from the SDO server, assuming it is an u32

Source

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

Alias for upload_u32

This is a convenience function to allow for a more intuitive API

Source

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

Read a sub-object from the SDO server, assuming it is an i8

Source

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

Alias for upload_i8

This is a convenience function to allow for a more intuitive API

Source

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

Read a sub-object from the SDO server, assuming it is an i16

Source

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

Alias for upload_i16

This is a convenience function to allow for a more intuitive API

Source

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

Read a sub-object from the SDO server, assuming it is an i32

Source

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

Alias for upload_i32

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.