added a timeout counter, also as fake channel

This commit is contained in:
2023-06-01 17:38:16 +02:00
parent 89446f0c56
commit 2c66613b88

View File

@ -26,14 +26,18 @@ class BSCache:
def run(self, running):
timeout_counter = 0
configs = self.channels.values()
with source(channels=configs, receive_timeout=self.timeout) as src:
while running.is_set():
msg = src.receive()
if msg is None:
timeout_counter += 1
print("receive timed out", timeout_counter)
continue
data = repack(msg)
if data:
data["toc"] = timeout_counter
yield data
@ -42,7 +46,7 @@ class BSCache:
def get_var(self, name, modulo=None, offset=None):
if name != "pid" and name not in self.channels:
if name not in ["pid", "toc"] and name not in self.channels:
if not is_available(name):
raise ValueError(f"channel {name} is not available")
cfg = make_channel_config(name, modulo, offset)