8000 Add serial support by polling on windows by jabdoa2 · Pull Request #8 · pyserial/pyserial-asyncio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 3 commits into from
Jul 16, 2016

Conversation

jabdoa2
Copy link
Contributor
@jabdoa2 jabdoa2 commented Jul 13, 2016

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

jabdoa2 added 2 commits July 13, 2016 23:23
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.
@jabdoa2 jabdoa2 force-pushed the windows_polling_support branch from 66468df to 20f4aa5 Compare July 13, 2016 23:16
@SzieberthAdam
Copy link

@jabdoa2
Copy link
Contributor Author
jabdoa2 commented Jul 14, 2016

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.

@SzieberthAdam
Copy link
SzieberthAdam commented Jul 14, 2016

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!

8000

@SzieberthAdam
Copy link
SzieberthAdam commented Jul 14, 2016

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).

@jabdoa2
Copy link
Contributor Author
jabdoa2 commented Jul 14, 2016

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.

@rob-smallshire
Copy link
Collaborator

I agree this is a valuable workaround for Windows users until we can integrate IOCP support properly.

@rob-smallshire rob-smallshire merged commit cc15462 into pyserial:master Jul 16, 2016
@etseidler
Copy link

@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?

@rob-smallshire
Copy link
Collaborator

@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.

@jabdoa2
Copy link
Contributor Author
jabdoa2 commented Jan 22, 2017

@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).

@rob-smallshire
Copy link
Collaborator

@jabdoa2 Am I right in thinking that the call to self._loop.remove_writer(self._serial.fileno()) in the Windows version of SerialTransport._remove_writer() is incorrect, as we never call add_reader() on Windows?

Also, the conditionals in the Windows versions of self._loop.remove_writer() self._loop.remove_reader() seem unnecessary, do you agree?

@jabdoa2
Copy link
Contributor Author
jabdoa2 commented Jan 22, 2017

@rob-smallshire remove_writer is indeed incorrect. And yes both can be simplified.

@jabdoa2 jabdoa2 deleted the windows_polling_support branch January 22, 2017 13:52
mvn23 pushed a commit to mvn23/pyserial-asyncio that referenced this pull request Jun 28, 2024
Co-authored-by: J. Nick Koston <nick@koston.org>
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

Successfully merging this pull request may close these issues.

4 participants
0