Trait dynamixel::Interface
[−]
[src]
pub trait Interface { 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>; }
The interface for communicating with dynamixel servos.
Required Methods
fn set_baud_rate(&mut self, b: BaudRate) -> Result<(), CommunicationError>
Set the baud rate of the interface
BaudRate
must not be matched against exhaustively.
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.
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()
intodata
and 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".
fn write(&mut self, data: &[u8]) -> Result<(), CommunicationError>
A blocking/spinning write.
This function should either:
- write every byte in
data
and 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.