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

Is there an asynchronous API option? #141

Open
juleq opened this issue May 14, 2020 · 2 comments
Open

Is there an asynchronous API option? #141

juleq opened this issue May 14, 2020 · 2 comments

Comments

@juleq
Copy link

juleq commented May 14, 2020

Hi there,

I am using readHoldingRegisters() and getResponseBuffer() to read two words from a device. Unfortunately the device takes ~400ms to answer and the readHoldingRegisters is blocking. I would like an API that offers either a callback or a completion flag that I can poll.

An implementation of readHoldingRegisters() would look like this:

  • Transmit the read command
  • Return control to caller immediately after that instead of a blocking receive
  • Regularly check for Serial.available by having the user all a task() function in his loop
  • Call a callback on completion or set a flag that the user can check

Maybe I have missed something and that is already available? Would seem natural when the alternative is that the whole controller is dead in the water while the slave is twiddling its thumbs :).

@nmaas87
Copy link

nmaas87 commented Dec 1, 2023

That would be really awesome, but I have also not yet found a solution for that.

@juleq
Copy link
Author

juleq commented Dec 1, 2023

It has been a while, but I did that for my employer at the time. It was not a product and contributing back was not an option at the time. It would have been a showstopper otherwise, it was a controller for multiple PSUs and loads and it could not effort that blocking.

That said, I can still offer some comforting words :). I recall that to have been rather straightforward. So I can encourage you to give it a shot. Sorry that it's not more from me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants