alicat icon indicating copy to clipboard operation
alicat copied to clipboard

Serial communication may be blocking

Open alexrudd2 opened this issue 3 years ago • 2 comments

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

alexrudd2 avatar Apr 12 '23 17:04 alexrudd2

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.

griffinmilsap avatar Mar 11 '25 15:03 griffinmilsap

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.

alexrudd2 avatar Mar 11 '25 17:03 alexrudd2

https://github.com/alexrudd2/alicat/pull/44

alexrudd2 avatar Nov 04 '25 01:11 alexrudd2