Created
October 19, 2023 01:19
-
-
Save btoconnor/37c35b0cb0c0aba4c779d73049c8594d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/tvapp/tuner/base.py b/tvapp/tuner/base.py | |
index 9a12e96..50195ea 100644 | |
--- a/tvapp/tuner/base.py | |
+++ b/tvapp/tuner/base.py | |
@@ -168,28 +168,38 @@ class Tuner: | |
# self.tunerproc = None | |
subprocess.call("rm " + STREAMDIR+self.prefix+"*", shell=True) | |
self.status = 'Stopped' | |
def check_stream(self, curtime): | |
if self.tunerproc.poll() is not None: | |
# Stream died | |
self.stop_stream(abnormal=True) | |
time.sleep(1) | |
return | |
- res = select.select([self.tunerproc.stderr], [], [], 0.1) | |
+ | |
+ procs_to_watch = [self.tunerproc.stderr] | |
+ | |
+ # TODO: This is pretty janky, just working around the | |
+ # fact that the antenna tuner has a monitor proc | |
+ # and the HDHR device doesn't. Should make this nicer | |
+ if self.monitor_proc is not None: | |
+ procs_to_watch.append(self.monitor_proc) | |
+ | |
+ res = select.select(procs_to_watch, [], [], 0.1) | |
if res[0]: | |
- self.updatetime = curtime | |
- self.tunerproc.stderr.read() | |
- # TODO: Grab output from monitor proc for CNR and SNR values | |
- # Sample message: | |
- # `Lock (0x1f) Signal= -13.00dBm C/N= 23.20dB` | |
+ if self.tunerproc.stderr in res[0]: | |
+ self.updatetime = curtime | |
+ self.tunerproc.stderr.read() | |
+ | |
+ if self.monitor_proc and self.monitor_proc.stderr in res[0]: | |
+ logging.info("Message!") | |
return | |
if (curtime - self.updatetime > FREEZETIME | |
and curtime - self.start_time > FREEZESTARTTIME): | |
# Tuner got stuck - restart it | |
logging.info( | |
"Stopping stream because frozen: curtime: {}, updatetime: {}, start time: {}".format( | |
curtime, self.updatetime, self.start_time | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment