Skip to content
Snippets Groups Projects
Commit c9cecece authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-244: Include fail safe if packets are unparsable for a reason we didnt know about yet

parent d9594ecd
No related branches found
No related tags found
1 merge request!56L2SS-244: Expose the SSTs in MPs
......@@ -188,11 +188,12 @@ class SST_collector(Thread):
self.last_packet = self.queue.get()
if self.last_packet is None:
logging.info("shutting down SST thread")
break
self.process_packet(self.last_packet)
logging.info("shutting down SST thread")
def join(self, timeout=0):
logging.info("sending shutdown to SST thread")
self.queue.put(None)
......@@ -205,31 +206,37 @@ class SST_collector(Thread):
self.parameters["queue_fill_percentage"] = numpy.double(100 * self.queue.qsize() / self.queue.maxsize if self.queue.maxsize else 0)
try:
fields = StatisticsPacket(packet)
except ValueError:
# could not parse header
self.parameters["nof_invalid_packets"] += numpy.uint64(1)
return
if fields.marker != 'S':
# packet is not SST
self.parameters["nof_invalid_packets"] += numpy.uint64(1)
return
input_index = fields.sst_signal_input_index
try:
fields = StatisticsPacket(packet)
except ValueError:
# could not parse header
self.parameters["nof_invalid_packets"] += numpy.uint64(1)
return
if fields.marker != 'S':
# packet is not SST
self.parameters["nof_invalid_packets"] += numpy.uint64(1)
return
input_index = fields.sst_signal_input_index
if input_index >= self.MAX_INPUTS:
# packet describes an input that is out of bounds for us
self.parameters["nof_invalid_packets"] += numpy.uint64(1)
return
if fields.payload_error:
# cannot trust the data if a payload error is reported
self.parameters["nof_payload_errors"][input_index] += numpy.uint64(1)
return
# process the packet
self.parameters["nof_valid_packets"][input_index] += numpy.uint64(1)
self.parameters["last_values"][input_index][:fields.nof_statistics_per_packet] = fields.payload_sst
self.parameters["last_timestamps"][input_index] = numpy.float64(fields.timestamp().timestamp())
self.parameters["integration_intervals"][input_index] = fields.integration_interval()
except Exception as e:
# This is unexpected, so print a stack trace
logging.exception("Could not parse UDP packet")
if input_index >= self.MAX_INPUTS:
# packet describes an input that is out of bounds for us
self.parameters["nof_invalid_packets"] += numpy.uint64(1)
return
if fields.payload_error:
# cannot trust the data if a payload error is reported
self.parameters["nof_payload_errors"][input_index] += numpy.uint64(1)
return
# process the packet
self.parameters["nof_valid_packets"][input_index] += numpy.uint64(1)
self.parameters["last_values"][input_index][:fields.nof_statistics_per_packet] = fields.payload_sst
self.parameters["last_timestamps"][input_index] = numpy.float64(fields.timestamp().timestamp())
self.parameters["integration_intervals"][input_index] = fields.integration_interval()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment