Skip to content

Commit

Permalink
Merge pull request #93 from robamu-org/diagnostic-removed
Browse files Browse the repository at this point in the history
Diagnostic API removed for FSFW houskeeping API
  • Loading branch information
robamu authored Aug 15, 2023
2 parents c13aac0 + 50e60f5 commit a566622
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 14 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ Starting from v4.0.0, this project adheres to [Semantic Versioning](http://semve

# [unreleased]

# [v6.0.0rc0]

## Changed

- Adapted the FSFW specific Housekeeping service API to make HK requests diagnostic agnostic.
The PUS interface has proven to be cumbersome and problematic, so the split between diagnostic
and regular HK packets has been removed in newer version of the FSFW. The new API reflects that.
The old API is still available by using the `*_with_diag` suffix.

# [v5.0.0] 2023-07-13

## Changed
Expand Down
89 changes: 75 additions & 14 deletions tmtccmd/tc/pus_3_fsfw_hk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
import struct
import deprecation
from typing import Tuple

from tmtccmd import __version__
from spacepackets.ecss.tc import PusTelecommand
Expand All @@ -24,18 +25,42 @@ def make_interval(interval_seconds: float) -> bytearray:
details="use create... API instead",
)
def enable_periodic_hk_command(diag: bool, sid: bytes) -> PusTelecommand:
return create_enable_periodic_hk_command(diag, sid)
return create_enable_periodic_hk_command_with_diag(diag, sid)


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


def create_enable_periodic_hk_command_with_interval(
@deprecation.deprecated(
deprecated_in="v6.0.0rc0",
current_version=__version__,
details="use diagnostic agnostic API if possible",
)
def create_enable_periodic_hk_command_with_diag(
diag: bool, sid: bytes
) -> PusTelecommand:
return __generate_periodic_hk_command_legacy(diag=diag, enable=True, sid=sid)


@deprecation.deprecated(
deprecated_in="v6.0.0rc0",
current_version=__version__,
details="use diagnostic agnostic API if possible",
)
def create_enable_periodic_hk_command_with_interval_with_diag(
diag: bool, sid: bytes, interval_seconds: float
) -> (PusTelecommand, PusTelecommand):
cmd0 = create_modify_collection_interval_cmd(diag, sid, interval_seconds)
cmd1 = __generate_periodic_hk_command(diag=diag, enable=True, sid=sid)
) -> Tuple[PusTelecommand, PusTelecommand]:
cmd0 = create_modify_collection_interval_cmd_with_diag(diag, sid, interval_seconds)
cmd1 = __generate_periodic_hk_command_legacy(diag=diag, enable=True, sid=sid)
return cmd0, cmd1


def create_enable_periodic_hk_command_with_interval(
sid: bytes, interval_seconds: float
) -> Tuple[PusTelecommand, PusTelecommand]:
cmd0 = create_modify_collection_interval_cmd(sid, interval_seconds)
cmd1 = __generate_periodic_hk_command(enable=True, sid=sid)
return cmd0, cmd1


Expand All @@ -46,12 +71,25 @@ def create_enable_periodic_hk_command_with_interval(
)
def enable_periodic_hk_command_with_interval(
diag: bool, sid: bytes, interval_seconds: float
) -> (PusTelecommand, PusTelecommand):
return create_enable_periodic_hk_command_with_interval(diag, sid, interval_seconds)
) -> Tuple[PusTelecommand, PusTelecommand]:
return create_enable_periodic_hk_command_with_interval_with_diag(
diag, sid, interval_seconds
)


def create_disable_periodic_hk_command(sid: bytes) -> PusTelecommand:
return __generate_periodic_hk_command(enable=False, sid=sid)

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

@deprecation.deprecated(
deprecated_in="v6.0.0rc0",
current_version=__version__,
details="use diagnostic agnostic API if possible",
)
def create_disable_periodic_hk_command_with_diag(
diag: bool, sid: bytes
) -> PusTelecommand:
return __generate_periodic_hk_command_legacy(diag=diag, enable=False, sid=sid)


@deprecation.deprecated(
Expand All @@ -60,10 +98,19 @@ def create_disable_periodic_hk_command(diag: bool, sid: bytes) -> PusTelecommand
details="use create... API instead",
)
def disable_periodic_hk_command(diag: bool, sid: bytes) -> PusTelecommand:
return create_disable_periodic_hk_command(diag, sid)
return create_disable_periodic_hk_command_with_diag(diag, sid)


def __generate_periodic_hk_command(enable: bool, sid: bytes) -> PusTelecommand:
app_data = bytearray(sid)
if enable:
subservice = Subservice.TC_ENABLE_PERIODIC_HK_GEN
else:
subservice = Subservice.TC_DISABLE_PERIODIC_HK_GEN
return PusTelecommand(service=3, subservice=subservice, app_data=app_data)


def __generate_periodic_hk_command(
def __generate_periodic_hk_command_legacy(
diag: bool, enable: bool, sid: bytes
) -> PusTelecommand:
app_data = bytearray(sid)
Expand All @@ -88,10 +135,24 @@ def __generate_periodic_hk_command(
def modify_collection_interval(
diag: bool, sid: bytes, interval_seconds: float
) -> PusTelecommand:
return create_modify_collection_interval_cmd(diag, sid, interval_seconds)
return create_modify_collection_interval_cmd_with_diag(diag, sid, interval_seconds)


def create_modify_collection_interval_cmd(
sid: bytes, interval_seconds: float
) -> PusTelecommand:
app_data = bytearray(sid)
app_data += make_interval(interval_seconds)
subservice = Subservice.TC_MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL
return PusTelecommand(service=3, subservice=subservice, app_data=app_data)


@deprecation.deprecated(
deprecated_in="v6.0.0rc0",
current_version=__version__,
details="use diagnostic agnostic API if possible",
)
def create_modify_collection_interval_cmd_with_diag(
diag: bool, sid: bytes, interval_seconds: float
) -> PusTelecommand:
app_data = bytearray(sid)
Expand Down

0 comments on commit a566622

Please sign in to comment.