-
Notifications
You must be signed in to change notification settings - Fork 69
Add serial support by polling on windows #8
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
Add serial support by polling on windows #8
Conversation
This allows to use pyserial-asyncio on windows. Obviously, this is a suboptimal solution and should be improved once asyncio can use IOCP to wait on serial ports.
66468df
to
20f4aa5
Compare
ProactorEventLoop is for IOCP. |
I have seen that. Afaik, ProactorEventLoop can not wait on serials currently. Thats why we are using this workaround in the meantime. And since nobody seems to be currently trying to implement that I propose to merge the workaround in the meantime. |
Thanks for letting me know. Btw, I am very happy you made this up. I am working on a virtual RS232 hardware (SportIdent) to be able to simulate orienteering events. The current software we use which organizes them is on Windows. This workaround is very helpful for me to make a plainer code. Thanks! |
Just a single remark: I would keep the windows (read/write) poll interval (currently .0005) in the SerialTransport class as an (or two) attribute(s). |
Added a timeout attribute. Its probably simple to add the IOCP stuff to the event loop but so far nobody did that yet. This should be fine as intermediate solution. |
I agree this is a valuable workaround for Windows users until we can integrate IOCP support properly. |
@jabdoa2 @SzieberthAdam is the performance of this polling workaround hypothetically in the same ballpark as the performance in the ideal solution? or is there a pretty big gap? |
@etseidler I would expect the polling solution to be slower in principle. as the asycio scheduler cannot schedule the task which is waiting for serial I/O when such I/O becomes available. In other words, the polling solution leaves the scheduler oblivious that the task is waiting on I/O. In practice, I don't know how much difference it makes. |
@etseidler We use this on Windows for the Mission Pinball Framework to control pinball hardware and did not see any performance/latency differences so far. It just creates more CPU load when the process would be otherwise idle. 200Hz polling is not much slower than the usual schedule frequency of an OS (100-1000Hz on Linux typically). |
@jabdoa2 Am I right in thinking that the call to Also, the conditionals in the Windows versions of |
@rob-smallshire remove_writer is indeed incorrect. And yes both can be simplified. |
Co-authored-by: J. Nick Koston <nick@koston.org>
This allows to use pyserial-asyncio on windows. Obviously, this is a suboptimal solution and should be improved once asyncio can use IOCP to wait on serial ports.
Adds workaround for #3