Skip to content

Commit

Permalink
Merge pull request #74 from robamu-org/eive
Browse files Browse the repository at this point in the history
Update from EIVE fork
  • Loading branch information
robamu committed May 19, 2022
2 parents e81e6db + 163ed8c commit 264ca3e
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/tmtccmd/config/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class CoreGlobalIds(enum.IntEnum):
SERIAL_CONFIG = 161
USE_ETHERNET = 162
ETHERNET_CONFIG = 163
END = 300


class OpCodeDictKeys(enum.IntEnum):
Expand Down
14 changes: 8 additions & 6 deletions src/tmtccmd/core/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(
com_if=self.__com_if,
tm_handler=self.__tm_handler,
tm_listener=self.__tm_listener,
tc_queue=None,
tc_queue=deque(),
apid=self.__apid,
usr_send_wrapper=self.usr_send_wrapper,
)
Expand Down Expand Up @@ -241,13 +241,15 @@ def __com_if_closing(self):
else:
time.sleep(0.2)

def startDaemonReceiver(self):
def start_daemon_receiver(self):
try:
self.daemon_receiver.start_daemon()
except:
# TODO check which exceptions we should handle
LOGGER.error("receiver daemon could not be opened!")
LOGGER.info("Receiver daemon will not be started")
except RuntimeError:
LOGGER.error("Error when starting daemon receiver. Not starting it")
except Exception as e:
LOGGER.exception(
f"Unknown exception {e} when starting daemon receiver. Not starting it"
)

def __handle_action(self):
"""Command handling."""
Expand Down
4 changes: 0 additions & 4 deletions src/tmtccmd/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ def init_and_start_daemons(tmtc_backend: BackendBase):
__start_tmtc_commander_cli(tmtc_backend=tmtc_backend, perform_op_immediately=False)


def performOperation(tmtc_backend: BackendBase):
tmtc_backend.perform_operation()


def __assign_tmtc_commander_hooks(hook_object: TmTcHookBase):
if hook_object is None:
raise ValueError
Expand Down
4 changes: 2 additions & 2 deletions src/tmtccmd/sendreceive/tm_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TmListener:
or any other software component can get the received packets from the internal deque container.
"""

MODE_OPERATION_TIMEOUT = 30.0
DEFAULT_MODE_OPERATION_TIMEOUT = 300.0
DEFAULT_UNKNOWN_QUEUE_MAX_LEN = 50
QUEUE_DICT_QUEUE_IDX = 0
QUEUE_DICT_MAX_LEN_IDX = 1
Expand All @@ -59,7 +59,7 @@ def __init__(
:param tm_type: Telemetry type. Default to CCSDS space packets for now
"""
self.__com_if = com_if
self._mode_op_timeout = self.MODE_OPERATION_TIMEOUT
self._mode_op_timeout = TmListener.DEFAULT_MODE_OPERATION_TIMEOUT
# TM Listener operations can be suspended by setting this flag
self.event_listener_active = threading.Event()
self.listener_active = False
Expand Down
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_ENABLE_PERIODIC_HK_GEN
else:
if diag:
subservice = Subservices.TC_DISABLE_PERIODIC_DIAGNOSTICS_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
8 changes: 6 additions & 2 deletions src/tmtccmd/tm/pus_17_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ def __init__(
)
PusTmBase.__init__(self, pus_tm=self.pus_tm)
PusTmInfoBase.__init__(self, pus_tm=self.pus_tm)
if self.subservice == Subservices.TM_REPLY:
self.set_packet_info("Ping Reply")
self.__set_internal_fields()

@classmethod
def __empty(cls) -> Service17TMExtended:
return cls(subservice=0)

def __set_internal_fields(self):
if self.subservice == Subservices.TM_REPLY:
self.set_packet_info("Ping Reply")

@classmethod
def unpack(
cls,
Expand All @@ -53,4 +56,5 @@ def unpack(
service_17_tm.pus_tm = PusTelemetry.unpack(
raw_telemetry=raw_telemetry, pus_version=pus_version
)
service_17_tm.__set_internal_fields()
return service_17_tm
4 changes: 2 additions & 2 deletions src/tmtccmd/utility/tmtc_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(

@staticmethod
def generic_short_string(packet_if: PusTmInterface) -> str:
return f"Received TM[{packet_if.service}, {packet_if.subservice}]"
return f"Got TM[{packet_if.service}, {packet_if.subservice}]"

def handle_long_tm_print(
self, packet_if: PusTmInterface, info_if: PusTmInfoInterface
Expand All @@ -49,7 +49,7 @@ def handle_long_tm_print(
:param info_if: Information interface
:return:
"""
base_string = "Received Telemetry: " + info_if.get_print_info()
base_string = "Got TM: " + info_if.get_print_info()
LOGGER.info(base_string)
if self.file_logger is not None:
self.file_logger.info(f"{get_current_time_string(True)}: {base_string}")
Expand Down

0 comments on commit 264ca3e

Please sign in to comment.