Skip to content

Commit

Permalink
Merge pull request #153 from robamu-org/update-exaple-app
Browse files Browse the repository at this point in the history
updated example app
  • Loading branch information
robamu authored Apr 23, 2024
2 parents fd4accd + 7c1018c commit a56a9bd
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions examples/app/tmtcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def __init__(
def handle_tm(self, packet: bytes, _user_args: Any):
try:
tm_packet = PusTelemetry.unpack(
packet, time_reader=CdsShortTimestamp.empty()
packet, timestamp_len=CdsShortTimestamp.TIMESTAMP_SIZE
)
except ValueError as e:
_LOGGER.warning("Could not generate PUS TM object from raw data")
Expand All @@ -154,7 +154,7 @@ def handle_tm(self, packet: bytes, _user_args: Any):
dedicated_handler = False
if service == 1:
verif_tm = Service1Tm.unpack(
data=packet, params=UnpackParams(CdsShortTimestamp.empty(), 1, 2)
data=packet, params=UnpackParams(CdsShortTimestamp.TIMESTAMP_SIZE, 1, 2)
)
res = self.verif_wrapper.add_tm(verif_tm)
if res is None:
Expand All @@ -171,12 +171,16 @@ def handle_tm(self, packet: bytes, _user_args: Any):
self.verif_wrapper.log_to_file(verif_tm, res)
dedicated_handler = True
if service == 5:
event_tm = Service5Tm.unpack(packet, time_reader=CdsShortTimestamp.empty())
event_tm = Service5Tm.unpack(
packet, timestamp_len=CdsShortTimestamp.TIMESTAMP_SIZE
)
_LOGGER.info(
f"Received event packet TM [{event_tm.service}, {event_tm.subservice}]"
)
if service == 17:
ping_tm = Service17Tm.unpack(packet, time_reader=CdsShortTimestamp.empty())
ping_tm = Service17Tm.unpack(
packet, timestamp_len=CdsShortTimestamp.TIMESTAMP_SIZE
)
dedicated_handler = True
if ping_tm.subservice == 2:
_LOGGER.info("Received Ping Reply TM[17,2]")
Expand All @@ -190,7 +194,7 @@ def handle_tm(self, packet: bytes, _user_args: Any):
f"The service {service} is not implemented in Telemetry Factory"
)
tm_packet = PusTelemetry.unpack(
packet, time_reader=CdsShortTimestamp.empty()
packet, timestamp_len=CdsShortTimestamp.TIMESTAMP_SIZE
)
# TODO: Insert this into a DB instead. Maybe use sqlite for first variant.
# self.raw_logger.log_tm(tm_packet)
Expand Down Expand Up @@ -250,12 +254,14 @@ def feed_cb(self, helper: ProcedureWrapper, wrapper: FeedWrapper):
cmd_path_list = cmd_path.split("/")[1:]
if cmd_path_list[0] == "ping":
return self.queue_helper.add_pus_tc(
PusTelecommand(service=17, subservice=1)
PusTelecommand(apid=EXAMPLE_PUS_APID, service=17, subservice=1)
)
elif cmd_path_list[0] == "test":
if cmd_path_list[1] == "event":
return self.queue_helper.add_pus_tc(
PusTelecommand(service=17, subservice=128)
PusTelecommand(
apid=EXAMPLE_PUS_APID, service=17, subservice=128
)
)


Expand Down

0 comments on commit a56a9bd

Please sign in to comment.