pub trait Interface {
// Required methods
fn set_baud_rate(&mut self, b: BaudRate) -> Result<(), CommunicationError>;
fn flush(&mut self);
fn read(&mut self, data: &mut [u8]) -> Result<(), CommunicationError>;
fn write(&mut self, data: &[u8]) -> Result<(), CommunicationError>;
}Expand description
The interface for communicating with dynamixel servos.
Required Methods§
Sourcefn set_baud_rate(&mut self, b: BaudRate) -> Result<(), CommunicationError>
fn set_baud_rate(&mut self, b: BaudRate) -> Result<(), CommunicationError>
Set the baud rate of the interface
BaudRate must not be matched against exhaustively.
Sourcefn flush(&mut self)
fn flush(&mut self)
Flush out the read buffer
Whenever a new transmission is started, old data from the read buffer needs to be flushed out first.
Sourcefn read(&mut self, data: &mut [u8]) -> Result<(), CommunicationError>
fn read(&mut self, data: &mut [u8]) -> Result<(), CommunicationError>
A blocking/spinning read with timeout.
This function should either:
- read a number of bytes corresponding to
data.len()intodataand returnOk(()). - return
Err(_).
If bytes are not received for a given time, a timeout should occur.
A timeout is signaled by returning Err(Error::Timeout).
The time between bytes before a timeout occur should be 100ms or more.
If the timeout is not implemented, a “dead” servo can cause the code to “freeze”.
Sourcefn write(&mut self, data: &[u8]) -> Result<(), CommunicationError>
fn write(&mut self, data: &[u8]) -> Result<(), CommunicationError>
A blocking/spinning write.
This function should either:
- write every byte in
dataand returnOk(()). - return
Err(_).
After a transmission is started the time between two consecutive bytes need to be less than 100ms. This is because the dynamixel actuator recognizes a time of more than 100ms between bytes as a communication problem.