amorphic / tosr0x Goto Github PK
View Code? Open in Web Editor NEWWrapper around the Python serial module to control tosr0x USB relay boards.
License: Other
Wrapper around the Python serial module to control tosr0x USB relay boards.
License: Other
tosr0x.py fails to detect the number of relays on a 4-relay version of the board.
The reported error is:
python closezone1.py
Testing USB serial device on /dev/ttyUSB2
Traceback (most recent call last):
File "closezone1.py", line 3, in
th = tosr0x.handler('/dev/ttyUSB2')
File "/usr/local/lib/python2.7/dist-packages/tosr0x.py", line 93, in handler
devices = locate_devices(devicePaths)
File "/usr/local/lib/python2.7/dist-packages/tosr0x.py", line 101, in locate_devices
device = check_path(devicePath)
File "/usr/local/lib/python2.7/dist-packages/tosr0x.py", line 131, in check_path
thisTosr0x = relayModule(serialDevice)
File "/usr/local/lib/python2.7/dist-packages/tosr0x.py", line 163, in init
self.set_relay_count()
File "/usr/local/lib/python2.7/dist-packages/tosr0x.py", line 174, in set_relay_count
responseBits = convert_hex_to_bin_str(self.device.readall())
File "/usr/local/lib/python2.7/dist-packages/tosr0x.py", line 149, in convert_hex_to_bin_str
response = convert_hex_to_int(hexChars)[0]
IndexError: list index out of range
I added some print commands to try get the output of "self.device.readall()" and got no output.
I worked around by hardcoding __set_relay_count to report 4 relays and it works fine :)
As per this comment, apparently the call serialDevice = serial.Serial(devicePath, timeout=2)
causes a reset to 0 of all relays regardless of whether or not the relay count is passed.
If thread A and thread B both send commands to a tosr0x device in quick succession it it currently possible for thread A to receive thread B's response and vice versa.
Currently there is thread locking in place which attempts to isolate each thread's communication with the device. But apparently this isn't working in all cases.
A good suggestion in this post suggests using a queuing mechanism:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.