Skip to content

Commit

Permalink
added new HK API functions
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed May 18, 2022
1 parent e81e6db commit 4433284
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/tmtccmd/tc/pus_3_fsfw_hk.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,51 @@ def make_interval(interval_seconds: float) -> bytearray:
return bytearray(struct.pack("!f", interval_seconds))


def enable_periodic_hk_command(diag: bool, sid: bytes, ssc: int) -> PusTelecommand:
return __generate_periodic_hk_command(diag=diag, enable=True, sid=sid, ssc=ssc)


def enable_periodic_hk_command_with_interval(
diag: bool, sid: bytes, interval_seconds: float, ssc: int
) -> (PusTelecommand, PusTelecommand):
cmd0 = (modify_collection_interval(diag, sid, interval_seconds, ssc),)
cmd1 = __generate_periodic_hk_command(diag=diag, enable=True, sid=sid, ssc=ssc)
return cmd0, cmd1


def disable_periodic_hk_command(diag: bool, sid: bytes, ssc: int) -> PusTelecommand:
return __generate_periodic_hk_command(diag=diag, enable=False, sid=sid, ssc=ssc)


def __generate_periodic_hk_command(
diag: bool, enable: bool, sid: bytes, ssc: int
) -> PusTelecommand:
app_data = bytearray(sid)
if enable:
if diag:
subservice = Subservices.TC_ENABLE_PERIODIC_DIAGNOSTICS_GEN
else:
subservice = Subservices.TC_DISABLE_PERIODIC_DIAGNOSTICS_GEN
else:
if diag:
subservice = Subservices.TC_ENABLE_PERIODIC_HK_GEN
else:
subservice = Subservices.TC_DISABLE_PERIODIC_HK_GEN
return PusTelecommand(service=3, subservice=subservice, ssc=ssc, app_data=app_data)


def modify_collection_interval(
diag: bool, sid: bytes, interval_seconds: float, ssc: int
) -> PusTelecommand:
app_data = bytearray(sid)
app_data += make_interval(interval_seconds)
if diag:
subservice = Subservices.TC_MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL
else:
subservice = Subservices.TC_MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL
return PusTelecommand(service=3, subservice=subservice, ssc=ssc, app_data=app_data)


def generate_one_hk_command(sid: bytes, ssc: int) -> PusTelecommand:
return PusTelecommand(
service=3,
Expand Down

0 comments on commit 4433284

Please sign in to comment.