|
@@ -57,6 +57,12 @@ if TX_interface_prefer is None: # compatibility with old ini file structure
|
|
|
|
|
|
repeat_received_commands = False # not yet implemented
|
|
|
|
|
|
+dataReceiveTimeout = config['main'].getint('dataReceiveTimeout')
|
|
|
+
|
|
|
+lastReceivedStatusFile = config['main'].get('lastReceivedStatusFile')
|
|
|
+lastReceivedStatusFileUpdateTime = 0
|
|
|
+
|
|
|
+
|
|
|
if len(sys.argv) >= 2:
|
|
|
if sys.argv[1] == "-q":
|
|
|
verbose = False
|
|
@@ -580,11 +586,28 @@ def encodeInterTechnoRX(itname, cmd):
|
|
|
if debug: log_write(" unknown or invalid IT code '" + rx_code + "'")
|
|
|
|
|
|
def cul_received(payload, source_cul):
|
|
|
- global lastReceivedTime, lastReceivedMaxAge, lastDataReceiveTime
|
|
|
+ global lastReceivedTime, lastReceivedMaxAge, lastDataReceiveTime, lastReceivedStatusFile, lastReceivedStatusFileUpdateTime
|
|
|
|
|
|
lastDataReceiveTime = time.time()
|
|
|
if debug:
|
|
|
- print("lastDataReceiveTime=" + str(lastDataReceiveTime))
|
|
|
+ print("DEBUG: lastDataReceiveTime=" + str(lastDataReceiveTime))
|
|
|
+
|
|
|
+ # touch lastReceivedStatusFile if configured
|
|
|
+ if lastReceivedStatusFile is not None:
|
|
|
+ if (time.time() - lastReceivedStatusFileUpdateTime) >= 60:
|
|
|
+ # try updating lastReceivedStatusFile if last time was >60s ago
|
|
|
+ lastReceivedStatusFileUpdateTime = time.time()
|
|
|
+ try:
|
|
|
+ touch(lastReceivedStatusFile)
|
|
|
+ if debug:
|
|
|
+ print("DEBUG: lastReceivedStatusFile updated")
|
|
|
+ except:
|
|
|
+ if debug:
|
|
|
+ print("ERROR: could not update lastReceivedStatusFile")
|
|
|
+ else:
|
|
|
+ if debug:
|
|
|
+ print("DEBUG: lastReceivedStatusFile not defined")
|
|
|
+
|
|
|
|
|
|
if payload[:2] == 'is': # msg is reply from CUL to raw send command
|
|
|
pass
|
|
@@ -882,12 +905,12 @@ try:
|
|
|
# check if receive timeout is exceeded
|
|
|
# - if so there is possibly something wrong
|
|
|
# -> quit program (will be restarted by systemd)
|
|
|
- if config['main'].get('dataReceiveTimeout') is not None:
|
|
|
- if (time.time() - lastDataReceiveTime) >= float(config['main'].get('dataReceiveTimeout')):
|
|
|
- print("WARNING: received no data from CUL for >" + str(config['main'].get('dataReceiveTimeout')) + "s -> something has gone wrong -> quitting program.")
|
|
|
+ if dataReceiveTimeout is not None:
|
|
|
+ if (time.time() - lastDataReceiveTime) >= dataReceiveTimeout:
|
|
|
+ print("WARNING: received no data from CUL for >" + str(dataReceiveTimeout) + "s -> something has gone wrong -> quitting program.")
|
|
|
quit()
|
|
|
- #else:
|
|
|
- # print("dataReceiveTimeout not configured")
|
|
|
+ ##else:
|
|
|
+ ## print("dataReceiveTimeout not configured")
|
|
|
|
|
|
|
|
|
sleep(0.05)
|