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>
impl<S: AsyncCanSender, R: AsyncCanReceiver> SdoClient<S, R>
Sourcepub fn new_std(server_node_id: u8, sender: S, receiver: R) -> Self
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()
Sourcepub fn new(
req_cob_id: CanId,
resp_cob_id: CanId,
sender: S,
receiver: R,
) -> Self
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
Sourcepub fn set_timeout(&mut self, timeout: Duration)
pub fn set_timeout(&mut self, timeout: Duration)
Set the timeout for waiting on SDO server responses
Sourcepub fn get_timeout(&self) -> Duration
pub fn get_timeout(&self) -> Duration
Get the current timeout for waiting on SDO server responses
Sourcepub async fn download(
&mut self,
index: u16,
sub: u8,
data: &[u8],
) -> Result<(), SdoClientError>
pub async fn download( &mut self, index: u16, sub: u8, data: &[u8], ) -> Result<(), SdoClientError>
Write data to a sub-object on the SDO server
Sourcepub async fn upload(
&mut self,
index: u16,
sub: u8,
) -> Result<Vec<u8>, SdoClientError>
pub async fn upload( &mut self, index: u16, sub: u8, ) -> Result<Vec<u8>, SdoClientError>
Read a sub-object on the SDO server
Sourcepub async fn block_download(
&mut self,
index: u16,
sub: u8,
data: &[u8],
) -> Result<(), SdoClientError>
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.
Sourcepub async fn block_upload(
&mut self,
index: u16,
sub: u8,
) -> Result<Vec<u8>, SdoClientError>
pub async fn block_upload( &mut self, index: u16, sub: u8, ) -> Result<Vec<u8>, SdoClientError>
Perform a block upload of data from the node
Sourcepub async fn download_u32(
&mut self,
index: u16,
sub: u8,
data: u32,
) -> Result<(), SdoClientError>
pub async fn download_u32( &mut self, index: u16, sub: u8, data: u32, ) -> Result<(), SdoClientError>
Write to a u32 object on the SDO server
Sourcepub async fn write_u32(
&mut self,
index: u16,
sub: u8,
data: u32,
) -> Result<(), SdoClientError>
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
Sourcepub async fn download_u16(
&mut self,
index: u16,
sub: u8,
data: u16,
) -> Result<(), SdoClientError>
pub async fn download_u16( &mut self, index: u16, sub: u8, data: u16, ) -> Result<(), SdoClientError>
Write to a u16 object on the SDO server
Sourcepub async fn write_u16(
&mut self,
index: u16,
sub: u8,
data: u16,
) -> Result<(), SdoClientError>
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
Sourcepub async fn download_u8(
&mut self,
index: u16,
sub: u8,
data: u8,
) -> Result<(), SdoClientError>
pub async fn download_u8( &mut self, index: u16, sub: u8, data: u8, ) -> Result<(), SdoClientError>
Write to a u16 object on the SDO server
Sourcepub async fn write_u8(
&mut self,
index: u16,
sub: u8,
data: u8,
) -> Result<(), SdoClientError>
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
Sourcepub async fn download_i32(
&mut self,
index: u16,
sub: u8,
data: i32,
) -> Result<(), SdoClientError>
pub async fn download_i32( &mut self, index: u16, sub: u8, data: i32, ) -> Result<(), SdoClientError>
Write to an i32 object on the SDO server
Sourcepub async fn write_i32(
&mut self,
index: u16,
sub: u8,
data: i32,
) -> Result<(), SdoClientError>
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
Sourcepub async fn download_i16(
&mut self,
index: u16,
sub: u8,
data: i16,
) -> Result<(), SdoClientError>
pub async fn download_i16( &mut self, index: u16, sub: u8, data: i16, ) -> Result<(), SdoClientError>
Write to an i16 object on the SDO server
Sourcepub async fn write_i16(
&mut self,
index: u16,
sub: u8,
data: i16,
) -> Result<(), SdoClientError>
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
Sourcepub async fn download_i8(
&mut self,
index: u16,
sub: u8,
data: i8,
) -> Result<(), SdoClientError>
pub async fn download_i8( &mut self, index: u16, sub: u8, data: i8, ) -> Result<(), SdoClientError>
Write to an i8 object on the SDO server
Sourcepub async fn write_i8(
&mut self,
index: u16,
sub: u8,
data: i8,
) -> Result<(), SdoClientError>
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
Sourcepub async fn upload_utf8(
&mut self,
index: u16,
sub: u8,
) -> Result<String, SdoClientError>
pub async fn upload_utf8( &mut self, index: u16, sub: u8, ) -> Result<String, SdoClientError>
Read a string from the SDO server
Sourcepub async fn read_utf8(
&mut self,
index: u16,
sub: u8,
) -> Result<String, SdoClientError>
pub async fn read_utf8( &mut self, index: u16, sub: u8, ) -> Result<String, SdoClientError>
Alias for upload_utf8
Sourcepub async fn upload_u8(
&mut self,
index: u16,
sub: u8,
) -> Result<u8, SdoClientError>
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
Sourcepub async fn read_u8(
&mut self,
index: u16,
sub: u8,
) -> Result<u8, SdoClientError>
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
Sourcepub async fn upload_u16(
&mut self,
index: u16,
sub: u8,
) -> Result<u16, SdoClientError>
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
Sourcepub async fn read_u16(
&mut self,
index: u16,
sub: u8,
) -> Result<u16, SdoClientError>
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
Sourcepub async fn upload_u32(
&mut self,
index: u16,
sub: u8,
) -> Result<u32, SdoClientError>
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
Sourcepub async fn read_u32(
&mut self,
index: u16,
sub: u8,
) -> Result<u32, SdoClientError>
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
Sourcepub async fn upload_i8(
&mut self,
index: u16,
sub: u8,
) -> Result<i8, SdoClientError>
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
Sourcepub async fn read_i8(
&mut self,
index: u16,
sub: u8,
) -> Result<i8, SdoClientError>
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
Sourcepub async fn upload_i16(
&mut self,
index: u16,
sub: u8,
) -> Result<i16, SdoClientError>
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
Sourcepub async fn read_i16(
&mut self,
index: u16,
sub: u8,
) -> Result<i16, SdoClientError>
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
Sourcepub async fn upload_i32(
&mut self,
index: u16,
sub: u8,
) -> Result<i32, SdoClientError>
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
Sourcepub async fn read_i32(
&mut self,
index: u16,
sub: u8,
) -> Result<i32, SdoClientError>
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
Sourcepub async fn read_visible_string(
&mut self,
index: u16,
sub: u8,
) -> Result<String, SdoClientError>
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
Sourcepub async fn read_identity(&mut self) -> Result<LssIdentity, SdoClientError>
pub async fn read_identity(&mut self) -> Result<LssIdentity, SdoClientError>
Read the identity object
All nodes should implement this object
Sourcepub async fn save_objects(&mut self) -> Result<(), SdoClientError>
pub async fn save_objects(&mut self) -> Result<(), SdoClientError>
Write object 0x1010sub1 to command all objects be saved
Sourcepub async fn read_device_name(&mut self) -> Result<String, SdoClientError>
pub async fn read_device_name(&mut self) -> Result<String, SdoClientError>
Read the device name object
All nodes should implement this object
Sourcepub async fn read_software_version(&mut self) -> Result<String, SdoClientError>
pub async fn read_software_version(&mut self) -> Result<String, SdoClientError>
Read the software version object
All nodes should implement this object
Sourcepub async fn read_hardware_version(&mut self) -> Result<String, SdoClientError>
pub async fn read_hardware_version(&mut self) -> Result<String, SdoClientError>
Read the hardware version object
All nodes should implement this object
Sourcepub async fn configure_tpdo(
&mut self,
pdo_num: usize,
cfg: &PdoConfig,
) -> Result<(), SdoClientError>
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.
Sourcepub async fn configure_rpdo(
&mut self,
pdo_num: usize,
cfg: &PdoConfig,
) -> Result<(), SdoClientError>
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.
Sourcepub async fn read_rpdo_config(
&mut self,
pdo_num: usize,
) -> Result<PdoConfig, SdoClientError>
pub async fn read_rpdo_config( &mut self, pdo_num: usize, ) -> Result<PdoConfig, SdoClientError>
Read the configuration of an RPDO from the node
Sourcepub async fn read_tpdo_config(
&mut self,
pdo_num: usize,
) -> Result<PdoConfig, SdoClientError>
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§
Auto Trait Implementations§
impl<S, R> Freeze for SdoClient<S, R>
impl<S, R> RefUnwindSafe for SdoClient<S, R>where
S: RefUnwindSafe,
R: RefUnwindSafe,
impl<S, R> Send for SdoClient<S, R>
impl<S, R> Sync for SdoClient<S, R>
impl<S, R> Unpin for SdoClient<S, R>
impl<S, R> UnwindSafe for SdoClient<S, R>where
S: UnwindSafe,
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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