added try except block

This commit is contained in:
Robin Müller 2021-12-15 11:19:19 +01:00
parent f6a3f79220
commit eca5bba1d8
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -26,6 +26,7 @@ def ccsds_tm_handler(apid: int, raw_tm_packet: bytearray, tmtc_printer: TmTcPrin
def pus_factory_hook(raw_tm_packet: bytearray, tmtc_printer: TmTcPrinter):
service_type = raw_tm_packet[7]
tm_packet = None
try:
if service_type == 1:
tm_packet = Service1TMExtended.unpack(raw_telemetry=raw_tm_packet)
if service_type == 3:
@ -40,3 +41,6 @@ def pus_factory_hook(raw_tm_packet: bytearray, tmtc_printer: TmTcPrinter):
LOGGER.info(f'The service {service_type} is not implemented in Telemetry Factory')
tm_packet = PusTelemetry.unpack(raw_telemetry=raw_tm_packet)
tmtc_printer.print_telemetry(packet_if=tm_packet, info_if=tm_packet, print_raw_tm=False)
except ValueError:
# TODO: Log faulty packet
LOGGER.warning("Invalid packet format detected")