-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Device/Peripheral api #17
Conversation
…ructionPacket`. Moved shared reading/writing to `Messenger`, added tests `MockSerialPort` for testing
updated CHANGELOG
I had to make the endian module pub to use the fns in the tests. Not sure if this is desired or if we replace it with an external crate like byteorder |
} | ||
|
||
/// Read a single [`InstructionPacket`]. | ||
pub fn read_instruction_packet_timeout(&mut self, timeout: Duration) -> Result<InstructionPacket, ReadError<T::Error>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only having this function to read isn't very ergonomic. Ideally there would be a few for different use cases:
- blocking for some time and timing out, current behavour
- blocking forever until a packet is returned (timeout code be
None
) - returning immeditialy if there is no packet (could use crate nb, common in the embedded world)
I'm also trying to figure out how this could work with interrupts on an MCU
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only having this function to read isn't very ergonomic. Ideally there would be a few for different use cases:
* blocking for some time and timing out, current behavour * blocking forever until a packet is returned (timeout code be `None`)
This sounds good to me!
* returning immeditialy if there is no packet (could use crate [nb](https://crates.io/crates/nb), common in the embedded world) I'm also trying to figure out how this could work with interrupts on an MCU
I don't want to use the nb
crate. I think it just adds an unnecessary layer of complexity.
I prefer the approach taking by std
where you can put a socket in non-blocking mode with a member function and functions will start returning Err(WouldBlock)
.
However, this is something that serial2
doesn't support right now. That needs to be added either way, to support non-blocking reads/writes. Or we need to allow the serial port to return an error when configuring non-blocking mode (I think this is necessary either way, because there will probably be syscalls involved).
Cool!
I'm fine with the duplication. In this case I would prioritize ease-of-use over the desire not to duplicate anything. So that means not exposing the And I agree macros are too clunky. They make it more difficult for other contributors (and also for me in a year from now :p ) to understand the code base.
Cool! |
Endianness handling is simple enough with But, even better would be an API that fully parses instruction packets into Rust structs. So instead of having a |
Sweet! The Otherwise I'm pretty happy with how this feels now. I left the timeout as is for now. I think if we were to make it an I saw in the async pull request the github checks were updated to test a matrix of the different features. This is something that needs doing for this pr but I'm not very familiar with github actions. Would you be able to do that? |
Sorry for the long wait. I've been really busy with non-digital things :( Anyway, looks good! I've started on making some adjustments on the |
Added
Device
to allow a full dynamixel network to be built.Moved low level communication to to a shared private struct
Messenger
Not attached to any of the names.
Currently the methods like
open
,new
,with_buffers
etc are basically duplicated forBus
andDevice
. I wonder if we should create a builder type or makeMessenger
public and add methods for building it into aBus
orDevice
? What are your thoughts? Could also be a macro but that feels clunky.I also added an integration test with
MockSerialPort
, I thought it would be useful.