Compare commits
48 Commits
5f44cb96be
...
v5.2.0
Author | SHA1 | Date | |
---|---|---|---|
eea7683581 | |||
df6aa80169
|
|||
2fd1a46e66
|
|||
2153aa2842
|
|||
9be81f1725 | |||
601adfc9c2 | |||
ac84ac2c3e | |||
7ed18bd570 | |||
e27ad147d4
|
|||
ba47757b50
|
|||
7e9c626ec8
|
|||
8d6dd97d85
|
|||
2fae5613ce
|
|||
fdb14cbdc5
|
|||
0cef3fa924
|
|||
37a35c4446
|
|||
15d25b4c5b
|
|||
069f84d220 | |||
627a16d51a | |||
fcfae1f67f | |||
01ebd356ba | |||
5785bbd0cc
|
|||
d3e6101447
|
|||
6d5bde40db
|
|||
c48f04eed5
|
|||
18304c31fa | |||
8caa408cbd | |||
4a983958bf | |||
03ec5bdc39 | |||
9c5d6a15db | |||
ddc80071e0 | |||
deb0275bb5
|
|||
ec0ebc3653
|
|||
c9f4a8070d | |||
b917358b9f | |||
5db9f383a6 | |||
fe3accb9ad | |||
68d74a4748 | |||
b6ec7da7fa | |||
c7df13fa68 | |||
daceb6bc1d | |||
8239e610cc | |||
b28d938468 | |||
e0457831d7 | |||
96fab88a55 | |||
50f2eb42f3 | |||
1bb8bea8d9 | |||
80d231586e |
33
CHANGELOG.md
33
CHANGELOG.md
@ -10,6 +10,39 @@ list yields a list of all related PRs for each release.
|
|||||||
|
|
||||||
# [unreleased]
|
# [unreleased]
|
||||||
|
|
||||||
|
# [v5.2.0] 2023-07-13
|
||||||
|
|
||||||
|
- `tmtccmd` v5.0.0
|
||||||
|
|
||||||
|
## Added
|
||||||
|
|
||||||
|
- New TCS controller events
|
||||||
|
|
||||||
|
## Changed
|
||||||
|
|
||||||
|
- HK level can be specified as CLI argument now.
|
||||||
|
|
||||||
|
# [v5.1.0] 2023-06-28
|
||||||
|
|
||||||
|
## Added
|
||||||
|
|
||||||
|
- Internal error reporter dataset handling.
|
||||||
|
|
||||||
|
## Fixed
|
||||||
|
|
||||||
|
- `APP_LOGGER` is the root logger now.
|
||||||
|
|
||||||
|
## Changed
|
||||||
|
|
||||||
|
- HK is only displayed in brief format per default now. This will soon be adaptable by CLI
|
||||||
|
argument.
|
||||||
|
|
||||||
|
# [v5.0.0] 2023-06-22
|
||||||
|
|
||||||
|
## Changed
|
||||||
|
|
||||||
|
- Force flag for copy helper.
|
||||||
|
|
||||||
# [v4.1.0] 2023-06-14
|
# [v4.1.0] 2023-06-14
|
||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
__version__ = "4.1.0"
|
__version__ = "5.2.0"
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
SW_NAME = "eive-tmtc"
|
SW_NAME = "eive-tmtc"
|
||||||
VERSION_MAJOR = 4
|
VERSION_MAJOR = 5
|
||||||
VERSION_MINOR = 1
|
VERSION_MINOR = 2
|
||||||
VERSION_REVISION = 0
|
VERSION_REVISION = 0
|
||||||
|
|
||||||
EIVE_TMTC_ROOT = Path(__file__).parent
|
EIVE_TMTC_ROOT = Path(__file__).parent
|
||||||
PACKAGE_ROOT = EIVE_TMTC_ROOT.parent
|
PACKAGE_ROOT = EIVE_TMTC_ROOT.parent
|
||||||
|
|
||||||
APP_LOGGER = logging.getLogger(__name__)
|
APP_LOGGER = logging.getLogger()
|
||||||
|
@ -65,7 +65,8 @@ class CustomServiceList(str, enum.Enum):
|
|||||||
PL_SS = "pl_subsystem"
|
PL_SS = "pl_subsystem"
|
||||||
ACS_BRD_ASS = "acs_brd_ass"
|
ACS_BRD_ASS = "acs_brd_ass"
|
||||||
SUS_BRD_ASS = "sus_brd_ass"
|
SUS_BRD_ASS = "sus_brd_ass"
|
||||||
TCS = "tcs"
|
TCS_SS = "tcs_subsystem"
|
||||||
|
TCS_CTRL = "tcs_ctrl"
|
||||||
TCS_ASS = "tcs_ass"
|
TCS_ASS = "tcs_ass"
|
||||||
TIME = "time"
|
TIME = "time"
|
||||||
PROCEDURE = "proc"
|
PROCEDURE = "proc"
|
||||||
|
@ -271,6 +271,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
|
|||||||
14010;0x36ba;TRYING_I2C_RECOVERY;HIGH;I2C is unavailable. Trying recovery of I2C bus by power cycling all I2C devices.;mission/sysDefs.h
|
14010;0x36ba;TRYING_I2C_RECOVERY;HIGH;I2C is unavailable. Trying recovery of I2C bus by power cycling all I2C devices.;mission/sysDefs.h
|
||||||
14011;0x36bb;I2C_REBOOT;HIGH;I2C is unavailable. Recovery did not work, performing full reboot.;mission/sysDefs.h
|
14011;0x36bb;I2C_REBOOT;HIGH;I2C is unavailable. Recovery did not work, performing full reboot.;mission/sysDefs.h
|
||||||
14012;0x36bc;PDEC_REBOOT;HIGH;PDEC recovery through reset was not possible, performing full reboot.;mission/sysDefs.h
|
14012;0x36bc;PDEC_REBOOT;HIGH;PDEC recovery through reset was not possible, performing full reboot.;mission/sysDefs.h
|
||||||
|
14013;0x36bd;FIRMWARE_INFO;INFO;Version information of the firmware (not OBSW). P1: Byte 0: Major, Byte 1: Minor, Byte 2: Patch, Byte 3: Has Git Hash P2: First four letters of Git SHA is the last byte of P1 is set.;mission/sysDefs.h
|
||||||
14100;0x3714;NO_VALID_SENSOR_TEMPERATURE;MEDIUM;No description;mission/controller/tcsDefs.h
|
14100;0x3714;NO_VALID_SENSOR_TEMPERATURE;MEDIUM;No description;mission/controller/tcsDefs.h
|
||||||
14101;0x3715;NO_HEALTHY_HEATER_AVAILABLE;MEDIUM;No description;mission/controller/tcsDefs.h
|
14101;0x3715;NO_HEALTHY_HEATER_AVAILABLE;MEDIUM;No description;mission/controller/tcsDefs.h
|
||||||
14102;0x3716;SYRLINKS_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h
|
14102;0x3716;SYRLINKS_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h
|
||||||
@ -279,6 +280,9 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
|
|||||||
14106;0x371a;PCDU_SYSTEM_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h
|
14106;0x371a;PCDU_SYSTEM_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h
|
||||||
14107;0x371b;HEATER_NOT_OFF_FOR_OFF_MODE;MEDIUM;No description;mission/controller/tcsDefs.h
|
14107;0x371b;HEATER_NOT_OFF_FOR_OFF_MODE;MEDIUM;No description;mission/controller/tcsDefs.h
|
||||||
14108;0x371c;MGT_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h
|
14108;0x371c;MGT_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h
|
||||||
|
14109;0x371d;TCS_SWITCHING_HEATER_ON;INFO;P1: Module index. P2: Heater index;mission/controller/tcsDefs.h
|
||||||
|
14110;0x371e;TCS_SWITCHING_HEATER_OFF;INFO;P1: Module index. P2: Heater index;mission/controller/tcsDefs.h
|
||||||
|
14111;0x371f;TCS_HEATER_MAX_BURN_TIME_REACHED;MEDIUM;P1: Heater index. P2: Maximum burn time for heater.;mission/controller/tcsDefs.h
|
||||||
14201;0x3779;TX_TIMER_EXPIRED;INFO;The transmit timer to protect the Syrlinks expired P1: The current timer value;mission/system/com/ComSubsystem.h
|
14201;0x3779;TX_TIMER_EXPIRED;INFO;The transmit timer to protect the Syrlinks expired P1: The current timer value;mission/system/com/ComSubsystem.h
|
||||||
14202;0x377a;BIT_LOCK_TX_ON;INFO;Transmitter will be turned on due to detection of bitlock;mission/system/com/ComSubsystem.h
|
14202;0x377a;BIT_LOCK_TX_ON;INFO;Transmitter will be turned on due to detection of bitlock;mission/system/com/ComSubsystem.h
|
||||||
14300;0x37dc;POSSIBLE_FILE_CORRUPTION;LOW;P1: Result code of TM packet parser. P2: Timestamp of possibly corrupt file as a unix timestamp.;mission/persistentTmStoreDefs.h
|
14300;0x37dc;POSSIBLE_FILE_CORRUPTION;LOW;P1: Result code of TM packet parser. P2: Timestamp of possibly corrupt file as a unix timestamp.;mission/persistentTmStoreDefs.h
|
||||||
|
|
@ -18,6 +18,7 @@ __OBJECT_ID_DICT = None
|
|||||||
|
|
||||||
# Core Object IDs
|
# Core Object IDs
|
||||||
SOLAR_ARRAY_DEPLOYMENT_ID = bytes([0x44, 0x41, 0x00, 0xA2])
|
SOLAR_ARRAY_DEPLOYMENT_ID = bytes([0x44, 0x41, 0x00, 0xA2])
|
||||||
|
INTERNAL_ERROR_REPORTER_ID = bytes([0x53, 0x04, 0x00, 0x00])
|
||||||
|
|
||||||
# Power Object IDs
|
# Power Object IDs
|
||||||
PCDU_HANDLER_ID = bytes([0x44, 0x20, 0x00, 0xA1])
|
PCDU_HANDLER_ID = bytes([0x44, 0x20, 0x00, 0xA1])
|
||||||
|
@ -6,6 +6,7 @@ from typing import cast
|
|||||||
from eive_tmtc.tmtc.acs.gyros import handle_gyr_cmd
|
from eive_tmtc.tmtc.acs.gyros import handle_gyr_cmd
|
||||||
from eive_tmtc.tmtc.acs.mgms import handle_mgm_cmd
|
from eive_tmtc.tmtc.acs.mgms import handle_mgm_cmd
|
||||||
from eive_tmtc.tmtc.power.power import pack_power_commands
|
from eive_tmtc.tmtc.power.power import pack_power_commands
|
||||||
|
from eive_tmtc.tmtc.tcs.ctrl import pack_tcs_ctrl_commands
|
||||||
from eive_tmtc.tmtc.tcs.rtd import pack_rtd_commands
|
from eive_tmtc.tmtc.tcs.rtd import pack_rtd_commands
|
||||||
from eive_tmtc.tmtc.payload.scex import pack_scex_cmds
|
from eive_tmtc.tmtc.payload.scex import pack_scex_cmds
|
||||||
from eive_tmtc.tmtc.tcs.subsystem import pack_tcs_sys_commands
|
from eive_tmtc.tmtc.tcs.subsystem import pack_tcs_sys_commands
|
||||||
@ -99,8 +100,10 @@ def handle_default_procedure( # noqa C901: Complexity okay here.
|
|||||||
if service == CustomServiceList.ACU.value:
|
if service == CustomServiceList.ACU.value:
|
||||||
object_id = cast(ObjectIdU32, obj_id_man.get(ACU_HANDLER_ID))
|
object_id = cast(ObjectIdU32, obj_id_man.get(ACU_HANDLER_ID))
|
||||||
return pack_acu_commands(object_id=object_id, q=queue_helper, op_code=op_code)
|
return pack_acu_commands(object_id=object_id, q=queue_helper, op_code=op_code)
|
||||||
if service == CustomServiceList.TCS.value:
|
if service == CustomServiceList.TCS_SS.value:
|
||||||
return pack_tcs_sys_commands(q=queue_helper, op_code=op_code)
|
return pack_tcs_sys_commands(q=queue_helper, op_code=op_code)
|
||||||
|
if service == CustomServiceList.TCS_CTRL.value:
|
||||||
|
return pack_tcs_ctrl_commands(q=queue_helper, op_code=op_code)
|
||||||
if service == CustomServiceList.TMP1075.value:
|
if service == CustomServiceList.TMP1075.value:
|
||||||
menu_dict = {
|
menu_dict = {
|
||||||
"0": ("TMP1075 TCS Board 0", TMP1075_HANDLER_TCS_BRD_0_ID),
|
"0": ("TMP1075 TCS Board 0", TMP1075_HANDLER_TCS_BRD_0_ID),
|
||||||
|
@ -765,7 +765,6 @@ def gen_disable_listen_to_hk_for_x_seconds(
|
|||||||
def activate_mgts_alternately(
|
def activate_mgts_alternately(
|
||||||
q: DefaultPusQueueHelper,
|
q: DefaultPusQueueHelper,
|
||||||
):
|
):
|
||||||
|
|
||||||
q.add_pus_tc(
|
q.add_pus_tc(
|
||||||
pack_dipole_command(
|
pack_dipole_command(
|
||||||
object_id=oids.IMTQ_HANDLER_ID,
|
object_id=oids.IMTQ_HANDLER_ID,
|
||||||
|
@ -95,7 +95,7 @@ def handle_event_packet( # noqa C901: Complexity okay here
|
|||||||
if info.name == "REBOOT_COUNTER":
|
if info.name == "REBOOT_COUNTER":
|
||||||
boot_count = (event_def.param1 << 32) | event_def.param2
|
boot_count = (event_def.param1 << 32) | event_def.param2
|
||||||
pw.dlog(f"Total boot count: {boot_count}")
|
pw.dlog(f"Total boot count: {boot_count}")
|
||||||
if info.name == "VERSION_INFO":
|
if info.name == "VERSION_INFO" or info.name == "FIRMWARE_INFO":
|
||||||
specific_handler = True
|
specific_handler = True
|
||||||
ver_major = (event_def.param1 >> 24) & 0xFF
|
ver_major = (event_def.param1 >> 24) & 0xFF
|
||||||
ver_minor = (event_def.param1 >> 16) & 0xFF
|
ver_minor = (event_def.param1 >> 16) & 0xFF
|
||||||
@ -105,8 +105,11 @@ def handle_event_packet( # noqa C901: Complexity okay here
|
|||||||
if has_git_sha:
|
if has_git_sha:
|
||||||
p2_as_bytes = event_def.param2.to_bytes(4, sys.byteorder)
|
p2_as_bytes = event_def.param2.to_bytes(4, sys.byteorder)
|
||||||
git_sha = p2_as_bytes.decode("ascii")
|
git_sha = p2_as_bytes.decode("ascii")
|
||||||
version_string = f"v{ver_major}.{ver_minor}.{ver_rev}"
|
if info.name == "VERSION_INFO":
|
||||||
pw.dlog(f"Version {version_string}")
|
name = "OBSW version: "
|
||||||
|
else:
|
||||||
|
name = "Firmware version: "
|
||||||
|
pw.dlog(f"{name} v{ver_major}.{ver_minor}.{ver_rev}")
|
||||||
if has_git_sha:
|
if has_git_sha:
|
||||||
pw.dlog(f"Git SHA first four letters: {git_sha}")
|
pw.dlog(f"Git SHA first four letters: {git_sha}")
|
||||||
if info.name == "CLOCK_SET":
|
if info.name == "CLOCK_SET":
|
||||||
|
@ -3,6 +3,7 @@ import logging
|
|||||||
|
|
||||||
# from pus_tm.tcp_server_objects import TCP_SEVER_SENSOR_TEMPERATURES
|
# from pus_tm.tcp_server_objects import TCP_SEVER_SENSOR_TEMPERATURES
|
||||||
from eive_tmtc.tmtc.acs.acs_ctrl import handle_acs_ctrl_hk_data
|
from eive_tmtc.tmtc.acs.acs_ctrl import handle_acs_ctrl_hk_data
|
||||||
|
from eive_tmtc.tmtc.internal_err_reporter import handle_ier_hk_data
|
||||||
from eive_tmtc.tmtc.payload.ploc_mpsoc import handle_ploc_mpsoc_hk_data
|
from eive_tmtc.tmtc.payload.ploc_mpsoc import handle_ploc_mpsoc_hk_data
|
||||||
from eive_tmtc.tmtc.tcs.rtd import RTD_NAMES, handle_rtd_hk
|
from eive_tmtc.tmtc.tcs.rtd import RTD_NAMES, handle_rtd_hk
|
||||||
from eive_tmtc.tmtc.acs.star_tracker import handle_str_hk_data
|
from eive_tmtc.tmtc.acs.star_tracker import handle_str_hk_data
|
||||||
@ -47,9 +48,7 @@ FORWARD_SENSOR_TEMPS = False
|
|||||||
|
|
||||||
|
|
||||||
def handle_hk_packet(
|
def handle_hk_packet(
|
||||||
raw_tm: bytes,
|
raw_tm: bytes, obj_id_dict: ObjectIdDictT, printer: FsfwTmTcPrinter, hk_level: int
|
||||||
obj_id_dict: ObjectIdDictT,
|
|
||||||
printer: FsfwTmTcPrinter,
|
|
||||||
):
|
):
|
||||||
tm_packet = Service3FsfwTm.unpack(raw_telemetry=raw_tm, custom_hk_handling=False)
|
tm_packet = Service3FsfwTm.unpack(raw_telemetry=raw_tm, custom_hk_handling=False)
|
||||||
named_obj_id = obj_id_dict.get(tm_packet.object_id.as_bytes)
|
named_obj_id = obj_id_dict.get(tm_packet.object_id.as_bytes)
|
||||||
@ -70,13 +69,16 @@ def handle_hk_packet(
|
|||||||
hk_data=hk_data,
|
hk_data=hk_data,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
handle_regular_hk_print(
|
if hk_level == 1:
|
||||||
printer=printer,
|
pass
|
||||||
object_id=named_obj_id,
|
elif hk_level > 1:
|
||||||
hk_packet=tm_packet,
|
handle_regular_hk_print(
|
||||||
tm=tm_packet.pus_tm,
|
printer=printer,
|
||||||
hk_data=hk_data,
|
object_id=named_obj_id,
|
||||||
)
|
hk_packet=tm_packet,
|
||||||
|
tm=tm_packet.pus_tm,
|
||||||
|
hk_data=hk_data,
|
||||||
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
_LOGGER.exception(
|
_LOGGER.exception(
|
||||||
f"{e} error when parsing HK data coming from {named_obj_id}"
|
f"{e} error when parsing HK data coming from {named_obj_id}"
|
||||||
@ -119,6 +121,8 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here
|
|||||||
return handle_ploc_mpsoc_hk_data(pw=pw, hk_data=hk_data, set_id=set_id)
|
return handle_ploc_mpsoc_hk_data(pw=pw, hk_data=hk_data, set_id=set_id)
|
||||||
elif objb == obj_ids.ACU_HANDLER_ID:
|
elif objb == obj_ids.ACU_HANDLER_ID:
|
||||||
return handle_acu_hk_data(pw=pw, hk_data=hk_data, set_id=set_id)
|
return handle_acu_hk_data(pw=pw, hk_data=hk_data, set_id=set_id)
|
||||||
|
elif objb == obj_ids.INTERNAL_ERROR_REPORTER_ID:
|
||||||
|
return handle_ier_hk_data(pw=pw, hk_data=hk_data, set_id=set_id)
|
||||||
elif objb == obj_ids.RAD_SENSOR_ID:
|
elif objb == obj_ids.RAD_SENSOR_ID:
|
||||||
return handle_rad_sensor_data(pw=pw, hk_data=hk_data, set_id=set_id)
|
return handle_rad_sensor_data(pw=pw, hk_data=hk_data, set_id=set_id)
|
||||||
elif objb in [obj_ids.RW1_ID, obj_ids.RW2_ID, obj_ids.RW3_ID, obj_ids.RW4_ID]:
|
elif objb in [obj_ids.RW1_ID, obj_ids.RW2_ID, obj_ids.RW3_ID, obj_ids.RW4_ID]:
|
||||||
@ -177,6 +181,7 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here
|
|||||||
obj_ids.TMP1075_HANDLER_TCS_BRD_1_ID,
|
obj_ids.TMP1075_HANDLER_TCS_BRD_1_ID,
|
||||||
obj_ids.TMP1075_HANDLER_IF_BRD_ID,
|
obj_ids.TMP1075_HANDLER_IF_BRD_ID,
|
||||||
obj_ids.TMP1075_HANDLER_PLPCDU_0_ID,
|
obj_ids.TMP1075_HANDLER_PLPCDU_0_ID,
|
||||||
|
obj_ids.TMP1075_HANDLER_PLPCDU_1_ID,
|
||||||
]:
|
]:
|
||||||
return handle_tmp_1075_hk_data(set_id=set_id, hk_data=hk_data, pw=pw)
|
return handle_tmp_1075_hk_data(set_id=set_id, hk_data=hk_data, pw=pw)
|
||||||
elif objb == obj_ids.ACS_CONTROLLER:
|
elif objb == obj_ids.ACS_CONTROLLER:
|
||||||
|
@ -29,12 +29,14 @@ def pus_factory_hook( # noqa C901 : Complexity okay here
|
|||||||
verif_wrapper: VerificationWrapper,
|
verif_wrapper: VerificationWrapper,
|
||||||
printer: FsfwTmTcPrinter,
|
printer: FsfwTmTcPrinter,
|
||||||
raw_logger: RawTmtcTimedLogWrapper,
|
raw_logger: RawTmtcTimedLogWrapper,
|
||||||
|
hk_level: int,
|
||||||
):
|
):
|
||||||
if len(packet) < 8:
|
if len(packet) < 8:
|
||||||
_LOGGER.warning("Detected packet shorter than 8 bytes!")
|
_LOGGER.warning("Detected packet shorter than 8 bytes!")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
tm_packet = PusTelemetry.unpack(packet, CdsShortTimestamp.empty())
|
tm_packet = PusTelemetry.unpack(packet, CdsShortTimestamp.empty())
|
||||||
|
# _LOGGER.info(f"Sequence count: {tm_packet.seq_count}")
|
||||||
except ValueError as value_error:
|
except ValueError as value_error:
|
||||||
_LOGGER.warning(f"{value_error}")
|
_LOGGER.warning(f"{value_error}")
|
||||||
_LOGGER.warning("Could not generate PUS TM object from raw data")
|
_LOGGER.warning("Could not generate PUS TM object from raw data")
|
||||||
@ -47,7 +49,9 @@ def pus_factory_hook( # noqa C901 : Complexity okay here
|
|||||||
if service == 1:
|
if service == 1:
|
||||||
handle_service_1_fsfw_packet(wrapper=verif_wrapper, raw_tm=packet)
|
handle_service_1_fsfw_packet(wrapper=verif_wrapper, raw_tm=packet)
|
||||||
elif service == 3:
|
elif service == 3:
|
||||||
handle_hk_packet(printer=printer, raw_tm=packet, obj_id_dict=obj_id_dict)
|
handle_hk_packet(
|
||||||
|
printer=printer, raw_tm=packet, obj_id_dict=obj_id_dict, hk_level=hk_level
|
||||||
|
)
|
||||||
elif service == 5:
|
elif service == 5:
|
||||||
handle_event_packet(raw_tm=packet, pw=pw)
|
handle_event_packet(raw_tm=packet, pw=pw)
|
||||||
elif service == 8:
|
elif service == 8:
|
@ -12,7 +12,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class TmTcpServer:
|
class TmTcpServer:
|
||||||
def __init__(self, ip_address: str, port: int):
|
def __init__(self, ip_address: str, port: int):
|
||||||
|
|
||||||
self.server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
|
||||||
self.server_socket.bind((ip_address, port))
|
self.server_socket.bind((ip_address, port))
|
||||||
@ -46,7 +45,6 @@ class TmTcpServer:
|
|||||||
self.client_connection.setblocking(False)
|
self.client_connection.setblocking(False)
|
||||||
print("Client connected")
|
print("Client connected")
|
||||||
except IOError:
|
except IOError:
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
data_json_bytes = json.dumps(dictionary).encode()
|
data_json_bytes = json.dumps(dictionary).encode()
|
||||||
@ -65,7 +63,6 @@ class TmTcpServer:
|
|||||||
self.client_connection = None
|
self.client_connection = None
|
||||||
|
|
||||||
def report_raw_hk_data(self, object_id: ObjectIdU32, set_id: int, hk_data: bytes):
|
def report_raw_hk_data(self, object_id: ObjectIdU32, set_id: int, hk_data: bytes):
|
||||||
|
|
||||||
data_dict = {
|
data_dict = {
|
||||||
"type": "TM",
|
"type": "TM",
|
||||||
"tmType": "Raw HK",
|
"tmType": "Raw HK",
|
||||||
|
@ -61,7 +61,7 @@ GYR_SEL_DICT = {
|
|||||||
|
|
||||||
def handle_gyr_cmd(q: DefaultPusQueueHelper, op_code: str):
|
def handle_gyr_cmd(q: DefaultPusQueueHelper, op_code: str):
|
||||||
print("Please select the Gyro Device")
|
print("Please select the Gyro Device")
|
||||||
for (k, v) in GYR_SEL_DICT.items():
|
for k, v in GYR_SEL_DICT.items():
|
||||||
print(f"{k}: {v[0]}")
|
print(f"{k}: {v[0]}")
|
||||||
sel_idx = int(input("Select gyro device by index: "))
|
sel_idx = int(input("Select gyro device by index: "))
|
||||||
gyr_info = GYR_SEL_DICT[GyrSel(sel_idx)]
|
gyr_info = GYR_SEL_DICT[GyrSel(sel_idx)]
|
||||||
|
@ -49,7 +49,7 @@ MGM_SEL_DICT = {
|
|||||||
|
|
||||||
def handle_mgm_cmd(q: DefaultPusQueueHelper, op_code: str):
|
def handle_mgm_cmd(q: DefaultPusQueueHelper, op_code: str):
|
||||||
print("Please select the MGM Device")
|
print("Please select the MGM Device")
|
||||||
for (k, v) in MGM_SEL_DICT.items():
|
for k, v in MGM_SEL_DICT.items():
|
||||||
print(f"{k}: {v[0]}")
|
print(f"{k}: {v[0]}")
|
||||||
sel_idx = int(input("Select MGM device by index: "))
|
sel_idx = int(input("Select MGM device by index: "))
|
||||||
mgm_info = MGM_SEL_DICT[MgmSel(sel_idx)]
|
mgm_info = MGM_SEL_DICT[MgmSel(sel_idx)]
|
||||||
|
@ -290,7 +290,6 @@ def pack_set_speed_command(
|
|||||||
def handle_rw_hk_data(
|
def handle_rw_hk_data(
|
||||||
pw: PrintWrapper, object_id: ObjectIdU32, set_id: int, hk_data: bytes
|
pw: PrintWrapper, object_id: ObjectIdU32, set_id: int, hk_data: bytes
|
||||||
):
|
):
|
||||||
|
|
||||||
current_idx = 0
|
current_idx = 0
|
||||||
if set_id == RwSetId.STATUS_SET_ID:
|
if set_id == RwSetId.STATUS_SET_ID:
|
||||||
pw.dlog(
|
pw.dlog(
|
||||||
|
@ -32,6 +32,7 @@ class ActionId(enum.IntEnum):
|
|||||||
RESET_REBOOT_COUNTER = 6
|
RESET_REBOOT_COUNTER = 6
|
||||||
SWITCH_IMG_LOCK = 7
|
SWITCH_IMG_LOCK = 7
|
||||||
SET_MAX_REBOOT_CNT = 8
|
SET_MAX_REBOOT_CNT = 8
|
||||||
|
READ_REBOOT_MECHANISM_INFO = 9
|
||||||
UPDATE_OBSW_FROM_SD_0 = 10
|
UPDATE_OBSW_FROM_SD_0 = 10
|
||||||
UPDATE_OBSW_FROM_SD_1 = 11
|
UPDATE_OBSW_FROM_SD_1 = 11
|
||||||
UPDATE_OBSW_FROM_TMP = 12
|
UPDATE_OBSW_FROM_TMP = 12
|
||||||
@ -87,14 +88,15 @@ class OpCode:
|
|||||||
SWITCH_TO_SD_0 = ["switch_to_sd_0"]
|
SWITCH_TO_SD_0 = ["switch_to_sd_0"]
|
||||||
SWITCH_TO_SD_1 = ["switch_to_sd_1"]
|
SWITCH_TO_SD_1 = ["switch_to_sd_1"]
|
||||||
SWITCH_TO_BOTH_SD_CARDS = ["switch_to_both_sd_cards"]
|
SWITCH_TO_BOTH_SD_CARDS = ["switch_to_both_sd_cards"]
|
||||||
ENABLE_REBOOT_FILE_HANDLING = ["rbh_off"]
|
READ_REBOOT_MECHANISM_INFO = "rbh_info"
|
||||||
DISABLE_REBOOT_FILE_HANDLING = ["rbh_on"]
|
ENABLE_REBOOT_FILE_HANDLING = "rwd_on"
|
||||||
RESET_ALL_REBOOT_COUNTERS = ["rbh_reset_a"]
|
DISABLE_REBOOT_FILE_HANDLING = "rwd_off"
|
||||||
RESET_REBOOT_COUNTER_00 = ["rbh_reset_00"]
|
RESET_ALL_REBOOT_COUNTERS = "rwd_reset_a"
|
||||||
RESET_REBOOT_COUNTER_01 = ["rbh_reset_01"]
|
RWD_RESET_REBOOT_COUNTER_00 = "rwd_reset_00"
|
||||||
RESET_REBOOT_COUNTER_10 = ["rbh_reset_10"]
|
RWD_RESET_REBOOT_COUNTER_01 = "rwd_reset_01"
|
||||||
RESET_REBOOT_COUNTER_11 = ["rbh_reset_11"]
|
RWD_RESET_REBOOT_COUNTER_10 = "rwd_reset_10"
|
||||||
SET_MAX_REBOOT_CNT = ["rbh_max_cnt"]
|
RWD_RESET_REBOOT_COUNTER_11 = "rwd_reset_11"
|
||||||
|
RWD_SET_MAX_REBOOT_CNT = "rwd_max_cnt"
|
||||||
|
|
||||||
|
|
||||||
class Info:
|
class Info:
|
||||||
@ -110,6 +112,7 @@ class Info:
|
|||||||
OBSW_UPDATE_FROM_SD_0 = "Update OBSW from SD Card 0"
|
OBSW_UPDATE_FROM_SD_0 = "Update OBSW from SD Card 0"
|
||||||
OBSW_UPDATE_FROM_SD_1 = "Update OBSW from SD Card 1"
|
OBSW_UPDATE_FROM_SD_1 = "Update OBSW from SD Card 1"
|
||||||
OBSW_UPDATE_FROM_TMP = "Update OBSW from tmp folder"
|
OBSW_UPDATE_FROM_TMP = "Update OBSW from tmp folder"
|
||||||
|
READ_REBOOT_MECHANISM_INFO = "Read reboot mechansm information"
|
||||||
SWITCH_TO_SD_0 = "Switch to SD card 0"
|
SWITCH_TO_SD_0 = "Switch to SD card 0"
|
||||||
SWITCH_TO_SD_1 = "Switch to SD card 1"
|
SWITCH_TO_SD_1 = "Switch to SD card 1"
|
||||||
SWITCH_TO_BOTH_SD_CARDS = "Switch to both SD cards with specified active card"
|
SWITCH_TO_BOTH_SD_CARDS = "Switch to both SD cards with specified active card"
|
||||||
@ -154,6 +157,9 @@ def add_core_controller_definitions(defs: TmtcDefinitionWrapper):
|
|||||||
oce.add(keys=OpCode.XSC_REBOOT_1_0, info="Reboot 1 0")
|
oce.add(keys=OpCode.XSC_REBOOT_1_0, info="Reboot 1 0")
|
||||||
oce.add(keys=OpCode.XSC_REBOOT_1_1, info="Reboot 1 1")
|
oce.add(keys=OpCode.XSC_REBOOT_1_1, info="Reboot 1 1")
|
||||||
oce.add(keys=OpCode.SET_PREF_SD, info=Info.SET_PREF_SD)
|
oce.add(keys=OpCode.SET_PREF_SD, info=Info.SET_PREF_SD)
|
||||||
|
oce.add(
|
||||||
|
keys=OpCode.READ_REBOOT_MECHANISM_INFO, info=Info.READ_REBOOT_MECHANISM_INFO
|
||||||
|
)
|
||||||
oce.add(keys=OpCode.OBSW_UPDATE_FROM_TMP, info=Info.OBSW_UPDATE_FROM_TMP)
|
oce.add(keys=OpCode.OBSW_UPDATE_FROM_TMP, info=Info.OBSW_UPDATE_FROM_TMP)
|
||||||
oce.add(keys=OpCode.OBSW_UPDATE_FROM_SD_0, info=Info.OBSW_UPDATE_FROM_SD_0)
|
oce.add(keys=OpCode.OBSW_UPDATE_FROM_SD_0, info=Info.OBSW_UPDATE_FROM_SD_0)
|
||||||
oce.add(keys=OpCode.OBSW_UPDATE_FROM_SD_1, info=Info.OBSW_UPDATE_FROM_SD_1)
|
oce.add(keys=OpCode.OBSW_UPDATE_FROM_SD_1, info=Info.OBSW_UPDATE_FROM_SD_1)
|
||||||
@ -182,21 +188,25 @@ def add_core_controller_definitions(defs: TmtcDefinitionWrapper):
|
|||||||
info="Reset all reboot counters",
|
info="Reset all reboot counters",
|
||||||
)
|
)
|
||||||
oce.add(
|
oce.add(
|
||||||
keys=OpCode.RESET_REBOOT_COUNTER_00,
|
keys=OpCode.RWD_RESET_REBOOT_COUNTER_00,
|
||||||
info="Reset reboot counter 0 0",
|
info="Reset reboot counter 0 0",
|
||||||
)
|
)
|
||||||
oce.add(
|
oce.add(
|
||||||
keys=OpCode.RESET_REBOOT_COUNTER_01,
|
keys=OpCode.RWD_RESET_REBOOT_COUNTER_01,
|
||||||
info="Reset reboot counter 0 1",
|
info="Reset reboot counter 0 1",
|
||||||
)
|
)
|
||||||
oce.add(
|
oce.add(
|
||||||
keys=OpCode.RESET_REBOOT_COUNTER_10,
|
keys=OpCode.RWD_RESET_REBOOT_COUNTER_10,
|
||||||
info="Reset reboot counter 1 0",
|
info="Reset reboot counter 1 0",
|
||||||
)
|
)
|
||||||
oce.add(
|
oce.add(
|
||||||
keys=OpCode.RESET_REBOOT_COUNTER_11,
|
keys=OpCode.RWD_RESET_REBOOT_COUNTER_11,
|
||||||
info="Reset reboot counter 1 1",
|
info="Reset reboot counter 1 1",
|
||||||
)
|
)
|
||||||
|
oce.add(
|
||||||
|
keys=OpCode.RWD_SET_MAX_REBOOT_CNT,
|
||||||
|
info="Reset max reboot count for reboot watchdog",
|
||||||
|
)
|
||||||
oce.add(keys=OpCode.OBSW_UPDATE_FROM_SD_0, info=Info.OBSW_UPDATE_FROM_SD_0)
|
oce.add(keys=OpCode.OBSW_UPDATE_FROM_SD_0, info=Info.OBSW_UPDATE_FROM_SD_0)
|
||||||
oce.add(keys=OpCode.OBSW_UPDATE_FROM_SD_1, info=Info.OBSW_UPDATE_FROM_SD_1)
|
oce.add(keys=OpCode.OBSW_UPDATE_FROM_SD_1, info=Info.OBSW_UPDATE_FROM_SD_1)
|
||||||
oce.add(keys=OpCode.OBSW_UPDATE_FROM_TMP, info=Info.OBSW_UPDATE_FROM_TMP)
|
oce.add(keys=OpCode.OBSW_UPDATE_FROM_TMP, info=Info.OBSW_UPDATE_FROM_TMP)
|
||||||
@ -294,7 +304,15 @@ def pack_core_commands( # noqa C901
|
|||||||
chip=Chip.CHIP_1,
|
chip=Chip.CHIP_1,
|
||||||
copy=Copy.COPY_1_GOLD,
|
copy=Copy.COPY_1_GOLD,
|
||||||
)
|
)
|
||||||
elif op_code in OpCode.DISABLE_REBOOT_FILE_HANDLING:
|
elif op_code == OpCode.READ_REBOOT_MECHANISM_INFO:
|
||||||
|
q.add_log_cmd(Info.READ_REBOOT_MECHANISM_INFO)
|
||||||
|
q.add_pus_tc(
|
||||||
|
create_action_cmd(
|
||||||
|
object_id=CORE_CONTROLLER_ID,
|
||||||
|
action_id=ActionId.READ_REBOOT_MECHANISM_INFO,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
elif op_code == OpCode.DISABLE_REBOOT_FILE_HANDLING:
|
||||||
q.add_log_cmd("Disabling reboot file handling")
|
q.add_log_cmd("Disabling reboot file handling")
|
||||||
user_data = bytearray([0])
|
user_data = bytearray([0])
|
||||||
q.add_pus_tc(
|
q.add_pus_tc(
|
||||||
@ -304,7 +322,7 @@ def pack_core_commands( # noqa C901
|
|||||||
user_data=user_data,
|
user_data=user_data,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif op_code in OpCode.ENABLE_REBOOT_FILE_HANDLING:
|
elif op_code == OpCode.ENABLE_REBOOT_FILE_HANDLING:
|
||||||
q.add_log_cmd("Enabling reboot file handling")
|
q.add_log_cmd("Enabling reboot file handling")
|
||||||
user_data = bytearray([1])
|
user_data = bytearray([1])
|
||||||
q.add_pus_tc(
|
q.add_pus_tc(
|
||||||
@ -314,7 +332,7 @@ def pack_core_commands( # noqa C901
|
|||||||
user_data=user_data,
|
user_data=user_data,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif op_code in OpCode.RESET_ALL_REBOOT_COUNTERS:
|
elif op_code == OpCode.RESET_ALL_REBOOT_COUNTERS:
|
||||||
q.add_log_cmd("Resetting all reboot counters")
|
q.add_log_cmd("Resetting all reboot counters")
|
||||||
q.add_pus_tc(
|
q.add_pus_tc(
|
||||||
create_action_cmd(
|
create_action_cmd(
|
||||||
@ -322,14 +340,25 @@ def pack_core_commands( # noqa C901
|
|||||||
action_id=ActionId.RESET_REBOOT_COUNTER,
|
action_id=ActionId.RESET_REBOOT_COUNTER,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif op_code in OpCode.RESET_REBOOT_COUNTER_00:
|
elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_00:
|
||||||
reset_specific_boot_counter(q, 0, 0)
|
reset_specific_boot_counter(q, 0, 0)
|
||||||
elif op_code in OpCode.RESET_REBOOT_COUNTER_01:
|
elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_01:
|
||||||
reset_specific_boot_counter(q, 0, 1)
|
reset_specific_boot_counter(q, 0, 1)
|
||||||
elif op_code in OpCode.RESET_REBOOT_COUNTER_10:
|
elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_10:
|
||||||
reset_specific_boot_counter(q, 1, 0)
|
reset_specific_boot_counter(q, 1, 0)
|
||||||
elif op_code in OpCode.RESET_REBOOT_COUNTER_11:
|
elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_11:
|
||||||
reset_specific_boot_counter(q, 1, 1)
|
reset_specific_boot_counter(q, 1, 1)
|
||||||
|
elif op_code == OpCode.RWD_SET_MAX_REBOOT_CNT:
|
||||||
|
max_count = int(input("Set new maximum reboot threshold [1, 50]: "))
|
||||||
|
if max_count < 1 or max_count > 50:
|
||||||
|
raise ValueError("Invalid value, must be in range 1 to 50")
|
||||||
|
q.add_pus_tc(
|
||||||
|
create_action_cmd(
|
||||||
|
CORE_CONTROLLER_ID,
|
||||||
|
ActionId.SET_MAX_REBOOT_CNT,
|
||||||
|
user_data=bytes([max_count]),
|
||||||
|
)
|
||||||
|
)
|
||||||
elif op_code in OpCode.OBSW_UPDATE_FROM_SD_0:
|
elif op_code in OpCode.OBSW_UPDATE_FROM_SD_0:
|
||||||
q.add_log_cmd(Info.OBSW_UPDATE_FROM_SD_0)
|
q.add_log_cmd(Info.OBSW_UPDATE_FROM_SD_0)
|
||||||
q.add_pus_tc(pack_obsw_update_cmd(ActionId.UPDATE_OBSW_FROM_SD_0))
|
q.add_pus_tc(pack_obsw_update_cmd(ActionId.UPDATE_OBSW_FROM_SD_0))
|
||||||
@ -385,14 +414,17 @@ def pack_core_commands( # noqa C901
|
|||||||
domain_id=0,
|
domain_id=0,
|
||||||
unique_id=ParamId.PREF_SD,
|
unique_id=ParamId.PREF_SD,
|
||||||
parameter=pref_sd,
|
parameter=pref_sd,
|
||||||
).pack()
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif op_code == OpCode.CP_HELPER:
|
elif op_code == OpCode.CP_HELPER:
|
||||||
cp_recursive = int(input("Copy recursively (0/1) ?: "))
|
cp_recursive = int(input("Copy recursively (0/1) ?: "))
|
||||||
if cp_recursive not in [0, 1]:
|
if cp_recursive not in [0, 1]:
|
||||||
raise ValueError("Invalid value, only 0 or 1 allowed")
|
raise ValueError("Invalid value, only 0 or 1 allowed")
|
||||||
user_data = bytearray([cp_recursive])
|
cp_force = int(input("Copy with force option(0/1) ?: "))
|
||||||
|
if cp_force not in [0, 1]:
|
||||||
|
raise ValueError("Invalid value, only 0 or 1 allowed")
|
||||||
|
user_data = bytearray([cp_recursive, cp_force])
|
||||||
user_data.extend(packet_source_dest_path("Copy"))
|
user_data.extend(packet_source_dest_path("Copy"))
|
||||||
q.add_log_cmd(Info.CP_HELPER)
|
q.add_log_cmd(Info.CP_HELPER)
|
||||||
q.add_pus_tc(
|
q.add_pus_tc(
|
||||||
@ -603,43 +635,85 @@ def handle_core_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes):
|
|||||||
def handle_core_ctrl_action_replies(
|
def handle_core_ctrl_action_replies(
|
||||||
action_id: int, pw: PrintWrapper, custom_data: bytes
|
action_id: int, pw: PrintWrapper, custom_data: bytes
|
||||||
):
|
):
|
||||||
if action_id == ActionId.LIST_DIR_DUMP_DIRECTLY:
|
if action_id == ActionId.READ_REBOOT_MECHANISM_INFO:
|
||||||
if len(custom_data) < 4:
|
handle_reboot_mechanism_info_reply(pw, custom_data)
|
||||||
_LOGGER.warning("Data unexpectedly small")
|
elif action_id == ActionId.LIST_DIR_DUMP_DIRECTLY:
|
||||||
return
|
handle_list_dir_dump_reply(pw, custom_data)
|
||||||
seq_idx = struct.unpack("!I", custom_data[0:4])[0]
|
|
||||||
total_chunks = struct.unpack("!I", custom_data[4:8])[0]
|
|
||||||
compressed = custom_data[8]
|
def handle_reboot_mechanism_info_reply(pw: PrintWrapper, custom_data: bytes):
|
||||||
ls_cmd = custom_data[9:].split(b"\x00")[0].decode()
|
pw.dlog("Received reboot mechansm information")
|
||||||
# Include length of NULL termination
|
fmt_str = "!BIIIIIBBBBBBBB"
|
||||||
file_data_offset = 9 + len(ls_cmd) + 1
|
inc_len = struct.calcsize(fmt_str)
|
||||||
|
if len(custom_data) < inc_len:
|
||||||
|
raise ValueError(f"Received custom data shorter than expected {inc_len}")
|
||||||
|
(
|
||||||
|
enabled,
|
||||||
|
max_count,
|
||||||
|
img00_count,
|
||||||
|
img01_count,
|
||||||
|
img10_count,
|
||||||
|
img11_count,
|
||||||
|
img00_lock,
|
||||||
|
img01_lock,
|
||||||
|
img10_lock,
|
||||||
|
img11_lock,
|
||||||
|
last_chip,
|
||||||
|
last_copy,
|
||||||
|
next_chip,
|
||||||
|
next_copy,
|
||||||
|
) = struct.unpack(fmt_str, custom_data[:inc_len])
|
||||||
|
pw.dlog(f"Enabled: {enabled}")
|
||||||
|
pw.dlog(f"Max Count: {max_count}")
|
||||||
|
pw.dlog(f"Count 00: {img00_count}")
|
||||||
|
pw.dlog(f"Count 01: {img01_count}")
|
||||||
|
pw.dlog(f"Count 10: {img10_count}")
|
||||||
|
pw.dlog(f"Count 11: {img11_count}")
|
||||||
|
pw.dlog(f"Lock 00: {img00_lock}")
|
||||||
|
pw.dlog(f"Lock 01: {img01_lock}")
|
||||||
|
pw.dlog(f"Lock 10: {img10_lock}")
|
||||||
|
pw.dlog(f"Lock 11: {img11_lock}")
|
||||||
|
pw.dlog(f"Last Chip: {last_chip}")
|
||||||
|
pw.dlog(f"Last Copy: {last_copy}")
|
||||||
|
pw.dlog(f"Next Chip: {next_chip}")
|
||||||
|
pw.dlog(f"Next Copy: {next_copy}")
|
||||||
|
|
||||||
|
|
||||||
|
def handle_list_dir_dump_reply(pw: PrintWrapper, custom_data: bytes):
|
||||||
|
if len(custom_data) < 4:
|
||||||
|
_LOGGER.warning("Data unexpectedly small")
|
||||||
|
return
|
||||||
|
seq_idx = struct.unpack("!I", custom_data[0:4])[0]
|
||||||
|
total_chunks = struct.unpack("!I", custom_data[4:8])[0]
|
||||||
|
compressed = custom_data[8]
|
||||||
|
ls_cmd = custom_data[9:].split(b"\x00")[0].decode()
|
||||||
|
# Include length of NULL termination
|
||||||
|
file_data_offset = 9 + len(ls_cmd) + 1
|
||||||
|
pw.dlog(
|
||||||
|
f"Received directory listing dump for ls command {ls_cmd}. "
|
||||||
|
f"Chunk {seq_idx + 1}/{total_chunks}"
|
||||||
|
)
|
||||||
|
|
||||||
|
def remove_if_exists_and_new(seq_idx_: int, path_: Path):
|
||||||
|
if seq_idx_ == 0 and path_.exists():
|
||||||
|
os.remove(path_)
|
||||||
|
|
||||||
|
if compressed:
|
||||||
|
path = Path("dir_listing.txt.gz")
|
||||||
|
remove_if_exists_and_new(seq_idx, path)
|
||||||
pw.dlog(
|
pw.dlog(
|
||||||
f"Received directory listing dump for ls command {ls_cmd}. "
|
f"Compression option: {compressed}. Dumping file into dir_listing.txt.gz"
|
||||||
f"Chunk {seq_idx + 1}/{total_chunks}"
|
|
||||||
)
|
)
|
||||||
|
with open(path, "ab") as listing_file:
|
||||||
def remove_if_exists_and_new(seq_idx_: int, path_: Path):
|
listing_file.write(custom_data[file_data_offset:])
|
||||||
if seq_idx_ == 0 and path_.exists():
|
else:
|
||||||
os.remove(path_)
|
path = Path("dir_listing.txt")
|
||||||
|
remove_if_exists_and_new(seq_idx, path)
|
||||||
if compressed:
|
pw.dlog(f"Compression option: {compressed}. Dumping file into dir_listing.txt")
|
||||||
path = Path("dir_listing.txt.gz")
|
with open(path, "a") as listing_file:
|
||||||
remove_if_exists_and_new(seq_idx, path)
|
listing_file_str = custom_data[file_data_offset:].decode()
|
||||||
pw.dlog(
|
listing_file.write(listing_file_str)
|
||||||
f"Compression option: {compressed}. Dumping file into dir_listing.txt.gz"
|
if seq_idx + 1 == total_chunks:
|
||||||
)
|
pw.dlog("Full directory listing: ")
|
||||||
with open(path, "ab") as listing_file:
|
with open("dir_listing.txt", "r") as listing_file:
|
||||||
listing_file.write(custom_data[file_data_offset:])
|
print(listing_file.read())
|
||||||
else:
|
|
||||||
path = Path("dir_listing.txt")
|
|
||||||
remove_if_exists_and_new(seq_idx, path)
|
|
||||||
pw.dlog(
|
|
||||||
f"Compression option: {compressed}. Dumping file into dir_listing.txt"
|
|
||||||
)
|
|
||||||
with open(path, "a") as listing_file:
|
|
||||||
listing_file_str = custom_data[file_data_offset:].decode()
|
|
||||||
listing_file.write(listing_file_str)
|
|
||||||
if seq_idx + 1 == total_chunks:
|
|
||||||
pw.dlog("Full directory listing: ")
|
|
||||||
with open("dir_listing.txt", "r") as listing_file:
|
|
||||||
print(listing_file.read())
|
|
||||||
|
24
eive_tmtc/tmtc/internal_err_reporter.py
Normal file
24
eive_tmtc/tmtc/internal_err_reporter.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import enum
|
||||||
|
import struct
|
||||||
|
|
||||||
|
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter
|
||||||
|
|
||||||
|
from eive_tmtc.pus_tm.defs import PrintWrapper
|
||||||
|
|
||||||
|
|
||||||
|
class SetId(enum.IntEnum):
|
||||||
|
ERROR_ID = 0
|
||||||
|
|
||||||
|
|
||||||
|
def handle_ier_hk_data(pw: PrintWrapper, hk_data: bytes, set_id: int):
|
||||||
|
pw.dlog(f"Received internal error reporter HK data with set ID {set_id}")
|
||||||
|
if set_id == SetId.ERROR_ID:
|
||||||
|
fmt_str = "!III"
|
||||||
|
inc_len = struct.calcsize(fmt_str)
|
||||||
|
(tm_errors, queue_errors, store_hits) = struct.unpack(
|
||||||
|
fmt_str, hk_data[:inc_len]
|
||||||
|
)
|
||||||
|
pw.dlog(f"TM Errors: {tm_errors}")
|
||||||
|
pw.dlog(f"Queue Errors: {queue_errors}")
|
||||||
|
pw.dlog(f"Store Errors: {store_hits}")
|
||||||
|
pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[inc_len:], 3))
|
@ -14,6 +14,11 @@ from eive_tmtc.config.object_ids import (
|
|||||||
RW1_ID,
|
RW1_ID,
|
||||||
RW2_ID,
|
RW2_ID,
|
||||||
RTD_0_PLOC_HSPD,
|
RTD_0_PLOC_HSPD,
|
||||||
|
TMP1075_HANDLER_TCS_BRD_1_ID,
|
||||||
|
TMP1075_HANDLER_TCS_BRD_0_ID,
|
||||||
|
TMP1075_HANDLER_PLPCDU_0_ID,
|
||||||
|
TMP1075_HANDLER_PLPCDU_1_ID,
|
||||||
|
TMP1075_HANDLER_IF_BRD_ID,
|
||||||
)
|
)
|
||||||
|
|
||||||
SUBSYSTEM_DICT = {
|
SUBSYSTEM_DICT = {
|
||||||
@ -41,6 +46,11 @@ ACS_OBJ_DICT = {
|
|||||||
|
|
||||||
TCS_OBJ_DICT = {
|
TCS_OBJ_DICT = {
|
||||||
0: ("RTD 0", RTD_0_PLOC_HSPD),
|
0: ("RTD 0", RTD_0_PLOC_HSPD),
|
||||||
|
1: ("TMP1075 PL PCDU 0", TMP1075_HANDLER_PLPCDU_0_ID),
|
||||||
|
2: ("TMP1075 PL PCDU 1", TMP1075_HANDLER_PLPCDU_1_ID),
|
||||||
|
3: ("TMP1075 TCS 0", TMP1075_HANDLER_TCS_BRD_0_ID),
|
||||||
|
4: ("TMP1075 TCS 1", TMP1075_HANDLER_TCS_BRD_1_ID),
|
||||||
|
5: ("TMP1075 IF BOARD", TMP1075_HANDLER_IF_BRD_ID),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,7 +172,6 @@ class Info(str, enum.Enum):
|
|||||||
|
|
||||||
@tmtc_definitions_provider
|
@tmtc_definitions_provider
|
||||||
def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper):
|
def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper):
|
||||||
|
|
||||||
oce = OpCodeEntry()
|
oce = OpCodeEntry()
|
||||||
oce.add(OpCodes.OFF, Info.OFF)
|
oce.add(OpCodes.OFF, Info.OFF)
|
||||||
oce.add(OpCodes.ON, Info.ON)
|
oce.add(OpCodes.ON, Info.ON)
|
||||||
|
92
eive_tmtc/tmtc/tcs/ctrl.py
Normal file
92
eive_tmtc/tmtc/tcs/ctrl.py
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
from eive_tmtc.config.definitions import CustomServiceList
|
||||||
|
from eive_tmtc.config.object_ids import TCS_CONTROLLER
|
||||||
|
from eive_tmtc.tmtc.tcs import CtrlSetId
|
||||||
|
from eive_tmtc.tmtc.tcs.brd_assy import pack_tcs_ass_cmds
|
||||||
|
from tmtccmd.config.tmtc import (
|
||||||
|
tmtc_definitions_provider,
|
||||||
|
TmtcDefinitionWrapper,
|
||||||
|
OpCodeEntry,
|
||||||
|
)
|
||||||
|
from tmtccmd.tc import DefaultPusQueueHelper
|
||||||
|
from tmtccmd.tc.pus_3_fsfw_hk import (
|
||||||
|
make_sid,
|
||||||
|
generate_one_hk_command,
|
||||||
|
create_request_one_diag_command,
|
||||||
|
create_enable_periodic_hk_command_with_interval,
|
||||||
|
create_request_one_hk_command,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class OpCode:
|
||||||
|
REQUEST_PRIMARY_TEMP_SET = "temp"
|
||||||
|
ENABLE_TEMP_SET = "enable_temp_set"
|
||||||
|
REQUEST_DEVICE_TEMP_SET = "temp_devs"
|
||||||
|
REQUEST_DEVICE_SUS_SET = "temp_sus"
|
||||||
|
REQUEST_HEATER_INFO = "heater_info"
|
||||||
|
REQUEST_TCS_CTRL_INFO = "tcs_ctrl_info"
|
||||||
|
|
||||||
|
|
||||||
|
class Info:
|
||||||
|
ENABLE_TEMP_SET = "Enable Primary Temperature Set"
|
||||||
|
REQUEST_PRIMARY_TEMP_SET = "Request HK set of primary sensor temperatures"
|
||||||
|
REQUEST_DEVICE_TEMP_SET = "Request HK set of device sensor temperatures"
|
||||||
|
REQUEST_DEVICE_SUS_SET = "Request HK set of the SUS temperatures"
|
||||||
|
REQUEST_HEATER_INFO = "Request heater information"
|
||||||
|
REQUEST_TCS_CTRL_INFO = "Request TCS controller information"
|
||||||
|
|
||||||
|
|
||||||
|
def pack_tcs_ctrl_commands(q: DefaultPusQueueHelper, op_code: str):
|
||||||
|
if op_code == OpCode.REQUEST_PRIMARY_TEMP_SET:
|
||||||
|
sensor_set_sid = make_sid(TCS_CONTROLLER, CtrlSetId.PRIMARY_SENSORS)
|
||||||
|
q.add_log_cmd(Info.REQUEST_PRIMARY_TEMP_SET)
|
||||||
|
q.add_pus_tc(generate_one_hk_command(sensor_set_sid))
|
||||||
|
if op_code == OpCode.REQUEST_DEVICE_TEMP_SET:
|
||||||
|
q.add_log_cmd(Info.REQUEST_DEVICE_TEMP_SET)
|
||||||
|
q.add_pus_tc(
|
||||||
|
generate_one_hk_command(make_sid(TCS_CONTROLLER, CtrlSetId.DEVICE_SENSORS))
|
||||||
|
)
|
||||||
|
if op_code == OpCode.REQUEST_DEVICE_SUS_SET:
|
||||||
|
q.add_log_cmd(Info.REQUEST_DEVICE_SUS_SET)
|
||||||
|
q.add_pus_tc(
|
||||||
|
generate_one_hk_command(
|
||||||
|
make_sid(TCS_CONTROLLER, CtrlSetId.SUS_TEMP_SENSORS)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if op_code == OpCode.REQUEST_HEATER_INFO:
|
||||||
|
q.add_log_cmd(Info.REQUEST_HEATER_INFO)
|
||||||
|
q.add_pus_tc(
|
||||||
|
create_request_one_diag_command(
|
||||||
|
make_sid(TCS_CONTROLLER, CtrlSetId.HEATER_INFO)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if op_code == OpCode.REQUEST_TCS_CTRL_INFO:
|
||||||
|
q.add_log_cmd(Info.REQUEST_TCS_CTRL_INFO)
|
||||||
|
q.add_pus_tc(
|
||||||
|
create_request_one_hk_command(
|
||||||
|
make_sid(TCS_CONTROLLER, CtrlSetId.TCS_CTRL_INFO)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if op_code == OpCode.ENABLE_TEMP_SET:
|
||||||
|
interval_seconds = float(input("Please specify interval in seconds: "))
|
||||||
|
cmds = create_enable_periodic_hk_command_with_interval(
|
||||||
|
False, make_sid(TCS_CONTROLLER, CtrlSetId.PRIMARY_SENSORS), interval_seconds
|
||||||
|
)
|
||||||
|
for cmd in cmds:
|
||||||
|
q.add_pus_tc(cmd)
|
||||||
|
pack_tcs_ass_cmds(q, op_code)
|
||||||
|
|
||||||
|
|
||||||
|
@tmtc_definitions_provider
|
||||||
|
def add_tcs_ctrl_cmds(defs: TmtcDefinitionWrapper):
|
||||||
|
oce = OpCodeEntry()
|
||||||
|
oce.add(keys=OpCode.ENABLE_TEMP_SET, info=Info.ENABLE_TEMP_SET)
|
||||||
|
oce.add(keys=OpCode.REQUEST_PRIMARY_TEMP_SET, info=Info.REQUEST_PRIMARY_TEMP_SET)
|
||||||
|
oce.add(keys=OpCode.REQUEST_DEVICE_TEMP_SET, info=Info.REQUEST_DEVICE_TEMP_SET)
|
||||||
|
oce.add(keys=OpCode.REQUEST_DEVICE_SUS_SET, info=Info.REQUEST_DEVICE_SUS_SET)
|
||||||
|
oce.add(keys=OpCode.REQUEST_HEATER_INFO, info=Info.REQUEST_HEATER_INFO)
|
||||||
|
oce.add(keys=OpCode.REQUEST_TCS_CTRL_INFO, info=Info.REQUEST_TCS_CTRL_INFO)
|
||||||
|
defs.add_service(
|
||||||
|
name=CustomServiceList.TCS_CTRL,
|
||||||
|
info="TCS controller",
|
||||||
|
op_code_entry=oce,
|
||||||
|
)
|
@ -6,3 +6,22 @@ class CtrlSetId(enum.IntEnum):
|
|||||||
DEVICE_SENSORS = 1
|
DEVICE_SENSORS = 1
|
||||||
SUS_TEMP_SENSORS = 2
|
SUS_TEMP_SENSORS = 2
|
||||||
HEATER_INFO = 4
|
HEATER_INFO = 4
|
||||||
|
TCS_CTRL_INFO = 5
|
||||||
|
|
||||||
|
|
||||||
|
class TcsSubmode(enum.IntEnum):
|
||||||
|
DEFAULT = 0
|
||||||
|
NO_HEATER_CTRL = 1
|
||||||
|
|
||||||
|
|
||||||
|
class Heater(enum.IntEnum):
|
||||||
|
HEATER_0_PLOC_PROC_BRD = 0
|
||||||
|
HEATER_1_PCDU_BRD = 1
|
||||||
|
HEATER_2_ACS_BRD = 2
|
||||||
|
HEATER_3_OBC_BRD = 3
|
||||||
|
HEATER_4_CAMERA = 4
|
||||||
|
HEATER_5_STR = 5
|
||||||
|
HEATER_6_DRO = 6
|
||||||
|
HEATER_7_SYRLINKS = 7
|
||||||
|
NUMBER_OF_SWITCHES = 8
|
||||||
|
NONE = 0xFF
|
||||||
|
@ -7,6 +7,7 @@ import enum
|
|||||||
|
|
||||||
from eive_tmtc.config.definitions import CustomServiceList
|
from eive_tmtc.config.definitions import CustomServiceList
|
||||||
from eive_tmtc.config.object_ids import get_object_ids
|
from eive_tmtc.config.object_ids import get_object_ids
|
||||||
|
from eive_tmtc.tmtc.tcs.defs import Heater
|
||||||
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
|
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
|
||||||
from tmtccmd.config.tmtc import tmtc_definitions_provider
|
from tmtccmd.config.tmtc import tmtc_definitions_provider
|
||||||
from tmtccmd.tc import DefaultPusQueueHelper
|
from tmtccmd.tc import DefaultPusQueueHelper
|
||||||
@ -20,18 +21,6 @@ from tmtccmd.pus.s8_fsfw_funccmd import create_action_cmd
|
|||||||
from spacepackets.ecss.tc import PusTelecommand
|
from spacepackets.ecss.tc import PusTelecommand
|
||||||
|
|
||||||
|
|
||||||
class Heater(enum.IntEnum):
|
|
||||||
HEATER_0_PLOC_PROC_BRD = 0
|
|
||||||
HEATER_1_PCDU_BRD = 1
|
|
||||||
HEATER_2_ACS_BRD = 2
|
|
||||||
HEATER_3_OBC_BRD = 3
|
|
||||||
HEATER_4_CAMERA = 4
|
|
||||||
HEATER_5_STR = 5
|
|
||||||
HEATER_6_DRO = 6
|
|
||||||
HEATER_7_SYRLINKS = 7
|
|
||||||
NUMBER_OF_SWITCHES = 8
|
|
||||||
|
|
||||||
|
|
||||||
HEATER_LOCATION = [
|
HEATER_LOCATION = [
|
||||||
"PLOC Processing Board",
|
"PLOC Processing Board",
|
||||||
"PCDU PDU",
|
"PCDU PDU",
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from .defs import CtrlSetId
|
|
||||||
from eive_tmtc.config.definitions import CustomServiceList
|
from eive_tmtc.config.definitions import CustomServiceList
|
||||||
from eive_tmtc.config.object_ids import TCS_CONTROLLER, TCS_SUBSYSTEM_ID
|
from eive_tmtc.config.object_ids import TCS_SUBSYSTEM_ID
|
||||||
from eive_tmtc.tmtc.common import pack_mode_cmd_with_info
|
from eive_tmtc.tmtc.common import pack_mode_cmd_with_info
|
||||||
from eive_tmtc.tmtc.tcs.brd_assy import pack_tcs_ass_cmds
|
from eive_tmtc.tmtc.tcs.brd_assy import pack_tcs_ass_cmds
|
||||||
from tmtccmd.config.tmtc import (
|
from tmtccmd.config.tmtc import (
|
||||||
@ -10,64 +9,28 @@ from tmtccmd.config.tmtc import (
|
|||||||
)
|
)
|
||||||
from tmtccmd.tc import DefaultPusQueueHelper
|
from tmtccmd.tc import DefaultPusQueueHelper
|
||||||
from tmtccmd.tc.pus_200_fsfw_mode import Mode, create_announce_mode_recursive_command
|
from tmtccmd.tc.pus_200_fsfw_mode import Mode, create_announce_mode_recursive_command
|
||||||
from tmtccmd.tc.pus_3_fsfw_hk import (
|
|
||||||
make_sid,
|
|
||||||
generate_one_hk_command,
|
|
||||||
create_request_one_diag_command,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class OpCodeSys:
|
class OpCode:
|
||||||
OFF = ["off"]
|
OFF = "off"
|
||||||
NML = ["nml"]
|
NML = "nml"
|
||||||
REQUEST_PRIMARY_TEMP_SET = ["temp"]
|
|
||||||
REQUEST_DEVICE_TEMP_SET = ["temp_devs"]
|
|
||||||
REQUEST_DEVICE_SUS_SET = ["temp_sus"]
|
|
||||||
REQUEST_HEATER_INFO = "heater_info"
|
|
||||||
ANNOUNCE_MODES = "announce_modes"
|
ANNOUNCE_MODES = "announce_modes"
|
||||||
|
|
||||||
|
|
||||||
class InfoSys:
|
class InfoSys:
|
||||||
OFF = "Switch TCS subsystem OFF"
|
OFF = "Switch TCS subsystem OFF"
|
||||||
NML = "Switch TCS subsystem NORMAL (nominal)"
|
NML = "Switch TCS subsystem NORMAL (nominal)"
|
||||||
REQUEST_PRIMARY_TEMP_SET = "Request HK set of primary sensor temperatures"
|
|
||||||
REQUEST_DEVICE_TEMP_SET = "Request HK set of device sensor temperatures"
|
|
||||||
REQUEST_DEVICE_SUS_SET = "Request HK set of the SUS temperatures"
|
|
||||||
REQUEST_HEATER_INFO = "Request heater information"
|
|
||||||
ANNOUNCE_MODES = "Announce Modes recursively"
|
ANNOUNCE_MODES = "Announce Modes recursively"
|
||||||
|
|
||||||
|
|
||||||
def pack_tcs_sys_commands(q: DefaultPusQueueHelper, op_code: str):
|
def pack_tcs_sys_commands(q: DefaultPusQueueHelper, op_code: str):
|
||||||
if op_code in OpCodeSys.REQUEST_PRIMARY_TEMP_SET:
|
if op_code == OpCode.OFF:
|
||||||
sensor_set_sid = make_sid(TCS_CONTROLLER, CtrlSetId.PRIMARY_SENSORS)
|
|
||||||
q.add_log_cmd(InfoSys.REQUEST_PRIMARY_TEMP_SET)
|
|
||||||
q.add_pus_tc(generate_one_hk_command(sensor_set_sid))
|
|
||||||
if op_code in OpCodeSys.REQUEST_DEVICE_TEMP_SET:
|
|
||||||
q.add_log_cmd(InfoSys.REQUEST_DEVICE_TEMP_SET)
|
|
||||||
q.add_pus_tc(
|
|
||||||
generate_one_hk_command(make_sid(TCS_CONTROLLER, CtrlSetId.DEVICE_SENSORS))
|
|
||||||
)
|
|
||||||
if op_code in OpCodeSys.REQUEST_DEVICE_SUS_SET:
|
|
||||||
q.add_log_cmd(InfoSys.REQUEST_DEVICE_SUS_SET)
|
|
||||||
q.add_pus_tc(
|
|
||||||
generate_one_hk_command(
|
|
||||||
make_sid(TCS_CONTROLLER, CtrlSetId.SUS_TEMP_SENSORS)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if op_code == OpCodeSys.REQUEST_HEATER_INFO:
|
|
||||||
q.add_log_cmd(InfoSys.REQUEST_HEATER_INFO)
|
|
||||||
q.add_pus_tc(
|
|
||||||
create_request_one_diag_command(
|
|
||||||
make_sid(TCS_CONTROLLER, CtrlSetId.HEATER_INFO)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if op_code in OpCodeSys.OFF:
|
|
||||||
q.add_log_cmd(InfoSys.OFF)
|
q.add_log_cmd(InfoSys.OFF)
|
||||||
pack_mode_cmd_with_info(TCS_SUBSYSTEM_ID, Mode.OFF, 0, q, InfoSys.OFF)
|
pack_mode_cmd_with_info(TCS_SUBSYSTEM_ID, Mode.OFF, 0, q, InfoSys.OFF)
|
||||||
if op_code in OpCodeSys.NML:
|
if op_code == OpCode.NML:
|
||||||
q.add_log_cmd(InfoSys.NML)
|
q.add_log_cmd(InfoSys.NML)
|
||||||
pack_mode_cmd_with_info(TCS_SUBSYSTEM_ID, Mode.NORMAL, 0, q, InfoSys.OFF)
|
pack_mode_cmd_with_info(TCS_SUBSYSTEM_ID, Mode.NORMAL, 0, q, InfoSys.OFF)
|
||||||
if op_code == OpCodeSys.ANNOUNCE_MODES:
|
if op_code == OpCode.ANNOUNCE_MODES:
|
||||||
q.add_log_cmd(InfoSys.ANNOUNCE_MODES)
|
q.add_log_cmd(InfoSys.ANNOUNCE_MODES)
|
||||||
q.add_pus_tc(create_announce_mode_recursive_command(TCS_SUBSYSTEM_ID))
|
q.add_pus_tc(create_announce_mode_recursive_command(TCS_SUBSYSTEM_ID))
|
||||||
pack_tcs_ass_cmds(q, op_code)
|
pack_tcs_ass_cmds(q, op_code)
|
||||||
@ -76,19 +39,11 @@ def pack_tcs_sys_commands(q: DefaultPusQueueHelper, op_code: str):
|
|||||||
@tmtc_definitions_provider
|
@tmtc_definitions_provider
|
||||||
def add_tcs_subsystem_cmds(defs: TmtcDefinitionWrapper):
|
def add_tcs_subsystem_cmds(defs: TmtcDefinitionWrapper):
|
||||||
oce = OpCodeEntry()
|
oce = OpCodeEntry()
|
||||||
oce.add(keys=OpCodeSys.OFF, info=InfoSys.OFF)
|
oce.add(keys=OpCode.OFF, info=InfoSys.OFF)
|
||||||
oce.add(keys=OpCodeSys.NML, info=InfoSys.NML)
|
oce.add(keys=OpCode.NML, info=InfoSys.NML)
|
||||||
oce.add(
|
oce.add(keys=OpCode.ANNOUNCE_MODES, info=InfoSys.ANNOUNCE_MODES)
|
||||||
keys=OpCodeSys.REQUEST_PRIMARY_TEMP_SET, info=InfoSys.REQUEST_PRIMARY_TEMP_SET
|
|
||||||
)
|
|
||||||
oce.add(
|
|
||||||
keys=OpCodeSys.REQUEST_DEVICE_TEMP_SET, info=InfoSys.REQUEST_DEVICE_TEMP_SET
|
|
||||||
)
|
|
||||||
oce.add(keys=OpCodeSys.REQUEST_DEVICE_SUS_SET, info=InfoSys.REQUEST_DEVICE_SUS_SET)
|
|
||||||
oce.add(keys=OpCodeSys.REQUEST_HEATER_INFO, info=InfoSys.REQUEST_HEATER_INFO)
|
|
||||||
oce.add(keys=OpCodeSys.ANNOUNCE_MODES, info=InfoSys.ANNOUNCE_MODES)
|
|
||||||
defs.add_service(
|
defs.add_service(
|
||||||
name=CustomServiceList.TCS,
|
name=CustomServiceList.TCS_SS,
|
||||||
info="TCS Board",
|
info="TCS subsystem",
|
||||||
op_code_entry=oce,
|
op_code_entry=oce,
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
import dataclasses
|
||||||
|
import datetime
|
||||||
|
import enum
|
||||||
import logging
|
import logging
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from eive_tmtc.pus_tm.defs import PrintWrapper
|
from eive_tmtc.pus_tm.defs import PrintWrapper
|
||||||
|
from eive_tmtc.tmtc.tcs.defs import Heater
|
||||||
from tmtccmd.fsfw import validity_buffer_list
|
from tmtccmd.fsfw import validity_buffer_list
|
||||||
from tmtccmd.util import ObjectIdU32
|
from tmtccmd.util import ObjectIdU32
|
||||||
from .defs import CtrlSetId
|
from .defs import CtrlSetId
|
||||||
@ -11,7 +15,46 @@ from .heater import HEATER_LOCATION
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def handle_thermal_controller_hk_data(
|
class ThermalComponent(enum.IntEnum):
|
||||||
|
NONE = 0
|
||||||
|
ACS_BOARD = 1
|
||||||
|
MGT = 2
|
||||||
|
RW = 3
|
||||||
|
STR = 4
|
||||||
|
IF_BOARD = 5
|
||||||
|
TCS_BOARD = 6
|
||||||
|
OBC = 7
|
||||||
|
LEGACY_OBCIF_BOARD = 8
|
||||||
|
SBAND_TRANSCEIVER = 9
|
||||||
|
PCDUP60_BOARD = 10
|
||||||
|
PCDUACU = 11
|
||||||
|
PCDUPDU = 12
|
||||||
|
PLPCDU_BOARD = 13
|
||||||
|
PLOCMISSION_BOARD = 14
|
||||||
|
PLOCPROCESSING_BOARD = 15
|
||||||
|
DAC = 16
|
||||||
|
CAMERA = 17
|
||||||
|
DRO = 18
|
||||||
|
X8 = 19
|
||||||
|
HPA = 20
|
||||||
|
TX = 21
|
||||||
|
MPA = 22
|
||||||
|
SCEX_BOARD = 23
|
||||||
|
NUM_ENTRIES = 24
|
||||||
|
|
||||||
|
|
||||||
|
@dataclasses.dataclass
|
||||||
|
class TcsCtrlComponentInfo:
|
||||||
|
component: ThermalComponent
|
||||||
|
# Heater on or off?
|
||||||
|
state: bool
|
||||||
|
used_sensor_idx: int
|
||||||
|
used_heater: Heater
|
||||||
|
start_time: datetime.datetime
|
||||||
|
end_time: datetime.datetime
|
||||||
|
|
||||||
|
|
||||||
|
def handle_thermal_controller_hk_data( # noqa C901: complexity is okay.
|
||||||
object_id: ObjectIdU32, pw: PrintWrapper, set_id: int, hk_data: bytes
|
object_id: ObjectIdU32, pw: PrintWrapper, set_id: int, hk_data: bytes
|
||||||
):
|
):
|
||||||
# need a better solutuon for this is this is used again..
|
# need a better solutuon for this is this is used again..
|
||||||
@ -119,5 +162,50 @@ def handle_thermal_controller_hk_data(
|
|||||||
)
|
)
|
||||||
current_draw = struct.unpack("!H", hk_data[8:10])[0]
|
current_draw = struct.unpack("!H", hk_data[8:10])[0]
|
||||||
print(f"Heater Power Channel Current Draw: {current_draw} mA")
|
print(f"Heater Power Channel Current Draw: {current_draw} mA")
|
||||||
|
elif set_id == CtrlSetId.TCS_CTRL_INFO:
|
||||||
|
pw.dlog("Received TCS CTRL information set")
|
||||||
|
current_idx = 0
|
||||||
|
heater_states = hk_data[0 : ThermalComponent.NUM_ENTRIES]
|
||||||
|
current_idx += ThermalComponent.NUM_ENTRIES
|
||||||
|
used_sensor_idx = hk_data[
|
||||||
|
current_idx : current_idx + ThermalComponent.NUM_ENTRIES
|
||||||
|
]
|
||||||
|
current_idx += ThermalComponent.NUM_ENTRIES
|
||||||
|
used_heater_idx = hk_data[
|
||||||
|
current_idx : current_idx + ThermalComponent.NUM_ENTRIES
|
||||||
|
]
|
||||||
|
current_idx += ThermalComponent.NUM_ENTRIES
|
||||||
|
start_and_end_time_fmt_str = "!IIIIIIIIIIIIIIIIIIIIIIII"
|
||||||
|
data_len = struct.calcsize(start_and_end_time_fmt_str)
|
||||||
|
start_times = struct.unpack(
|
||||||
|
start_and_end_time_fmt_str, hk_data[current_idx : current_idx + data_len]
|
||||||
|
)
|
||||||
|
current_idx += data_len
|
||||||
|
end_times = struct.unpack(
|
||||||
|
start_and_end_time_fmt_str, hk_data[current_idx : current_idx + data_len]
|
||||||
|
)
|
||||||
|
current_idx += data_len
|
||||||
|
component_list = []
|
||||||
|
for i in range(ThermalComponent.NUM_ENTRIES):
|
||||||
|
info = TcsCtrlComponentInfo(
|
||||||
|
component=ThermalComponent(i),
|
||||||
|
state=bool(heater_states[i]),
|
||||||
|
used_sensor_idx=used_sensor_idx[i],
|
||||||
|
used_heater=Heater(used_heater_idx[i]),
|
||||||
|
start_time=datetime.datetime.fromtimestamp(
|
||||||
|
start_times[i], datetime.timezone.utc
|
||||||
|
),
|
||||||
|
end_time=datetime.datetime.fromtimestamp(
|
||||||
|
end_times[i], datetime.timezone.utc
|
||||||
|
),
|
||||||
|
)
|
||||||
|
component_str = f"{info.component!r}".ljust(46)
|
||||||
|
state_str = "ON" if info.state else "OFF"
|
||||||
|
pw.dlog(
|
||||||
|
f"{component_str}: {state_str.ljust(4)} | Sensor Index "
|
||||||
|
f"{info.used_sensor_idx} | {info.used_heater!r} | Start "
|
||||||
|
f"{info.start_time} | End {info.end_time}"
|
||||||
|
)
|
||||||
|
component_list.append(info)
|
||||||
else:
|
else:
|
||||||
_LOGGER.warning(f"Unimplemented set ID {set_id}")
|
_LOGGER.warning(f"Unimplemented set ID {set_id}")
|
||||||
|
@ -29,9 +29,9 @@ classifiers = [
|
|||||||
"Topic :: Scientific/Engineering"
|
"Topic :: Scientific/Engineering"
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tmtccmd ~= 5.0.0rc0",
|
"tmtccmd ~= 5.0",
|
||||||
"python-dateutil ~= 2.8",
|
"python-dateutil ~= 2.8",
|
||||||
# tmtccmd @ git+https://github.com/robamu-org/tmtccmd@<gitRev>#egg=tmtccmd
|
# "tmtccmd @ git+https://github.com/robamu-org/tmtccmd@1b110d321ef85#egg=tmtccmd"
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
|
27
tmtcc.py
27
tmtcc.py
@ -94,7 +94,7 @@ from eive_tmtc.config.definitions import (
|
|||||||
CFDP_REMOTE_ENTITY_ID,
|
CFDP_REMOTE_ENTITY_ID,
|
||||||
)
|
)
|
||||||
from eive_tmtc.config.hook import EiveHookObject
|
from eive_tmtc.config.hook import EiveHookObject
|
||||||
from eive_tmtc.pus_tm.factory_hook import pus_factory_hook
|
from eive_tmtc.pus_tm.pus_demux import pus_factory_hook
|
||||||
from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure
|
from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure
|
||||||
|
|
||||||
_LOGGER = APP_LOGGER
|
_LOGGER = APP_LOGGER
|
||||||
@ -166,16 +166,20 @@ class PusHandler(SpecificApidHandlerBase):
|
|||||||
wrapper: VerificationWrapper,
|
wrapper: VerificationWrapper,
|
||||||
printer: FsfwTmTcPrinter,
|
printer: FsfwTmTcPrinter,
|
||||||
raw_logger: RawTmtcTimedLogWrapper,
|
raw_logger: RawTmtcTimedLogWrapper,
|
||||||
|
hk_level: int,
|
||||||
):
|
):
|
||||||
super().__init__(PUS_APID, None)
|
super().__init__(PUS_APID, None)
|
||||||
self.printer = printer
|
self.printer = printer
|
||||||
self.verif_wrapper = wrapper
|
self.verif_wrapper = wrapper
|
||||||
self.raw_logger = raw_logger
|
self.raw_logger = raw_logger
|
||||||
|
self.hk_level = hk_level
|
||||||
|
|
||||||
def handle_tm(self, packet: bytes, _user_args: any):
|
def handle_tm(self, packet: bytes, _user_args: any):
|
||||||
# with open("tc.bin", "wb") as of:
|
# with open("tc.bin", "wb") as of:
|
||||||
# of.write(packet)
|
# of.write(packet)
|
||||||
pus_factory_hook(packet, self.verif_wrapper, self.printer, self.raw_logger)
|
pus_factory_hook(
|
||||||
|
packet, self.verif_wrapper, self.printer, self.raw_logger, self.hk_level
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class UnknownApidHandler(GenericApidHandlerBase):
|
class UnknownApidHandler(GenericApidHandlerBase):
|
||||||
@ -335,13 +339,18 @@ class TcHandler(TcHandlerBase):
|
|||||||
_LOGGER.info("Finished CFDP queue")
|
_LOGGER.info("Finished CFDP queue")
|
||||||
|
|
||||||
|
|
||||||
def setup_params() -> SetupWrapper:
|
def setup_params() -> (SetupWrapper, int):
|
||||||
hook_obj = EiveHookObject(default_json_path())
|
hook_obj = EiveHookObject(default_json_path())
|
||||||
params = SetupParams()
|
params = SetupParams()
|
||||||
parser_wrapper = PreArgsParsingWrapper()
|
parser_wrapper = PreArgsParsingWrapper()
|
||||||
parser_wrapper.create_default_parent_parser()
|
parser_wrapper.create_default_parent_parser()
|
||||||
parser_wrapper.create_default_parser()
|
parser_wrapper.create_default_parser()
|
||||||
parser_wrapper.add_def_proc_and_cfdp_as_subparsers()
|
tmtc_parser, cfdp_parser = parser_wrapper.add_def_proc_and_cfdp_as_subparsers()
|
||||||
|
tmtc_parser.add_argument(
|
||||||
|
"--hk",
|
||||||
|
help="HK output level",
|
||||||
|
default=2,
|
||||||
|
)
|
||||||
post_arg_parsing_wrapper = parser_wrapper.parse(
|
post_arg_parsing_wrapper = parser_wrapper.parse(
|
||||||
setup_params=params, hook_obj=hook_obj
|
setup_params=params, hook_obj=hook_obj
|
||||||
)
|
)
|
||||||
@ -352,13 +361,14 @@ def setup_params() -> SetupWrapper:
|
|||||||
post_arg_parsing_wrapper.set_params_with_prompts(proc_param_wrapper)
|
post_arg_parsing_wrapper.set_params_with_prompts(proc_param_wrapper)
|
||||||
else:
|
else:
|
||||||
post_arg_parsing_wrapper.set_params_without_prompts(proc_param_wrapper)
|
post_arg_parsing_wrapper.set_params_without_prompts(proc_param_wrapper)
|
||||||
|
hk_level = int(post_arg_parsing_wrapper.args_raw.hk)
|
||||||
params.apid = PUS_APID
|
params.apid = PUS_APID
|
||||||
if params.com_if is None:
|
if params.com_if is None:
|
||||||
raise ValueError("could not determine a COM interface.")
|
raise ValueError("could not determine a COM interface.")
|
||||||
setup_wrapper = SetupWrapper(
|
setup_wrapper = SetupWrapper(
|
||||||
hook_obj=hook_obj, setup_params=params, proc_param_wrapper=proc_param_wrapper
|
hook_obj=hook_obj, setup_params=params, proc_param_wrapper=proc_param_wrapper
|
||||||
)
|
)
|
||||||
return setup_wrapper
|
return setup_wrapper, hk_level
|
||||||
|
|
||||||
|
|
||||||
def setup_cfdp_handler() -> CfdpInCcsdsWrapper:
|
def setup_cfdp_handler() -> CfdpInCcsdsWrapper:
|
||||||
@ -400,12 +410,13 @@ def setup_tmtc_handlers(
|
|||||||
printer: FsfwTmTcPrinter,
|
printer: FsfwTmTcPrinter,
|
||||||
raw_logger: RawTmtcTimedLogWrapper,
|
raw_logger: RawTmtcTimedLogWrapper,
|
||||||
gui: bool,
|
gui: bool,
|
||||||
|
hk_level: int,
|
||||||
) -> (CcsdsTmHandler, TcHandler):
|
) -> (CcsdsTmHandler, TcHandler):
|
||||||
cfdp_in_ccsds_wrapper = setup_cfdp_handler()
|
cfdp_in_ccsds_wrapper = setup_cfdp_handler()
|
||||||
verification_wrapper = VerificationWrapper(
|
verification_wrapper = VerificationWrapper(
|
||||||
verificator, _LOGGER, printer.file_logger
|
verificator, _LOGGER, printer.file_logger
|
||||||
)
|
)
|
||||||
pus_handler = PusHandler(verification_wrapper, printer, raw_logger)
|
pus_handler = PusHandler(verification_wrapper, printer, raw_logger, hk_level)
|
||||||
ccsds_handler = CustomCcsdsTmHandler(generic_handler=UnknownApidHandler(None))
|
ccsds_handler = CustomCcsdsTmHandler(generic_handler=UnknownApidHandler(None))
|
||||||
ccsds_handler.add_apid_handler(pus_handler)
|
ccsds_handler.add_apid_handler(pus_handler)
|
||||||
ccsds_handler.add_apid_handler(cfdp_in_ccsds_wrapper)
|
ccsds_handler.add_apid_handler(cfdp_in_ccsds_wrapper)
|
||||||
@ -444,7 +455,7 @@ def main(): # noqa C901: Complexity okay here.
|
|||||||
# TODO: -V CLI argument to enable this?
|
# TODO: -V CLI argument to enable this?
|
||||||
_LOGGER.setLevel(_LOG_LEVEL)
|
_LOGGER.setLevel(_LOG_LEVEL)
|
||||||
try:
|
try:
|
||||||
setup_wrapper = setup_params()
|
setup_wrapper, hk_level = setup_params()
|
||||||
except KeyboardInterrupt as e:
|
except KeyboardInterrupt as e:
|
||||||
_LOGGER.info(f"{e}. Exiting")
|
_LOGGER.info(f"{e}. Exiting")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@ -457,7 +468,7 @@ def main(): # noqa C901: Complexity okay here.
|
|||||||
)
|
)
|
||||||
pus_verificator = PusVerificator()
|
pus_verificator = PusVerificator()
|
||||||
ccsds_handler, tc_handler = setup_tmtc_handlers(
|
ccsds_handler, tc_handler = setup_tmtc_handlers(
|
||||||
pus_verificator, printer, raw_logger, setup_wrapper.params.use_gui
|
pus_verificator, printer, raw_logger, setup_wrapper.params.use_gui, hk_level
|
||||||
)
|
)
|
||||||
|
|
||||||
tmtccmd.setup(setup_wrapper)
|
tmtccmd.setup(setup_wrapper)
|
||||||
|
Reference in New Issue
Block a user