Skip to content
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

Avoid using event callbacks for mono compatibility #13

Merged
merged 2 commits into from
Jan 31, 2024
Merged

Conversation

glopesdev
Copy link
Member

This PR refactors the serial interface to use an interruptible polling strategy to allow the Pulse Pal package to run cross-platform using the Mono framework.

Fixes #11

@glopesdev glopesdev added the feature New planned feature label Jan 30, 2024
@glopesdev glopesdev added this to the 0.2.0 milestone Jan 30, 2024
@RoboDoig
Copy link
Collaborator

This doesn't necessarily need to be resolved for this PR, but I notice now that the behavior of the ProcessInput method needs to be slightly different depending on what command caused bytes to be read in the serial reading task.

Most commands return a single byte, but the value can represent a voltage, state etc. depending on what the initiating command was. Moreover, some commands will return sequences of bytes, for example the handshake command that is used to determine firmware version returns the ack character followed by 4 bytes, in this case ProcessInput needs to operate on a byte array rather than a single byte.

One option might be to write an op code into the readBuffer on every command. ProcessInput is always called on the full readBuffer rather than a single byte, and can expect that the first byte will be a context op code determining how it should treat the remaining values in the readBuffer.

@glopesdev
Copy link
Member Author

This doesn't necessarily need to be resolved for this PR, but I notice now that the behavior of the ProcessInput method needs to be slightly different depending on what command caused bytes to be read in the serial reading task.

@RoboDoig agreed that ProcessInput needs to be changed for the new implementation, I avoided doing it in this PR so we could keep it contained to the change from event-based to polling.

@glopesdev glopesdev merged commit d03a742 into main Jan 31, 2024
2 checks passed
@glopesdev glopesdev deleted the create-pulsepal branch January 31, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New planned feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use polling pattern to allow package to run on mono
3 participants