You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
aioserial is an excellent package for writing and reading data from serial ports. Thanks for creating it!
I have a serial device I am communicating with that can receive commands and respond to those commands. For example, I can write {get_temperature} to the serial port and the serial device will respond back with the current temperature. The aioserial package handles this task elegantly.
My serial device will also send back data to indicate that a button, for example, has been pushed on the device. This data is sent back asynchronously without being initiated by a command from the client computer. I think it's just my ignorance of asyncio, but I'm trying to figure out how to receive and process these button push events arriving from the serial device while still being able to send specific commands and receive responses from the serial device.
Here's the code I've written so far for getting temperature:
You are awaiting a readline. So long as your async button response is terminated as well, you could add a line after your result = await ... to handle the button push.
Personally, I would use the send_command_await_response and a dict of responses with handlers and maybe regex too depending on the responses (if it cannot be filtered with a simple starts_with).
Judging from the date, you probably solved this by now. I am really just probing to see how active this project is before using it in my own applications.
aioserial
is an excellent package for writing and reading data from serial ports. Thanks for creating it!I have a serial device I am communicating with that can receive commands and respond to those commands. For example, I can write
{get_temperature}
to the serial port and the serial device will respond back with the current temperature. Theaioserial
package handles this task elegantly.My serial device will also send back data to indicate that a button, for example, has been pushed on the device. This data is sent back asynchronously without being initiated by a command from the client computer. I think it's just my ignorance of
asyncio
, but I'm trying to figure out how to receive and process these button push events arriving from the serial device while still being able to send specific commands and receive responses from the serial device.Here's the code I've written so far for getting temperature:
Can you share some insights into how I could use
aioserial
to accomplish my objective?The text was updated successfully, but these errors were encountered: