|
Post by Jason on Sept 7, 2023 4:45:55 GMT -8
It appears the thread used to run the radio stops working periodically on my RPi Zero W. I spent some time this weekend testing a code change that appears to address the problem.
I moved the following code block in readSensors() within wirelessSensors.py to a separate function:
p = Popen(cmd, stdout=PIPE, stderr=STDOUT, bufsize=1, close_fds=ON_POSIX) q = Queue()
t = Thread(target=enqueue_output, args=('stdout', p.stdout, q))
t.daemon = True # thread dies with the program t.start() The new function is as follows:
def open_radio():
p = Popen(cmd, stdout=PIPE, stderr=STDOUT, bufsize=1, close_fds=ON_POSIX) q = Queue()
t = Thread(target=enqueue_output, args=('stdout', p.stdout, q))
t.daemon = True # thread dies with the program t.start()
return q, t The first code block above has been replaced with the following block:
q, t = open_radio() Within the main WHILE loop, I added the following IF block:
while true: if not t.is_alive(): q, t = open_radio() Thanks,
Jason
|
|