-
Notifications
You must be signed in to change notification settings - Fork 14
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
Supports any serial protocol supported by the serial module #7
base: main
Are you sure you want to change the base?
Conversation
Python 3.6 support
Usage: import aioserial import serial port = serial.serial_from_url("aioserial://test?handler=loop") port = serial.serial_from_url("aioserial://<device>?handler=alt&class=<class>") port = serial.serial_from_url("aioserial://<host>:<port>?handler=rfc2217") ...
Thank for the contribution, @Governa. The idea looks great. Please allow me to take some time digesting the PR. |
If this helps, I'm going to try explaining the code a bit. I've tried to change as little as possible. Divided AioSerial in two. The first part, AioSerialMixin, is the old implementation of all methods. The AioSerial is there just so the constructor signature is fully documented and the API doesn't change. The Mixin class has a generic constructor that extracts the loop parameter and forwards all other parameters to the super class. The magic is done in protocol_serial.py. Here we find the needed serial class (using code shamelessly stolen from the serial module :) ) and create a new class using the class we found and the AioSerialMixin. The created class is named AioSerial[class name]. And finally, in the module init, we register this module as the handler of "aioserial://" URLs so that by importing aioserial this functionality is already working. This is the part I like the least, as it is a bit magical and inspecting the code, the import may seem not to be used. |
Now there are conflicting changes in the repository. I could try to fix the conflicts, but only if you think this is mergeable |
Hello to everyone, Following the documentation that states that all of the pyserial's API can be called from your library, can you illustrate a quick example of a RS485 support? https://pyserial.readthedocs.io/en/latest/pyserial_api.html#rs485-support |
The executor that reads the serial port is not terminated gracefully by aioserial when close is called and thus it touches some variables set to `Note` at that point causing `TypeError` to be raised. We handle this as disconnect because it should happen only on disconnect. The fix seems to be present in PR mrjohannchang/aioserial.py#7 but it seems that development of this project somewhat stalled. We should think about moving to some alternative if nothing happens in year or two.
Usage: