Skip to content
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

x10_any/cm17a.py is not thread safe #2

Closed
clach04 opened this issue Apr 23, 2018 · 1 comment
Closed

x10_any/cm17a.py is not thread safe #2

clach04 opened this issue Apr 23, 2018 · 1 comment

Comments

@clach04
Copy link
Owner

clach04 commented Apr 23, 2018

Simple test case (note requires hardware) will silently fail, devices will not change state:

#!/usr/bin/env python3

import threading

import x10_any

#x10_any.default_logger.setLevel(x10_any.logging.DEBUG) # DEBUG


class X10(threading.Thread):
    def __init__(self, house_code, house_num):
        threading.Thread.__init__(self)
        self.house_code = house_code
        self.house_num = house_num
        #print('%r' % ((self.house_code, self.house_num),))

    def run(self):
        # TODO use same device, probably not?
        dev = x10_any.FirecrackerDriver()
        #dev = x10_any.FirecrackerDriver('COM11')
        #dev = x10_any.FirecrackerDriver('/dev/ttyUSB0')

        #print('%r ON' % ((self.house_code, self.house_num),))
        #print('%r OFF' % ((self.house_code, self.house_num),))
        dev.x10_command(self.house_code, self.house_num, x10_any.ON)
        dev.x10_command(self.house_code, self.house_num, x10_any.OFF)


# TODO there are better ways than this....

c4 = X10('C', 4)
c6 = X10('C', 6)

c4.start()
c6.start()

# wait to stop
"""
c4.join()
c6.join()
"""
@clach04
Copy link
Owner Author

clach04 commented Apr 23, 2018

Fixed by a436608

@clach04 clach04 closed this as completed Apr 23, 2018
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

No branches or pull requests

1 participant