aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2020-11-02 14:13:39 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2020-11-02 14:13:39 +0100
commitdac531ddb170c6ad01ad479d5bc1158cfb98be3e (patch)
treed95616908619f46fb65a686b26b820806dda60bf
parent2f0530459ae5a2ae6b1c46a1083096d11d68cc83 (diff)
downloadglutte-serial-web-dac531ddb170c6ad01ad479d5bc1158cfb98be3e.tar.gz
glutte-serial-web-dac531ddb170c6ad01ad479d5bc1158cfb98be3e.tar.bz2
glutte-serial-web-dac531ddb170c6ad01ad479d5bc1158cfb98be3e.zip
Also parse CC uptime
-rw-r--r--serialrx.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/serialrx.py b/serialrx.py
index 5f62fea..2d4238a 100644
--- a/serialrx.py
+++ b/serialrx.py
@@ -30,7 +30,7 @@ import time
import config
-re_cc_capa = re.compile(r"\[\d+\] CC: CAPA,\d+,(\d+)")
+re_cc_capa = re.compile(r"\[\d+\] CC: CAPA,(\d+),(\d+)")
re_cc_vbat_plus = re.compile(r"\[\d+\] CC: VBAT\+,\d+,(\d+)")
re_num_sv = re.compile(r"\[\d+\] T_GPS.+ (\d+) SV tracked")
re_alim = re.compile(r"\[\d+\] ALIM (\d+) mV")
@@ -41,6 +41,8 @@ class MessageParser:
def __init__(self):
self._lock = threading.Lock()
+ self._last_cc_timestamp_time = 0
+ self._last_cc_timestamp = 0
self._last_cc_capa = 0
self._last_cc_capa_time = 0
self._last_vbat_plus = 0
@@ -58,8 +60,10 @@ class MessageParser:
with self._lock:
match = re_cc_capa.search(message)
if match:
- self._last_cc_capa = int(match.group(1))
- self._last_cc_capa_time = time.time()
+ self._last_cc_timestamp = int(match.group(1))
+ self._last_cc_capa = int(match.group(2))
+ self._last_cc_timestamp_time = \
+ self._last_cc_capa_time = time.time()
match = re_cc_vbat_plus.search(message)
if match:
@@ -93,7 +97,8 @@ class MessageParser:
"alim": (self._last_alim, self._last_alim_time),
"num_sv": (self._last_num_sv, self._last_num_sv_time),
"temp": (self._last_temp, self._last_temp_time),
- "relay": (self._last_relay, self._last_relay_time)}
+ "relay": (self._last_relay, self._last_relay_time),
+ "uptime": (self._last_cc_timestamp, self._last_cc_timestamp_time)}
class SerialRX(threading.Thread):
def __init__(self):