added try except block
This commit is contained in:
parent
f6a3f79220
commit
eca5bba1d8
@ -26,17 +26,21 @@ 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
|
||||
if service_type == 1:
|
||||
tm_packet = Service1TMExtended.unpack(raw_telemetry=raw_tm_packet)
|
||||
if service_type == 3:
|
||||
tm_packet = Service3TM.unpack(raw_telemetry=raw_tm_packet, custom_hk_handling=False)
|
||||
if service_type == 5:
|
||||
tm_packet = Service5TM.unpack(raw_telemetry=raw_tm_packet)
|
||||
if service_type == 8:
|
||||
tm_packet = Service8TM.unpack(raw_telemetry=raw_tm_packet)
|
||||
if service_type == 17:
|
||||
tm_packet = Service17TMExtended.unpack(raw_telemetry=raw_tm_packet)
|
||||
if tm_packet is None:
|
||||
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)
|
||||
try:
|
||||
if service_type == 1:
|
||||
tm_packet = Service1TMExtended.unpack(raw_telemetry=raw_tm_packet)
|
||||
if service_type == 3:
|
||||
tm_packet = Service3TM.unpack(raw_telemetry=raw_tm_packet, custom_hk_handling=False)
|
||||
if service_type == 5:
|
||||
tm_packet = Service5TM.unpack(raw_telemetry=raw_tm_packet)
|
||||
if service_type == 8:
|
||||
tm_packet = Service8TM.unpack(raw_telemetry=raw_tm_packet)
|
||||
if service_type == 17:
|
||||
tm_packet = Service17TMExtended.unpack(raw_telemetry=raw_tm_packet)
|
||||
if tm_packet is None:
|
||||
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")
|
||||
|
Loading…
Reference in New Issue
Block a user