Giter VIP home page Giter VIP logo

tosr0x's People

Contributors

alexroche avatar amorphic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tosr0x's Issues

tosr0x does not work on 4-relay versions of the board

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

Ensure thread safety

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:

http://stackoverflow.com/questions/4043193/python-how-to-share-a-serial-port-with-two-different-threads-class-a-class-b

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.