-
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
changed functions to return a response struct, #7
changed functions to return a response struct, #7
Conversation
this allows for the reading of the alert bit to check for hardware errors
Solved Point 1 with a private _read function |
Also flagging that I need to update the CHANGELOG with the changes from this and the previous PR |
The PR is looking good! Thanks!
Perfect!
👍
👍 We could still create a However, it would have to have the same generic parameters as the
I like this idea. Although instead of a panic we could also just not check for it. Then the user will get a timeout on the response. I'm on the fence which is better. We could also add a strongly typed
👍 As mentioned with an in-line comment, we could also just remove the address field entirely. It's user input, so the caller doesn't really need it. |
Co-authored-by: Maarten de Vries <maarten@de-vri.es>
A leading underscore tells the compiler not to complain when the function is unused. We should avoid that. Co-authored-by: Maarten de Vries <maarten@de-vri.es>
BulkRead now returns Response with no address data renamed BulkData to BulkWriteData renamed SyncData to SyncWriteData moved and rename BulkRead to BulkReadData
Re point 2 |
I think that's everything. Ready to merge once you've had a look over :) |
Looks good! There's still the issue of We can merge the PR without these, but I want to resolve them before a new release (since both are the public API). |
see my inline comments re the |
I don't see any inline comment? Maybe you started a review instead of posting a single comment. Atleast that happens to me sometimes :) |
Can you see it now? Sorry newish to github's PR system. Here's what I wrote anyway:
Would this ever actually panic? The responses are only converted into the primitive types inside the read_u8, ... functions. If the StatusPacket has passed the crc check it should have the correct number of bytes to safely convert to the primitive. Or is that not correct? @omelia-wetaworkshop omelia-wetaworkshop Dec 14, 2023 |
No problem. I can see them now! I replied in that thread again :) |
Although the CRC check doesn't necessarily mean the message has the right format. If the other side of the communication is misbehaving, it could arrive with a wrong format but valid CRC. Although that is not a common case, we should still not panic in such situations but allow the user code to deal with it (they may panic if they want). |
I hope you don't mind, I pushed a few commits to your branch. I want to release this before going on holiday (which is very soon) :) I switched to I also changed |
Released as Thanks again for the PR. This was a pretty important fix! Btw, if you do something cool and not secret with servos using this crate, I would love to hear about it. I would also love to add some example projects to the |
Fantastic, Thanks for finishing all that off! Certainly, I would love to add some examples to the ReadMe. Ill open a PR when I have some that are cleared from secrecy ;) |
Cool! I would love to know how it's being used :D And thanks again for the PRs! Don't hesitate to send more if you have more improvements! |
This allows for the reading of the alert bit to check for hardware errors
Key changes:
Response
struct toStatusPacket
Response
motor_id
, some generically typed data, an alert bit for checking hardware errors, and an optional address used for bulkdata readsResponse
A few things I'm unsure about at the moment:
the
read
function still returns aStatusPacket
struct, its the only pub fn to do so.read_u8
is called, I didn't want to have read creating aResponse<Vec<u8>>
for it just to be converted into aResponse<u8>
.The
action
,clear
,factory_reset
, andreboot
functions returnResult<Option<Response<()>>, crate::TransferError>
The
address: Option<u16>
field of theResponse
struct is only used forbulk_read