Serial communication may be blocking
I think the higher-level write_and_read will block with this serial implementation. There needs to be an async wait-until-ready part.
I don't know how best to do this with serial today.
Originally posted by @patrickfuller in https://github.com/numat/alicat/pull/37#discussion_r1164442331
I can confirm this is definitely an issue with the module. I believe pyserial was mostly written before asyncio was common. There's a pyserial-asyncio extension that appears to implement a cross-platfrom async serial implementation, but ... it also looks like pyserial is not well maintained these days.
Unclear if the solution is to bring in pyserial-asyncio (or the homelab fork) and hope for the best, or if it makes sense to make changes the serial backend to natively support interactions with serial file-descriptors using O_NONBLOCK and some Windows-specific nonsense for that platform.
I was thrilled to see that this module was recent and featured an async API, but learning that the serial comms are not actually async under the hood makes a fix for this issue imperative for me. I'll start work on a PR.
I can confirm this is definitely an issue with the module. I believe pyserial was mostly written before asyncio was common. There's a pyserial-asyncio extension that appears to implement a cross-platfrom async serial implementation, but ... it also looks like pyserial is not well maintained these days.
Unclear if the solution is to bring in pyserial-asyncio (or the homelab fork) and hope for the best, or if it makes sense to make changes the serial backend to natively support interactions with serial file-descriptors using O_NONBLOCK and some Windows-specific nonsense for that platform.
I was thrilled to see that this module was recent and featured an async API, but learning that the serial comms are not actually async under the hood makes a fix for this issue imperative for me. I'll start work on a PR.
Thanks for your comment, and I hope the library can be of use to you. Please send any pull requests to alexrudd2/alicat as that fork is actively maintained.
https://github.com/alexrudd2/alicat/pull/44