Compare commits

..

20 Commits

Author SHA1 Message Date
0c1bfc6fd3 bump changelog 2023-05-12 16:27:16 +02:00
04bbe057e7 flash c ontent report works now 2023-05-12 16:24:45 +02:00
e05a54b076 somethings wrong with the format 2023-05-12 16:08:57 +02:00
ef0adef04a start adding action reply handler for MPSoC 2023-05-12 15:51:17 +02:00
377e98b5c2 bugfix MPSoC HK parsing 2023-05-12 13:22:58 +02:00
87e5abe8eb add missing command list of PLOC MPSoC commands 2023-05-12 11:51:47 +02:00
13fd9a7d84 Merge pull request 'impl MPSoC HK parsing' (#188) from mpsoc_commands into main
Reviewed-on: #188
Reviewed-by: Marius Eggert <eggertm@irs.uni-stuttgart.de>
2023-05-04 15:30:49 +02:00
bbcc0f9de7 Merge branch 'mpsoc_commands' of https://egit.irs.uni-stuttgart.de/eive/eive-tmtc into mpsoc_commands 2023-05-04 15:17:12 +02:00
a0aa6525e4 fix 2023-05-04 15:17:00 +02:00
1ab8710040 Merge branch 'main' into mpsoc_commands 2023-05-04 14:51:13 +02:00
f480d86fbd impl MPSoC HK parsing 2023-05-04 14:50:38 +02:00
4d921e01af Merge pull request 'MPSoC module update' (#187) from mpsoc_commands into main
Reviewed-on: #187
Reviewed-by: Marius Eggert <eggertm@irs.uni-stuttgart.de>
2023-05-04 12:01:43 +02:00
b505524e0b Merge branch 'main' into mpsoc_commands 2023-05-04 12:01:33 +02:00
e0e9a310b9 add command to get flash dir content 2023-05-04 11:51:50 +02:00
0e9ebefc87 new mpsoc commands 2023-05-04 11:27:12 +02:00
e85d1a1966 Merge pull request 'most important bugfix' (#186) from most-important-bugfix into main
Reviewed-on: #186
2023-05-03 13:36:31 +02:00
4ff50b6559 bub 2023-05-03 13:34:14 +02:00
60fba8b6d9 Merge pull request 'more system modes' (#185) from more-system-modes into main
Reviewed-on: #185
2023-04-28 10:25:35 +02:00
1707f24612 more system modes 2023-04-19 15:10:44 +02:00
5fbd19bb6c Merge branch 'main' of https://egit.irs.uni-stuttgart.de/eive/eive-tmtc 2023-04-17 18:41:08 +02:00
92 changed files with 1262 additions and 2523 deletions

17
.flake8 Normal file
View File

@ -0,0 +1,17 @@
[flake8]
max-line-length = 100
ignore = D203, W503
per-file-ignores =
*/__init__.py: F401
exclude =
.git,
__pycache__,
docs/conf.py,
old,
build,
dist,
venv
max-complexity = 10
extend-ignore =
# See https://github.com/PyCQA/pycodestyle/issues/373
E203,

View File

@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="CFDP Downlink Test Large" type="PythonConfigurationType" factoryName="Python" folderName="CFDP">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtcc.py" />
<option name="PARAMETERS" value="cfdp -p /tmp/obsw_update.bin /tmp/obsw_update_copy.bin -d 0.1" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

View File

@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="CFDP Downlink Test Larger" type="PythonConfigurationType" factoryName="Python" folderName="CFDP">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtcc.py" />
<option name="PARAMETERS" value="cfdp -p /tmp/fake_5kb.bin /tmp/fake_5kb_copy.bin -d 0.1" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

View File

@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="CFDP Downlink Test" type="PythonConfigurationType" factoryName="Python" folderName="CFDP">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtcc.py" />
<option name="PARAMETERS" value="cfdp -p /tmp/hello.txt /tmp/hello2.txt -d 0.1" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

View File

@ -10,144 +10,12 @@ list yields a list of all related PRs for each release.
# [unreleased] # [unreleased]
# [v5.7.1] 2023-10-11
## Added
- SCEX normal command
# [v5.7.0] 2023-10-10
- `tmtccmd` v6.0.0
- `spacepackets` v18.0.0
## Added
- Power controller commands.
# [v5.6.0] 2023-09-14
- `tmtccmd` v6.0.0
- `spacepackets` v18.0.0
## Added
- CFDP file downlink support.
# [v5.5.1] 2023-09-12
## Fixed
- Some API usage fixes related to `tmtccmd` update.
# [v5.5.0] 2023-09-12
- Version is not specfied dynamically anymore and can be updated in `pyproject.toml`
- New events and returnvalues
- Bump `tmtccmd` to v6.0.0rc0
# [v5.4.3] 2023-08-15
## Added
- PLOC SUPV HK parsing.
# [v5.4.2] 2023-08-15
## Added
- New NONE entry for PL PCDU submode enum.
# [v5.4.1] 2023-08-15
## Added
- New event TLE_TOO_OLD
## Changed
- PL Subsystem mode ID is int enum now.
# [v5.4.0] 2023-08-15
## Added
- New enumeration for PL PCDU commanding.
- Some new events
# [v5.3.1] 2023-07-26
## Changed
- Adaptions for ACS CTRL strategy enum to make it compatible to software. Also make it re-usable
by putting it in global scope.
# [v5.3.0] 2023-07-26
## Added
- Dataset handling for new ACS fused rot rate dataset.
# [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
## Added
- Some BPX battery commands
# [v4.0.0] 2023-06-10
`tmtccmd` version: v5.0.0rc0
## Added ## Added
- Event handling for reboot counter events. - Event handling for reboot counter events.
- Start adding new MPSoC commands, improve MPSoC commanding module a bit. - Start adding new MPSoC commands, improve MPSoC commanding module a bit.
- Handling for PLOC MPSoC flash content report. - Handling for PLOC MPSoC flash content report.
## Fixed
- Fix for PLOC power switching.
- Bump `tmtccmd` to v5.0.0rc0 for important bugfix in CFDP header.
# [v3.1.2] 2023-06-19
## Fixed
- Pin `tmtccmd` to v4.1.3 to enforce correct `spacepackets` version on install
# [v3.1.1] 2023-04-17 # [v3.1.1] 2023-04-17
## Added ## Added

View File

@ -4,7 +4,7 @@ This application can be used to test the EIVE On-Board Software. Furthermore, it
also be used to retrieve all sorts of telemetry data like housekeeping data. also be used to retrieve all sorts of telemetry data like housekeeping data.
It is recommended to use this application with a virtual environment. It is recommended to use this application with a virtual environment.
The [virtual environment](#venv) chapter describes how to set one up. The [requirements](#reqs) The [virtual environemnt](#venv) chapter describes how to set one up. The [requirements](#reqs)
describes how to install all required packages. describes how to install all required packages.
The configuration file can currently be found at `tmtc_conf.json`. It caches settings The configuration file can currently be found at `tmtc_conf.json`. It caches settings
@ -61,57 +61,42 @@ Run GUI mode
# <a id="reqs"></a> Install requirements # <a id="reqs"></a> Install requirements
There are two ways to install the requirements. One is to install the primary dependency There are two ways to install the requirements. One is to install the primary dependency
`tmtccmd` interactively. `tmtccmd` interactively. This is the recommended way
## Installing via PyPI Assuming you are running in a virtual environment:
It is recommended to install `eive-tmtc` itself interactively, which also installs 1. Install `tmtccmd` for virtual environment. `-e` for interactive installation.
all required dependencies.
```sh ```sh
pip install -e . cd deps/tmtccmd
``` pip install -e .[gui]
```
If you only want to install all dependencies: Alternatively you can also install the packages from PyPI completely, but the risk of
incompatibilities will be high there
```sh ```sh
pip install -r requirements.txt pip install -r requirements.txt
``` ```
## Install interactively
Clone the dependency first inside the `deps` folder
```sh
cd deps
./install_tmtccmd.sh
```
Then you can install `tmtccmd` interactively
```sh
cd tmtccmd
pip install -e .
```
# Run Linter # Run Linter
Can be used to quickly check validity of script. Install `flake8` first Can be used to quickly check validity of script. Install `flake8` first
```sh ```sh
python3 -m pip install ruff python3 -m pip install flake8
``` ```
or on Windows or on Windows
```sh ```sh
py -m pip install ruff py -m pip install flake8
``` ```
and then run it and then run the `lint.py` script
```sh ```sh
ruff . ./lint.py
``` ```
# Run Auto-Formatter # Run Auto-Formatter

View File

@ -1,9 +0,0 @@
FROM python:3
RUN apt-get update
RUN apt-get --yes upgrade
#tzdata is a dependency, won't install otherwise
ARG DEBIAN_FRONTEND=noninteractive
#pip needs a valid user to work
RUN adduser --uid 114 jenkins

View File

@ -1,14 +0,0 @@
pipeline {
agent {
docker {
image 'eive-tmtc-ci:d2'
}
}
stages {
stage('Package') {
steps {
sh 'pip install .'
}
}
}
}

View File

@ -1,7 +1,14 @@
__version__ = "3.1.1"
import logging import logging
from pathlib import Path from pathlib import Path
SW_NAME = "eive-tmtc"
VERSION_MAJOR = 3
VERSION_MINOR = 1
VERSION_REVISION = 1
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() APP_LOGGER = logging.getLogger(__name__)

View File

@ -1,20 +0,0 @@
import logging
from spacepackets.cfdp import ConditionCode
from tmtccmd.cfdp.mib import DefaultFaultHandlerBase
_LOGGER = logging.getLogger(__name__)
class EiveCfdpFaultHandler(DefaultFaultHandlerBase):
def notice_of_suspension_cb(self, cond: ConditionCode):
_LOGGER.info(f"Received notice of suspension: {cond!r}")
def notice_of_cancellation_cb(self, cond: ConditionCode):
_LOGGER.info(f"Received notice of cancellation: {cond!r}")
def abandoned_cb(self, cond: ConditionCode):
_LOGGER.info(f"Abandoned transaction: {cond!r}")
def ignore_cb(self, cond: ConditionCode):
_LOGGER.info(f"Ignored transaction: {cond!r}")

View File

@ -1,27 +0,0 @@
import logging
from eive_tmtc.config.definitions import CFDP_APID
from spacepackets.ccsds import SPACE_PACKET_HEADER_SIZE
from spacepackets.cfdp import PduFactory, PduType, DirectiveType
from tmtccmd.cfdp.handler import CfdpInCcsdsHandler
from tmtccmd.tm import SpecificApidHandlerBase
_LOGGER = logging.getLogger(__name__)
class CfdpInCcsdsWrapper(SpecificApidHandlerBase):
def __init__(self, cfdp_in_ccsds_handler: CfdpInCcsdsHandler):
super().__init__(CFDP_APID, None)
self.handler = cfdp_in_ccsds_handler
def handle_tm(self, packet: bytes, _user_args: any):
# Ignore the space packet header. Its only purpose is to use the same protocol and
# have a seaprate APID for space packets. If this function is called, the APID is correct.
pdu = packet[SPACE_PACKET_HEADER_SIZE:]
pdu_base = PduFactory.from_raw(pdu)
if pdu_base.pdu_type == PduType.FILE_DATA:
_LOGGER.info("Received File Data PDU")
else:
directive_type = DirectiveType(pdu_base.directive_type)
_LOGGER.info(f"Received File Directive PDU with type {directive_type!r}")
self.handler.insert_pdu_packet(pdu_base)

View File

@ -1,58 +0,0 @@
import logging
from spacepackets.cfdp import ConditionCode
from tmtccmd.cfdp import CfdpUserBase, TransactionId
from tmtccmd.cfdp.user import (
TransactionFinishedParams,
MetadataRecvParams,
FileSegmentRecvdParams,
)
_LOGGER = logging.getLogger(__name__)
class EiveCfdpUser(CfdpUserBase):
def transaction_indication(self, transaction_id: TransactionId):
_LOGGER.info(f"CFDP User: Start of File {transaction_id}")
def eof_sent_indication(self, transaction_id: TransactionId):
_LOGGER.info(f"CFDP User: EOF sent for {transaction_id}")
def transaction_finished_indication(self, params: TransactionFinishedParams):
_LOGGER.info(f"CFDP User: {params.transaction_id} finished")
_LOGGER.info(f"Delivery Code: {params.delivery_code!r}")
_LOGGER.info(f"Condition code: {params.condition_code!r}")
_LOGGER.info(f"File delivery status: {params.delivery_code!r}")
def metadata_recv_indication(self, params: MetadataRecvParams):
pass
def file_segment_recv_indication(self, params: FileSegmentRecvdParams):
_LOGGER.info(
f"CFDP User: Received File Data PDU for {params.transaction_id} | Offset:"
f" {params.offset} | Segment Length: {params.length}"
)
def report_indication(self, transaction_id: TransactionId, status_report: any):
pass
def suspended_indication(
self, transaction_id: TransactionId, cond_code: ConditionCode
):
pass
def resumed_indication(self, transaction_id: TransactionId, progress: int):
pass
def fault_indication(
self, transaction_id: TransactionId, cond_code: ConditionCode, progress: int
):
pass
def abandoned_indication(
self, transaction_id: TransactionId, cond_code: ConditionCode, progress: int
):
pass
def eof_recv_indication(self, transaction_id: TransactionId):
_LOGGER.info(f"CFDP User: EOF received for {transaction_id}")

View File

@ -9,6 +9,7 @@ import enum
from spacepackets import PacketType from spacepackets import PacketType
from spacepackets.ccsds import PacketId from spacepackets.ccsds import PacketId
from spacepackets.util import UnsignedByteField from spacepackets.util import UnsignedByteField
from pathlib import Path
PUS_APID = 0x65 PUS_APID = 0x65
@ -65,16 +66,13 @@ 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_SS = "tcs_subsystem" TCS = "tcs"
TCS_CTRL = "tcs_ctrl"
TCS_ASS = "tcs_ass" TCS_ASS = "tcs_ass"
TIME = "time" TIME = "time"
PROCEDURE = "proc" PROCEDURE = "proc"
RTD = "rtd" RTD = "rtd"
TMP1075 = "tmp1075" TMP1075 = "tcs_tmp"
TVTTESTPROCEDURE = "tvtestproc" TVTTESTPROCEDURE = "tvtestproc"
SCEX = "scex" SCEX = "scex"
TM_STORE = "tm_store" TM_STORE = "tm_store"
SYSTEM = "system" SYSTEM = "system"
PWR_CTRL = "pwr_ctrl"
EPS_SS = "eps_subsystem"

View File

@ -94,16 +94,10 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
11205;0x2bc5;MEKF_AUTOMATIC_RESET;INFO;MEKF performed an automatic reset after detection of nonfinite values.;mission/acs/defs.h 11205;0x2bc5;MEKF_AUTOMATIC_RESET;INFO;MEKF performed an automatic reset after detection of nonfinite values.;mission/acs/defs.h
11206;0x2bc6;MEKF_INVALID_MODE_VIOLATION;HIGH;MEKF was not able to compute a solution during any pointing ACS mode for a prolonged time.;mission/acs/defs.h 11206;0x2bc6;MEKF_INVALID_MODE_VIOLATION;HIGH;MEKF was not able to compute a solution during any pointing ACS mode for a prolonged time.;mission/acs/defs.h
11207;0x2bc7;SAFE_MODE_CONTROLLER_FAILURE;HIGH;The ACS safe mode controller was not able to compute a solution and has failed. P1: Missing information about magnetic field, P2: Missing information about rotational rate;mission/acs/defs.h 11207;0x2bc7;SAFE_MODE_CONTROLLER_FAILURE;HIGH;The ACS safe mode controller was not able to compute a solution and has failed. P1: Missing information about magnetic field, P2: Missing information about rotational rate;mission/acs/defs.h
11208;0x2bc8;TLE_TOO_OLD;INFO;The TLE for the SGP4 Propagator has become too old.;mission/acs/defs.h
11300;0x2c24;SWITCH_CMD_SENT;INFO;Indicates that a FSFW object requested setting a switch P1: 1 if on was requested, 0 for off | P2: Switch Index;mission/power/defs.h 11300;0x2c24;SWITCH_CMD_SENT;INFO;Indicates that a FSFW object requested setting a switch P1: 1 if on was requested, 0 for off | P2: Switch Index;mission/power/defs.h
11301;0x2c25;SWITCH_HAS_CHANGED;INFO;Indicated that a switch state has changed P1: New switch state, 1 for on, 0 for off | P2: Switch Index;mission/power/defs.h 11301;0x2c25;SWITCH_HAS_CHANGED;INFO;Indicated that a switch state has changed P1: New switch state, 1 for on, 0 for off | P2: Switch Index;mission/power/defs.h
11302;0x2c26;SWITCHING_Q7S_DENIED;MEDIUM;No description;mission/power/defs.h 11302;0x2c26;SWITCHING_Q7S_DENIED;MEDIUM;No description;mission/power/defs.h
11303;0x2c27;FDIR_REACTION_IGNORED;MEDIUM;No description;mission/power/defs.h 11303;0x2c27;FDIR_REACTION_IGNORED;MEDIUM;No description;mission/power/defs.h
11304;0x2c28;DATASET_READ_FAILED;INFO;The dataset read for the inputs of the Power Controller has failed.;mission/power/defs.h
11305;0x2c29;VOLTAGE_OUT_OF_BOUNDS;HIGH;No description;mission/power/defs.h
11306;0x2c2a;TIMEDELTA_OUT_OF_BOUNDS;LOW;Time difference for Coulomb Counter was too large. P1: time in s * 10;mission/power/defs.h
11307;0x2c2b;POWER_LEVEL_LOW;HIGH;The State of Charge is below the limit for payload use. Setting Payload to faulty.;mission/power/defs.h
11308;0x2c2c;POWER_LEVEL_CRITICAL;HIGH;The State of Charge is below the limit for higher modes. Setting Reaction Wheels to faulty.;mission/power/defs.h
11400;0x2c88;GPIO_PULL_HIGH_FAILED;LOW;No description;mission/tcs/HeaterHandler.h 11400;0x2c88;GPIO_PULL_HIGH_FAILED;LOW;No description;mission/tcs/HeaterHandler.h
11401;0x2c89;GPIO_PULL_LOW_FAILED;LOW;No description;mission/tcs/HeaterHandler.h 11401;0x2c89;GPIO_PULL_LOW_FAILED;LOW;No description;mission/tcs/HeaterHandler.h
11402;0x2c8a;HEATER_WENT_ON;INFO;No description;mission/tcs/HeaterHandler.h 11402;0x2c8a;HEATER_WENT_ON;INFO;No description;mission/tcs/HeaterHandler.h
@ -127,8 +121,6 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
11604;0x2d54;MPSOC_HANDLER_CRC_FAILURE;LOW;PLOC reply has invalid crc;linux/payload/PlocMpsocHandler.h 11604;0x2d54;MPSOC_HANDLER_CRC_FAILURE;LOW;PLOC reply has invalid crc;linux/payload/PlocMpsocHandler.h
11605;0x2d55;MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH;LOW;Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocHandler.h 11605;0x2d55;MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH;LOW;Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocHandler.h
11606;0x2d56;MPSOC_SHUTDOWN_FAILED;HIGH;Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor.;linux/payload/PlocMpsocHandler.h 11606;0x2d56;MPSOC_SHUTDOWN_FAILED;HIGH;Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor.;linux/payload/PlocMpsocHandler.h
11607;0x2d57;SUPV_NOT_ON;LOW;SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition.;linux/payload/PlocMpsocHandler.h
11608;0x2d58;SUPV_REPLY_TIMEOUT;LOW;No description;linux/payload/PlocMpsocHandler.h
11701;0x2db5;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11701;0x2db5;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h
11702;0x2db6;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11702;0x2db6;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h
11703;0x2db7;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11703;0x2db7;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h
@ -141,7 +133,6 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
11802;0x2e1a;RESET_OCCURED;LOW;No description;mission/acs/rwHelpers.h 11802;0x2e1a;RESET_OCCURED;LOW;No description;mission/acs/rwHelpers.h
11901;0x2e7d;BOOTING_FIRMWARE_FAILED_EVENT;LOW;Failed to boot firmware;mission/acs/str/StarTrackerHandler.h 11901;0x2e7d;BOOTING_FIRMWARE_FAILED_EVENT;LOW;Failed to boot firmware;mission/acs/str/StarTrackerHandler.h
11902;0x2e7e;BOOTING_BOOTLOADER_FAILED_EVENT;LOW;Failed to boot star tracker into bootloader mode;mission/acs/str/StarTrackerHandler.h 11902;0x2e7e;BOOTING_BOOTLOADER_FAILED_EVENT;LOW;Failed to boot star tracker into bootloader mode;mission/acs/str/StarTrackerHandler.h
11903;0x2e7f;COM_ERROR_REPLY_RECEIVED;LOW;Received COM error. P1: Communication Error ID (datasheet p32);mission/acs/str/StarTrackerHandler.h
12001;0x2ee1;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;linux/payload/PlocSupervisorHandler.h 12001;0x2ee1;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;linux/payload/PlocSupervisorHandler.h
12002;0x2ee2;SUPV_UNKNOWN_TM;LOW;Unhandled event. P1: APID, P2: Service ID;linux/payload/PlocSupervisorHandler.h 12002;0x2ee2;SUPV_UNKNOWN_TM;LOW;Unhandled event. P1: APID, P2: Service ID;linux/payload/PlocSupervisorHandler.h
12003;0x2ee3;SUPV_UNINIMPLEMENTED_TM;LOW;No description;linux/payload/PlocSupervisorHandler.h 12003;0x2ee3;SUPV_UNINIMPLEMENTED_TM;LOW;No description;linux/payload/PlocSupervisorHandler.h
@ -169,7 +160,6 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
12412;0x307c;PDEC_RESET_FAILED;HIGH;Failed to pull PDEC reset to low;linux/ipcore/pdec.h 12412;0x307c;PDEC_RESET_FAILED;HIGH;Failed to pull PDEC reset to low;linux/ipcore/pdec.h
12413;0x307d;OPEN_IRQ_FILE_FAILED;HIGH;Failed to open the IRQ uio file;linux/ipcore/pdec.h 12413;0x307d;OPEN_IRQ_FILE_FAILED;HIGH;Failed to open the IRQ uio file;linux/ipcore/pdec.h
12414;0x307e;PDEC_INIT_FAILED;HIGH;PDEC initialization failed. This might also be due to the persistent confiuration never becoming available, for example due to SD card issues.;linux/ipcore/pdec.h 12414;0x307e;PDEC_INIT_FAILED;HIGH;PDEC initialization failed. This might also be due to the persistent confiuration never becoming available, for example due to SD card issues.;linux/ipcore/pdec.h
12415;0x307f;PDEC_CONFIG_CORRUPTED;HIGH;The PDEC configuration area has been corrupted P1: The first configuration word P2: The second configuration word;linux/ipcore/pdec.h
12500;0x30d4;IMAGE_UPLOAD_FAILED;LOW;Image upload failed;linux/acs/StrComHandler.h 12500;0x30d4;IMAGE_UPLOAD_FAILED;LOW;Image upload failed;linux/acs/StrComHandler.h
12501;0x30d5;IMAGE_DOWNLOAD_FAILED;LOW;Image download failed;linux/acs/StrComHandler.h 12501;0x30d5;IMAGE_DOWNLOAD_FAILED;LOW;Image download failed;linux/acs/StrComHandler.h
12502;0x30d6;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successfulop;linux/acs/StrComHandler.h 12502;0x30d6;IMAGE_UPLOAD_SUCCESSFUL;LOW;Uploading image to star tracker was successfulop;linux/acs/StrComHandler.h
@ -187,24 +177,20 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
12515;0x30e3;STR_HELPER_FILE_NOT_EXISTS;LOW;Specified file does not exist P1: Internal state of str helper;linux/acs/StrComHandler.h 12515;0x30e3;STR_HELPER_FILE_NOT_EXISTS;LOW;Specified file does not exist P1: Internal state of str helper;linux/acs/StrComHandler.h
12516;0x30e4;STR_HELPER_SENDING_PACKET_FAILED;LOW;No description;linux/acs/StrComHandler.h 12516;0x30e4;STR_HELPER_SENDING_PACKET_FAILED;LOW;No description;linux/acs/StrComHandler.h
12517;0x30e5;STR_HELPER_REQUESTING_MSG_FAILED;LOW;No description;linux/acs/StrComHandler.h 12517;0x30e5;STR_HELPER_REQUESTING_MSG_FAILED;LOW;No description;linux/acs/StrComHandler.h
12600;0x3138;MPSOC_FLASH_WRITE_FAILED;LOW;Flash write fails;linux/payload/PlocMpsocSpecialComHelper.h 12600;0x3138;MPSOC_FLASH_WRITE_FAILED;LOW;Flash write fails;linux/payload/PlocMpsocHelper.h
12601;0x3139;MPSOC_FLASH_WRITE_SUCCESSFUL;INFO;Flash write successful;linux/payload/PlocMpsocSpecialComHelper.h 12601;0x3139;MPSOC_FLASH_WRITE_SUCCESSFUL;LOW;Flash write successful;linux/payload/PlocMpsocHelper.h
12602;0x313a;MPSOC_SENDING_COMMAND_FAILED;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h 12602;0x313a;MPSOC_SENDING_COMMAND_FAILED;LOW;No description;linux/payload/PlocMpsocHelper.h
12603;0x313b;MPSOC_HELPER_REQUESTING_REPLY_FAILED;LOW;Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h 12603;0x313b;MPSOC_HELPER_REQUESTING_REPLY_FAILED;LOW;Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h
12604;0x313c;MPSOC_HELPER_READING_REPLY_FAILED;LOW;Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h 12604;0x313c;MPSOC_HELPER_READING_REPLY_FAILED;LOW;Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h
12605;0x313d;MPSOC_MISSING_ACK;LOW;Did not receive acknowledgment report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h 12605;0x313d;MPSOC_MISSING_ACK;LOW;Did not receive acknowledgment report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h
12606;0x313e;MPSOC_MISSING_EXE;LOW;Did not receive execution report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h 12606;0x313e;MPSOC_MISSING_EXE;LOW;Did not receive execution report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h
12607;0x313f;MPSOC_ACK_FAILURE_REPORT;LOW;Received acknowledgment failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h 12607;0x313f;MPSOC_ACK_FAILURE_REPORT;LOW;Received acknowledgment failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h
12608;0x3140;MPSOC_EXE_FAILURE_REPORT;LOW;Received execution failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h 12608;0x3140;MPSOC_EXE_FAILURE_REPORT;LOW;Received execution failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h
12609;0x3141;MPSOC_ACK_INVALID_APID;LOW;Expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h 12609;0x3141;MPSOC_ACK_INVALID_APID;LOW;Expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h
12610;0x3142;MPSOC_EXE_INVALID_APID;LOW;Expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h 12610;0x3142;MPSOC_EXE_INVALID_APID;LOW;Expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h
12611;0x3143;MPSOC_HELPER_SEQ_CNT_MISMATCH;LOW;Received sequence count does not match expected sequence count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocSpecialComHelper.h 12611;0x3143;MPSOC_HELPER_SEQ_CNT_MISMATCH;LOW;Received sequence count does not match expected sequence count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocHelper.h
12612;0x3144;MPSOC_TM_SIZE_ERROR;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h 12612;0x3144;MPSOC_TM_SIZE_ERROR;LOW;No description;linux/payload/PlocMpsocHelper.h
12613;0x3145;MPSOC_TM_CRC_MISSMATCH;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h 12613;0x3145;MPSOC_TM_CRC_MISSMATCH;LOW;No description;linux/payload/PlocMpsocHelper.h
12614;0x3146;MPSOC_FLASH_READ_PACKET_ERROR;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
12615;0x3147;MPSOC_FLASH_READ_FAILED;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
12616;0x3148;MPSOC_FLASH_READ_SUCCESSFUL;INFO;No description;linux/payload/PlocMpsocSpecialComHelper.h
12617;0x3149;MPSOC_READ_TIMEOUT;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
12700;0x319c;TRANSITION_BACK_TO_OFF;MEDIUM;Could not transition properly and went back to ALL OFF;mission/payload/PayloadPcduHandler.h 12700;0x319c;TRANSITION_BACK_TO_OFF;MEDIUM;Could not transition properly and went back to ALL OFF;mission/payload/PayloadPcduHandler.h
12701;0x319d;NEG_V_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h 12701;0x319d;NEG_V_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h
12702;0x319e;U_DRO_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h 12702;0x319e;U_DRO_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h
@ -264,7 +250,6 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
13800;0x35e8;MISSING_PACKET;LOW;No description;mission/payload/scexHelpers.h 13800;0x35e8;MISSING_PACKET;LOW;No description;mission/payload/scexHelpers.h
13801;0x35e9;EXPERIMENT_TIMEDOUT;LOW;No description;mission/payload/scexHelpers.h 13801;0x35e9;EXPERIMENT_TIMEDOUT;LOW;No description;mission/payload/scexHelpers.h
13802;0x35ea;MULTI_PACKET_COMMAND_DONE;INFO;No description;mission/payload/scexHelpers.h 13802;0x35ea;MULTI_PACKET_COMMAND_DONE;INFO;No description;mission/payload/scexHelpers.h
13803;0x35eb;FS_UNUSABLE;LOW;No description;mission/payload/scexHelpers.h
13901;0x364d;SET_CONFIGFILEVALUE_FAILED;MEDIUM;No description;mission/utility/GlobalConfigHandler.h 13901;0x364d;SET_CONFIGFILEVALUE_FAILED;MEDIUM;No description;mission/utility/GlobalConfigHandler.h
13902;0x364e;GET_CONFIGFILEVALUE_FAILED;MEDIUM;No description;mission/utility/GlobalConfigHandler.h 13902;0x364e;GET_CONFIGFILEVALUE_FAILED;MEDIUM;No description;mission/utility/GlobalConfigHandler.h
13903;0x364f;INSERT_CONFIGFILEVALUE_FAILED;MEDIUM;No description;mission/utility/GlobalConfigHandler.h 13903;0x364f;INSERT_CONFIGFILEVALUE_FAILED;MEDIUM;No description;mission/utility/GlobalConfigHandler.h
@ -282,8 +267,6 @@ 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
14014;0x36be;ACTIVE_SD_INFO;INFO;Active SD card info. SD States: 0: OFF, 1: ON, 2: MOUNTED. P1: Active SD Card Index, 0 if none is active P2: First two bytes: SD state of SD card 0, last two bytes SD state of SD card 1;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
@ -291,10 +274,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
14105;0x3719;CAMERA_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h 14105;0x3719;CAMERA_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h
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;MEDIUM;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
@ -310,5 +290,3 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
14312;0x37e8;DUMP_MISC_CANCELLED;LOW;P1: Number of dumped packets. P2: Total dumped bytes.;mission/persistentTmStoreDefs.h 14312;0x37e8;DUMP_MISC_CANCELLED;LOW;P1: Number of dumped packets. P2: Total dumped bytes.;mission/persistentTmStoreDefs.h
14313;0x37e9;DUMP_HK_CANCELLED;LOW;P1: Number of dumped packets. P2: Total dumped bytes.;mission/persistentTmStoreDefs.h 14313;0x37e9;DUMP_HK_CANCELLED;LOW;P1: Number of dumped packets. P2: Total dumped bytes.;mission/persistentTmStoreDefs.h
14314;0x37ea;DUMP_CFDP_CANCELLED;LOW;P1: Number of dumped packets. P2: Total dumped bytes.;mission/persistentTmStoreDefs.h 14314;0x37ea;DUMP_CFDP_CANCELLED;LOW;P1: Number of dumped packets. P2: Total dumped bytes.;mission/persistentTmStoreDefs.h
14500;0x38a4;TEMPERATURE_ALL_ONES_START;MEDIUM;Detected invalid values, starting invalid message counting;mission/acs/SusHandler.h
14501;0x38a5;TEMPERATURE_ALL_ONES_RECOVERY;INFO;Detected valid values again, resetting invalid message counter. P1: Invalid message counter.;mission/acs/SusHandler.h

1 Event ID (dec) Event ID (hex) Name Severity Description File Path
94 11205 0x2bc5 MEKF_AUTOMATIC_RESET INFO MEKF performed an automatic reset after detection of nonfinite values. mission/acs/defs.h
95 11206 0x2bc6 MEKF_INVALID_MODE_VIOLATION HIGH MEKF was not able to compute a solution during any pointing ACS mode for a prolonged time. mission/acs/defs.h
96 11207 0x2bc7 SAFE_MODE_CONTROLLER_FAILURE HIGH The ACS safe mode controller was not able to compute a solution and has failed. P1: Missing information about magnetic field, P2: Missing information about rotational rate mission/acs/defs.h
11208 0x2bc8 TLE_TOO_OLD INFO The TLE for the SGP4 Propagator has become too old. mission/acs/defs.h
97 11300 0x2c24 SWITCH_CMD_SENT INFO Indicates that a FSFW object requested setting a switch P1: 1 if on was requested, 0 for off | P2: Switch Index mission/power/defs.h
98 11301 0x2c25 SWITCH_HAS_CHANGED INFO Indicated that a switch state has changed P1: New switch state, 1 for on, 0 for off | P2: Switch Index mission/power/defs.h
99 11302 0x2c26 SWITCHING_Q7S_DENIED MEDIUM No description mission/power/defs.h
100 11303 0x2c27 FDIR_REACTION_IGNORED MEDIUM No description mission/power/defs.h
11304 0x2c28 DATASET_READ_FAILED INFO The dataset read for the inputs of the Power Controller has failed. mission/power/defs.h
11305 0x2c29 VOLTAGE_OUT_OF_BOUNDS HIGH No description mission/power/defs.h
11306 0x2c2a TIMEDELTA_OUT_OF_BOUNDS LOW Time difference for Coulomb Counter was too large. P1: time in s * 10 mission/power/defs.h
11307 0x2c2b POWER_LEVEL_LOW HIGH The State of Charge is below the limit for payload use. Setting Payload to faulty. mission/power/defs.h
11308 0x2c2c POWER_LEVEL_CRITICAL HIGH The State of Charge is below the limit for higher modes. Setting Reaction Wheels to faulty. mission/power/defs.h
101 11400 0x2c88 GPIO_PULL_HIGH_FAILED LOW No description mission/tcs/HeaterHandler.h
102 11401 0x2c89 GPIO_PULL_LOW_FAILED LOW No description mission/tcs/HeaterHandler.h
103 11402 0x2c8a HEATER_WENT_ON INFO No description mission/tcs/HeaterHandler.h
121 11604 0x2d54 MPSOC_HANDLER_CRC_FAILURE LOW PLOC reply has invalid crc linux/payload/PlocMpsocHandler.h
122 11605 0x2d55 MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH LOW Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count linux/payload/PlocMpsocHandler.h
123 11606 0x2d56 MPSOC_SHUTDOWN_FAILED HIGH Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor. linux/payload/PlocMpsocHandler.h
11607 0x2d57 SUPV_NOT_ON LOW SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition. linux/payload/PlocMpsocHandler.h
11608 0x2d58 SUPV_REPLY_TIMEOUT LOW No description linux/payload/PlocMpsocHandler.h
124 11701 0x2db5 SELF_TEST_I2C_FAILURE LOW Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h
125 11702 0x2db6 SELF_TEST_SPI_FAILURE LOW Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h
126 11703 0x2db7 SELF_TEST_ADC_FAILURE LOW Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h
133 11802 0x2e1a RESET_OCCURED LOW No description mission/acs/rwHelpers.h
134 11901 0x2e7d BOOTING_FIRMWARE_FAILED_EVENT LOW Failed to boot firmware mission/acs/str/StarTrackerHandler.h
135 11902 0x2e7e BOOTING_BOOTLOADER_FAILED_EVENT LOW Failed to boot star tracker into bootloader mode mission/acs/str/StarTrackerHandler.h
11903 0x2e7f COM_ERROR_REPLY_RECEIVED LOW Received COM error. P1: Communication Error ID (datasheet p32) mission/acs/str/StarTrackerHandler.h
136 12001 0x2ee1 SUPV_MEMORY_READ_RPT_CRC_FAILURE LOW PLOC supervisor crc failure in telemetry packet linux/payload/PlocSupervisorHandler.h
137 12002 0x2ee2 SUPV_UNKNOWN_TM LOW Unhandled event. P1: APID, P2: Service ID linux/payload/PlocSupervisorHandler.h
138 12003 0x2ee3 SUPV_UNINIMPLEMENTED_TM LOW No description linux/payload/PlocSupervisorHandler.h
160 12412 0x307c PDEC_RESET_FAILED HIGH Failed to pull PDEC reset to low linux/ipcore/pdec.h
161 12413 0x307d OPEN_IRQ_FILE_FAILED HIGH Failed to open the IRQ uio file linux/ipcore/pdec.h
162 12414 0x307e PDEC_INIT_FAILED HIGH PDEC initialization failed. This might also be due to the persistent confiuration never becoming available, for example due to SD card issues. linux/ipcore/pdec.h
12415 0x307f PDEC_CONFIG_CORRUPTED HIGH The PDEC configuration area has been corrupted P1: The first configuration word P2: The second configuration word linux/ipcore/pdec.h
163 12500 0x30d4 IMAGE_UPLOAD_FAILED LOW Image upload failed linux/acs/StrComHandler.h
164 12501 0x30d5 IMAGE_DOWNLOAD_FAILED LOW Image download failed linux/acs/StrComHandler.h
165 12502 0x30d6 IMAGE_UPLOAD_SUCCESSFUL LOW Uploading image to star tracker was successfulop linux/acs/StrComHandler.h
177 12515 0x30e3 STR_HELPER_FILE_NOT_EXISTS LOW Specified file does not exist P1: Internal state of str helper linux/acs/StrComHandler.h
178 12516 0x30e4 STR_HELPER_SENDING_PACKET_FAILED LOW No description linux/acs/StrComHandler.h
179 12517 0x30e5 STR_HELPER_REQUESTING_MSG_FAILED LOW No description linux/acs/StrComHandler.h
180 12600 0x3138 MPSOC_FLASH_WRITE_FAILED LOW Flash write fails linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
181 12601 0x3139 MPSOC_FLASH_WRITE_SUCCESSFUL INFO LOW Flash write successful linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
182 12602 0x313a MPSOC_SENDING_COMMAND_FAILED LOW No description linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
183 12603 0x313b MPSOC_HELPER_REQUESTING_REPLY_FAILED LOW Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of MPSoC helper linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
184 12604 0x313c MPSOC_HELPER_READING_REPLY_FAILED LOW Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of MPSoC helper linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
185 12605 0x313d MPSOC_MISSING_ACK LOW Did not receive acknowledgment report P1: Number of bytes missing P2: Internal state of MPSoC helper linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
186 12606 0x313e MPSOC_MISSING_EXE LOW Did not receive execution report P1: Number of bytes missing P2: Internal state of MPSoC helper linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
187 12607 0x313f MPSOC_ACK_FAILURE_REPORT LOW Received acknowledgment failure report P1: Internal state of MPSoC linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
188 12608 0x3140 MPSOC_EXE_FAILURE_REPORT LOW Received execution failure report P1: Internal state of MPSoC linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
189 12609 0x3141 MPSOC_ACK_INVALID_APID LOW Expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
190 12610 0x3142 MPSOC_EXE_INVALID_APID LOW Expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
191 12611 0x3143 MPSOC_HELPER_SEQ_CNT_MISMATCH LOW Received sequence count does not match expected sequence count P1: Expected sequence count P2: Received sequence count linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
192 12612 0x3144 MPSOC_TM_SIZE_ERROR LOW No description linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
193 12613 0x3145 MPSOC_TM_CRC_MISSMATCH LOW No description linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
12614 0x3146 MPSOC_FLASH_READ_PACKET_ERROR LOW No description linux/payload/PlocMpsocSpecialComHelper.h
12615 0x3147 MPSOC_FLASH_READ_FAILED LOW No description linux/payload/PlocMpsocSpecialComHelper.h
12616 0x3148 MPSOC_FLASH_READ_SUCCESSFUL INFO No description linux/payload/PlocMpsocSpecialComHelper.h
12617 0x3149 MPSOC_READ_TIMEOUT LOW No description linux/payload/PlocMpsocSpecialComHelper.h
194 12700 0x319c TRANSITION_BACK_TO_OFF MEDIUM Could not transition properly and went back to ALL OFF mission/payload/PayloadPcduHandler.h
195 12701 0x319d NEG_V_OUT_OF_BOUNDS MEDIUM P1: 0 -> too low, 1 -> too high P2: Float value mission/payload/PayloadPcduHandler.h
196 12702 0x319e U_DRO_OUT_OF_BOUNDS MEDIUM P1: 0 -> too low, 1 -> too high P2: Float value mission/payload/PayloadPcduHandler.h
250 13800 0x35e8 MISSING_PACKET LOW No description mission/payload/scexHelpers.h
251 13801 0x35e9 EXPERIMENT_TIMEDOUT LOW No description mission/payload/scexHelpers.h
252 13802 0x35ea MULTI_PACKET_COMMAND_DONE INFO No description mission/payload/scexHelpers.h
13803 0x35eb FS_UNUSABLE LOW No description mission/payload/scexHelpers.h
253 13901 0x364d SET_CONFIGFILEVALUE_FAILED MEDIUM No description mission/utility/GlobalConfigHandler.h
254 13902 0x364e GET_CONFIGFILEVALUE_FAILED MEDIUM No description mission/utility/GlobalConfigHandler.h
255 13903 0x364f INSERT_CONFIGFILEVALUE_FAILED MEDIUM No description mission/utility/GlobalConfigHandler.h
267 14010 0x36ba TRYING_I2C_RECOVERY HIGH I2C is unavailable. Trying recovery of I2C bus by power cycling all I2C devices. mission/sysDefs.h
268 14011 0x36bb I2C_REBOOT HIGH I2C is unavailable. Recovery did not work, performing full reboot. mission/sysDefs.h
269 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
14014 0x36be ACTIVE_SD_INFO INFO Active SD card info. SD States: 0: OFF, 1: ON, 2: MOUNTED. P1: Active SD Card Index, 0 if none is active P2: First two bytes: SD state of SD card 0, last two bytes SD state of SD card 1 mission/sysDefs.h
270 14100 0x3714 NO_VALID_SENSOR_TEMPERATURE MEDIUM No description mission/controller/tcsDefs.h
271 14101 0x3715 NO_HEALTHY_HEATER_AVAILABLE MEDIUM No description mission/controller/tcsDefs.h
272 14102 0x3716 SYRLINKS_OVERHEATING HIGH No description mission/controller/tcsDefs.h
274 14105 0x3719 CAMERA_OVERHEATING HIGH No description mission/controller/tcsDefs.h
275 14106 0x371a PCDU_SYSTEM_OVERHEATING HIGH No description mission/controller/tcsDefs.h
276 14107 0x371b HEATER_NOT_OFF_FOR_OFF_MODE MEDIUM No description mission/controller/tcsDefs.h
277 14108 0x371c MGT_OVERHEATING HIGH MEDIUM 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
278 14201 0x3779 TX_TIMER_EXPIRED INFO The transmit timer to protect the Syrlinks expired P1: The current timer value mission/system/com/ComSubsystem.h
279 14202 0x377a BIT_LOCK_TX_ON INFO Transmitter will be turned on due to detection of bitlock mission/system/com/ComSubsystem.h
280 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
290 14312 0x37e8 DUMP_MISC_CANCELLED LOW P1: Number of dumped packets. P2: Total dumped bytes. mission/persistentTmStoreDefs.h
291 14313 0x37e9 DUMP_HK_CANCELLED LOW P1: Number of dumped packets. P2: Total dumped bytes. mission/persistentTmStoreDefs.h
292 14314 0x37ea DUMP_CFDP_CANCELLED LOW P1: Number of dumped packets. P2: Total dumped bytes. mission/persistentTmStoreDefs.h
14500 0x38a4 TEMPERATURE_ALL_ONES_START MEDIUM Detected invalid values, starting invalid message counting mission/acs/SusHandler.h
14501 0x38a5 TEMPERATURE_ALL_ONES_RECOVERY INFO Detected valid values again, resetting invalid message counter. P1: Invalid message counter. mission/acs/SusHandler.h

View File

@ -8,7 +8,7 @@ import os.path
from typing import Dict from typing import Dict
from eive_tmtc import EIVE_TMTC_ROOT from eive_tmtc import EIVE_TMTC_ROOT
from tmtccmd.util.obj_id import ObjectIdU32 from tmtccmd.util.obj_id import ObjectIdDictT, ObjectIdU32
from tmtccmd.fsfw import parse_fsfw_objects_csv from tmtccmd.fsfw import parse_fsfw_objects_csv
@ -18,7 +18,6 @@ __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])
@ -35,7 +34,6 @@ HEATER_CONTROLLER_ID = bytes([0x44, 0x41, 0x00, 0xA4])
TMP1075_HANDLER_TCS_BRD_0_ID = bytes([0x44, 0x42, 0x00, 0x04]) TMP1075_HANDLER_TCS_BRD_0_ID = bytes([0x44, 0x42, 0x00, 0x04])
TMP1075_HANDLER_TCS_BRD_1_ID = bytes([0x44, 0x42, 0x00, 0x05]) TMP1075_HANDLER_TCS_BRD_1_ID = bytes([0x44, 0x42, 0x00, 0x05])
TMP1075_HANDLER_PLPCDU_0_ID = bytes([0x44, 0x42, 0x00, 0x06]) TMP1075_HANDLER_PLPCDU_0_ID = bytes([0x44, 0x42, 0x00, 0x06])
TMP1075_HANDLER_PLPCDU_1_ID = bytes([0x44, 0x42, 0x00, 0x07])
TMP1075_HANDLER_IF_BRD_ID = bytes([0x44, 0x42, 0x00, 0x08]) TMP1075_HANDLER_IF_BRD_ID = bytes([0x44, 0x42, 0x00, 0x08])
# Communication Object IDs # Communication Object IDs
@ -136,7 +134,6 @@ ACS_SUBSYSTEM_ID = bytes([0x73, 0x01, 0x00, 0x01])
PL_SUBSYSTEM_ID = bytes([0x73, 0x01, 0x00, 0x02]) PL_SUBSYSTEM_ID = bytes([0x73, 0x01, 0x00, 0x02])
TCS_SUBSYSTEM_ID = bytes([0x73, 0x01, 0x00, 0x03]) TCS_SUBSYSTEM_ID = bytes([0x73, 0x01, 0x00, 0x03])
COM_SUBSYSTEM_ID = bytes([0x73, 0x01, 0x00, 0x04]) COM_SUBSYSTEM_ID = bytes([0x73, 0x01, 0x00, 0x04])
EPS_SUBSYSTEM_ID = bytes([0x73, 0x01, 0x00, 0x05])
# Legacy names, kept for backwards compatibility # Legacy names, kept for backwards compatibility
ACS_BOARD_ASS_ID = bytes([0x73, 0x00, 0x00, 0x01]) ACS_BOARD_ASS_ID = bytes([0x73, 0x00, 0x00, 0x01])
@ -158,7 +155,6 @@ STR_ASSEMBLY = bytes([0x73, 0x00, 0x00, 0x09])
TCS_CONTROLLER = bytes([0x43, 0x40, 0x00, 0x01]) TCS_CONTROLLER = bytes([0x43, 0x40, 0x00, 0x01])
ACS_CONTROLLER = bytes([0x43, 0x00, 0x00, 0x02]) ACS_CONTROLLER = bytes([0x43, 0x00, 0x00, 0x02])
CORE_CONTROLLER_ID = bytes([0x43, 0x00, 0x00, 0x03]) CORE_CONTROLLER_ID = bytes([0x43, 0x00, 0x00, 0x03])
PWR_CONTROLLER = bytes([0x43, 0x00, 0x00, 0x04])
MISC_TM_STORE = bytes([0x73, 0x02, 0x00, 0x01]) MISC_TM_STORE = bytes([0x73, 0x02, 0x00, 0x01])
OK_TM_STORE = bytes([0x73, 0x02, 0x00, 0x02]) OK_TM_STORE = bytes([0x73, 0x02, 0x00, 0x02])

View File

@ -1,7 +1,6 @@
0x00005060;P60DOCK_TEST_TASK 0x00005060;P60DOCK_TEST_TASK
0x43000002;ACS_CONTROLLER 0x43000002;ACS_CONTROLLER
0x43000003;CORE_CONTROLLER 0x43000003;CORE_CONTROLLER
0x43000004;POWER_CONTROLLER
0x43000006;GLOBAL_JSON_CFG 0x43000006;GLOBAL_JSON_CFG
0x43400001;THERMAL_CONTROLLER 0x43400001;THERMAL_CONTROLLER
0x44120006;MGM_0_LIS3_HANDLER 0x44120006;MGM_0_LIS3_HANDLER
@ -162,7 +161,6 @@
0x73010002;PL_SUBSYSTEM 0x73010002;PL_SUBSYSTEM
0x73010003;TCS_SUBSYSTEM 0x73010003;TCS_SUBSYSTEM
0x73010004;COM_SUBSYSTEM 0x73010004;COM_SUBSYSTEM
0x73010005;EPS_SUBSYSTEM
0x73020001;MISC_TM_STORE 0x73020001;MISC_TM_STORE
0x73020002;OK_TM_STORE 0x73020002;OK_TM_STORE
0x73020003;NOT_OK_TM_STORE 0x73020003;NOT_OK_TM_STORE

1 0x00005060 P60DOCK_TEST_TASK
2 0x43000002 ACS_CONTROLLER
3 0x43000003 CORE_CONTROLLER
0x43000004 POWER_CONTROLLER
4 0x43000006 GLOBAL_JSON_CFG
5 0x43400001 THERMAL_CONTROLLER
6 0x44120006 MGM_0_LIS3_HANDLER
161 0x73010002 PL_SUBSYSTEM
162 0x73010003 TCS_SUBSYSTEM
163 0x73010004 COM_SUBSYSTEM
0x73010005 EPS_SUBSYSTEM
164 0x73020001 MISC_TM_STORE
165 0x73020002 OK_TM_STORE
166 0x73020003 NOT_OK_TM_STORE

View File

@ -210,7 +210,6 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path
0x27a8;DHI_NoReplyExpected;No description;168;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27a8;DHI_NoReplyExpected;No description;168;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
0x27a9;DHI_NonOpTemperature;No description;169;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27a9;DHI_NonOpTemperature;No description;169;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
0x27aa;DHI_CommandNotImplemented;No description;170;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27aa;DHI_CommandNotImplemented;No description;170;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
0x27ab;DHI_NonOpStateOfCharge;No description;171;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
0x27b0;DHI_ChecksumError;No description;176;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b0;DHI_ChecksumError;No description;176;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
0x27b1;DHI_LengthMissmatch;No description;177;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b1;DHI_LengthMissmatch;No description;177;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
0x27b2;DHI_InvalidData;No description;178;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b2;DHI_InvalidData;No description;178;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
@ -479,8 +478,8 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path
0x53b6;STRH_StartrackerAlreadyBooted;Star tracker is already in firmware mode;182;STR_HANDLER;mission/acs/str/StarTrackerHandler.h 0x53b6;STRH_StartrackerAlreadyBooted;Star tracker is already in firmware mode;182;STR_HANDLER;mission/acs/str/StarTrackerHandler.h
0x53b7;STRH_StartrackerNotRunningFirmware;Star tracker must be in firmware mode to run this command;183;STR_HANDLER;mission/acs/str/StarTrackerHandler.h 0x53b7;STRH_StartrackerNotRunningFirmware;Star tracker must be in firmware mode to run this command;183;STR_HANDLER;mission/acs/str/StarTrackerHandler.h
0x53b8;STRH_StartrackerNotRunningBootloader;Star tracker must be in bootloader mode to run this command;184;STR_HANDLER;mission/acs/str/StarTrackerHandler.h 0x53b8;STRH_StartrackerNotRunningBootloader;Star tracker must be in bootloader mode to run this command;184;STR_HANDLER;mission/acs/str/StarTrackerHandler.h
0x54e0;DWLPWRON_InvalidMode;Received command has invalid JESD mode (valid modes are 0 - 5);224;DWLPWRON_CMD;linux/payload/plocMpsocHelpers.h 0x54e0;DWLPWRON_InvalidMode;Received command has invalid JESD mode (valid modes are 0 - 5);224;DWLPWRON_CMD;linux/payload/plocMpscoDefs.h
0x54e1;DWLPWRON_InvalidLaneRate;Received command has invalid lane rate (valid lane rate are 0 - 9);225;DWLPWRON_CMD;linux/payload/plocMpsocHelpers.h 0x54e1;DWLPWRON_InvalidLaneRate;Received command has invalid lane rate (valid lane rate are 0 - 9);225;DWLPWRON_CMD;linux/payload/plocMpscoDefs.h
0x5700;PLSPVhLP_RequestDone;No description;0;PLOC_SUPV_HELPER;linux/payload/PlocSupvUartMan.h 0x5700;PLSPVhLP_RequestDone;No description;0;PLOC_SUPV_HELPER;linux/payload/PlocSupvUartMan.h
0x5701;PLSPVhLP_NoPacketFound;No description;1;PLOC_SUPV_HELPER;linux/payload/PlocSupvUartMan.h 0x5701;PLSPVhLP_NoPacketFound;No description;1;PLOC_SUPV_HELPER;linux/payload/PlocSupvUartMan.h
0x5702;PLSPVhLP_DecodeBufTooSmall;No description;2;PLOC_SUPV_HELPER;linux/payload/PlocSupvUartMan.h 0x5702;PLSPVhLP_DecodeBufTooSmall;No description;2;PLOC_SUPV_HELPER;linux/payload/PlocSupvUartMan.h
@ -544,8 +543,7 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path
0x63a0;NVMB_KeyNotExists;Specified key does not exist in json file;160;NVM_PARAM_BASE;mission/memory/NvmParameterBase.h 0x63a0;NVMB_KeyNotExists;Specified key does not exist in json file;160;NVM_PARAM_BASE;mission/memory/NvmParameterBase.h
0x64a0;FSHLP_SdNotMounted;SD card specified with path string not mounted;160;FILE_SYSTEM_HELPER;bsp_q7s/fs/FilesystemHelper.h 0x64a0;FSHLP_SdNotMounted;SD card specified with path string not mounted;160;FILE_SYSTEM_HELPER;bsp_q7s/fs/FilesystemHelper.h
0x64a1;FSHLP_FileNotExists;Specified file does not exist on filesystem;161;FILE_SYSTEM_HELPER;bsp_q7s/fs/FilesystemHelper.h 0x64a1;FSHLP_FileNotExists;Specified file does not exist on filesystem;161;FILE_SYSTEM_HELPER;bsp_q7s/fs/FilesystemHelper.h
0x65a0;PLMPHLP_FileWriteError;File error occured for file transfers from OBC to the MPSoC.;160;PLOC_MPSOC_HELPER;linux/payload/PlocMpsocSpecialComHelper.h 0x65a0;PLMPHLP_FileClosedAccidentally;File accidentally close;160;PLOC_MPSOC_HELPER;linux/payload/PlocMpsocHelper.h
0x65a1;PLMPHLP_FileReadError;File error occured for file transfers from MPSoC to OBC.;161;PLOC_MPSOC_HELPER;linux/payload/PlocMpsocSpecialComHelper.h
0x66a0;SADPL_CommandNotSupported;No description;160;SA_DEPL_HANDLER;mission/SolarArrayDeploymentHandler.h 0x66a0;SADPL_CommandNotSupported;No description;160;SA_DEPL_HANDLER;mission/SolarArrayDeploymentHandler.h
0x66a1;SADPL_DeploymentAlreadyExecuting;No description;161;SA_DEPL_HANDLER;mission/SolarArrayDeploymentHandler.h 0x66a1;SADPL_DeploymentAlreadyExecuting;No description;161;SA_DEPL_HANDLER;mission/SolarArrayDeploymentHandler.h
0x66a2;SADPL_MainSwitchTimeoutFailure;No description;162;SA_DEPL_HANDLER;mission/SolarArrayDeploymentHandler.h 0x66a2;SADPL_MainSwitchTimeoutFailure;No description;162;SA_DEPL_HANDLER;mission/SolarArrayDeploymentHandler.h

1 Full ID (hex) Name Description Unique ID Subsytem Name File Path
210 0x27a8 DHI_NoReplyExpected No description 168 DEVICE_HANDLER_IF fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
211 0x27a9 DHI_NonOpTemperature No description 169 DEVICE_HANDLER_IF fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
212 0x27aa DHI_CommandNotImplemented No description 170 DEVICE_HANDLER_IF fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
0x27ab DHI_NonOpStateOfCharge No description 171 DEVICE_HANDLER_IF fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
213 0x27b0 DHI_ChecksumError No description 176 DEVICE_HANDLER_IF fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
214 0x27b1 DHI_LengthMissmatch No description 177 DEVICE_HANDLER_IF fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
215 0x27b2 DHI_InvalidData No description 178 DEVICE_HANDLER_IF fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h
478 0x53b6 STRH_StartrackerAlreadyBooted Star tracker is already in firmware mode 182 STR_HANDLER mission/acs/str/StarTrackerHandler.h
479 0x53b7 STRH_StartrackerNotRunningFirmware Star tracker must be in firmware mode to run this command 183 STR_HANDLER mission/acs/str/StarTrackerHandler.h
480 0x53b8 STRH_StartrackerNotRunningBootloader Star tracker must be in bootloader mode to run this command 184 STR_HANDLER mission/acs/str/StarTrackerHandler.h
481 0x54e0 DWLPWRON_InvalidMode Received command has invalid JESD mode (valid modes are 0 - 5) 224 DWLPWRON_CMD linux/payload/plocMpsocHelpers.h linux/payload/plocMpscoDefs.h
482 0x54e1 DWLPWRON_InvalidLaneRate Received command has invalid lane rate (valid lane rate are 0 - 9) 225 DWLPWRON_CMD linux/payload/plocMpsocHelpers.h linux/payload/plocMpscoDefs.h
483 0x5700 PLSPVhLP_RequestDone No description 0 PLOC_SUPV_HELPER linux/payload/PlocSupvUartMan.h
484 0x5701 PLSPVhLP_NoPacketFound No description 1 PLOC_SUPV_HELPER linux/payload/PlocSupvUartMan.h
485 0x5702 PLSPVhLP_DecodeBufTooSmall No description 2 PLOC_SUPV_HELPER linux/payload/PlocSupvUartMan.h
543 0x63a0 NVMB_KeyNotExists Specified key does not exist in json file 160 NVM_PARAM_BASE mission/memory/NvmParameterBase.h
544 0x64a0 FSHLP_SdNotMounted SD card specified with path string not mounted 160 FILE_SYSTEM_HELPER bsp_q7s/fs/FilesystemHelper.h
545 0x64a1 FSHLP_FileNotExists Specified file does not exist on filesystem 161 FILE_SYSTEM_HELPER bsp_q7s/fs/FilesystemHelper.h
546 0x65a0 PLMPHLP_FileWriteError PLMPHLP_FileClosedAccidentally File error occured for file transfers from OBC to the MPSoC. File accidentally close 160 PLOC_MPSOC_HELPER linux/payload/PlocMpsocSpecialComHelper.h linux/payload/PlocMpsocHelper.h
0x65a1 PLMPHLP_FileReadError File error occured for file transfers from MPSoC to OBC. 161 PLOC_MPSOC_HELPER linux/payload/PlocMpsocSpecialComHelper.h
547 0x66a0 SADPL_CommandNotSupported No description 160 SA_DEPL_HANDLER mission/SolarArrayDeploymentHandler.h
548 0x66a1 SADPL_DeploymentAlreadyExecuting No description 161 SA_DEPL_HANDLER mission/SolarArrayDeploymentHandler.h
549 0x66a2 SADPL_MainSwitchTimeoutFailure No description 162 SA_DEPL_HANDLER mission/SolarArrayDeploymentHandler.h

View File

@ -60,4 +60,3 @@
142;COM_SUBSYSTEM 142;COM_SUBSYSTEM
143;PERSISTENT_TM_STORE 143;PERSISTENT_TM_STORE
144;SYRLINKS_COM 144;SYRLINKS_COM
145;SUS_HANDLER

1 22 MEMORY
60 142 COM_SUBSYSTEM
61 143 PERSISTENT_TM_STORE
62 144 SYRLINKS_COM
145 SUS_HANDLER

View File

@ -74,9 +74,7 @@ def pack_get_param_command(
memory_address: Union[int, bytes], memory_address: Union[int, bytes],
parameter_size: int, parameter_size: int,
) -> PusTelecommand: ) -> PusTelecommand:
"""Function to generate a command to retrieve parameters like the temperature from a """Function to generate a command to retrieve parameters like the temperature from a gomspace device.
gomspace device.
@param object_id: The object id of the gomspace device handler. @param object_id: The object id of the gomspace device handler.
@param table_id: The table id of the gomspace device @param table_id: The table id of the gomspace device
@param memory_address: Address offset within table of the value to read. @param memory_address: Address offset within table of the value to read.
@ -220,9 +218,9 @@ def prompt_and_pack_set_integer_param_command(
def pack_ping_command(object_id: ObjectIdU32, data: bytearray) -> PusTelecommand: def pack_ping_command(object_id: ObjectIdU32, data: bytearray) -> PusTelecommand:
""" " Function to generate the command to ping a gomspace device """ " Function to generate the command to ping a gomspace device
:param object_id: Object Id of the gomspace device handler. @param object_id Object Id of the gomspace device handler.
:param data: Bytearray containing the bytes to send to the gomspace device. For now the on board @param data Bytearray containing the bytes to send to the gomspace device. For now the on board software
software supports only the handling of up to 33 bytes. supports only the handling of up to 33 bytes.
@note The ping request sends the specified data to a gompsace device. These @note The ping request sends the specified data to a gompsace device. These
data are simply copied by the device and then sent back. data are simply copied by the device and then sent back.
""" """

View File

@ -1,5 +1,7 @@
from eive_tmtc.config.definitions import CustomServiceList
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry, CoreServiceList from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry, CoreServiceList
from tmtccmd.config.tmtc import ( from tmtccmd.config.tmtc import (
tmtc_definitions_provider,
call_all_definitions_providers, call_all_definitions_providers,
) )
from tmtccmd.config.globals import get_default_tmtc_defs from tmtccmd.config.globals import get_default_tmtc_defs

View File

@ -6,7 +6,6 @@ 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
@ -30,7 +29,7 @@ from eive_tmtc.tmtc.acs.reaction_wheels import (
pack_rw_ass_cmds, pack_rw_ass_cmds,
) )
from eive_tmtc.tmtc.payload.ploc_memory_dumper import pack_ploc_memory_dumper_cmd from eive_tmtc.tmtc.payload.ploc_memory_dumper import pack_ploc_memory_dumper_cmd
from eive_tmtc.tmtc.com.ccsds_handler import pack_ccsds_handler_command from eive_tmtc.tmtc.com.ccsds_handler import pack_ccsds_handler_test
from eive_tmtc.tmtc.core import pack_core_commands from eive_tmtc.tmtc.core import pack_core_commands
from eive_tmtc.tmtc.acs.star_tracker import pack_star_tracker_commands from eive_tmtc.tmtc.acs.star_tracker import pack_star_tracker_commands
from eive_tmtc.tmtc.com.syrlinks_handler import pack_syrlinks_command from eive_tmtc.tmtc.com.syrlinks_handler import pack_syrlinks_command
@ -76,7 +75,7 @@ from tmtccmd.util import ObjectIdU32
from eive_tmtc.utility.input_helper import InputHelper from eive_tmtc.utility.input_helper import InputHelper
def handle_default_procedure( # noqa C901: Complexity okay here. def handle_default_procedure(
tc_base: TcHandlerBase, tc_base: TcHandlerBase,
info: DefaultProcedureInfo, info: DefaultProcedureInfo,
queue_helper: DefaultPusQueueHelper, queue_helper: DefaultPusQueueHelper,
@ -100,16 +99,13 @@ 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_SS.value: if service == CustomServiceList.TCS.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),
"1": ("TMP1075 TCS Board 1", TMP1075_HANDLER_TCS_BRD_1_ID), "1": ("TMP1075 TCS Board 1", TMP1075_HANDLER_TCS_BRD_1_ID),
"2": ("TMP1075 PL PCDU 0", TMP1075_HANDLER_PLPCDU_0_ID), "2": ("TMP1075 PL PCDU 0", TMP1075_HANDLER_PLPCDU_0_ID),
"3": ("TMP1075 PL PCDU 1", oids.TMP1075_HANDLER_PLPCDU_1_ID),
"4": ("TMP1075 IF Board", TMP1075_HANDLER_IF_BRD_ID), "4": ("TMP1075 IF Board", TMP1075_HANDLER_IF_BRD_ID),
} }
input_helper = InputHelper(menu_dict) input_helper = InputHelper(menu_dict)
@ -174,7 +170,7 @@ def handle_default_procedure( # noqa C901: Complexity okay here.
) )
if service == CustomServiceList.CCSDS_HANDLER.value: if service == CustomServiceList.CCSDS_HANDLER.value:
object_id = cast(ObjectIdU32, obj_id_man.get(CCSDS_HANDLER_ID)) object_id = cast(ObjectIdU32, obj_id_man.get(CCSDS_HANDLER_ID))
return pack_ccsds_handler_command( return pack_ccsds_handler_test(
object_id=object_id, q=queue_helper, op_code=op_code object_id=object_id, q=queue_helper, op_code=op_code
) )
if service == CustomServiceList.PDEC_HANDLER.value: if service == CustomServiceList.PDEC_HANDLER.value:

View File

@ -10,11 +10,14 @@ from PyQt5.QtWidgets import (
from PyQt5 import QtCore from PyQt5 import QtCore
from tmtccmd.config import CoreModeList
from tmtccmd.core.globals_manager import get_global
class Parameter: class Parameter:
def __init__(self, name: str, default_value: str, widget: QLineEdit): def __init__(self, name: str, defaultValue: str, widget: QLineEdit):
self.name = name self.name = name
self.defaultValue = default_value self.defaultValue = defaultValue
self.widget = widget self.widget = widget
self.value = self.defaultValue self.value = self.defaultValue
self.widget.setPlaceholderText(self.defaultValue) self.widget.setPlaceholderText(self.defaultValue)
@ -31,9 +34,9 @@ class ParameterDialog(QDialog):
self.setWindowTitle("Enter Parameters") self.setWindowTitle("Enter Parameters")
buttons = QDialogButtonBox.Ok | QDialogButtonBox.Cancel | QDialogButtonBox.Reset Buttons = QDialogButtonBox.Ok | QDialogButtonBox.Cancel | QDialogButtonBox.Reset
self.buttonBox = QDialogButtonBox(buttons) self.buttonBox = QDialogButtonBox(Buttons)
self.buttonBox.accepted.connect(self.accept) self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject) self.buttonBox.rejected.connect(self.reject)
self.buttonBox.button(QDialogButtonBox.Reset).clicked.connect(self._reset) self.buttonBox.button(QDialogButtonBox.Reset).clicked.connect(self._reset)
@ -51,14 +54,14 @@ class ParameterDialog(QDialog):
self.parameters = {} self.parameters = {}
def add_parameter(self, name: str, default_value: str): def addParameter(self, name: str, defaultValue: str):
row = self.groupLayout.rowCount() + 1 row = self.groupLayout.rowCount() + 1
description = QLabel(name) description = QLabel(name)
self.groupLayout.addWidget(description, row, 0) self.groupLayout.addWidget(description, row, 0)
value_widget = QLineEdit() valueWidget = QLineEdit()
self.groupLayout.addWidget(value_widget, row, 1) self.groupLayout.addWidget(valueWidget, row, 1)
parameter = Parameter(name, default_value, value_widget) parameter = Parameter(name, defaultValue, valueWidget)
self.parameters[name] = parameter self.parameters[name] = parameter
@ -66,10 +69,10 @@ class ParameterDialog(QDialog):
for value in self.parameters.values(): for value in self.parameters.values():
value.reset() value.reset()
def get_parameters(self): def getParameters(self):
output = {} output = {}
for key, parameter in self.parameters.items(): for key, parameter in self.parameters.items():
if parameter.widget is not None: if parameter.widget != None:
if parameter.widget.text() != "": if parameter.widget.text() != "":
parameter.value = parameter.widget.text() parameter.value = parameter.widget.text()
output[key] = parameter.value output[key] = parameter.value
@ -100,9 +103,9 @@ def prompt_parameters_cli(param_list) -> dict:
def _gui_prompt(param_list) -> dict: def _gui_prompt(param_list) -> dict:
dialog = ParameterDialog() dialog = ParameterDialog()
for parameter in param_list: for parameter in param_list:
dialog.add_parameter(parameter["name"], parameter["defaultValue"]) dialog.addParameter(parameter["name"], parameter["defaultValue"])
dialog.exec_() dialog.exec_()
return dialog.get_parameters() return dialog.getParameters()
def _cli_prompt(param_list) -> dict: def _cli_prompt(param_list) -> dict:

View File

@ -0,0 +1 @@

View File

@ -86,8 +86,9 @@ def pack_cmd_ctrl_to_nml(
def get_object_from_op_code(op_code: str): def get_object_from_op_code(op_code: str):
try: try:
return bytes.fromhex(op_code) return bytes.fromhex(op_code)
except ValueError: except:
pass pass
if op_code in OpCode.THERMAL_CONTROLLER: if op_code in OpCode.THERMAL_CONTROLLER:
return obj_ids.THERMAL_CONTROLLER_ID return obj_ids.THERMAL_CONTROLLER_ID
if op_code in OpCode.CORE_CONTROLLER: if op_code in OpCode.CORE_CONTROLLER:

View File

@ -1,12 +1,10 @@
from __future__ import annotations from __future__ import annotations
import struct
import time import time
from datetime import timedelta from datetime import timedelta
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 spacepackets.ecss import PusTelecommand
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
@ -16,6 +14,7 @@ from tmtccmd.pus.s11_tc_sched import (
create_enable_tc_sched_cmd, create_enable_tc_sched_cmd,
create_reset_tc_sched_cmd, create_reset_tc_sched_cmd,
) )
from tmtccmd.tc.pus_3_fsfw_hk import *
import eive_tmtc.config.object_ids as oids import eive_tmtc.config.object_ids as oids
from eive_tmtc.tmtc.tcs.brd_assy import OpCodeAssy as TcsOpCodes from eive_tmtc.tmtc.tcs.brd_assy import OpCodeAssy as TcsOpCodes
@ -50,11 +49,6 @@ from eive_tmtc.tmtc.acs.gyros import (
L3gGyroSetId as L3gGyroSetIds_1_3, L3gGyroSetId as L3gGyroSetIds_1_3,
) )
from eive_tmtc.tmtc.acs.gps import SetId as GpsSetIds from eive_tmtc.tmtc.acs.gps import SetId as GpsSetIds
from tmtccmd.tc.pus_3_fsfw_hk import (
make_sid,
disable_periodic_hk_command,
create_enable_periodic_hk_command_with_interval,
)
class OpCode: class OpCode:
@ -160,7 +154,7 @@ def add_proc_cmds(defs: TmtcDefinitionWrapper):
) )
def pack_generic_hk_listening_cmds( # noqa C901: Complexity okay here. def pack_generic_hk_listening_cmds(
q: DefaultPusQueueHelper, q: DefaultPusQueueHelper,
proc_key: str, proc_key: str,
sid_list: list[bytearray], sid_list: list[bytearray],
@ -228,9 +222,7 @@ def pack_generic_hk_listening_cmds( # noqa C901: Complexity okay here.
diag_list.clear() diag_list.clear()
def pack_proc_commands( # noqa C901: Complexity is okay here. def pack_proc_commands(q: DefaultPusQueueHelper, op_code: str):
q: DefaultPusQueueHelper, op_code: str
): # noqa C901: Complexity okay here.
sid_list = [] sid_list = []
obj_id_dict = get_object_ids() obj_id_dict = get_object_ids()
if op_code in OpCode.RESET_SCHED: if op_code in OpCode.RESET_SCHED:
@ -741,7 +733,7 @@ def enable_listen_to_hk_for_x_seconds(
interval_seconds: float, interval_seconds: float,
): ):
q.add_log_cmd(f"Enabling periodic HK for {device}") q.add_log_cmd(f"Enabling periodic HK for {device}")
cmd_tuple = create_enable_periodic_hk_command_with_interval( cmd_tuple = enable_periodic_hk_command_with_interval(
diag=diag, sid=sid, interval_seconds=interval_seconds diag=diag, sid=sid, interval_seconds=interval_seconds
) )
for cmd in cmd_tuple: for cmd in cmd_tuple:
@ -765,6 +757,7 @@ 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,

View File

@ -1,163 +0,0 @@
import logging
from typing import cast
from eive_tmtc.config.definitions import (
CFDP_REMOTE_ENTITY_ID,
PUS_APID,
CFDP_LOCAL_ENTITY_ID,
)
from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure
from tmtccmd import TcHandlerBase, ProcedureWrapper
from tmtccmd.cfdp.defs import CfdpRequestType
from tmtccmd.cfdp.handler import CfdpInCcsdsHandler
from tmtccmd.logging import get_current_time_string
from tmtccmd.logging.pus import RawTmtcTimedLogWrapper
from tmtccmd.tc import (
DefaultPusQueueHelper,
QueueWrapper,
FeedWrapper,
TcProcedureType,
SendCbParams,
TcQueueEntryType,
)
from tmtccmd.config.cfdp import generic_cfdp_params_to_put_request
from spacepackets.ecss import PusVerificator
from tmtccmd.util import FileSeqCountProvider
from spacepackets.cfdp import PduHolder, DirectiveType
_LOGGER = logging.getLogger(__name__)
class TcHandler(TcHandlerBase):
def __init__(
self,
seq_count_provider: FileSeqCountProvider,
cfdp_in_ccsds_handler: CfdpInCcsdsHandler,
pus_verificator: PusVerificator,
high_level_file_logger: logging.Logger,
raw_pus_logger: RawTmtcTimedLogWrapper,
gui: bool,
):
super().__init__()
self.cfdp_handler_started = False
self.seq_count_provider = seq_count_provider
self.pus_verificator = pus_verificator
self.high_level_file_logger = high_level_file_logger
self.pus_raw_logger = raw_pus_logger
self.gui = gui
self.proxy_op = True
self.queue_helper = DefaultPusQueueHelper(
queue_wrapper=QueueWrapper.empty(),
default_pus_apid=PUS_APID,
seq_cnt_provider=seq_count_provider,
pus_verificator=pus_verificator,
tc_sched_timestamp_len=4,
)
self.cfdp_in_ccsds_handler = cfdp_in_ccsds_handler
def cfdp_done(self) -> bool:
if self.cfdp_handler_started:
if (
not self.cfdp_in_ccsds_handler.put_request_pending()
and not self.proxy_op
):
self.cfdp_handler_started = False
return True
return False
def feed_cb(self, info: ProcedureWrapper, wrapper: FeedWrapper):
self.queue_helper.queue_wrapper = wrapper.queue_wrapper
if info.proc_type == TcProcedureType.DEFAULT:
handle_default_procedure(self, info.to_def_procedure(), self.queue_helper)
elif info.proc_type == TcProcedureType.CFDP:
self.handle_cfdp_procedure(info)
def send_cb(self, send_params: SendCbParams):
entry_helper = send_params.entry
if entry_helper.is_tc:
if entry_helper.entry_type == TcQueueEntryType.PUS_TC:
pus_tc_wrapper = entry_helper.to_pus_tc_entry()
# pus_tc_wrapper.pus_tc.apid = PUS_APID
raw_tc = pus_tc_wrapper.pus_tc.pack()
self.pus_raw_logger.log_tc(pus_tc_wrapper.pus_tc)
tc_info_string = f"Sent {pus_tc_wrapper.pus_tc}"
_LOGGER.info(tc_info_string)
self.high_level_file_logger.info(
f"{get_current_time_string(True)}: {tc_info_string}"
)
# with open("tc.bin", "wb") as of:
# of.write(raw_tc)
send_params.com_if.send(raw_tc)
elif entry_helper.entry_type == TcQueueEntryType.CCSDS_TC:
cfdp_packet_in_ccsds = entry_helper.to_space_packet_entry()
send_params.com_if.send(cfdp_packet_in_ccsds.space_packet.pack())
# TODO: Log raw CFDP packets similarly to how PUS packets are logged.
# - Log full raw format including space packet wrapper
# - Log context information: Transaction ID, and PDU type and directive
# Could re-use file logger. Should probably do that
# print(f"sending packet: [{cfdp_packet_in_ccsds.space_packet.pack()}]")
# with open(f"cfdp_packet_{self.cfdp_counter}", "wb") as of:
# of.write(cfdp_packet_in_ccsds.space_packet.pack())
# self.cfdp_counter += 1
elif entry_helper.entry_type == TcQueueEntryType.LOG:
log_entry = entry_helper.to_log_entry()
_LOGGER.info(log_entry.log_str)
self.high_level_file_logger.info(log_entry.log_str)
def handle_cfdp_procedure(self, info: ProcedureWrapper):
cfdp_procedure = info.to_cfdp_procedure()
if cfdp_procedure.cfdp_request_type == CfdpRequestType.PUT:
if (
not self.cfdp_in_ccsds_handler.put_request_pending()
and not self.cfdp_handler_started
):
put_req_cfg_wrapper = cfdp_procedure.request_wrapper.to_put_request()
if put_req_cfg_wrapper.cfg.proxy_op:
self.proxy_op = True
put_req = generic_cfdp_params_to_put_request(
params=put_req_cfg_wrapper.cfg,
local_id=CFDP_LOCAL_ENTITY_ID,
remote_id=CFDP_REMOTE_ENTITY_ID,
dest_id_proxy_put_req=CFDP_LOCAL_ENTITY_ID,
)
_LOGGER.info(
f"CFDP: Starting file put request with parameters:\n{put_req}"
)
self.cfdp_in_ccsds_handler.cfdp_handler.put_request(put_req)
self.cfdp_handler_started = True
for source_pair, dest_pair in self.cfdp_in_ccsds_handler:
pdu, sp = source_pair
pdu = cast(PduHolder, pdu)
if pdu.is_file_directive:
if pdu.pdu_directive_type == DirectiveType.METADATA_PDU:
metadata = pdu.to_metadata_pdu()
self.queue_helper.add_log_cmd(
"CFDP Source: Sending Metadata PDU for file with size "
f"{metadata.file_size}"
)
elif pdu.pdu_directive_type == DirectiveType.EOF_PDU:
self.queue_helper.add_log_cmd(
"CFDP Source: Sending EOF PDU"
)
else:
fd_pdu = pdu.to_file_data_pdu()
self.queue_helper.add_log_cmd(
"CFDP Source: Sending File Data PDU for segment at offset "
f"{fd_pdu.offset} with length {len(fd_pdu.file_data)}"
)
self.queue_helper.add_ccsds_tc(sp)
self.cfdp_in_ccsds_handler.confirm_source_packet_sent()
self.cfdp_in_ccsds_handler.source_handler.state_machine()
def queue_finished_cb(self, info: ProcedureWrapper):
if info is not None:
if info.proc_type == TcQueueEntryType.PUS_TC:
def_proc = info.to_def_procedure()
_LOGGER.info(
f"Finished queue for service {def_proc.service} and op code"
f" {def_proc.op_code}"
)
elif info.proc_type == TcProcedureType.CFDP:
_LOGGER.info("Finished CFDP queue")

View File

@ -1,16 +1,5 @@
import logging
import struct import struct
from eive_tmtc.config.object_ids import ( from eive_tmtc.config.object_ids import *
ACU_HANDLER_ID,
PDU_1_HANDLER_ID,
PDU_2_HANDLER_ID,
IMTQ_HANDLER_ID,
PLOC_MPSOC_ID,
PLOC_SUPV_ID,
CORE_CONTROLLER_ID,
STAR_TRACKER_ID,
P60_DOCK_HANDLER,
)
from eive_tmtc.tmtc.acs.imtq import ImtqActionId from eive_tmtc.tmtc.acs.imtq import ImtqActionId
from eive_tmtc.pus_tm.defs import PrintWrapper from eive_tmtc.pus_tm.defs import PrintWrapper
from eive_tmtc.tmtc.core import handle_core_ctrl_action_replies from eive_tmtc.tmtc.core import handle_core_ctrl_action_replies
@ -19,9 +8,8 @@ from eive_tmtc.tmtc.payload.ploc_supervisor import SupvActionId
from eive_tmtc.tmtc.acs.star_tracker import StarTrackerActionId from eive_tmtc.tmtc.acs.star_tracker import StarTrackerActionId
from eive_tmtc.tmtc.power.tm import handle_get_param_data_reply from eive_tmtc.tmtc.power.tm import handle_get_param_data_reply
from tmtccmd.tm import Service8FsfwTm from tmtccmd.tm import Service8FsfwTm
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from spacepackets.ccsds.time import CdsShortTimestamp from spacepackets.ccsds.time import CdsShortTimestamp
from tmtccmd.util import ObjectIdDictT
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -36,7 +24,7 @@ def handle_action_reply(
raw_telemetry=raw_tm, time_reader=CdsShortTimestamp.empty() raw_telemetry=raw_tm, time_reader=CdsShortTimestamp.empty()
) )
object_id = obj_id_dict.get(tm_packet.source_object_id_as_bytes) object_id = obj_id_dict.get(tm_packet.source_object_id_as_bytes)
pw = PrintWrapper(printer.file_logger) pw = PrintWrapper(printer)
custom_data = tm_packet.custom_data custom_data = tm_packet.custom_data
action_id = tm_packet.action_id action_id = tm_packet.action_id
generic_print_str = printer.generic_action_packet_tm_print( generic_print_str = printer.generic_action_packet_tm_print(
@ -44,15 +32,15 @@ def handle_action_reply(
) )
pw.dlog(generic_print_str) pw.dlog(generic_print_str)
if object_id.as_bytes == IMTQ_HANDLER_ID: if object_id.as_bytes == IMTQ_HANDLER_ID:
return handle_imtq_replies(action_id, pw, custom_data) return handle_imtq_replies(action_id, printer, custom_data)
elif object_id.as_bytes == PLOC_MPSOC_ID: elif object_id.as_bytes == PLOC_MPSOC_ID:
return handle_mpsoc_data_reply(action_id, pw, custom_data) return handle_mpsoc_data_reply(action_id, printer, custom_data)
elif object_id.as_bytes == PLOC_SUPV_ID: elif object_id.as_bytes == PLOC_SUPV_ID:
return handle_supervisor_replies(action_id, pw, custom_data) return handle_supervisor_replies(action_id, printer, custom_data)
elif object_id.as_bytes == CORE_CONTROLLER_ID: elif object_id.as_bytes == CORE_CONTROLLER_ID:
return handle_core_ctrl_action_replies(action_id, pw, custom_data) return handle_core_ctrl_action_replies(action_id, printer, custom_data)
elif object_id.as_bytes == STAR_TRACKER_ID: elif object_id.as_bytes == STAR_TRACKER_ID:
return handle_startracker_replies(action_id, pw, custom_data) return handle_startracker_replies(action_id, printer, custom_data)
elif object_id.as_bytes in [ elif object_id.as_bytes in [
ACU_HANDLER_ID, ACU_HANDLER_ID,
PDU_1_HANDLER_ID, PDU_1_HANDLER_ID,
@ -65,7 +53,9 @@ def handle_action_reply(
pw.dlog(f"Raw Data: {tm_packet.custom_data.hex(sep=',')}") pw.dlog(f"Raw Data: {tm_packet.custom_data.hex(sep=',')}")
def handle_imtq_replies(action_id: int, pw: PrintWrapper, custom_data: bytearray): def handle_imtq_replies(
action_id: int, printer: FsfwTmTcPrinter, custom_data: bytearray
):
if action_id == struct.unpack("!I", ImtqActionId.get_commanded_dipole)[0]: if action_id == struct.unpack("!I", ImtqActionId.get_commanded_dipole)[0]:
header_list = [ header_list = [
"Commanded X-Dipole", "Commanded X-Dipole",
@ -74,25 +64,33 @@ def handle_imtq_replies(action_id: int, pw: PrintWrapper, custom_data: bytearray
] ]
[x_dipole, y_dipole, z_dipole] = struct.unpack("!HHH", custom_data[0:6]) [x_dipole, y_dipole, z_dipole] = struct.unpack("!HHH", custom_data[0:6])
content_list = [x_dipole, y_dipole, z_dipole] content_list = [x_dipole, y_dipole, z_dipole]
pw.dlog(f"{header_list}") print(header_list)
pw.dlog(f"{content_list}") print(content_list)
printer.file_logger.info(header_list)
printer.file_logger.info(content_list)
def handle_supervisor_replies(action_id: int, pw: PrintWrapper, custom_data: bytearray): def handle_supervisor_replies(
action_id: int, printer: FsfwTmTcPrinter, custom_data: bytearray
):
if action_id == SupvActionId.DUMP_MRAM: if action_id == SupvActionId.DUMP_MRAM:
header_list = ["MRAM Dump"] header_list = ["MRAM Dump"]
content_list = [custom_data[: len(custom_data)]] content_list = [custom_data[: len(custom_data)]]
pw.dlog(f"{header_list}") print(header_list)
pw.dlog(f"{content_list}") print(content_list)
printer.file_logger.info(header_list)
printer.file_logger.info(content_list)
elif action_id == SupvActionId.READ_GPIO: elif action_id == SupvActionId.READ_GPIO:
header_list = ["GPIO state"] header_list = ["GPIO state"]
content_list = [struct.unpack("!H", custom_data[:2])[0]] content_list = [struct.unpack("!H", custom_data[:2])[0]]
pw.dlog(f"{header_list}") print(header_list)
pw.dlog(f"{content_list}") print(content_list)
printer.file_logger.info(header_list)
printer.file_logger.info(content_list)
def handle_startracker_replies( def handle_startracker_replies(
action_id: int, pw: PrintWrapper, custom_data: bytearray action_id: int, printer: FsfwTmTcPrinter, custom_data: bytearray
): ):
if action_id == StarTrackerActionId.CHECKSUM: if action_id == StarTrackerActionId.CHECKSUM:
if len(custom_data) != 5: if len(custom_data) != 5:
@ -104,5 +102,7 @@ def handle_startracker_replies(
print(custom_data[4]) print(custom_data[4])
checksum_valid_flag = custom_data[4] >> 8 checksum_valid_flag = custom_data[4] >> 8
content_list = ["0x" + custom_data[:4].hex(), checksum_valid_flag] content_list = ["0x" + custom_data[:4].hex(), checksum_valid_flag]
pw.dlog(f"{header_list}") print(header_list)
pw.dlog(f"{content_list}") print(content_list)
printer.file_logger.info(header_list)
printer.file_logger.info(content_list)

View File

@ -1,27 +1,19 @@
import logging import logging
from typing import Optional
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class PrintWrapper: class PrintWrapper:
def __init__(self, file_logger: Optional[logging.Logger]): def __init__(self, printer: FsfwTmTcPrinter):
self.file_logger = file_logger self.printer = printer
def dlog(self, string: str): def dlog(self, string: str):
print(string) print(string)
if self.file_logger: self.printer.file_logger.info(string)
self.file_logger.info(string)
def wlog(self, logger: logging.Logger, string: str):
logger.warning(string)
if self.file_logger:
self.file_logger.warning(string)
def ilog(self, logger: logging.Logger, string: str): def ilog(self, logger: logging.Logger, string: str):
logger.info(string) logger.info(string)
if self.file_logger: self.printer.file_logger.info(string)
self.file_logger.info(string)
def log_to_both(printer: FsfwTmTcPrinter, string: str): def log_to_both(printer: FsfwTmTcPrinter, string: str):

View File

@ -1,5 +1,6 @@
import logging import logging
import datetime import datetime
import struct
import sys import sys
from eive_tmtc.config.events import get_event_dict from eive_tmtc.config.events import get_event_dict
@ -7,20 +8,19 @@ from eive_tmtc.config.object_ids import get_object_ids
from eive_tmtc.pus_tm.defs import PrintWrapper from eive_tmtc.pus_tm.defs import PrintWrapper
from eive_tmtc.pus_tm.verification_handler import generic_retval_printout from eive_tmtc.pus_tm.verification_handler import generic_retval_printout
from eive_tmtc.tmtc.acs.subsystem import AcsMode from eive_tmtc.tmtc.acs.subsystem import AcsMode
from eive_tmtc.tmtc.core import SdState, SdCardSelect
from tmtccmd.tc.pus_200_fsfw_mode import Mode from tmtccmd.tc.pus_200_fsfw_mode import Mode
from tmtccmd.tc.pus_201_fsfw_health import FsfwHealth from tmtccmd.tc.pus_201_fsfw_health import FsfwHealth
from tmtccmd.tm import Service5Tm from tmtccmd.tm import Service5Tm
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from tmtccmd.fsfw import EventInfo from tmtccmd.fsfw import EventInfo
from spacepackets.ccsds.time import CdsShortTimestamp from spacepackets.ccsds.time import CdsShortTimestamp
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
def handle_event_packet( # noqa C901: Complexity okay here def handle_event_packet(raw_tm: bytes, printer: FsfwTmTcPrinter):
raw_tm: bytes, pw: PrintWrapper pw = PrintWrapper(printer)
): # noqa C901: Complexity okay here
tm = Service5Tm.unpack(data=raw_tm, time_reader=CdsShortTimestamp.empty()) tm = Service5Tm.unpack(data=raw_tm, time_reader=CdsShortTimestamp.empty())
event_dict = get_event_dict() event_dict = get_event_dict()
event_def = tm.event_definition event_def = tm.event_definition
@ -36,14 +36,10 @@ def handle_event_packet( # noqa C901: Complexity okay here
obj_name = event_def.reporter_id.hex(sep=",") obj_name = event_def.reporter_id.hex(sep=",")
else: else:
obj_name = obj_id_obj.name obj_name = obj_id_obj.name
generic_event_string = ( generic_event_string = f"Object {obj_name} generated Event {info.name} (ID: {event_def.event_id:#04x}) at {tm.time_provider.as_date_time()}"
f"Object {obj_name} generated Event {info.name} (ID: {event_def.event_id:#04x})"
f" at {tm.time_provider.as_date_time()}"
)
_LOGGER.info(generic_event_string) _LOGGER.info(generic_event_string)
pw.file_logger.info( pw.printer.file_logger.info(
f"{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}:" f"{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}: {generic_event_string}"
f" {generic_event_string}"
) )
specific_handler = False specific_handler = False
if info.name == "MODE_TRANSITION_FAILED": if info.name == "MODE_TRANSITION_FAILED":
@ -55,8 +51,8 @@ def handle_event_packet( # noqa C901: Complexity okay here
if info.name == "SUPV_UPDATE_PROGRESS" or info.name == "WRITE_MEMORY_FAILED": if info.name == "SUPV_UPDATE_PROGRESS" or info.name == "WRITE_MEMORY_FAILED":
additional_event_info = f"Additional info: {info.info}" additional_event_info = f"Additional info: {info.info}"
context = ( context = (
f"Progress Percent: {event_def.param1 >> 24 & 0xff} | Sequence Count:" f"Progress Percent: {event_def.param1 >> 24 & 0xff} | Sequence Count: {event_def.param1 & 0xffff} "
f" {event_def.param1 & 0xffff} | Bytes Written: {event_def.param2}" f"| Bytes Written: {event_def.param2}"
) )
pw.dlog(additional_event_info) pw.dlog(additional_event_info)
pw.dlog(context) pw.dlog(context)
@ -82,8 +78,7 @@ def handle_event_packet( # noqa C901: Complexity okay here
elif event_def.param1 == Mode.RAW: elif event_def.param1 == Mode.RAW:
mode_name = "Raw" mode_name = "Raw"
pw.dlog( pw.dlog(
f"Mode Number {event_def.param1}, Mode Name {mode_name}, " f"Mode Number {event_def.param1}, Mode Name {mode_name}, Submode: {event_def.param2}"
f"Submode: {event_def.param2}"
) )
if info.name == "INDIVIDUAL_BOOT_COUNTS": if info.name == "INDIVIDUAL_BOOT_COUNTS":
boot_count_00 = (event_def.param1 >> 16) & 0xFFFF boot_count_00 = (event_def.param1 >> 16) & 0xFFFF
@ -97,7 +92,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" or info.name == "FIRMWARE_INFO": if info.name == "VERSION_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
@ -107,11 +102,8 @@ 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")
if info.name == "VERSION_INFO": version_string = f"v{ver_major}.{ver_minor}.{ver_rev}"
name = "OBSW version: " pw.dlog(f"Version {version_string}")
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":
@ -128,21 +120,6 @@ def handle_event_packet( # noqa C901: Complexity okay here
time = event_def.param1 + event_def.param2 / 1000.0 time = event_def.param1 + event_def.param2 / 1000.0
time_dt = datetime.datetime.fromtimestamp(time, datetime.timezone.utc) time_dt = datetime.datetime.fromtimestamp(time, datetime.timezone.utc)
pw.dlog(f"Current time: {time_dt}") pw.dlog(f"Current time: {time_dt}")
if info.name == "ACTIVE_SD_INFO":
sd_0_state = (event_def.param2 >> 16) & 0xFFFF
sd_1_state = event_def.param2 & 0xFFFF
active_sd = event_def.param1
try:
active_sd = SdCardSelect(event_def.param1)
sd_0_state = SdState((event_def.param2 >> 16) & 0xFFFF)
sd_1_state = SdState(event_def.param2 & 0xFFFF)
except IndexError:
_LOGGER.error(f"Received invalid event fields for event {event_def}")
finally:
pw.dlog(
f"Active SD card {active_sd!r} | SD 0 State {sd_0_state!r} | SD 1 "
f"State {sd_1_state!r}"
)
if info.name == "HEALTH_INFO": if info.name == "HEALTH_INFO":
specific_handler = True specific_handler = True
health = FsfwHealth(event_def.param1) health = FsfwHealth(event_def.param1)
@ -152,10 +129,7 @@ def handle_event_packet( # noqa C901: Complexity okay here
submode = event_def.param2 submode = event_def.param2
pw.dlog(f"Mode Number {mode}, Submode: {submode}") pw.dlog(f"Mode Number {mode}, Submode: {submode}")
if not specific_handler: if not specific_handler:
additional_event_info = ( additional_event_info = f"Additional info: {info.info} | P1: {event_def.param1} | P2: {event_def.param2}"
f"Additional info: {info.info} | P1: {event_def.param1} | "
f"P2: {event_def.param2}"
)
pw.dlog(additional_event_info) pw.dlog(additional_event_info)
if not specific_handler: if not specific_handler:
# printer.handle_long_tm_print(packet_if=tm.pus_tm, info_if=tm.pus_tm) # printer.handle_long_tm_print(packet_if=tm.pus_tm, info_if=tm.pus_tm)

View File

@ -13,47 +13,42 @@ from tmtccmd.tm import Service20FsfwTm, Service200FsfwTm
from tmtccmd.tm.pus_20_fsfw_param import Service20ParamDumpWrapper from tmtccmd.tm.pus_20_fsfw_param import Service20ParamDumpWrapper
from tmtccmd.pus.s20_fsfw_param_defs import CustomSubservice as ParamSubservice from tmtccmd.pus.s20_fsfw_param_defs import CustomSubservice as ParamSubservice
from tmtccmd.tm.pus_200_fsfw_mode import Subservice as ModeSubservice from tmtccmd.tm.pus_200_fsfw_mode import Subservice as ModeSubservice
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from .defs import PrintWrapper from .defs import PrintWrapper
from .event_handler import handle_event_packet from .event_handler import handle_event_packet
from .verification_handler import handle_service_1_fsfw_packet, generic_retval_printout from .verification_handler import handle_service_1_fsfw_packet, generic_retval_printout
from .hk_handler import handle_hk_packet from .hk_handling import handle_hk_packet
from .action_reply_handler import handle_action_reply from .action_reply_handler import handle_action_reply
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
def pus_factory_hook( # noqa C901 : Complexity okay here def pus_factory_hook(
packet: bytes, packet: bytes,
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:
except ValueError as 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")
_LOGGER.warning(f"Raw Packet: [{packet.hex(sep=',')}], REPR: {packet!r}") _LOGGER.warning(f"Raw Packet: [{packet.hex(sep=',')}], REPR: {packet!r}")
return return
service = tm_packet.service service = tm_packet.service
obj_id_dict = get_object_ids() obj_id_dict = get_object_ids()
pw = PrintWrapper(printer.file_logger) pw = PrintWrapper(printer)
dedicated_handler = True dedicated_handler = True
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( handle_hk_packet(printer=printer, raw_tm=packet, obj_id_dict=obj_id_dict)
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, printer=printer)
elif service == 8: elif service == 8:
handle_action_reply(raw_tm=packet, printer=printer, obj_id_dict=obj_id_dict) handle_action_reply(raw_tm=packet, printer=printer, obj_id_dict=obj_id_dict)
elif service == 17: elif service == 17:
@ -82,13 +77,12 @@ def pus_factory_hook( # noqa C901 : Complexity okay here
elif isinstance(scalar_param, float): elif isinstance(scalar_param, float):
pw.dlog(f"Scalar floating point parameter: {scalar_param}") pw.dlog(f"Scalar floating point parameter: {scalar_param}")
except ValueError as e: except ValueError as e:
pw.dlog(f"received {e} trying to parse scalar parameter") pw.dlog("received {e} trying to parse scalar parameter")
else: else:
# TODO: Could improve display further by actually displaying a matrix as a # TODO: Could improve display further by actually displaying a matrix as a
# matrix using row and column information # matrix using row and column information
pw.dlog( pw.dlog(
"Received vector or matrix data:" f"Received vector or matrix data: {param.param_raw.hex(sep=',')}"
f" {param.param_raw.hex(sep=',')}"
) )
except ValueError as e: except ValueError as e:
pw.dlog(f"received {e} when trying to parse parameters") pw.dlog(f"received {e} when trying to parse parameters")

View File

@ -1,8 +1,9 @@
"""HK Handling for EIVE OBSW""" """HK Handling for EIVE OBSW"""
import datetime
import logging import logging
# 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
@ -13,7 +14,6 @@ from eive_tmtc.tmtc.payload.ploc_supervisor import handle_supv_hk_data
from eive_tmtc.tmtc.acs.reaction_wheels import handle_rw_hk_data from eive_tmtc.tmtc.acs.reaction_wheels import handle_rw_hk_data
from eive_tmtc.tmtc.com.syrlinks_handler import handle_syrlinks_hk_data from eive_tmtc.tmtc.com.syrlinks_handler import handle_syrlinks_hk_data
from eive_tmtc.tmtc.tcs import handle_thermal_controller_hk_data from eive_tmtc.tmtc.tcs import handle_thermal_controller_hk_data
from eive_tmtc.tmtc.tcs.tmp1075 import handle_tmp_1075_hk_data
from spacepackets.ecss import PusTelemetry from spacepackets.ecss import PusTelemetry
from tmtccmd.tm.pus_3_fsfw_hk import ( from tmtccmd.tm.pus_3_fsfw_hk import (
Service3Base, Service3Base,
@ -34,7 +34,7 @@ from eive_tmtc.tmtc.power.tm import (
from eive_tmtc.tmtc.acs.imtq import ( from eive_tmtc.tmtc.acs.imtq import (
handle_imtq_hk, handle_imtq_hk,
) )
from eive_tmtc.pus_tm.defs import FsfwTmTcPrinter, PrintWrapper from eive_tmtc.pus_tm.defs import FsfwTmTcPrinter
from eive_tmtc.tmtc.core import handle_core_hk_data from eive_tmtc.tmtc.core import handle_core_hk_data
from eive_tmtc.tmtc.acs.mgms import handle_mgm_hk_data from eive_tmtc.tmtc.acs.mgms import handle_mgm_hk_data
import eive_tmtc.config.object_ids as obj_ids import eive_tmtc.config.object_ids as obj_ids
@ -47,7 +47,9 @@ FORWARD_SENSOR_TEMPS = False
def handle_hk_packet( def handle_hk_packet(
raw_tm: bytes, obj_id_dict: ObjectIdDictT, printer: FsfwTmTcPrinter, hk_level: int raw_tm: bytes,
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)
@ -55,25 +57,26 @@ def handle_hk_packet(
named_obj_id = tm_packet.object_id named_obj_id = tm_packet.object_id
if tm_packet.subservice == 25 or tm_packet.subservice == 26: if tm_packet.subservice == 25 or tm_packet.subservice == 26:
hk_data = tm_packet.tm_data[8:] hk_data = tm_packet.tm_data[8:]
if FORWARD_SENSOR_TEMPS:
# TODO: Maybe use singleton?
# TCP_SEVER_SENSOR_TEMPERATURES.report_raw_hk_data(
# object_id=named_obj_id, set_id=tm_packet.set_id, hk_data=hk_data
# )
pass
printer.generic_hk_tm_print( printer.generic_hk_tm_print(
content_type=HkContentType.HK, content_type=HkContentType.HK,
object_id=named_obj_id, object_id=named_obj_id,
set_id=tm_packet.set_id, set_id=tm_packet.set_id,
hk_data=hk_data, hk_data=hk_data,
) )
try: try:
if hk_level == 1: handle_regular_hk_print(
pass printer=printer,
elif hk_level > 1: object_id=named_obj_id,
handle_regular_hk_print( hk_packet=tm_packet,
printer=printer, tm=tm_packet.pus_tm,
object_id=named_obj_id, hk_data=hk_data,
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}"
@ -82,7 +85,7 @@ def handle_hk_packet(
_LOGGER.warning("HK definitions printout not implemented yet") _LOGGER.warning("HK definitions printout not implemented yet")
def handle_regular_hk_print( # noqa C901: Complexity okay here def handle_regular_hk_print(
printer: FsfwTmTcPrinter, printer: FsfwTmTcPrinter,
object_id: ObjectIdU32, object_id: ObjectIdU32,
hk_packet: Service3Base, hk_packet: Service3Base,
@ -92,39 +95,40 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here
objb = object_id.as_bytes objb = object_id.as_bytes
set_id = hk_packet.set_id set_id = hk_packet.set_id
packet_dt = tm.time_provider.as_date_time() packet_dt = tm.time_provider.as_date_time()
pw = PrintWrapper(printer.file_logger)
"""This function is called when a Service 3 Housekeeping packet is received.""" """This function is called when a Service 3 Housekeeping packet is received."""
if objb in [obj_ids.RW1_ID, obj_ids.RW2_ID, obj_ids.RW3_ID, obj_ids.RW4_ID]: if objb in [obj_ids.RW1_ID, obj_ids.RW2_ID, obj_ids.RW3_ID, obj_ids.RW4_ID]:
return handle_rw_hk_data(pw, object_id, set_id, hk_data) return handle_rw_hk_data(printer, object_id, set_id, hk_data)
elif objb == obj_ids.SYRLINKS_HANDLER_ID: elif objb == obj_ids.SYRLINKS_HANDLER_ID:
return handle_syrlinks_hk_data(pw=pw, hk_data=hk_data, set_id=set_id) return handle_syrlinks_hk_data(printer=printer, hk_data=hk_data, set_id=set_id)
elif objb == obj_ids.IMTQ_HANDLER_ID: elif objb == obj_ids.IMTQ_HANDLER_ID:
return handle_imtq_hk(pw=pw, hk_data=hk_data, set_id=set_id) return handle_imtq_hk(printer=printer, hk_data=hk_data, set_id=set_id)
elif objb == obj_ids.GPS_CONTROLLER: elif objb == obj_ids.GPS_CONTROLLER:
return handle_gps_data( return handle_gps_data(printer=printer, hk_data=hk_data)
pw=pw, set_id=set_id, hk_data=hk_data, packet_time=packet_dt
)
elif objb == obj_ids.PCDU_HANDLER_ID: elif objb == obj_ids.PCDU_HANDLER_ID:
return handle_pcdu_hk(pw=pw, set_id=set_id, hk_data=hk_data) return handle_pcdu_hk(printer=printer, set_id=set_id, hk_data=hk_data)
elif objb == obj_ids.BPX_HANDLER_ID: elif objb == obj_ids.BPX_HANDLER_ID:
return handle_bpx_hk_data(hk_data=hk_data, set_id=set_id, pw=pw) return handle_bpx_hk_data(hk_data=hk_data, set_id=set_id, printer=printer)
elif objb == obj_ids.CORE_CONTROLLER_ID: elif objb == obj_ids.CORE_CONTROLLER_ID:
return handle_core_hk_data(pw=pw, hk_data=hk_data, set_id=set_id) return handle_core_hk_data(printer=printer, hk_data=hk_data, set_id=set_id)
elif objb == obj_ids.PDU_1_HANDLER_ID: elif objb == obj_ids.PDU_1_HANDLER_ID:
return handle_pdu_data(pw=pw, pdu_idx=1, set_id=set_id, hk_data=hk_data) return handle_pdu_data(
printer=printer, pdu_idx=1, set_id=set_id, hk_data=hk_data
)
elif objb == obj_ids.PDU_2_HANDLER_ID: elif objb == obj_ids.PDU_2_HANDLER_ID:
return handle_pdu_data(pw=pw, pdu_idx=2, set_id=set_id, hk_data=hk_data) return handle_pdu_data(
printer=printer, pdu_idx=2, set_id=set_id, hk_data=hk_data
)
elif objb == obj_ids.PLOC_MPSOC_ID: elif objb == obj_ids.PLOC_MPSOC_ID:
return handle_ploc_mpsoc_hk_data(pw=pw, hk_data=hk_data, set_id=set_id) return handle_ploc_mpsoc_hk_data(
printer=printer, 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(printer=printer, 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(printer=printer, 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]:
return handle_rw_hk_data( return handle_rw_hk_data(
pw=pw, object_id=object_id, set_id=set_id, hk_data=hk_data printer=printer, object_id=object_id, set_id=set_id, hk_data=hk_data
) )
if objb in [ if objb in [
obj_ids.SUS_0_N_LOC_XFYFZM_PT_XF, obj_ids.SUS_0_N_LOC_XFYFZM_PT_XF,
@ -140,11 +144,13 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here
obj_ids.SUS_10_R_LOC_XMYBZF_PT_ZF, obj_ids.SUS_10_R_LOC_XMYBZF_PT_ZF,
obj_ids.SUS_11_R_LOC_XBYMZB_PT_ZB, obj_ids.SUS_11_R_LOC_XBYMZB_PT_ZB,
]: ]:
return handle_sus_hk(object_id=object_id, hk_data=hk_data, pw=pw, set_id=set_id) return handle_sus_hk(
object_id=object_id, hk_data=hk_data, printer=printer, set_id=set_id
)
elif objb in RTD_NAMES.keys(): elif objb in RTD_NAMES.keys():
return handle_rtd_hk(object_id=objb, hk_data=hk_data, pw=pw) return handle_rtd_hk(object_id=objb, hk_data=hk_data, printer=printer)
elif objb == obj_ids.P60_DOCK_HANDLER: elif objb == obj_ids.P60_DOCK_HANDLER:
return handle_p60_hk_data(pw=pw, set_id=set_id, hk_data=hk_data) return handle_p60_hk_data(printer=printer, set_id=set_id, hk_data=hk_data)
elif objb in [ elif objb in [
obj_ids.GYRO_0_ADIS_HANDLER_ID, obj_ids.GYRO_0_ADIS_HANDLER_ID,
obj_ids.GYRO_1_L3G_HANDLER_ID, obj_ids.GYRO_1_L3G_HANDLER_ID,
@ -152,7 +158,7 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here
obj_ids.GYRO_3_L3G_HANDLER_ID, obj_ids.GYRO_3_L3G_HANDLER_ID,
]: ]:
return handle_gyros_hk_data( return handle_gyros_hk_data(
object_id=object_id, hk_data=hk_data, pw=pw, set_id=set_id object_id=object_id, hk_data=hk_data, printer=printer, set_id=set_id
) )
elif objb in [ elif objb in [
obj_ids.MGM_0_LIS3_HANDLER_ID, obj_ids.MGM_0_LIS3_HANDLER_ID,
@ -161,32 +167,24 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here
obj_ids.MGM_3_RM3100_HANDLER_ID, obj_ids.MGM_3_RM3100_HANDLER_ID,
]: ]:
return handle_mgm_hk_data( return handle_mgm_hk_data(
object_id=object_id, hk_data=hk_data, pw=pw, set_id=set_id object_id=object_id, hk_data=hk_data, printer=printer, set_id=set_id
) )
elif objb == obj_ids.PL_PCDU_ID: elif objb == obj_ids.PL_PCDU_ID:
return handle_plpcdu_hk(set_id=set_id, hk_data=hk_data, pw=pw) return handle_plpcdu_hk(set_id=set_id, hk_data=hk_data, printer=printer)
elif objb == obj_ids.THERMAL_CONTROLLER_ID: elif objb == obj_ids.THERMAL_CONTROLLER_ID:
return handle_thermal_controller_hk_data( return handle_thermal_controller_hk_data(
object_id=object_id, pw=pw, set_id=set_id, hk_data=hk_data object_id=object_id, printer=printer, set_id=set_id, hk_data=hk_data
) )
elif objb == obj_ids.STAR_TRACKER_ID: elif objb == obj_ids.STAR_TRACKER_ID:
return handle_str_hk_data(set_id=set_id, hk_data=hk_data, pw=pw) return handle_str_hk_data(set_id=set_id, hk_data=hk_data, printer=printer)
elif objb == obj_ids.PLOC_SUPV_ID: elif objb == obj_ids.PLOC_SUPV_ID:
return handle_supv_hk_data(set_id=set_id, hk_data=hk_data, pw=pw) return handle_supv_hk_data(set_id=set_id, hk_data=hk_data, printer=printer)
elif objb in [
obj_ids.TMP1075_HANDLER_TCS_BRD_0_ID,
obj_ids.TMP1075_HANDLER_TCS_BRD_1_ID,
obj_ids.TMP1075_HANDLER_IF_BRD_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)
elif objb == obj_ids.ACS_CONTROLLER: elif objb == obj_ids.ACS_CONTROLLER:
return handle_acs_ctrl_hk_data( return handle_acs_ctrl_hk_data(
pw=pw, set_id=set_id, hk_data=hk_data, packet_time=packet_dt printer=printer, set_id=set_id, hk_data=hk_data, packet_time=packet_dt
) )
else: else:
_LOGGER.info( _LOGGER.info(
f"Service 3 TM: Parsing for object {object_id} and set ID {set_id} " f"Service 3 TM: Parsing for object {object_id} and set ID {set_id} "
"has not been implemented." f"has not been implemented."
) )

View File

@ -1,17 +1,18 @@
import logging
import socket import socket
from typing import Optional from typing import Optional
import json import json
import base64 import base64
from tmtccmd.logging import get_console_logger
from tmtccmd.util.obj_id import ObjectIdU32 from tmtccmd.util.obj_id import ObjectIdU32
from dle_encoder import DleEncoder from dle_encoder import DleEncoder
_LOGGER = logging.getLogger(__name__) LOGGER = get_console_logger()
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))
@ -28,8 +29,8 @@ class TmTcpServer:
def __del__(self): def __del__(self):
try: try:
self.close() self.close()
except IOError: except:
_LOGGER.warning("Could not close sockets!") LOGGER.warning("Could not close sockets!")
def close(self): def close(self):
self.server_socket.close() self.server_socket.close()
@ -44,7 +45,8 @@ class TmTcpServer:
(self.client_connection, _) = self.server_socket.accept() (self.client_connection, _) = self.server_socket.accept()
self.client_connection.setblocking(False) self.client_connection.setblocking(False)
print("Client connected") print("Client connected")
except IOError: except:
# no client waiting
return return
data_json_bytes = json.dumps(dictionary).encode() data_json_bytes = json.dumps(dictionary).encode()
@ -55,7 +57,7 @@ class TmTcpServer:
try: try:
sent_length = self.client_connection.send(data_json_bytes) sent_length = self.client_connection.send(data_json_bytes)
except IOError: except:
self.client_connection = None self.client_connection = None
return return
if sent_length == 0: if sent_length == 0:
@ -63,6 +65,7 @@ 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",

View File

@ -48,7 +48,7 @@ def generic_retval_printout(
if retval_info is None: if retval_info is None:
raw_err = retval raw_err = retval
return [ return [
"No returnvalue information found for error code with " f"No returnvalue information found for error code with "
f"subsystem ID {(raw_err >> 8) & 0xff} and unique ID {raw_err & 0xff}" f"subsystem ID {(raw_err >> 8) & 0xff} and unique ID {raw_err & 0xff}"
] ]
else: else:
@ -58,9 +58,9 @@ def generic_retval_printout(
) )
string_list = [retval_string] string_list = [retval_string]
if p1: if p1:
error_param_1_str = f"Error Parameter 1: hex {p1:#010x} dec {p1} " error_param_1_str = f"Error Parameter 1: hex {p1:#010x} " f"dec {p1} "
string_list.append(error_param_1_str) string_list.append(error_param_1_str)
if p2: if p2:
error_param_2_str = f"Error Parameter 2: hex {p2:#010x} dec {p2}" error_param_2_str = f"Error Parameter 2: hex {p2:#010x} " f"dec {p2}"
string_list.append(error_param_2_str) string_list.append(error_param_2_str)
return string_list return string_list

View File

@ -5,4 +5,3 @@ from .time import add_time_cmds
from .health import add_health_cmd_defs from .health import add_health_cmd_defs
from .system import add_system_cmd_defs from .system import add_system_cmd_defs
from .tm_store import add_persistent_tm_store_cmd_defs from .tm_store import add_persistent_tm_store_cmd_defs
from .tcs import add_tmp_sens_cmds

View File

@ -28,7 +28,7 @@ from tmtccmd.tc.pus_3_fsfw_hk import (
create_request_one_diag_command, create_request_one_diag_command,
) )
from tmtccmd.pus.s8_fsfw_funccmd import create_action_cmd from tmtccmd.pus.s8_fsfw_funccmd import create_action_cmd
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from tmtccmd.tc.pus_20_fsfw_param import create_load_param_cmd from tmtccmd.tc.pus_20_fsfw_param import create_load_param_cmd
@ -59,44 +59,12 @@ class SetId(enum.IntEnum):
MEKF_DATA = 7 MEKF_DATA = 7
CTRL_VAL_DATA = 8 CTRL_VAL_DATA = 8
ACTUATOR_CMD_DATA = 9 ACTUATOR_CMD_DATA = 9
FUSED_ROT_RATE_DATA = 10
class ActionId(enum.IntEnum): class ActionId(enum.IntEnum):
SOLAR_ARRAY_DEPLOYMENT_SUCCESSFUL = 0 SOLAR_ARRAY_DEPLOYMENT_SUCCESSFUL = 0
RESET_MEKF = 1 RESET_MEKF = 1
RESTORE_MEKF_NONFINITE_RECOVERY = 2 RESTORE_MEKF_NONFINITE_RECOVERY = 2
UPDATE_TLE = 3
CTRL_STRAT_DICT = {
0: "OFF",
1: "NO_MAG_FIELD_FOR_CONTROL",
2: "NO_SENSORS_FOR_CONTROL",
# OBSW <= v6.1.0
10: "LEGACY_SAFE_MEKF",
11: "LEGACY_WITHOUT_MEKF",
12: "LEGACY_ECLIPSE_DAMPING",
13: "LEGACY_ECLIPSE_IDELING",
# Added in OBSW v6.2.0
14: "SAFE_MEKF",
15: "SAFE_GYR",
16: "SAFE_SUSMGM",
17: "SAFE_ECLIPSE_DAMPING_GYR",
18: "SAFE_ECLIPSE_DAMPING_SUSMGM",
19: "SAFE_ECLIPSE_IDELING",
20: "DETUMBLE_FULL",
21: "DETUMBLE_DETERIORATED",
30: "PTG_MEKF",
31: "PTG_RAW",
}
GPS_COURCE_DICT = {
0: "NONE",
1: "GPS",
2: "GPS_EXTRAPOLATED",
3: "SGP4",
}
class OpCodes: class OpCodes:
@ -111,7 +79,6 @@ class OpCodes:
SAFE_PTG = ["confirm_deployment"] SAFE_PTG = ["confirm_deployment"]
RESET_MEKF = ["reset_mekf"] RESET_MEKF = ["reset_mekf"]
RESTORE_MEKF_NONFINITE_RECOVERY = ["restore_mekf_nonfinite_recovery"] RESTORE_MEKF_NONFINITE_RECOVERY = ["restore_mekf_nonfinite_recovery"]
UPDATE_TLE = ["update_tle"]
SET_PARAMETER_SCALAR = ["set_scalar_param"] SET_PARAMETER_SCALAR = ["set_scalar_param"]
SET_PARAMETER_VECTOR = ["set_vector_param"] SET_PARAMETER_VECTOR = ["set_vector_param"]
SET_PARAMETER_MATRIX = ["set_matrix_param"] SET_PARAMETER_MATRIX = ["set_matrix_param"]
@ -145,9 +112,6 @@ class OpCodes:
REQUEST_ACT_CMD_HK = ["act_cmd_hk"] REQUEST_ACT_CMD_HK = ["act_cmd_hk"]
ENABLE_ACT_CMD_HK = ["act_cmd_enable_hk"] ENABLE_ACT_CMD_HK = ["act_cmd_enable_hk"]
DISABLE_ACT_CMD_HK = ["act_cmd_disable_hk"] DISABLE_ACT_CMD_HK = ["act_cmd_disable_hk"]
REQUEST_FUSED_ROT_RATE_HK = ["f_rot_rate_hk"]
ENABLE_FUSED_ROT_RATE_HK = ["f_rot_rate_enable_hk"]
DISABLE_FUSED_ROT_RATE_HK = ["f_rot_rate_disable_hk"]
class Info: class Info:
@ -162,7 +126,6 @@ class Info:
SAFE_PTG = "Confirm deployment of both solar arrays" SAFE_PTG = "Confirm deployment of both solar arrays"
RESET_MEKF = "Reset the MEKF" RESET_MEKF = "Reset the MEKF"
RESTORE_MEKF_NONFINITE_RECOVERY = "Restore MEKF non-finite recovery" RESTORE_MEKF_NONFINITE_RECOVERY = "Restore MEKF non-finite recovery"
UPDATE_TLE = "Update TLE"
SET_PARAMETER_SCALAR = "Set Scalar Parameter" SET_PARAMETER_SCALAR = "Set Scalar Parameter"
SET_PARAMETER_VECTOR = "Set Vector Parameter" SET_PARAMETER_VECTOR = "Set Vector Parameter"
SET_PARAMETER_MATRIX = "Set Matrix Parameter" SET_PARAMETER_MATRIX = "Set Matrix Parameter"
@ -196,9 +159,6 @@ class Info:
REQUEST_ACT_CMD_HK = "Request Actuator Commands HK" REQUEST_ACT_CMD_HK = "Request Actuator Commands HK"
ENABLE_ACT_CMD_HK = "Enable Actuator Commands HK data generation" ENABLE_ACT_CMD_HK = "Enable Actuator Commands HK data generation"
DISABLE_ACT_CMD_HK = "Disable Actuator Commands HK data generation" DISABLE_ACT_CMD_HK = "Disable Actuator Commands HK data generation"
REQUEST_FUSED_ROT_RATE_HK = "Request Fused Rotational Rates HK"
ENABLE_FUSED_ROT_RATE_HK = "Enable Fused Rotational Rates HK data generation"
DISABLE_FUSED_ROT_RATE_HK = "Disable Fused Rotational Rates HK data generation"
PERFORM_MGM_CALIBRATION = False PERFORM_MGM_CALIBRATION = False
@ -230,7 +190,6 @@ def acs_cmd_defs(defs: TmtcDefinitionWrapper):
keys=OpCodes.RESTORE_MEKF_NONFINITE_RECOVERY, keys=OpCodes.RESTORE_MEKF_NONFINITE_RECOVERY,
info=Info.RESTORE_MEKF_NONFINITE_RECOVERY, info=Info.RESTORE_MEKF_NONFINITE_RECOVERY,
) )
oce.add(keys=OpCodes.UPDATE_TLE, info=Info.UPDATE_TLE)
oce.add(keys=OpCodes.SET_PARAMETER_SCALAR, info=Info.SET_PARAMETER_SCALAR) oce.add(keys=OpCodes.SET_PARAMETER_SCALAR, info=Info.SET_PARAMETER_SCALAR)
oce.add(keys=OpCodes.SET_PARAMETER_VECTOR, info=Info.SET_PARAMETER_VECTOR) oce.add(keys=OpCodes.SET_PARAMETER_VECTOR, info=Info.SET_PARAMETER_VECTOR)
oce.add(keys=OpCodes.SET_PARAMETER_MATRIX, info=Info.SET_PARAMETER_MATRIX) oce.add(keys=OpCodes.SET_PARAMETER_MATRIX, info=Info.SET_PARAMETER_MATRIX)
@ -264,16 +223,13 @@ def acs_cmd_defs(defs: TmtcDefinitionWrapper):
oce.add(keys=OpCodes.REQUEST_ACT_CMD_HK, info=Info.REQUEST_ACT_CMD_HK) oce.add(keys=OpCodes.REQUEST_ACT_CMD_HK, info=Info.REQUEST_ACT_CMD_HK)
oce.add(keys=OpCodes.ENABLE_ACT_CMD_HK, info=Info.ENABLE_ACT_CMD_HK) oce.add(keys=OpCodes.ENABLE_ACT_CMD_HK, info=Info.ENABLE_ACT_CMD_HK)
oce.add(keys=OpCodes.DISABLE_ACT_CMD_HK, info=Info.DISABLE_ACT_CMD_HK) oce.add(keys=OpCodes.DISABLE_ACT_CMD_HK, info=Info.DISABLE_ACT_CMD_HK)
oce.add(keys=OpCodes.REQUEST_FUSED_ROT_RATE_HK, info=Info.REQUEST_FUSED_ROT_RATE_HK)
oce.add(keys=OpCodes.ENABLE_FUSED_ROT_RATE_HK, info=Info.ENABLE_FUSED_ROT_RATE_HK)
oce.add(keys=OpCodes.DISABLE_FUSED_ROT_RATE_HK, info=Info.DISABLE_FUSED_ROT_RATE_HK)
defs.add_service( defs.add_service(
name=CustomServiceList.ACS_CTRL.value, info="ACS Controller", op_code_entry=oce name=CustomServiceList.ACS_CTRL.value, info="ACS Controller", op_code_entry=oce
) )
@service_provider(CustomServiceList.ACS_CTRL.value) @service_provider(CustomServiceList.ACS_CTRL.value)
def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 def pack_acs_ctrl_command(p: ServiceProviderParams):
op_code = p.op_code op_code = p.op_code
q = p.queue_helper q = p.queue_helper
if op_code in OpCodes.OFF: if op_code in OpCodes.OFF:
@ -319,22 +275,6 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901
q.add_pus_tc( q.add_pus_tc(
create_action_cmd(ACS_CONTROLLER, ActionId.RESTORE_MEKF_NONFINITE_RECOVERY) create_action_cmd(ACS_CONTROLLER, ActionId.RESTORE_MEKF_NONFINITE_RECOVERY)
) )
elif op_code in OpCodes.UPDATE_TLE:
q.add_log_cmd(f"{Info.UPDATE_TLE}")
while True:
line1 = input("Please input the first line of the TLE: ")
if len(line1) == 69:
break
else:
print("The line does not have the required length of 69 characters")
while True:
line2 = input("Please input the second line of the TLE: ")
if len(line2) == 69:
break
else:
print("The line does not have the required length of 69 characters")
tle = line1.encode() + line2.encode()
q.add_pus_tc(create_action_cmd(ACS_CONTROLLER, ActionId.UPDATE_TLE, tle))
elif op_code in OpCodes.SET_PARAMETER_SCALAR: elif op_code in OpCodes.SET_PARAMETER_SCALAR:
q.add_log_cmd(f"{Info.SET_PARAMETER_SCALAR}") q.add_log_cmd(f"{Info.SET_PARAMETER_SCALAR}")
set_acs_ctrl_param_scalar(q) set_acs_ctrl_param_scalar(q)
@ -544,26 +484,6 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901
False, make_sid(ACS_CONTROLLER, SetId.ACTUATOR_CMD_DATA) False, make_sid(ACS_CONTROLLER, SetId.ACTUATOR_CMD_DATA)
) )
) )
elif op_code in OpCodes.REQUEST_FUSED_ROT_RATE_HK:
q.add_log_cmd(Info.REQUEST_FUSED_ROT_RATE_HK)
q.add_pus_tc(
generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.FUSED_ROT_RATE_DATA))
)
elif op_code in OpCodes.ENABLE_FUSED_ROT_RATE_HK:
interval = float(input("Please specify interval in floating point seconds: "))
q.add_log_cmd(Info.ENABLE_FUSED_ROT_RATE_HK)
cmd_tuple = enable_periodic_hk_command_with_interval(
False, make_sid(ACS_CONTROLLER, SetId.FUSED_ROT_RATE_DATA), interval
)
q.add_pus_tc(cmd_tuple[0])
q.add_pus_tc(cmd_tuple[1])
elif op_code in OpCodes.DISABLE_FUSED_ROT_RATE_HK:
q.add_log_cmd(Info.DISABLE_FUSED_ROT_RATE_HK)
q.add_pus_tc(
disable_periodic_hk_command(
False, make_sid(ACS_CONTROLLER, SetId.FUSED_ROT_RATE_DATA)
)
)
else: else:
logging.getLogger(__name__).info(f"Unknown op code {op_code}") logging.getLogger(__name__).info(f"Unknown op code {op_code}")
@ -571,8 +491,8 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901
def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper): def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper):
pt = int( pt = int(
input( input(
'Specify parameter type to set {0: "uint8", 1: "uint16", 2: "int32", 3:' 'Specify parameter type to set {0: "uint8", 1: "uint16", 2: "int32", 3: "float", '
' "float", 4: "double"}: ' '4: "double"}: '
) )
) )
sid = int(input("Specify parameter struct ID to set: ")) sid = int(input("Specify parameter struct ID to set: "))
@ -587,7 +507,7 @@ def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper):
domain_id=sid, domain_id=sid,
unique_id=pid, unique_id=pid,
parameter=param, parameter=param,
) ).pack()
) )
) )
case 1: case 1:
@ -599,7 +519,7 @@ def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper):
domain_id=sid, domain_id=sid,
unique_id=pid, unique_id=pid,
parameter=param, parameter=param,
) ).pack()
) )
) )
case 2: case 2:
@ -611,7 +531,7 @@ def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper):
domain_id=sid, domain_id=sid,
unique_id=pid, unique_id=pid,
parameter=param, parameter=param,
) ).pack()
) )
) )
case 3: case 3:
@ -623,7 +543,7 @@ def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper):
domain_id=sid, domain_id=sid,
unique_id=pid, unique_id=pid,
parameter=param, parameter=param,
) ).pack()
) )
) )
case 4: case 4:
@ -635,7 +555,7 @@ def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper):
domain_id=sid, domain_id=sid,
unique_id=pid, unique_id=pid,
parameter=param, parameter=param,
) ).pack()
) )
) )
@ -683,7 +603,7 @@ def set_acs_ctrl_param_vector(q: DefaultPusQueueHelper):
domain_id=sid, domain_id=sid,
unique_id=pid, unique_id=pid,
parameters=param, parameters=param,
) ).pack()
) )
) )
else: else:
@ -716,7 +636,7 @@ def set_acs_ctrl_param_matrix(q: DefaultPusQueueHelper):
domain_id=sid, domain_id=sid,
unique_id=pid, unique_id=pid,
parameters=param, parameters=param,
) ).pack()
) )
) )
else: else:
@ -743,7 +663,7 @@ def set_acs_ctrl_param_matrix(q: DefaultPusQueueHelper):
domain_id=sid, domain_id=sid,
unique_id=pid, unique_id=pid,
parameters=param, parameters=param,
) ).pack()
) )
) )
else: else:
@ -752,11 +672,12 @@ def set_acs_ctrl_param_matrix(q: DefaultPusQueueHelper):
def handle_acs_ctrl_hk_data( def handle_acs_ctrl_hk_data(
pw: PrintWrapper, printer: FsfwTmTcPrinter,
set_id: int, set_id: int,
hk_data: bytes, hk_data: bytes,
packet_time: datetime.datetime, packet_time: datetime.datetime,
): ):
pw = PrintWrapper(printer)
pw.ilog(_LOGGER, f"Received ACS CTRL HK with packet time {packet_time}") pw.ilog(_LOGGER, f"Received ACS CTRL HK with packet time {packet_time}")
match set_id: match set_id:
case SetId.MGM_RAW_SET: case SetId.MGM_RAW_SET:
@ -779,8 +700,6 @@ def handle_acs_ctrl_hk_data(
handle_ctrl_val_data(pw, hk_data) handle_ctrl_val_data(pw, hk_data)
case SetId.ACTUATOR_CMD_DATA: case SetId.ACTUATOR_CMD_DATA:
handle_act_cmd_data(pw, hk_data) handle_act_cmd_data(pw, hk_data)
case SetId.FUSED_ROT_RATE_DATA:
handle_fused_rot_rate_data(pw, hk_data)
def handle_acs_ctrl_sus_raw_data(pw: PrintWrapper, hk_data: bytes): def handle_acs_ctrl_sus_raw_data(pw: PrintWrapper, hk_data: bytes):
@ -802,14 +721,14 @@ def handle_acs_ctrl_sus_raw_data(pw: PrintWrapper, hk_data: bytes):
sus_list_formatted = vec_fmt.format(*sus_list) sus_list_formatted = vec_fmt.format(*sus_list)
current_idx += length current_idx += length
pw.dlog(f"SUS {idx} RAW: {sus_list_formatted}") pw.dlog(f"SUS {idx} RAW: {sus_list_formatted}")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=12) pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=12)
def handle_acs_ctrl_sus_processed_data(pw: PrintWrapper, hk_data: bytes): def handle_acs_ctrl_sus_processed_data(pw: PrintWrapper, hk_data: bytes):
if len(hk_data) < 3 * 4 * 12 + 3 * 8 * 3: if len(hk_data) < 3 * 4 * 12 + 3 * 8 * 3:
pw.dlog( pw.dlog(
f"SUS Processed dataset with size {len(hk_data)} does not have expected" f"SUS Processed dataset with size {len(hk_data)} does not have expected size"
f" size of {3 * 4 * 12 + 3 * 8 * 3} bytes" f" of {3 * 4 * 12 + 3 * 8 * 3} bytes"
) )
return return
current_idx = 0 current_idx = 0
@ -838,7 +757,7 @@ def handle_acs_ctrl_sus_processed_data(pw: PrintWrapper, hk_data: bytes):
sun_ijk_model = vec_fmt.format(*sun_ijk_model) sun_ijk_model = vec_fmt.format(*sun_ijk_model)
current_idx += inc_len current_idx += inc_len
pw.dlog(f"{'SUS ijk Model'.ljust(25)}: {sun_ijk_model}") pw.dlog(f"{'SUS ijk Model'.ljust(25)}: {sun_ijk_model}")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=15) pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=15)
def handle_raw_mgm_data(pw: PrintWrapper, hk_data: bytes): def handle_raw_mgm_data(pw: PrintWrapper, hk_data: bytes):
@ -846,8 +765,7 @@ def handle_raw_mgm_data(pw: PrintWrapper, hk_data: bytes):
if len(hk_data) < 61: if len(hk_data) < 61:
pw.dlog( pw.dlog(
f"ACS CTRL HK: MGM HK data with length {len(hk_data)} shorter than expected" f"ACS CTRL HK: MGM HK data with length {len(hk_data)} shorter than expected 61 bytes"
" 61 bytes"
) )
pw.dlog(f"Raw Data: {hk_data.hex(sep=',')}") pw.dlog(f"Raw Data: {hk_data.hex(sep=',')}")
return return
@ -894,7 +812,7 @@ def handle_raw_mgm_data(pw: PrintWrapper, hk_data: bytes):
pw.dlog(f"{entry[0].ljust(28)}: {entry[1]}") pw.dlog(f"{entry[0].ljust(28)}: {entry[1]}")
current_idx += 1 current_idx += 1
assert current_idx == 61 assert current_idx == 61
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=6) pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=6)
def handle_mgm_data_processed(pw: PrintWrapper, hk_data: bytes): def handle_mgm_data_processed(pw: PrintWrapper, hk_data: bytes):
@ -948,7 +866,7 @@ def handle_mgm_data_processed(pw: PrintWrapper, hk_data: bytes):
current_idx += inc_len current_idx += inc_len
if PERFORM_MGM_CALIBRATION: if PERFORM_MGM_CALIBRATION:
perform_mgm_calibration(pw, mgm_3) perform_mgm_calibration(pw, mgm_3)
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=8) pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=8)
def handle_gyr_data_raw(pw: PrintWrapper, hk_data: bytes): def handle_gyr_data_raw(pw: PrintWrapper, hk_data: bytes):
@ -982,7 +900,7 @@ def handle_gyr_data_raw(pw: PrintWrapper, hk_data: bytes):
pw.dlog(f"{'GYR 1 L3'.ljust(15)}: {float_str_fmt.format(*gyr_1_l3)}") pw.dlog(f"{'GYR 1 L3'.ljust(15)}: {float_str_fmt.format(*gyr_1_l3)}")
pw.dlog(f"{'GYR 2 ADIS'.ljust(15)}: {float_str_fmt.format(*gyr_2_adis)}") pw.dlog(f"{'GYR 2 ADIS'.ljust(15)}: {float_str_fmt.format(*gyr_2_adis)}")
pw.dlog(f"{'GYR 3 L3'.ljust(15)}: {float_str_fmt.format(*gyr_3_l3)}") pw.dlog(f"{'GYR 3 L3'.ljust(15)}: {float_str_fmt.format(*gyr_3_l3)}")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], 4) pw.printer.print_validity_buffer(hk_data[current_idx:], 4)
GYR_NAMES = ["GYR 0 ADIS", "GYR 1 L3", "GYR 2 ADIS", "GYR 3 L3"] GYR_NAMES = ["GYR 0 ADIS", "GYR 1 L3", "GYR 2 ADIS", "GYR 3 L3"]
@ -1008,18 +926,16 @@ def handle_gyr_data_processed(pw: PrintWrapper, hk_data: bytes):
] ]
pw.dlog(f"GYR Vec Total: {gyr_vec_tot}") pw.dlog(f"GYR Vec Total: {gyr_vec_tot}")
current_idx += inc_len current_idx += inc_len
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=5) pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=5)
def handle_gps_data_processed(pw: PrintWrapper, hk_data: bytes): def handle_gps_data_processed(pw: PrintWrapper, hk_data: bytes):
pw.dlog("Received GPS Processed Set") pw.dlog("Received GPS Processed Set")
fmt_source = "!B"
fmt_scalar = "!d" fmt_scalar = "!d"
fmt_vec = "!ddd" fmt_vec = "!ddd"
inc_len_source = struct.calcsize(fmt_source)
inc_len_scalar = struct.calcsize(fmt_scalar) inc_len_scalar = struct.calcsize(fmt_scalar)
inc_len_vec = struct.calcsize(fmt_vec) inc_len_vec = struct.calcsize(fmt_vec)
if len(hk_data) < 3 * inc_len_scalar + 2 * inc_len_vec + inc_len_source: if len(hk_data) < 2 * inc_len_scalar + 2 * inc_len_vec:
pw.dlog("Received HK set too small") pw.dlog("Received HK set too small")
return return
current_idx = 0 current_idx = 0
@ -1058,20 +974,12 @@ def handle_gps_data_processed(pw: PrintWrapper, hk_data: bytes):
) )
] ]
current_idx += inc_len_vec current_idx += inc_len_vec
source = struct.unpack(
fmt_source, hk_data[current_idx : current_idx + inc_len_source]
)[0]
current_idx += inc_len_source
if GPS_COURCE_DICT.get(source) is not None:
pw.dlog(f"GPS Source: {GPS_COURCE_DICT[source]}")
else:
pw.dlog(f"'GPS Source (key unknown)': {source}")
pw.dlog(f"GPS Latitude: {lat} [deg]") pw.dlog(f"GPS Latitude: {lat} [deg]")
pw.dlog(f"GPS Longitude: {long} [deg]") pw.dlog(f"GPS Longitude: {long} [deg]")
pw.dlog(f"GPS Altitude: {alt} [m]") pw.dlog(f"GPS Altitude: {alt} [m]")
pw.dlog(f"GPS Position: {pos} [m]") pw.dlog(f"GPS Position: {pos} [m]")
pw.dlog(f"GPS Velocity: {velo} [m/s]") pw.dlog(f"GPS Velocity: {velo} [m/s]")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=6) pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=5)
def handle_mekf_data(pw: PrintWrapper, hk_data: bytes): def handle_mekf_data(pw: PrintWrapper, hk_data: bytes):
@ -1115,10 +1023,21 @@ def handle_mekf_data(pw: PrintWrapper, hk_data: bytes):
pw.dlog(f"{'MEKF Raw Status (key unknown)'.ljust(25)}: {status}") pw.dlog(f"{'MEKF Raw Status (key unknown)'.ljust(25)}: {status}")
pw.dlog(f"{'MEKF Quaternion'.ljust(25)}: {fmt_str_4.format(*quat)}") pw.dlog(f"{'MEKF Quaternion'.ljust(25)}: {fmt_str_4.format(*quat)}")
pw.dlog(f"{'MEKF Rotational Rate'.ljust(25)}: {fmt_str_3.format(*rates)}") pw.dlog(f"{'MEKF Rotational Rate'.ljust(25)}: {fmt_str_3.format(*rates)}")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=3) pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=3)
def handle_ctrl_val_data(pw: PrintWrapper, hk_data: bytes): def handle_ctrl_val_data(pw: PrintWrapper, hk_data: bytes):
safe_strat = {
0: "OFF",
1: "NO_MAG_FIELD_FOR_CONTROL",
2: "NO_SENSORS_FOR_CONTROL",
10: "ACTIVE_MEKF",
11: "WITHOUT_MEKF",
12: "ECLIPSE_DAMPING",
13: "ECLIPSE_IDELING",
20: "DETUMBLE_FULL",
21: "DETUMBLE_DETERIORATED",
}
pw.dlog("Received CTRL Values Set") pw.dlog("Received CTRL Values Set")
fmt_strat = "!B" fmt_strat = "!B"
fmt_quat = "!dddd" fmt_quat = "!dddd"
@ -1164,15 +1083,15 @@ def handle_ctrl_val_data(pw: PrintWrapper, hk_data: bytes):
) )
] ]
current_idx += inc_len_vec current_idx += inc_len_vec
if CTRL_STRAT_DICT.get(strat) is not None: if safe_strat.get(strat) is not None:
pw.dlog(f"{'Safe Ctrl Strategy'.ljust(25)}: {CTRL_STRAT_DICT[strat]}") pw.dlog(f"{'Safe Ctrl Strategy'.ljust(25)}: {safe_strat[strat]}")
else: else:
pw.dlog(f"{'Safe Ctrl Strategy (key unknown)'.ljust(25)}: {strat}") pw.dlog(f"{'Safe Ctrl Strategy (key unknown)'.ljust(25)}: {strat}")
pw.dlog(f"Control Values Target Quaternion: {tgt_quat}") pw.dlog(f"Control Values Target Quaternion: {tgt_quat}")
pw.dlog(f"Control Values Error Quaternion: {err_quat}") pw.dlog(f"Control Values Error Quaternion: {err_quat}")
pw.dlog(f"Control Values Error Angle: {err_ang} [deg]") pw.dlog(f"Control Values Error Angle: {err_ang} [deg]")
pw.dlog(f"Control Values Target Rotational Rate: {tgt_rot} [deg/s]") pw.dlog(f"Control Values Target Rotational Rate: {tgt_rot} [deg/s]")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=5) pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=5)
def handle_act_cmd_data(pw: PrintWrapper, hk_data: bytes): def handle_act_cmd_data(pw: PrintWrapper, hk_data: bytes):
@ -1211,47 +1130,10 @@ def handle_act_cmd_data(pw: PrintWrapper, hk_data: bytes):
pw.dlog(f"Actuator Commands RW Target Torque: {rw_tgt_torque}") pw.dlog(f"Actuator Commands RW Target Torque: {rw_tgt_torque}")
pw.dlog(f"Actuator Commands RW Target Speed: {rw_tgt_speed}") pw.dlog(f"Actuator Commands RW Target Speed: {rw_tgt_speed}")
pw.dlog(f"Actuator Commands MTQ Target Dipole: {mtq_tgt_dipole}") pw.dlog(f"Actuator Commands MTQ Target Dipole: {mtq_tgt_dipole}")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=3) pw.printer.print_validity_buffer(hk_data[current_idx:], num_vars=3)
def handle_fused_rot_rate_data(pw: PrintWrapper, hk_data: bytes): def perform_mgm_calibration(pw: PrintWrapper, mgm_tuple: Tuple):
pw.dlog("Received Fused Rotation Rates Data Set")
fmt_vec3_double = "!ddd"
inc_len_vec3_double = struct.calcsize(fmt_vec3_double)
if len(hk_data) < 3 * inc_len_vec3_double:
pw.dlog("Received HK set too small")
return
current_idx = 0
rot_rate_orthogonal = [
f"{val*180/math.pi:8.3f}"
for val in struct.unpack(
fmt_vec3_double, hk_data[current_idx : current_idx + inc_len_vec3_double]
)
]
current_idx += inc_len_vec3_double
rot_rate_parallel = [
f"{val*180/math.pi:8.3f}"
for val in struct.unpack(
fmt_vec3_double, hk_data[current_idx : current_idx + inc_len_vec3_double]
)
]
current_idx += inc_len_vec3_double
rot_rate_total = [
f"{val*180/math.pi:8.3f}"
for val in struct.unpack(
fmt_vec3_double, hk_data[current_idx : current_idx + inc_len_vec3_double]
)
]
current_idx += inc_len_vec3_double
pw.dlog(f"Fused Rotational Rate Orthogonal: {rot_rate_orthogonal} [deg/s]")
pw.dlog(f"Fused Rotational Rate Parallel: {rot_rate_parallel} [deg/s]")
pw.dlog(f"Fused Rotational Rate Total: {rot_rate_total} [deg/s]")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=3)
def perform_mgm_calibration( # noqa C901: Complexity okay
pw: PrintWrapper, mgm_tuple: Tuple
): # noqa C901: Complexity okay
global CALIBR_SOCKET, CALIBRATION_ADDR global CALIBR_SOCKET, CALIBRATION_ADDR
try: try:
declare_api_cmd = "declare_api_version 2" declare_api_cmd = "declare_api_version 2"
@ -1265,7 +1147,7 @@ def perform_mgm_calibration( # noqa C901: Complexity okay
return return
else: else:
if str(reply[0]) == "0": if str(reply[0]) == "0":
pw.dlog("MGM calibration: API version 2 was not accepted") pw.dlog(f"MGM calibration: API version 2 was not accepted")
return return
if len(mgm_tuple) != 3: if len(mgm_tuple) != 3:
pw.dlog(f"MGM tuple has invalid length {len(mgm_tuple)}") pw.dlog(f"MGM tuple has invalid length {len(mgm_tuple)}")
@ -1277,13 +1159,13 @@ def perform_mgm_calibration( # noqa C901: Complexity okay
reply = CALIBR_SOCKET.recv(1024) reply = CALIBR_SOCKET.recv(1024)
if len(reply) != 2: if len(reply) != 2:
pw.dlog( pw.dlog(
"MGM calibration: Reply received command magnetometer_field has" f"MGM calibration: Reply received command magnetometer_field has invalid "
f" invalid length {len(reply)}" f"length {len(reply)}"
) )
return return
else: else:
if str(reply[0]) == "0": if str(reply[0]) == "0":
pw.dlog("MGM calibration: magnetmeter field format was not accepted") pw.dlog(f"MGM calibration: magnetmeter field format was not accepted")
return return
pw.dlog(f"Sent data {mgm_list} to Helmholtz Testbench successfully") pw.dlog(f"Sent data {mgm_list} to Helmholtz Testbench successfully")
except socket.timeout: except socket.timeout:
@ -1291,6 +1173,6 @@ def perform_mgm_calibration( # noqa C901: Complexity okay
except BlockingIOError as e: except BlockingIOError as e:
pw.dlog(f"Error {e}") pw.dlog(f"Error {e}")
except ConnectionResetError as e: except ConnectionResetError as e:
pw.dlog(f"Socket was closed: {e}") pw.dlog("Socket was closed")
except ConnectionRefusedError or OSError: except ConnectionRefusedError or OSError:
pw.dlog("Connecting to Calibration Socket on addrss {} failed") pw.dlog("Connecting to Calibration Socket on addrss {} failed")

View File

@ -12,59 +12,45 @@ from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import ( from tmtccmd.tc.pus_3_fsfw_hk import (
make_sid, make_sid,
create_request_one_hk_command, create_request_one_hk_command,
create_enable_periodic_hk_command_with_interval_with_diag, create_enable_periodic_hk_command_with_interval,
create_disable_periodic_hk_command_with_diag, create_disable_periodic_hk_command,
) )
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class GpsInfo:
MAX_SATELLITES = 30
class OpCode: class OpCode:
OFF = "off" OFF = "off"
ON = "on" ON = "on"
REQ_CORE_HK = ["core_hk_request"] REQ_OS_HK = ["hk"]
ENABLE_CORE_HK = ["core_hk_enable"] ENABLE_HK = ["enable_hk"]
DISABLE_CORE_HK = ["core_hk_disable"] DISABLE_HK = ["disable_hk"]
REQ_SKYVIEW_HK = ["skyview_hk_request"]
ENABLE_SKYVIEW_HK = ["skyview_hk_enable"]
DISABLE_SKYVIEW_HK = ["skyview_hk_disable"]
RESET_GNSS = ["reset"] RESET_GNSS = ["reset"]
class Info: class Info:
OFF = "Off" OFF = "Off"
ON = "On" ON = "On"
REQ_CORE_HK = "Request Core HK" REQ_OS_HK = "Request One-Shot HK"
ENABLE_CORE_HK = "Enable Core HK" ENABLE_HK = "Enable HK"
DISABLE_CORE_HK = "Disable Core HK" DISABLE_HK = "Disable HK"
REQ_SKYVIEW_HK = "Request Skyview HK"
ENABLE_SKYVIEW_HK = "Enable Skyview HK"
DISABLE_SKYVIEW_HK = "Disable Skyview HK"
RESET_GNSS = "Reset GNSS using reset pin" RESET_GNSS = "Reset GNSS using reset pin"
class SetId(enum.IntEnum): class SetId(enum.IntEnum):
CORE_HK = 0 HK = 0
SKYVIEW_HK = 1
@tmtc_definitions_provider @tmtc_definitions_provider
def add_gps_cmds(defs: TmtcDefinitionWrapper): def add_gps_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry() oce = OpCodeEntry()
oce.add(keys=OpCode.RESET_GNSS, info=Info.RESET_GNSS)
oce.add(keys=OpCode.REQ_OS_HK, info=Info.REQ_OS_HK)
oce.add(keys=OpCode.ENABLE_HK, info=Info.ENABLE_HK)
oce.add(keys=OpCode.DISABLE_HK, info=Info.DISABLE_HK)
oce.add(keys=OpCode.OFF, info=Info.OFF) oce.add(keys=OpCode.OFF, info=Info.OFF)
oce.add(keys=OpCode.ON, info=Info.ON) oce.add(keys=OpCode.ON, info=Info.ON)
oce.add(keys=OpCode.RESET_GNSS, info=Info.RESET_GNSS)
oce.add(keys=OpCode.REQ_CORE_HK, info=Info.REQ_CORE_HK)
oce.add(keys=OpCode.ENABLE_CORE_HK, info=Info.ENABLE_CORE_HK)
oce.add(keys=OpCode.DISABLE_CORE_HK, info=Info.DISABLE_CORE_HK)
oce.add(keys=OpCode.REQ_SKYVIEW_HK, info=Info.REQ_SKYVIEW_HK)
oce.add(keys=OpCode.ENABLE_SKYVIEW_HK, info=Info.ENABLE_SKYVIEW_HK)
oce.add(keys=OpCode.DISABLE_SKYVIEW_HK, info=Info.DISABLE_SKYVIEW_HK)
defs.add_service( defs.add_service(
name=CustomServiceList.GPS_CTRL.value, name=CustomServiceList.GPS_CTRL.value,
info="GPS/GNSS Controller", info="GPS/GNSS Controller",
@ -72,64 +58,27 @@ def add_gps_cmds(defs: TmtcDefinitionWrapper):
) )
def pack_gps_command( # noqa: C901 def pack_gps_command(object_id: bytes, q: DefaultPusQueueHelper, op_code: str):
object_id: bytes, q: DefaultPusQueueHelper, op_code: str sid = make_sid(object_id=object_id, set_id=SetId.HK)
): # noqa: C901:
if op_code in OpCode.RESET_GNSS: if op_code in OpCode.RESET_GNSS:
# TODO: This needs to be re-implemented # TODO: This needs to be re-implemented
_LOGGER.warning("Reset pin handling needs to be re-implemented") _LOGGER.warning("Reset pin handling needs to be re-implemented")
if op_code in OpCode.ENABLE_CORE_HK: if op_code in OpCode.ENABLE_HK:
interval = float(input("Please specify interval in floating point seconds: ")) interval = float(input("Please specify interval in floating point seconds: "))
if interval <= 0: if interval <= 0:
raise ValueError("invalid interval") raise ValueError("invalid interval")
q.add_log_cmd(f"GPS: {Info.ENABLE_CORE_HK}") q.add_log_cmd(f"GPS: {Info.ENABLE_HK}")
cmds = create_enable_periodic_hk_command_with_interval_with_diag( cmds = create_enable_periodic_hk_command_with_interval(
diag=False, diag=False, sid=sid, interval_seconds=interval
sid=make_sid(object_id=object_id, set_id=SetId.CORE_HK),
interval_seconds=interval,
) )
for cmd in cmds: for cmd in cmds:
q.add_pus_tc(cmd) q.add_pus_tc(cmd)
if op_code in OpCode.DISABLE_CORE_HK: if op_code in OpCode.DISABLE_HK:
q.add_log_cmd(f"gps: {Info.DISABLE_CORE_HK}") q.add_log_cmd(f"gps: {Info.DISABLE_HK}")
q.add_pus_tc( q.add_pus_tc(create_disable_periodic_hk_command(diag=False, sid=sid))
create_disable_periodic_hk_command_with_diag( if op_code in OpCode.REQ_OS_HK:
diag=False, sid=make_sid(object_id=object_id, set_id=SetId.CORE_HK) q.add_log_cmd(f"GPS: {Info.REQ_OS_HK}")
) q.add_pus_tc(create_request_one_hk_command(sid=sid))
)
if op_code in OpCode.REQ_CORE_HK:
q.add_log_cmd(f"GPS: {Info.REQ_CORE_HK}")
q.add_pus_tc(
create_request_one_hk_command(
sid=make_sid(object_id=object_id, set_id=SetId.CORE_HK)
)
)
if op_code in OpCode.ENABLE_SKYVIEW_HK:
interval = float(input("Please specify interval in floating point seconds: "))
if interval <= 0:
raise ValueError("invalid interval")
q.add_log_cmd(f"GPS: {Info.ENABLE_SKYVIEW_HK}")
cmds = create_enable_periodic_hk_command_with_interval_with_diag(
diag=False,
sid=make_sid(object_id=object_id, set_id=SetId.SKYVIEW_HK),
interval_seconds=interval,
)
for cmd in cmds:
q.add_pus_tc(cmd)
if op_code in OpCode.DISABLE_SKYVIEW_HK:
q.add_log_cmd(f"gps: {Info.DISABLE_SKYVIEW_HK}")
q.add_pus_tc(
create_disable_periodic_hk_command_with_diag(
diag=False, sid=make_sid(object_id=object_id, set_id=SetId.SKYVIEW_HK)
)
)
if op_code in OpCode.REQ_SKYVIEW_HK:
q.add_log_cmd(f"GPS: {Info.REQ_SKYVIEW_HK}")
q.add_pus_tc(
create_request_one_hk_command(
sid=make_sid(object_id=object_id, set_id=SetId.SKYVIEW_HK)
)
)
if op_code in OpCode.ON: if op_code in OpCode.ON:
q.add_log_cmd(f"GPS: {Info.ON}") q.add_log_cmd(f"GPS: {Info.ON}")
q.add_pus_tc(create_mode_command(object_id, Mode.ON, 0)) q.add_pus_tc(create_mode_command(object_id, Mode.ON, 0))
@ -138,27 +87,9 @@ def pack_gps_command( # noqa: C901
q.add_pus_tc(create_mode_command(object_id, Mode.OFF, 0)) q.add_pus_tc(create_mode_command(object_id, Mode.OFF, 0))
def handle_gps_data( def handle_gps_data(printer: FsfwTmTcPrinter, hk_data: bytes):
pw: PrintWrapper, pw = PrintWrapper(printer)
set_id: int, pw.dlog(f"Received GPS data, HK data length {len(hk_data)}")
hk_data: bytes,
packet_time: datetime.datetime,
):
pw.ilog(_LOGGER, f"Received GPS CTRL HK with packet time {packet_time}")
match set_id:
case SetId.CORE_HK:
handle_core_data(pw, hk_data)
case SetId.SKYVIEW_HK:
handle_skyview_data(pw, hk_data)
def handle_core_data(pw: PrintWrapper, hk_data: bytes):
if len(hk_data) < 4 * 8 + 4 + 2 + 8:
pw.dlog(
f"GPS Core dataset with size {len(hk_data)} does not have expected size"
f" of {4*8+4+2+8} bytes"
)
return
current_idx = 0 current_idx = 0
fmt_str = "!ddddBBBHBBBBBI" fmt_str = "!ddddBBBHBBBBBI"
inc_len = struct.calcsize(fmt_str) inc_len = struct.calcsize(fmt_str)
@ -193,68 +124,4 @@ def handle_core_data(pw: PrintWrapper, hk_data: bytes):
) )
pw.dlog(f"GNSS Date: {date_string}") pw.dlog(f"GNSS Date: {date_string}")
pw.dlog(f"Unix seconds {unix_seconds}") pw.dlog(f"Unix seconds {unix_seconds}")
FsfwTmTcPrinter.get_validity_buffer( printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=14)
validity_buffer=hk_data[current_idx:], num_vars=14
)
def handle_skyview_data(pw: PrintWrapper, hk_data: bytes):
data_length = 8 + GpsInfo.MAX_SATELLITES * (8 + 3 * 2 + 1)
if len(hk_data) < data_length:
pw.dlog(
f"GPS Skyview dataset with size {len(hk_data)} does not have expected size"
f" of {data_length} bytes"
)
return
current_idx = 0
fmt_str_unix = "!d"
fmt_str_int16 = "!" + "h" * GpsInfo.MAX_SATELLITES
fmt_str_double = "!" + "d" * GpsInfo.MAX_SATELLITES
fmt_str_uint8 = "!" + "B" * GpsInfo.MAX_SATELLITES
inc_len_unix = struct.calcsize(fmt_str_unix)
inc_len_int16 = struct.calcsize(fmt_str_int16)
inc_len_double = struct.calcsize(fmt_str_double)
inc_len_uint8 = struct.calcsize(fmt_str_uint8)
unix = struct.unpack(
fmt_str_unix, hk_data[current_idx : current_idx + inc_len_unix]
)[0]
current_idx += inc_len_unix
prn_id = struct.unpack(
fmt_str_int16, hk_data[current_idx : current_idx + inc_len_int16]
)
current_idx += inc_len_int16
azimuth = struct.unpack(
fmt_str_int16, hk_data[current_idx : current_idx + inc_len_int16]
)
current_idx += inc_len_int16
elevation = struct.unpack(
fmt_str_int16, hk_data[current_idx : current_idx + inc_len_int16]
)
current_idx += inc_len_int16
signal_to_noise = struct.unpack(
fmt_str_double, hk_data[current_idx : current_idx + inc_len_double]
)
current_idx += inc_len_double
used = struct.unpack(
fmt_str_uint8, hk_data[current_idx : current_idx + inc_len_uint8]
)
current_idx += inc_len_uint8
pw.dlog(f"Skyview Time: {unix} unix-sec")
pw.dlog(
"{:<8} {:<8} {:<8} {:<8} {:<8}".format(
"PRN_ID", "AZ [°]", "EL [°]", "S2N [dBHz]", "USED"
)
)
for idx in range(GpsInfo.MAX_SATELLITES):
pw.dlog(
"{:<8} {:<8} {:<8} {:<8} {:<8}".format(
prn_id[idx],
azimuth[idx],
elevation[idx],
signal_to_noise[idx],
used[idx],
)
)
FsfwTmTcPrinter.get_validity_buffer(
validity_buffer=hk_data[current_idx:], num_vars=6
)

View File

@ -25,6 +25,7 @@ from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.pus_tm.defs import PrintWrapper from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.util import ObjectIdU32 from tmtccmd.util import ObjectIdU32
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class OpCode: class OpCode:
@ -61,7 +62,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)]
@ -106,24 +107,29 @@ def handle_gyr_cmd(q: DefaultPusQueueHelper, op_code: str):
def handle_gyros_hk_data( def handle_gyros_hk_data(
object_id: ObjectIdU32, pw: PrintWrapper, set_id: int, hk_data: bytes object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
): ):
if object_id.as_bytes in [ if object_id.as_bytes in [
obj_ids.GYRO_0_ADIS_HANDLER_ID, obj_ids.GYRO_0_ADIS_HANDLER_ID,
obj_ids.GYRO_2_ADIS_HANDLER_ID, obj_ids.GYRO_2_ADIS_HANDLER_ID,
]: ]:
handle_adis_gyro_hk(object_id=object_id, pw=pw, set_id=set_id, hk_data=hk_data) handle_adis_gyro_hk(
object_id=object_id, printer=printer, set_id=set_id, hk_data=hk_data
)
elif object_id.as_bytes in [ elif object_id.as_bytes in [
obj_ids.GYRO_1_L3G_HANDLER_ID, obj_ids.GYRO_1_L3G_HANDLER_ID,
obj_ids.GYRO_3_L3G_HANDLER_ID, obj_ids.GYRO_3_L3G_HANDLER_ID,
]: ]:
handle_l3g_gyro_hk(object_id=object_id, pw=pw, set_id=set_id, hk_data=hk_data) handle_l3g_gyro_hk(
object_id=object_id, printer=printer, set_id=set_id, hk_data=hk_data
)
def handle_adis_gyro_hk( def handle_adis_gyro_hk(
object_id: ObjectIdU32, pw: PrintWrapper, set_id: int, hk_data: bytes object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
): ):
if set_id == AdisGyroSetId.CORE_HK: if set_id == AdisGyroSetId.CORE_HK:
pw = PrintWrapper(printer)
fmt_str = "!ddddddf" fmt_str = "!ddddddf"
inc_len = struct.calcsize(fmt_str) inc_len = struct.calcsize(fmt_str)
( (
@ -143,6 +149,7 @@ def handle_adis_gyro_hk(
pw.dlog(f"Acceleration (m/s^2): X {accel_x} | Y {accel_y} | Z {accel_z}") pw.dlog(f"Acceleration (m/s^2): X {accel_x} | Y {accel_y} | Z {accel_z}")
pw.dlog(f"Temperature {temp} C") pw.dlog(f"Temperature {temp} C")
if set_id == AdisGyroSetId.CFG_HK: if set_id == AdisGyroSetId.CFG_HK:
pw = PrintWrapper(printer)
fmt_str = "!HBHHH" fmt_str = "!HBHHH"
inc_len = struct.calcsize(fmt_str) inc_len = struct.calcsize(fmt_str)
print(len(hk_data)) print(len(hk_data))
@ -161,9 +168,10 @@ def handle_adis_gyro_hk(
def handle_l3g_gyro_hk( def handle_l3g_gyro_hk(
object_id: ObjectIdU32, pw: PrintWrapper, set_id: int, hk_data: bytes object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
): ):
if set_id == L3gGyroSetId.CORE_HK: if set_id == L3gGyroSetId.CORE_HK:
pw = PrintWrapper(printer)
fmt_str = "!ffff" fmt_str = "!ffff"
inc_len = struct.calcsize(fmt_str) inc_len = struct.calcsize(fmt_str)
(angVelocX, angVelocY, angVelocZ, temp) = struct.unpack( (angVelocX, angVelocY, angVelocZ, temp) = struct.unpack(

View File

@ -24,12 +24,13 @@ from tmtccmd.tc.pus_3_fsfw_hk import (
generate_one_diag_command, generate_one_diag_command,
generate_one_hk_command, generate_one_hk_command,
create_request_one_diag_command, create_request_one_diag_command,
create_enable_periodic_hk_command_with_interval_with_diag, create_enable_periodic_hk_command,
create_disable_periodic_hk_command_with_diag, create_disable_periodic_hk_command,
create_enable_periodic_hk_command_with_interval,
) )
from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode
from tmtccmd.util import ObjectIdU32 from tmtccmd.util import ObjectIdU32
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -128,9 +129,7 @@ def add_imtq_cmds(defs: TmtcDefinitionWrapper):
defs.add_service(CustomServiceList.IMTQ.value, "IMQT Device", oce) defs.add_service(CustomServiceList.IMTQ.value, "IMQT Device", oce)
def pack_imtq_test_into( # noqa C901 def pack_imtq_test_into(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str):
object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
):
q.add_log_cmd( q.add_log_cmd(
f"Testing ISIS IMTQ handler with object id: {object_id.as_hex_string}" f"Testing ISIS IMTQ handler with object id: {object_id.as_hex_string}"
) )
@ -227,13 +226,12 @@ def pack_imtq_test_into( # noqa C901
duration = int( duration = int(
input( input(
f"Specify torque duration [range [0, {pow(2, 16) - 1}, " f"Specify torque duration [range [0, {pow(2, 16) - 1}, "
"0 for continuous generation until update]: " f"0 for continuous generation until update]: "
) )
) )
dur_str = "infinite" if duration == 0 else str(duration) dur_str = "infinite" if duration == 0 else str(duration)
q.add_log_cmd( q.add_log_cmd(
f"IMTQ: Commanding dipole X={x_dipole}, Y={y_dipole}, Z={y_dipole}," f"IMTQ: Commanding dipole X={x_dipole}, Y={y_dipole}, Z={y_dipole}, duration={dur_str}"
f" duration={dur_str}"
) )
q.add_pus_tc( q.add_pus_tc(
pack_dipole_command( pack_dipole_command(
@ -249,7 +247,7 @@ def pack_imtq_test_into( # noqa C901
if op_code == OpCode.ENABLE_ENG_HK_NO_TORQUE: if op_code == OpCode.ENABLE_ENG_HK_NO_TORQUE:
q.add_log_cmd("IMTQ: Enable ENG HK") q.add_log_cmd("IMTQ: Enable ENG HK")
interval = float(input("Please enter collection interval in seconds: ")) interval = float(input("Please enter collection interval in seconds: "))
cmds = create_enable_periodic_hk_command_with_interval_with_diag( cmds = create_enable_periodic_hk_command_with_interval(
diag=True, diag=True,
sid=make_sid(object_id.as_bytes, ImtqSetId.ENG_HK_NO_TORQUE), sid=make_sid(object_id.as_bytes, ImtqSetId.ENG_HK_NO_TORQUE),
interval_seconds=interval, interval_seconds=interval,
@ -259,7 +257,7 @@ def pack_imtq_test_into( # noqa C901
if op_code == OpCode.DISABLE_ENG_HK_NO_TORQUE: if op_code == OpCode.DISABLE_ENG_HK_NO_TORQUE:
q.add_log_cmd("IMTQ: Disable ENG HK (No Torque)") q.add_log_cmd("IMTQ: Disable ENG HK (No Torque)")
q.add_pus_tc( q.add_pus_tc(
create_disable_periodic_hk_command_with_diag( create_disable_periodic_hk_command(
True, make_sid(object_id.as_bytes, ImtqSetId.ENG_HK_NO_TORQUE) True, make_sid(object_id.as_bytes, ImtqSetId.ENG_HK_NO_TORQUE)
) )
) )
@ -276,7 +274,7 @@ def pack_imtq_test_into( # noqa C901
if op_code == OpCode.ENABLE_ENG_HK_WITH_TORQUE: if op_code == OpCode.ENABLE_ENG_HK_WITH_TORQUE:
q.add_log_cmd("IMTQ: Enable ENG HK with torque") q.add_log_cmd("IMTQ: Enable ENG HK with torque")
interval = float(input("Please enter collection interval in seconds: ")) interval = float(input("Please enter collection interval in seconds: "))
cmds = create_enable_periodic_hk_command_with_interval_with_diag( cmds = create_enable_periodic_hk_command_with_interval(
diag=True, diag=True,
sid=make_sid(object_id.as_bytes, ImtqSetId.ENG_HK_SET_WITH_TORQUE), sid=make_sid(object_id.as_bytes, ImtqSetId.ENG_HK_SET_WITH_TORQUE),
interval_seconds=interval, interval_seconds=interval,
@ -286,7 +284,7 @@ def pack_imtq_test_into( # noqa C901
if op_code == OpCode.DISABLE_ENG_HK_WITH_TORQUE: if op_code == OpCode.DISABLE_ENG_HK_WITH_TORQUE:
q.add_log_cmd("IMTQ: Disable ENG HK with Torque") q.add_log_cmd("IMTQ: Disable ENG HK with Torque")
q.add_pus_tc( q.add_pus_tc(
create_disable_periodic_hk_command_with_diag( create_disable_periodic_hk_command(
True, make_sid(object_id.as_bytes, ImtqSetId.ENG_HK_SET_WITH_TORQUE) True, make_sid(object_id.as_bytes, ImtqSetId.ENG_HK_SET_WITH_TORQUE)
) )
) )
@ -321,14 +319,14 @@ def pack_imtq_test_into( # noqa C901
if op_code == OpCode.DISABLE_MGM_RAW_NO_TORQUE: if op_code == OpCode.DISABLE_MGM_RAW_NO_TORQUE:
q.add_log_cmd("IMTQ: Disable MGM RAW HK (No Torque)") q.add_log_cmd("IMTQ: Disable MGM RAW HK (No Torque)")
q.add_pus_tc( q.add_pus_tc(
create_disable_periodic_hk_command_with_diag( create_disable_periodic_hk_command(
True, make_sid(object_id.as_bytes, ImtqSetId.RAW_MTM_NO_TORQUE) True, make_sid(object_id.as_bytes, ImtqSetId.RAW_MTM_NO_TORQUE)
) )
) )
if op_code == OpCode.ENABLE_MGM_RAW_NO_TORQUE: if op_code == OpCode.ENABLE_MGM_RAW_NO_TORQUE:
q.add_log_cmd("IMTQ: Enable MGM RAW HK (No Torque)") q.add_log_cmd("IMTQ: Enable MGM RAW HK (No Torque)")
interval = float(input("Please enter collection interval in seconds: ")) interval = float(input("Please enter collection interval in seconds: "))
cmds = create_enable_periodic_hk_command_with_interval_with_diag( cmds = create_enable_periodic_hk_command_with_interval(
diag=True, diag=True,
sid=make_sid(object_id.as_bytes, ImtqSetId.RAW_MTM_NO_TORQUE), sid=make_sid(object_id.as_bytes, ImtqSetId.RAW_MTM_NO_TORQUE),
interval_seconds=interval, interval_seconds=interval,
@ -347,7 +345,7 @@ def pack_imtq_test_into( # noqa C901
if op_code == OpCode.ENABLE_MGM_RAW_WITH_TORQUE: if op_code == OpCode.ENABLE_MGM_RAW_WITH_TORQUE:
q.add_log_cmd("IMTQ: Enable MGM RAW HK (No Torque)") q.add_log_cmd("IMTQ: Enable MGM RAW HK (No Torque)")
interval = float(input("Please enter collection interval in seconds: ")) interval = float(input("Please enter collection interval in seconds: "))
cmds = create_enable_periodic_hk_command_with_interval_with_diag( cmds = create_enable_periodic_hk_command_with_interval(
diag=True, diag=True,
sid=make_sid(object_id.as_bytes, ImtqSetId.RAW_MTM_WITH_TORQUE), sid=make_sid(object_id.as_bytes, ImtqSetId.RAW_MTM_WITH_TORQUE),
interval_seconds=interval, interval_seconds=interval,
@ -357,7 +355,7 @@ def pack_imtq_test_into( # noqa C901
if op_code == OpCode.DISABLE_MGM_RAW_WITH_TORQUE: if op_code == OpCode.DISABLE_MGM_RAW_WITH_TORQUE:
q.add_log_cmd("IMTQ: Disable MGM RAW HK (No Torque)") q.add_log_cmd("IMTQ: Disable MGM RAW HK (No Torque)")
q.add_pus_tc( q.add_pus_tc(
create_disable_periodic_hk_command_with_diag( create_disable_periodic_hk_command(
True, make_sid(object_id.as_bytes, ImtqSetId.RAW_MTM_WITH_TORQUE) True, make_sid(object_id.as_bytes, ImtqSetId.RAW_MTM_WITH_TORQUE)
) )
) )
@ -389,8 +387,7 @@ def pack_dipole_command(
duration = int(round(duration)) duration = int(round(duration))
if duration < 0 or duration > pow(2, 16) - 1: if duration < 0 or duration > pow(2, 16) - 1:
raise ValueError( raise ValueError(
f"Duration in ms of {duration} smaller than 0 or larger than allowed" f"Duration in ms of {duration} smaller than 0 or larger than allowed {pow(2, 16) - 1}"
f" {pow(2, 16) - 1}"
) )
command += struct.pack("!h", x_dipole) command += struct.pack("!h", x_dipole)
command += struct.pack("!h", y_dipole) command += struct.pack("!h", y_dipole)
@ -402,8 +399,7 @@ def pack_dipole_command(
def raise_dipole_error(dipole_str: str, value: int): def raise_dipole_error(dipole_str: str, value: int):
raise ValueError( raise ValueError(
f"{dipole_str} {value} negative or larger than maximum allowed 2000 *" f"{dipole_str} {value} negative or larger than maximum allowed 2000 * 10^-4*Am^2"
" 10^-4*Am^2"
) )
@ -430,27 +426,26 @@ ENG_HK_HEADERS = [
] ]
def handle_imtq_hk(pw: PrintWrapper, hk_data: bytes, set_id: int): def handle_imtq_hk(printer: FsfwTmTcPrinter, hk_data: bytes, set_id: int):
if (set_id >= ImtqSetId.POSITIVE_X_TEST) and (set_id <= ImtqSetId.NEGATIVE_Z_TEST): if (set_id >= ImtqSetId.POSITIVE_X_TEST) and (set_id <= ImtqSetId.NEGATIVE_Z_TEST):
return handle_self_test_data(pw, hk_data) return handle_self_test_data(printer, hk_data)
elif set_id == ImtqSetId.ENG_HK_NO_TORQUE: elif set_id == ImtqSetId.ENG_HK_NO_TORQUE:
return handle_eng_set(pw, hk_data, False) return handle_eng_set(printer, hk_data, False)
elif set_id == ImtqSetId.ENG_HK_SET_WITH_TORQUE: elif set_id == ImtqSetId.ENG_HK_SET_WITH_TORQUE:
return handle_eng_set(pw, hk_data, True) return handle_eng_set(printer, hk_data, True)
elif set_id == ImtqSetId.CAL_MTM_SET: elif set_id == ImtqSetId.CAL_MTM_SET:
return handle_calibrated_mtm_measurement(pw, hk_data) return handle_calibrated_mtm_measurement(printer, hk_data)
elif set_id == ImtqSetId.RAW_MTM_NO_TORQUE: elif set_id == ImtqSetId.RAW_MTM_NO_TORQUE:
return handle_raw_mtm_measurement(pw, hk_data, False) return handle_raw_mtm_measurement(printer, hk_data, False)
elif set_id == ImtqSetId.RAW_MTM_WITH_TORQUE: elif set_id == ImtqSetId.RAW_MTM_WITH_TORQUE:
return handle_raw_mtm_measurement(pw, hk_data, True) return handle_raw_mtm_measurement(printer, hk_data, True)
elif set_id == ImtqSetId.DIPOLES: elif set_id == ImtqSetId.DIPOLES:
return handle_dipole_set(pw, hk_data) return handle_dipole_set(printer, hk_data)
elif set_id == ImtqSetId.STATUS_SET: elif set_id == ImtqSetId.STATUS_SET:
return handle_status_set(pw, hk_data) return handle_status_set(printer, hk_data)
else: else:
pw.wlog( _LOGGER.warning(
_LOGGER, f"IMTQ handler HK reply with unknown or unimplemented set id {set_id}"
f"IMTQ handler HK reply with unknown or unimplemented set id {set_id}",
) )
@ -462,7 +457,8 @@ def unpack_status_set(hk_data: bytes) -> List:
return [status_mode, status_error, status_conf, status_uptime] return [status_mode, status_error, status_conf, status_uptime]
def handle_dipole_set(pw: PrintWrapper, hk_data: bytes): def handle_dipole_set(printer: FsfwTmTcPrinter, hk_data: bytes):
pw = PrintWrapper(printer)
pw.dlog("Received iMTQ dipole set") pw.dlog("Received iMTQ dipole set")
fmt_str = "!hhhH" fmt_str = "!hhhH"
fmt_len = struct.calcsize(fmt_str) fmt_len = struct.calcsize(fmt_str)
@ -473,7 +469,7 @@ def handle_dipole_set(pw: PrintWrapper, hk_data: bytes):
pw.dlog(f"Dipole Y: {dipole_y}") pw.dlog(f"Dipole Y: {dipole_y}")
pw.dlog(f"Dipole Z: {dipole_z}") pw.dlog(f"Dipole Z: {dipole_z}")
pw.dlog(f"Current torque duration: {current_torque_duration}") pw.dlog(f"Current torque duration: {current_torque_duration}")
FsfwTmTcPrinter.get_validity_buffer(hk_data[fmt_len:], 2) pw.printer.print_validity_buffer(hk_data[fmt_len:], 2)
def unpack_eng_hk(hk_data: bytes) -> List: def unpack_eng_hk(hk_data: bytes) -> List:
@ -504,7 +500,8 @@ def unpack_eng_hk(hk_data: bytes) -> List:
return content_list return content_list
def handle_eng_set(pw: PrintWrapper, hk_data: bytes, torque_on: bool): def handle_eng_set(printer: FsfwTmTcPrinter, hk_data: bytes, torque_on: bool):
pw = PrintWrapper(printer)
pw.dlog(f"Found engineering HK. Torque Status: {torque_on}") pw.dlog(f"Found engineering HK. Torque Status: {torque_on}")
content_list = unpack_eng_hk(hk_data) content_list = unpack_eng_hk(hk_data)
validity_buffer = hk_data[32:] validity_buffer = hk_data[32:]
@ -512,28 +509,22 @@ def handle_eng_set(pw: PrintWrapper, hk_data: bytes, torque_on: bool):
num_of_vars = len(ENG_HK_HEADERS) num_of_vars = len(ENG_HK_HEADERS)
for k, v in zip(ENG_HK_HEADERS, content_list): for k, v in zip(ENG_HK_HEADERS, content_list):
pw.dlog(f"{k.ljust(30)}: {v}") pw.dlog(f"{k.ljust(30)}: {v}")
pw.dlog( printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=num_of_vars)
FsfwTmTcPrinter.get_validity_buffer(
validity_buffer=validity_buffer, num_vars=num_of_vars
)
)
def handle_status_set(pw: PrintWrapper, hk_data: bytes): def handle_status_set(printer: FsfwTmTcPrinter, hk_data: bytes):
pw = PrintWrapper(printer)
content_list = unpack_status_set(hk_data) content_list = unpack_status_set(hk_data)
validity_buffer = hk_data[7:] validity_buffer = hk_data[7:]
num_of_vars = 4 num_of_vars = 4
for k, v in zip(STATUS_HEADERS, content_list): for k, v in zip(STATUS_HEADERS, content_list):
pw.dlog(f"{k.ljust(30)}: {v}") pw.dlog(f"{k.ljust(30)}: {v}")
pw.dlog( printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=num_of_vars)
FsfwTmTcPrinter.get_validity_buffer(
validity_buffer=validity_buffer, num_vars=num_of_vars
)
)
def handle_calibrated_mtm_measurement(pw: PrintWrapper, hk_data: bytes): def handle_calibrated_mtm_measurement(printer: FsfwTmTcPrinter, hk_data: bytes):
pw = PrintWrapper(printer)
header_list = [ header_list = [
"Calibrated MTM X [nT]", "Calibrated MTM X [nT]",
"Calibrated MTM Y [nT]", "Calibrated MTM Y [nT]",
@ -549,14 +540,13 @@ def handle_calibrated_mtm_measurement(pw: PrintWrapper, hk_data: bytes):
num_of_vars = len(header_list) num_of_vars = len(header_list)
pw.dlog(str(header_list)) pw.dlog(str(header_list))
pw.dlog(str(content_list)) pw.dlog(str(content_list))
pw.dlog( printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=num_of_vars)
FsfwTmTcPrinter.get_validity_buffer(
validity_buffer=validity_buffer, num_vars=num_of_vars
)
)
def handle_raw_mtm_measurement(pw: PrintWrapper, hk_data: bytes, torque_status: bool): def handle_raw_mtm_measurement(
printer: FsfwTmTcPrinter, hk_data: bytes, torque_status: bool
):
pw = PrintWrapper(printer)
pw.dlog(f"Found raw MTM measurement. Torque Status: {torque_status}") pw.dlog(f"Found raw MTM measurement. Torque Status: {torque_status}")
header_list = [ header_list = [
"Raw MTM X [nT]", "Raw MTM X [nT]",
@ -573,14 +563,11 @@ def handle_raw_mtm_measurement(pw: PrintWrapper, hk_data: bytes, torque_status:
num_of_vars = 2 num_of_vars = 2
pw.dlog(str(header_list)) pw.dlog(str(header_list))
pw.dlog(str(content_list)) pw.dlog(str(content_list))
pw.dlog( printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=num_of_vars)
FsfwTmTcPrinter.get_validity_buffer(
validity_buffer=validity_buffer, num_vars=num_of_vars
)
)
def handle_self_test_data(pw: PrintWrapper, hk_data: bytes): def handle_self_test_data(printer: FsfwTmTcPrinter, hk_data: bytes):
pw = PrintWrapper(printer)
header_list = [ header_list = [
"Init Err", "Init Err",
"Init Raw Mag X [nT]", "Init Raw Mag X [nT]",
@ -684,7 +671,7 @@ def handle_self_test_data(pw: PrintWrapper, hk_data: bytes):
init_coil_z_temperature, init_coil_z_temperature,
err, err,
raw_mag_x, raw_mag_x,
raw_mag_y, init_raw_mag_y,
raw_mag_z, raw_mag_z,
cal_mag_x, cal_mag_x,
cal_mag_y, cal_mag_y,
@ -712,8 +699,4 @@ def handle_self_test_data(pw: PrintWrapper, hk_data: bytes):
num_of_vars = len(header_list) num_of_vars = len(header_list)
pw.dlog(str(header_list)) pw.dlog(str(header_list))
pw.dlog(str(content_list)) pw.dlog(str(content_list))
pw.dlog( printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=num_of_vars)
FsfwTmTcPrinter.get_validity_buffer(
validity_buffer=validity_buffer, num_vars=num_of_vars
)
)

View File

@ -17,6 +17,7 @@ from tmtccmd.config.tmtc import tmtc_definitions_provider, TmtcDefinitionWrapper
from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_200_fsfw_mode import create_mode_command, Mode from tmtccmd.tc.pus_200_fsfw_mode import create_mode_command, Mode
from tmtccmd.util import ObjectIdU32 from tmtccmd.util import ObjectIdU32
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class OpCode: class OpCode:
@ -49,7 +50,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)]
@ -63,25 +64,26 @@ def handle_mgm_cmd(q: DefaultPusQueueHelper, op_code: str):
def handle_mgm_hk_data( def handle_mgm_hk_data(
object_id: ObjectIdU32, pw: PrintWrapper, set_id: int, hk_data: bytes object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
): ):
if object_id.as_bytes in [ if object_id.as_bytes in [
obj_ids.MGM_0_LIS3_HANDLER_ID, obj_ids.MGM_0_LIS3_HANDLER_ID,
obj_ids.MGM_2_LIS3_HANDLER_ID, obj_ids.MGM_2_LIS3_HANDLER_ID,
]: ]:
handle_mgm_lis3_hk_data(object_id, pw, set_id, hk_data) handle_mgm_lis3_hk_data(object_id, printer, set_id, hk_data)
elif object_id.as_bytes in [ elif object_id.as_bytes in [
obj_ids.MGM_1_RM3100_HANDLER_ID, obj_ids.MGM_1_RM3100_HANDLER_ID,
obj_ids.MGM_3_RM3100_HANDLER_ID, obj_ids.MGM_3_RM3100_HANDLER_ID,
]: ]:
handle_mgm_rm3100_hk_data(object_id, pw, set_id, hk_data) handle_mgm_rm3100_hk_data(object_id, printer, set_id, hk_data)
pass pass
def handle_mgm_lis3_hk_data( def handle_mgm_lis3_hk_data(
object_id: ObjectIdU32, pw: PrintWrapper, set_id: int, hk_data: bytes object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
): ):
if set_id == MgmLis3SetId.CORE_HK: if set_id == MgmLis3SetId.CORE_HK:
pw = PrintWrapper(printer)
fmt_str = "!ffff" fmt_str = "!ffff"
inc_len = struct.calcsize(fmt_str) inc_len = struct.calcsize(fmt_str)
(field_x, field_y, field_z, temp) = struct.unpack( (field_x, field_y, field_z, temp) = struct.unpack(
@ -95,10 +97,11 @@ def handle_mgm_lis3_hk_data(
def handle_mgm_rm3100_hk_data( def handle_mgm_rm3100_hk_data(
object_id: ObjectIdU32, pw: PrintWrapper, set_id: int, hk_data: bytes object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
): ):
if set_id == MgmRm3100SetId.CORE_HK: if set_id == MgmRm3100SetId.CORE_HK:
fmt_str = "!fff" pw = PrintWrapper(printer)
fmt_str = f"!fff"
inc_len = struct.calcsize(fmt_str) inc_len = struct.calcsize(fmt_str)
(field_x, field_y, field_z) = struct.unpack(fmt_str, hk_data[0 : 0 + inc_len]) (field_x, field_y, field_z) = struct.unpack(fmt_str, hk_data[0 : 0 + inc_len])
pw.dlog(f"Received MGM RM3100 from object {object_id}") pw.dlog(f"Received MGM RM3100 from object {object_id}")

View File

@ -25,7 +25,7 @@ from spacepackets.ecss.tc import PusTelecommand
from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode, Subservice from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode, Subservice
from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.definitions import CustomServiceList
from tmtccmd.util import ObjectIdU32 from tmtccmd.util import ObjectIdU32
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class OpCodesDev: class OpCodesDev:
@ -144,7 +144,7 @@ def add_rw_cmds(defs: TmtcDefinitionWrapper):
) )
def pack_single_rw_test_into( # noqa C901: Complexity is okay here. def pack_single_rw_test_into(
object_id: bytes, rw_idx: int, q: DefaultPusQueueHelper, op_code: str object_id: bytes, rw_idx: int, q: DefaultPusQueueHelper, op_code: str
): ):
if op_code == OpCodesDev.SPEED: if op_code == OpCodesDev.SPEED:
@ -261,12 +261,14 @@ def pack_set_speed_command(
if speed > 0: if speed > 0:
if speed < 1000 or speed > 65000: if speed < 1000 or speed > 65000:
raise ValueError( raise ValueError(
"Invalid RW speed specified. Allowed range is [1000, 65000] 0.1 * RPM" "Invalid RW speed specified. "
"Allowed range is [1000, 65000] 0.1 * RPM"
) )
elif speed < 0: elif speed < 0:
if speed < -65000 or speed > -1000: if speed < -65000 or speed > -1000:
raise ValueError( raise ValueError(
"Invalid RW speed specified. Allowed range is [-65000, -1000] 0.1 * RPM" "Invalid RW speed specified. "
"Allowed range is [-65000, -1000] 0.1 * RPM"
) )
else: else:
# Speed is 0 # Speed is 0
@ -286,8 +288,10 @@ 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 printer: FsfwTmTcPrinter, object_id: ObjectIdU32, set_id: int, hk_data: bytes
): ):
pw = PrintWrapper(printer)
current_idx = 0 current_idx = 0
if set_id == RwSetId.STATUS_SET_ID: if set_id == RwSetId.STATUS_SET_ID:
pw.dlog( pw.dlog(
@ -302,18 +306,17 @@ def handle_rw_hk_data(
speed_rpm = speed / 10.0 speed_rpm = speed / 10.0
ref_speed_rpm = ref_speed / 10.0 ref_speed_rpm = ref_speed / 10.0
pw.dlog( pw.dlog(
f"Temperature {temp} C | Speed {speed_rpm} rpm | Reference Speed" f"Temperature {temp} C | Speed {speed_rpm} rpm | Reference Speed {ref_speed_rpm} rpm"
f" {ref_speed_rpm} rpm"
) )
pw.dlog( pw.dlog(
f"State {state}. 0: Error, 1: Idle, 2: Coasting, 3: Running, speed stable, " f"State {state}. 0: Error, 1: Idle, 2: Coasting, 3: Running, speed stable, "
"4: Running, speed changing" f"4: Running, speed changing"
) )
pw.dlog( pw.dlog(
f"Current Limit Control mode {clc_mode}. 0: Low Current Mode (0.3 A), " f"Current Limit Control mode {clc_mode}. 0: Low Current Mode (0.3 A), "
"1: High Current Mode (0.6 A)" f"1: High Current Mode (0.6 A)"
) )
pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], 5)) printer.print_validity_buffer(hk_data[current_idx:], 5)
if set_id == RwSetId.LAST_RESET: if set_id == RwSetId.LAST_RESET:
pw.dlog( pw.dlog(
f"Received Last Reset HK (ID {set_id}) from Reaction Wheel {object_id.name}" f"Received Last Reset HK (ID {set_id}) from Reaction Wheel {object_id.name}"
@ -360,24 +363,22 @@ def handle_rw_hk_data(
) = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len]) ) = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
pw.dlog( pw.dlog(
f"MCU Temperature {mcu_temp} | Pressure Sensore Temperature" f"MCU Temperature {mcu_temp} | Pressure Sensore Temperature {pressure_sens_temp} C"
f" {pressure_sens_temp} C"
) )
pw.dlog(f"Last Reset Status {last_reset_status}") pw.dlog(f"Last Reset Status {last_reset_status}")
pw.dlog( pw.dlog(
f"Current Limit Control mode {clc_mode}. 0: Low Current Mode (0.3 A), " f"Current Limit Control mode {clc_mode}. 0: Low Current Mode (0.3 A), "
"1: High Current Mode (0.6 A)" f"1: High Current Mode (0.6 A)"
) )
pw.dlog(f"Speed {current_speed} rpm | Reference Speed {ref_speed} rpm") pw.dlog(f"Speed {current_speed} rpm | Reference Speed {ref_speed} rpm")
pw.dlog( pw.dlog(
f"State {state}. 0: Error, 1: Idle, 2: Coasting, 3: Running, speed stable, " f"State {state}. 0: Error, 1: Idle, 2: Coasting, 3: Running, speed stable, "
"4: Running, speed changing" f"4: Running, speed changing"
) )
pw.dlog("Number Of Invalid Packets:") pw.dlog(f"Number Of Invalid Packets:")
pw.dlog("CRC | Length | CMD") pw.dlog("CRC | Length | CMD")
pw.dlog( pw.dlog(
f"{num_invalid_crc_packets} | {num_invalid_len_packets} |" f"{num_invalid_crc_packets} | {num_invalid_len_packets} | {num_invalid_cmd_packets}"
f" {num_invalid_cmd_packets}"
) )
pw.dlog( pw.dlog(
f"Num Of CMD Executed Requests {num_of_cmd_executed_requests} | " f"Num Of CMD Executed Requests {num_of_cmd_executed_requests} | "
@ -385,26 +386,23 @@ def handle_rw_hk_data(
) )
pw.dlog("UART COM information:") pw.dlog("UART COM information:")
pw.dlog( pw.dlog(
"NumBytesWritten | NumBytesRead | ParityErrs | NoiseErrs | FrameErrs | " f"NumBytesWritten | NumBytesRead | ParityErrs | NoiseErrs | FrameErrs | "
"RegOverrunErrs | TotalErrs" f"RegOverrunErrs | TotalErrs"
) )
pw.dlog( pw.dlog(
f"{uart_num_of_bytes_written} | {uart_num_of_bytes_read} |" f"{uart_num_of_bytes_written} | {uart_num_of_bytes_read} | {uart_num_parity_errors} | "
f" {uart_num_parity_errors} | {uart_num_noise_errors} |" f"{uart_num_noise_errors} | {uart_num_frame_errors} | {uart_num_reg_overrun_errors} | "
f" {uart_num_frame_errors} | {uart_num_reg_overrun_errors} |" f"{uart_total_num_errors}"
f" {uart_total_num_errors}"
) )
pw.dlog("SPI COM Info:") pw.dlog("SPI COM Info:")
pw.dlog("NumBytesWritten | NumBytesRead | RegOverrunErrs | TotalErrs") pw.dlog(f"NumBytesWritten | NumBytesRead | RegOverrunErrs | TotalErrs")
pw.dlog( pw.dlog(
f"{spi_num_bytes_written} | {spi_num_bytes_read} |" f"{spi_num_bytes_written} | {spi_num_bytes_read} | {spi_num_reg_overrun_errors} | "
f" {spi_num_reg_overrun_errors} | {spi_total_num_errors}" f"{spi_total_num_errors}"
) )
if current_idx > 0: if current_idx > 0:
pw.dlog( printer.print_validity_buffer(
FsfwTmTcPrinter.get_validity_buffer( validity_buffer=hk_data[current_idx:], num_vars=27
validity_buffer=hk_data[current_idx:], num_vars=27
)
) )

View File

@ -20,7 +20,7 @@ from tmtccmd.tc.pus_3_fsfw_hk import create_request_one_diag_command, make_sid
from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode
from tmtccmd.util import ObjectIdU32 from tmtccmd.util import ObjectIdU32
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from eive_tmtc.config.object_ids import STR_ASSEMBLY, STAR_TRACKER_ID from eive_tmtc.config.object_ids import STR_ASSEMBLY, STAR_TRACKER_ID
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -65,6 +65,7 @@ class StarTrackerActionId(enum.IntEnum):
CHANGE_DOWNLOAD_IMAGE = 57 CHANGE_DOWNLOAD_IMAGE = 57
SET_JSON_FILE_NAME = 58 SET_JSON_FILE_NAME = 58
SET_FLASH_READ_FILENAME = 59 SET_FLASH_READ_FILENAME = 59
SET_TIME = 60
DOWNLOAD_DBIMAGE = 61 DOWNLOAD_DBIMAGE = 61
DOWNLOAD_BLOBPIXEL = 62 DOWNLOAD_BLOBPIXEL = 62
DOWNLOAD_FPGA_IMAGE = 63 DOWNLOAD_FPGA_IMAGE = 63
@ -89,7 +90,6 @@ class StarTrackerActionId(enum.IntEnum):
LOG_SUBSCRIPTION = 82 LOG_SUBSCRIPTION = 82
DEBUG_CAMERA = 83 DEBUG_CAMERA = 83
FIRMWARE_UPDATE = 84 FIRMWARE_UPDATE = 84
SET_TIME_FROM_SYS_TIME = 87
class OpCodes: class OpCodes:
@ -104,7 +104,6 @@ class OpCodes:
UPLOAD_IMAGE = "upload_image" UPLOAD_IMAGE = "upload_image"
SET_IMG_PROCESSOR_MODE = "set_img_proc_mode" SET_IMG_PROCESSOR_MODE = "set_img_proc_mode"
FW_UPDATE = "fw_update" FW_UPDATE = "fw_update"
SET_TIME_FROM_SYS_TIME = "set_time"
class Info: class Info:
@ -114,7 +113,6 @@ class Info:
TAKE_IMAGE = "Take Image" TAKE_IMAGE = "Take Image"
SET_IMG_PROCESSOR_MODE = "Set Image Processor Mode" SET_IMG_PROCESSOR_MODE = "Set Image Processor Mode"
FW_UPDATE = "Firmware Update" FW_UPDATE = "Firmware Update"
SET_TIME_FROM_SYS_TIME = "Set time from system time"
class SetId(enum.IntEnum): class SetId(enum.IntEnum):
@ -204,7 +202,7 @@ def prompt_object_id_mode_cmd() -> bytes:
return STAR_TRACKER_ID return STAR_TRACKER_ID
def pack_star_tracker_commands( # noqa C901 def pack_star_tracker_commands(
object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
): ):
q.add_log_cmd( q.add_log_cmd(
@ -440,9 +438,14 @@ def pack_star_tracker_commands( # noqa C901
q.add_log_cmd("Star tracker: Get checksum") q.add_log_cmd("Star tracker: Get checksum")
data = pack_checksum_command(obyt) data = pack_checksum_command(obyt)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == OpCodes.SET_TIME_FROM_SYS_TIME: if op_code == "38":
q.add_log_cmd(Info.SET_TIME_FROM_SYS_TIME) q.add_log_cmd("Star tracker: Set time")
data = obyt + struct.pack("!I", StarTrackerActionId.SET_TIME_FROM_SYS_TIME) unix_time = 1640783543
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.SET_TIME)
+ struct.pack("!Q", unix_time)
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "39": if op_code == "39":
q.add_log_cmd("Star tracker: Download Centroid") q.add_log_cmd("Star tracker: Download Centroid")
@ -482,6 +485,34 @@ def pack_star_tracker_commands( # noqa C901
+ struct.pack("!B", type) + struct.pack("!B", type)
) )
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "44":
q.add_log_cmd("Star tracker: Download FPGA Image")
position = int(input("Start position: "))
length = int(input("Size to download: "))
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.DOWNLOAD_FPGA_IMAGE)
+ struct.pack("!I", position)
+ struct.pack("!I", length)
+ bytearray(FileDefs.downloadFpgaImagePath, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "45":
q.add_log_cmd("Star tracker: Change donwload FPGA image file name")
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.CHANGE_FPGA_DOWNLOAD_FILE)
+ bytearray(FileDefs.downloadFpgaImageName, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "46":
q.add_log_cmd("Star tracker: Upload FPGA image")
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.UPLOAD_FPGA_IMAGE)
+ bytearray(FileDefs.uploadFpgaImageName, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "47": if op_code == "47":
q.add_log_cmd("Star tracker: FPGA action") q.add_log_cmd("Star tracker: FPGA action")
id = 3 id = 3
@ -676,7 +707,8 @@ def get_upload_image() -> str:
return image return image
def handle_str_hk_data(set_id: int, hk_data: bytes, pw: PrintWrapper): def handle_str_hk_data(set_id: int, hk_data: bytes, printer: FsfwTmTcPrinter):
pw = PrintWrapper(printer)
pw.dlog(f"Received STR HK set with set ID {set_id}") pw.dlog(f"Received STR HK set with set ID {set_id}")
if set_id == SetId.SOLUTION: if set_id == SetId.SOLUTION:
handle_solution_set(hk_data, pw) handle_solution_set(hk_data, pw)
@ -693,7 +725,7 @@ def unpack_time_hk(hk_data: bytes, current_idx: int, pw: PrintWrapper) -> int:
ticks_time_fmt, hk_data[current_idx : current_idx + fmt_len] ticks_time_fmt, hk_data[current_idx : current_idx + fmt_len]
) )
unix_as_dt = datetime.datetime.fromtimestamp( unix_as_dt = datetime.datetime.fromtimestamp(
int(round(unix_time / 1e6)), tz=datetime.timezone.utc int(round(unix_time / 10e6)), tz=datetime.timezone.utc
) )
pw.dlog(f"Ticks: {ticks} | UNIX time: {unix_time}") pw.dlog(f"Ticks: {ticks} | UNIX time: {unix_time}")
pw.dlog(f"UNIX as datetime: {unix_as_dt}") pw.dlog(f"UNIX as datetime: {unix_as_dt}")
@ -715,7 +747,7 @@ def handle_temperature_set(hk_data: bytes, pw: PrintWrapper):
pw.dlog(f"CMOS Temperature: {cmos_temp}") pw.dlog(f"CMOS Temperature: {cmos_temp}")
pw.dlog(f"FPGA Temperature: {fpga_temp}") pw.dlog(f"FPGA Temperature: {fpga_temp}")
current_idx += fmt_len current_idx += fmt_len
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], 5) pw.printer.print_validity_buffer(hk_data[current_idx:], 5)
def handle_solution_set(hk_data: bytes, pw: PrintWrapper): def handle_solution_set(hk_data: bytes, pw: PrintWrapper):
@ -789,7 +821,7 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper):
solution_strategy = hk_data[current_idx] solution_strategy = hk_data[current_idx]
pw.dlog(f"Solution strategy: {solution_strategy}") pw.dlog(f"Solution strategy: {solution_strategy}")
current_idx += 1 current_idx += 1
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], 23) pw.printer.print_validity_buffer(hk_data[current_idx:], 23)
@tmtc_definitions_provider @tmtc_definitions_provider
@ -856,5 +888,4 @@ def add_str_cmds(defs: TmtcDefinitionWrapper):
oce.add(OpCodes.FW_UPDATE, Info.FW_UPDATE) oce.add(OpCodes.FW_UPDATE, Info.FW_UPDATE)
oce.add("70", "Star Tracker: Disable timestamp generation") oce.add("70", "Star Tracker: Disable timestamp generation")
oce.add("71", "Star Tracker: Enable timestamp generation") oce.add("71", "Star Tracker: Enable timestamp generation")
oce.add(OpCodes.SET_TIME_FROM_SYS_TIME, Info.SET_TIME_FROM_SYS_TIME)
defs.add_service(CustomServiceList.STAR_TRACKER.value, "Star Tracker", oce) defs.add_service(CustomServiceList.STAR_TRACKER.value, "Star Tracker", oce)

View File

@ -4,8 +4,7 @@
@brief Commanding of the star tracker image helper object which is responsible for uploading @brief Commanding of the star tracker image helper object which is responsible for uploading
and downloading images to/from the star tracker. and downloading images to/from the star tracker.
@details Images to uplaod must be previously transferred to the OBC with the CFDP protocol. @details Images to uplaod must be previously transferred to the OBC with the CFDP protocol.
Also downloaded images will be stored on the filesystem of the OBC and can be Also downloaded images will be stored on the filesystem of the OBC and can be transferred via CFDP.
transferred via CFDP.
@author J. Meier @author J. Meier
@date 29.11.2021 @date 29.11.2021
""" """

View File

@ -3,7 +3,7 @@ import struct
from eive_tmtc.pus_tm.defs import PrintWrapper from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.util import ObjectIdU32 from tmtccmd.util import ObjectIdU32
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class SetId(enum.IntEnum): class SetId(enum.IntEnum):
@ -11,8 +11,9 @@ class SetId(enum.IntEnum):
def handle_sus_hk( def handle_sus_hk(
object_id: ObjectIdU32, hk_data: bytes, pw: PrintWrapper, set_id: int object_id: ObjectIdU32, hk_data: bytes, printer: FsfwTmTcPrinter, set_id: int
): ):
pw = PrintWrapper(printer)
pw.dlog(f"Received SUS HK data from {object_id}") pw.dlog(f"Received SUS HK data from {object_id}")
if set_id == SetId.HK: if set_id == SetId.HK:
current_idx = 0 current_idx = 0
@ -23,9 +24,7 @@ def handle_sus_hk(
channels.append(struct.unpack("!H", hk_data[current_idx : current_idx + 2])) channels.append(struct.unpack("!H", hk_data[current_idx : current_idx + 2]))
current_idx += 2 current_idx += 2
pw.dlog(f"Temperature: {temperature} C") pw.dlog(f"Temperature: {temperature} C")
pw.dlog("AIN Channel | Raw Value (hex) | Raw Value (dec)") pw.dlog(f"AIN Channel | Raw Value (hex) | Raw Value (dec)")
for idx, val in enumerate(channels): for idx, val in enumerate(channels):
pw.dlog(f"{idx} | {val[0]:#06x} |" + str(val[0]).ljust(5)) pw.dlog(f"{idx} | {val[0]:#06x} |" + str(val[0]).ljust(5))
FsfwTmTcPrinter.get_validity_buffer( printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=7)
validity_buffer=hk_data[current_idx:], num_vars=7
)

View File

@ -18,6 +18,7 @@ from tmtccmd.config.tmtc import (
from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_200_fsfw_mode import create_mode_command, Mode from tmtccmd.tc.pus_200_fsfw_mode import create_mode_command, Mode
from tmtccmd.util import ObjectIdU32 from tmtccmd.util import ObjectIdU32
from eive_tmtc.config.object_ids import CCSDS_HANDLER_ID
class ActionId(enum.IntEnum): class ActionId(enum.IntEnum):
@ -66,7 +67,7 @@ class Info:
DISABLE_ACTION = "Disable TX (legacy)" DISABLE_ACTION = "Disable TX (legacy)"
def pack_ccsds_handler_command( # noqa C901 def pack_ccsds_handler_test(
object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
): ):
obyt = object_id.as_bytes obyt = object_id.as_bytes

View File

@ -83,7 +83,7 @@ def pack_pdec_handler_test(
0, 0,
ParameterId.POSITIVE_WINDOW, ParameterId.POSITIVE_WINDOW,
pw, pw,
) ).pack()
) )
) )
if op_code == OpCode.NEGATIVE_WINDOW: if op_code == OpCode.NEGATIVE_WINDOW:
@ -96,7 +96,7 @@ def pack_pdec_handler_test(
0, 0,
ParameterId.NEGATIVE_WINDOW, ParameterId.NEGATIVE_WINDOW,
nw, nw,
) ).pack()
) )
) )
if op_code == OpCode.RESET_NO_INIT: if op_code == OpCode.RESET_NO_INIT:

View File

@ -3,7 +3,6 @@ import enum
from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.config.object_ids import COM_SUBSYSTEM_ID from eive_tmtc.config.object_ids import COM_SUBSYSTEM_ID
from eive_tmtc.tmtc.com.syrlinks_handler import Datarate from eive_tmtc.tmtc.com.syrlinks_handler import Datarate
from tmtccmd.pus.s20_fsfw_param_defs import create_scalar_u8_parameter
from .defs import Mode as ComMode from .defs import Mode as ComMode
@ -22,6 +21,7 @@ from tmtccmd.tc.pus_200_fsfw_mode import (
) )
from tmtccmd.tc.pus_20_fsfw_param import ( from tmtccmd.tc.pus_20_fsfw_param import (
create_load_param_cmd, create_load_param_cmd,
pack_scalar_u8_parameter_app_data,
) )
from tmtccmd.pus.s20_fsfw_param import create_scalar_u32_parameter from tmtccmd.pus.s20_fsfw_param import create_scalar_u32_parameter
@ -61,7 +61,7 @@ class Info:
@service_provider(CustomServiceList.COM_SS) @service_provider(CustomServiceList.COM_SS)
def build_com_subsystem_cmd(p: ServiceProviderParams): # noqa C901 def build_com_subsystem_cmd(p: ServiceProviderParams):
q = p.queue_helper q = p.queue_helper
o = p.op_code o = p.op_code
prefix = "COM Subsystem" prefix = "COM Subsystem"
@ -87,7 +87,7 @@ def build_com_subsystem_cmd(p: ServiceProviderParams): # noqa C901
q.add_log_cmd(f"{prefix}: {Info.UPDATE_DEFAULT_DATARATE_LOW}") q.add_log_cmd(f"{prefix}: {Info.UPDATE_DEFAULT_DATARATE_LOW}")
q.add_pus_tc( q.add_pus_tc(
create_load_param_cmd( create_load_param_cmd(
create_scalar_u8_parameter( pack_scalar_u8_parameter_app_data(
COM_SUBSYSTEM_ID, COM_SUBSYSTEM_ID,
0, 0,
ParameterId.DATARATE, ParameterId.DATARATE,
@ -99,7 +99,7 @@ def build_com_subsystem_cmd(p: ServiceProviderParams): # noqa C901
q.add_log_cmd(f"{prefix}: {Info.UPDATE_DEFAULT_DATARATE_HIGH}") q.add_log_cmd(f"{prefix}: {Info.UPDATE_DEFAULT_DATARATE_HIGH}")
q.add_pus_tc( q.add_pus_tc(
create_load_param_cmd( create_load_param_cmd(
create_scalar_u8_parameter( pack_scalar_u8_parameter_app_data(
COM_SUBSYSTEM_ID, COM_SUBSYSTEM_ID,
0, 0,
ParameterId.DATARATE, ParameterId.DATARATE,
@ -122,7 +122,7 @@ def build_com_subsystem_cmd(p: ServiceProviderParams): # noqa C901
0, 0,
ParameterId.TRANSMITTER_TIMEOUT, ParameterId.TRANSMITTER_TIMEOUT,
timeout, timeout,
) ).pack()
) )
) )
elif o == OpCode.READ_MODE: elif o == OpCode.READ_MODE:

View File

@ -21,9 +21,9 @@ from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import ( from tmtccmd.tc.pus_3_fsfw_hk import (
make_sid, make_sid,
create_request_one_diag_command, create_request_one_diag_command,
create_enable_periodic_hk_command_with_interval,
create_disable_periodic_hk_command,
create_request_one_hk_command, create_request_one_hk_command,
create_enable_periodic_hk_command_with_interval_with_diag,
create_disable_periodic_hk_command_with_diag,
) )
from spacepackets.ecss.tc import PusTelecommand from spacepackets.ecss.tc import PusTelecommand
from tmtccmd.tc.pus_200_fsfw_mode import Mode, create_mode_command from tmtccmd.tc.pus_200_fsfw_mode import Mode, create_mode_command
@ -31,7 +31,7 @@ from eive_tmtc.config.object_ids import SYRLINKS_HANDLER_ID
import struct import struct
from tmtccmd.util import ObjectIdU32 from tmtccmd.util import ObjectIdU32
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class SetId(enum.IntEnum): class SetId(enum.IntEnum):
@ -142,7 +142,7 @@ def normal_mode_cmd(q: DefaultPusQueueHelper, info: str, submode: int):
q.add_pus_tc(create_mode_command(SYRLINKS_HANDLER_ID, Mode.NORMAL, submode)) q.add_pus_tc(create_mode_command(SYRLINKS_HANDLER_ID, Mode.NORMAL, submode))
def pack_syrlinks_command( # noqa C901: Complexity okay here. def pack_syrlinks_command(
object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
): ):
obyt = object_id.as_bytes obyt = object_id.as_bytes
@ -182,28 +182,24 @@ def pack_syrlinks_command( # noqa C901: Complexity okay here.
q.add_log_cmd(f"{prefix}: {Info.ENABLE_HK_RX_REGS}") q.add_log_cmd(f"{prefix}: {Info.ENABLE_HK_RX_REGS}")
sid = make_sid(obyt, SetId.RX_REGISTERS_DATASET) sid = make_sid(obyt, SetId.RX_REGISTERS_DATASET)
interval = float(input("HK interval in floating point seconds")) interval = float(input("HK interval in floating point seconds"))
cmds = create_enable_periodic_hk_command_with_interval_with_diag( cmds = create_enable_periodic_hk_command_with_interval(True, sid, interval)
True, sid, interval
)
for cmd in cmds: for cmd in cmds:
q.add_pus_tc(cmd) q.add_pus_tc(cmd)
if op_code in OpCode.DISABLE_HK_RX_REGS: if op_code in OpCode.DISABLE_HK_RX_REGS:
q.add_log_cmd(f"{prefix}: {Info.DISABLE_HK_RX_REGS}") q.add_log_cmd(f"{prefix}: {Info.DISABLE_HK_RX_REGS}")
sid = make_sid(obyt, SetId.RX_REGISTERS_DATASET) sid = make_sid(obyt, SetId.RX_REGISTERS_DATASET)
q.add_pus_tc(create_disable_periodic_hk_command_with_diag(True, sid)) q.add_pus_tc(create_disable_periodic_hk_command(True, sid))
if op_code in OpCode.ENABLE_HK_TX_REGS: if op_code in OpCode.ENABLE_HK_TX_REGS:
q.add_log_cmd(f"{prefix}: {Info.ENABLE_HK_TX_REGS}") q.add_log_cmd(f"{prefix}: {Info.ENABLE_HK_TX_REGS}")
sid = make_sid(obyt, SetId.TX_REGISTERS_DATASET) sid = make_sid(obyt, SetId.TX_REGISTERS_DATASET)
interval = float(input("HK interval in floating point seconds")) interval = float(input("HK interval in floating point seconds"))
cmds = create_enable_periodic_hk_command_with_interval_with_diag( cmds = create_enable_periodic_hk_command_with_interval(True, sid, interval)
True, sid, interval
)
for cmd in cmds: for cmd in cmds:
q.add_pus_tc(cmd) q.add_pus_tc(cmd)
if op_code in OpCode.DISABLE_HK_TX_REGS: if op_code in OpCode.DISABLE_HK_TX_REGS:
q.add_log_cmd(f"{prefix}: {Info.DISABLE_HK_TX_REGS}") q.add_log_cmd(f"{prefix}: {Info.DISABLE_HK_TX_REGS}")
sid = make_sid(obyt, SetId.TX_REGISTERS_DATASET) sid = make_sid(obyt, SetId.TX_REGISTERS_DATASET)
q.add_pus_tc(create_disable_periodic_hk_command_with_diag(True, sid)) q.add_pus_tc(create_disable_periodic_hk_command(True, sid))
if op_code in OpCode.HK_TX_REGS: if op_code in OpCode.HK_TX_REGS:
q.add_log_cmd(f"{prefix}: {Info.HK_TX_REGS}") q.add_log_cmd(f"{prefix}: {Info.HK_TX_REGS}")
sid = make_sid(obyt, SetId.TX_REGISTERS_DATASET) sid = make_sid(obyt, SetId.TX_REGISTERS_DATASET)
@ -258,28 +254,31 @@ def pack_syrlinks_command( # noqa C901: Complexity okay here.
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
def handle_syrlinks_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes): def handle_syrlinks_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
if set_id == SetId.RX_REGISTERS_DATASET: if set_id == SetId.RX_REGISTERS_DATASET:
return handle_syrlinks_rx_registers_dataset(pw, hk_data) return handle_syrlinks_rx_registers_dataset(printer, hk_data)
elif set_id == SetId.TX_REGISTERS_DATASET: elif set_id == SetId.TX_REGISTERS_DATASET:
return handle_syrlinks_tx_registers_dataset(pw, hk_data) return handle_syrlinks_tx_registers_dataset(printer, hk_data)
elif set_id == SetId.TEMPERATURE_SET_ID: elif set_id == SetId.TEMPERATURE_SET_ID:
return handle_syrlinks_temp_dataset(pw, hk_data) return handle_syrlinks_temp_dataset(printer, hk_data)
else: else:
pw = PrintWrapper(printer)
pw.dlog(f"Service 3 TM: Syrlinks handler reply with unknown set ID {set_id}") pw.dlog(f"Service 3 TM: Syrlinks handler reply with unknown set ID {set_id}")
def handle_syrlinks_temp_dataset(pw: PrintWrapper, hk_data: bytes): def handle_syrlinks_temp_dataset(printer: FsfwTmTcPrinter, hk_data: bytes):
pw = PrintWrapper(printer)
if len(hk_data) < 8: if len(hk_data) < 8:
raise ValueError("expected at least 8 bytes of HK data") raise ValueError("expected at least 8 bytes of HK data")
temp_power_amplifier = struct.unpack("!f", hk_data[0:4])[0] temp_power_amplifier = struct.unpack("!f", hk_data[0:4])[0]
temp_baseband_board = struct.unpack("!f", hk_data[4:8])[0] temp_baseband_board = struct.unpack("!f", hk_data[4:8])[0]
pw.dlog(f"Temperatur Power Amplifier [C]: {temp_power_amplifier}") pw.dlog(f"Temperatur Power Amplifier [C]: {temp_power_amplifier}")
pw.dlog(f"Temperatur Baseband Board [C]: {temp_baseband_board}") pw.dlog(f"Temperatur Baseband Board [C]: {temp_baseband_board}")
pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[8:], 2)) printer.print_validity_buffer(hk_data[8:], 2)
def handle_syrlinks_rx_registers_dataset(pw: PrintWrapper, hk_data: bytes): def handle_syrlinks_rx_registers_dataset(printer: FsfwTmTcPrinter, hk_data: bytes):
pw = PrintWrapper(printer)
header_list = [ header_list = [
"RX Status", "RX Status",
"RX Sensitivity", "RX Sensitivity",
@ -339,9 +338,7 @@ def handle_syrlinks_rx_registers_dataset(pw: PrintWrapper, hk_data: bytes):
validity_buffer = hk_data[22:] validity_buffer = hk_data[22:]
for header, content in zip(header_list, content_list): for header, content in zip(header_list, content_list):
pw.dlog(f"{header}: {content}") pw.dlog(f"{header}: {content}")
pw.dlog( printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=8)
FsfwTmTcPrinter.get_validity_buffer(validity_buffer=validity_buffer, num_vars=8)
)
pw.dlog(f"Carrier Detect: {carrier_detect}") pw.dlog(f"Carrier Detect: {carrier_detect}")
pw.dlog(f"Carrier Lock: {carrier_lock}") pw.dlog(f"Carrier Lock: {carrier_lock}")
pw.dlog(f"Data Lock (data clock recovery loop lock status): {data_lock}") pw.dlog(f"Data Lock (data clock recovery loop lock status): {data_lock}")
@ -375,9 +372,10 @@ WAVEFORM_STRINGS = ["OFF", "CW", "QPSK", "0QPSK", "PCM/PM", "PSK/PM", "BPSK"]
def handle_syrlinks_tx_registers_dataset( def handle_syrlinks_tx_registers_dataset(
pw: PrintWrapper, printer: FsfwTmTcPrinter,
hk_data: bytes, hk_data: bytes,
): ):
pw = PrintWrapper(printer)
header_list = ["TX Status Raw", "TX Waveform", "TX AGC value"] header_list = ["TX Status Raw", "TX Waveform", "TX AGC value"]
tx_status = hk_data[0] tx_status = hk_data[0]
""" """
@ -414,9 +412,7 @@ def handle_syrlinks_tx_registers_dataset(
validity_buffer = hk_data[4:] validity_buffer = hk_data[4:]
for header, content in zip(header_list, content_list): for header, content in zip(header_list, content_list):
pw.dlog(f"{header}: {content}") pw.dlog(f"{header}: {content}")
pw.dlog( printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=3)
FsfwTmTcPrinter.get_validity_buffer(validity_buffer=validity_buffer, num_vars=3)
)
# pw.dlog(f"TX CONV: {tx_conv!r}") # pw.dlog(f"TX CONV: {tx_conv!r}")
# pw.dlog(f"TX DIFF (differential encoder enable): {tx_diff_encoder_enable}") # pw.dlog(f"TX DIFF (differential encoder enable): {tx_diff_encoder_enable}")
pw.dlog(f"TX Status: {tx_status_status!r}") pw.dlog(f"TX Status: {tx_status_status!r}")

View File

@ -19,24 +19,11 @@ from tmtccmd.tc.pus_20_fsfw_param import (
) )
from tmtccmd.config.tmtc import OpCodeEntry, tmtc_definitions_provider from tmtccmd.config.tmtc import OpCodeEntry, tmtc_definitions_provider
from eive_tmtc.config.object_ids import CORE_CONTROLLER_ID from eive_tmtc.config.object_ids import CORE_CONTROLLER_ID
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class SdState(enum.IntEnum):
OFF = 0
ON = 1
MOUNTED = 2
class SdCardSelect(enum.IntEnum):
SD_0 = 0
SD_1 = 1
BOTH = 2
NONE = 3
class ActionId(enum.IntEnum): class ActionId(enum.IntEnum):
ANNOUNCE_VERSION = 1 ANNOUNCE_VERSION = 1
ANNOUNCE_CURRENT_IMAGE = 2 ANNOUNCE_CURRENT_IMAGE = 2
@ -45,7 +32,6 @@ 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
@ -101,15 +87,14 @@ 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"]
READ_REBOOT_MECHANISM_INFO = "rbh_info" ENABLE_REBOOT_FILE_HANDLING = ["rbh_off"]
ENABLE_REBOOT_FILE_HANDLING = "rwd_on" DISABLE_REBOOT_FILE_HANDLING = ["rbh_on"]
DISABLE_REBOOT_FILE_HANDLING = "rwd_off" RESET_ALL_REBOOT_COUNTERS = ["rbh_reset_a"]
RESET_ALL_REBOOT_COUNTERS = "rwd_reset_a" RESET_REBOOT_COUNTER_00 = ["rbh_reset_00"]
RWD_RESET_REBOOT_COUNTER_00 = "rwd_reset_00" RESET_REBOOT_COUNTER_01 = ["rbh_reset_01"]
RWD_RESET_REBOOT_COUNTER_01 = "rwd_reset_01" RESET_REBOOT_COUNTER_10 = ["rbh_reset_10"]
RWD_RESET_REBOOT_COUNTER_10 = "rwd_reset_10" RESET_REBOOT_COUNTER_11 = ["rbh_reset_11"]
RWD_RESET_REBOOT_COUNTER_11 = "rwd_reset_11" SET_MAX_REBOOT_CNT = ["rbh_max_cnt"]
RWD_SET_MAX_REBOOT_CNT = "rwd_max_cnt"
class Info: class Info:
@ -125,7 +110,6 @@ 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"
@ -170,9 +154,6 @@ 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)
@ -201,25 +182,21 @@ def add_core_controller_definitions(defs: TmtcDefinitionWrapper):
info="Reset all reboot counters", info="Reset all reboot counters",
) )
oce.add( oce.add(
keys=OpCode.RWD_RESET_REBOOT_COUNTER_00, keys=OpCode.RESET_REBOOT_COUNTER_00,
info="Reset reboot counter 0 0", info="Reset reboot counter 0 0",
) )
oce.add( oce.add(
keys=OpCode.RWD_RESET_REBOOT_COUNTER_01, keys=OpCode.RESET_REBOOT_COUNTER_01,
info="Reset reboot counter 0 1", info="Reset reboot counter 0 1",
) )
oce.add( oce.add(
keys=OpCode.RWD_RESET_REBOOT_COUNTER_10, keys=OpCode.RESET_REBOOT_COUNTER_10,
info="Reset reboot counter 1 0", info="Reset reboot counter 1 0",
) )
oce.add( oce.add(
keys=OpCode.RWD_RESET_REBOOT_COUNTER_11, keys=OpCode.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)
@ -235,9 +212,7 @@ def add_core_controller_definitions(defs: TmtcDefinitionWrapper):
defs.add_service(CustomServiceList.CORE.value, "Core Controller", oce) defs.add_service(CustomServiceList.CORE.value, "Core Controller", oce)
def pack_core_commands( # noqa C901 def pack_core_commands(q: DefaultPusQueueHelper, op_code: str):
q: DefaultPusQueueHelper, op_code: str
): # noqa: C901 , complexity okay here
if op_code == OpCode.ANNOUNCE_VERSION: if op_code == OpCode.ANNOUNCE_VERSION:
q.add_log_cmd(f"{Info.ANNOUNCE_VERSION}") q.add_log_cmd(f"{Info.ANNOUNCE_VERSION}")
q.add_pus_tc(create_action_cmd(CORE_CONTROLLER_ID, ActionId.ANNOUNCE_VERSION)) q.add_pus_tc(create_action_cmd(CORE_CONTROLLER_ID, ActionId.ANNOUNCE_VERSION))
@ -276,7 +251,15 @@ def pack_core_commands( # noqa C901
int(input("Specify systemctl command type by key: ")) int(input("Specify systemctl command type by key: "))
) )
unit_name = input("Specify unit name: ") unit_name = input("Specify unit name: ")
q.add_pus_tc(create_systemctl_cmd(systemctl_cmd, unit_name)) cmd_data = bytearray([systemctl_cmd])
cmd_data.extend(unit_name.encode())
q.add_pus_tc(
create_action_cmd(
object_id=CORE_CONTROLLER_ID,
action_id=ActionId.SYSTEMCTL_CMD_EXECUTOR,
user_data=cmd_data,
)
)
elif op_code == OpCode.EXECUTE_SHELL_CMD_BLOCKING: elif op_code == OpCode.EXECUTE_SHELL_CMD_BLOCKING:
custom_cmd = input("Please specify command to execute: ") custom_cmd = input("Please specify command to execute: ")
q.add_pus_tc( q.add_pus_tc(
@ -317,15 +300,7 @@ 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 == OpCode.READ_REBOOT_MECHANISM_INFO: elif op_code in OpCode.DISABLE_REBOOT_FILE_HANDLING:
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(
@ -335,7 +310,7 @@ def pack_core_commands( # noqa C901
user_data=user_data, user_data=user_data,
) )
) )
elif op_code == OpCode.ENABLE_REBOOT_FILE_HANDLING: elif op_code in 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(
@ -345,7 +320,7 @@ def pack_core_commands( # noqa C901
user_data=user_data, user_data=user_data,
) )
) )
elif op_code == OpCode.RESET_ALL_REBOOT_COUNTERS: elif op_code in 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(
@ -353,25 +328,14 @@ def pack_core_commands( # noqa C901
action_id=ActionId.RESET_REBOOT_COUNTER, action_id=ActionId.RESET_REBOOT_COUNTER,
) )
) )
elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_00: elif op_code in OpCode.RESET_REBOOT_COUNTER_00:
reset_specific_boot_counter(q, 0, 0) reset_specific_boot_counter(q, 0, 0)
elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_01: elif op_code in OpCode.RESET_REBOOT_COUNTER_01:
reset_specific_boot_counter(q, 0, 1) reset_specific_boot_counter(q, 0, 1)
elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_10: elif op_code in OpCode.RESET_REBOOT_COUNTER_10:
reset_specific_boot_counter(q, 1, 0) reset_specific_boot_counter(q, 1, 0)
elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_11: elif op_code in OpCode.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))
@ -427,17 +391,14 @@ 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")
cp_force = int(input("Copy with force option(0/1) ?: ")) user_data = bytearray([cp_recursive])
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(
@ -497,16 +458,6 @@ def pack_core_commands( # noqa C901
) )
def create_systemctl_cmd(systemctl_cmd: SystemctlCmd, unit_name: str):
cmd_data = bytearray([systemctl_cmd])
cmd_data.extend(unit_name.encode())
return create_action_cmd(
object_id=CORE_CONTROLLER_ID,
action_id=ActionId.SYSTEMCTL_CMD_EXECUTOR,
user_data=cmd_data,
)
def list_directory_base_user_data() -> bytearray: def list_directory_base_user_data() -> bytearray:
all_opt = int(input("Use all (-a) option (0/1) ?: ")) all_opt = int(input("Use all (-a) option (0/1) ?: "))
if all_opt not in [0, 1]: if all_opt not in [0, 1]:
@ -628,8 +579,9 @@ def create_xsc_reboot_cmds(
) )
def handle_core_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes): def handle_core_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
if set_id == SetId.HK: if set_id == SetId.HK:
pw = PrintWrapper(printer)
fmt_str = "!fff" fmt_str = "!fff"
inc_len = struct.calcsize(fmt_str) inc_len = struct.calcsize(fmt_str)
(temperature, ps_voltage, pl_voltage) = struct.unpack( (temperature, ps_voltage, pl_voltage) = struct.unpack(
@ -640,93 +592,50 @@ def handle_core_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes):
f"PL Voltage [mV] {pl_voltage}" f"PL Voltage [mV] {pl_voltage}"
) )
pw.dlog(printout) pw.dlog(printout)
FsfwTmTcPrinter.get_validity_buffer( printer.print_validity_buffer(validity_buffer=hk_data[inc_len:], num_vars=3)
validity_buffer=hk_data[inc_len:], num_vars=3
)
def handle_core_ctrl_action_replies( def handle_core_ctrl_action_replies(
action_id: int, pw: PrintWrapper, custom_data: bytes action_id: int, printer: FsfwTmTcPrinter, custom_data: bytes
): ):
if action_id == ActionId.READ_REBOOT_MECHANISM_INFO: pw = PrintWrapper(printer)
handle_reboot_mechanism_info_reply(pw, custom_data) if action_id == ActionId.LIST_DIR_DUMP_DIRECTLY:
elif action_id == ActionId.LIST_DIR_DUMP_DIRECTLY: if len(custom_data) < 4:
handle_list_dir_dump_reply(pw, custom_data) _LOGGER.warning("Data unexpectedly small")
return
seq_idx = struct.unpack("!I", custom_data[0:4])[0]
def handle_reboot_mechanism_info_reply(pw: PrintWrapper, custom_data: bytes): total_chunks = struct.unpack("!I", custom_data[4:8])[0]
pw.dlog("Received reboot mechansm information") compressed = custom_data[8]
fmt_str = "!BIIIIIBBBBBBBB" ls_cmd = custom_data[9:].split(b"\x00")[0].decode()
inc_len = struct.calcsize(fmt_str) # Include length of NULL termination
if len(custom_data) < inc_len: file_data_offset = 9 + len(ls_cmd) + 1
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"Compression option: {compressed}. Dumping file into dir_listing.txt.gz" f"Received directory listing dump for ls command {ls_cmd}. "
f"Chunk {seq_idx + 1}/{total_chunks}"
) )
with open(path, "ab") as listing_file:
listing_file.write(custom_data[file_data_offset:]) def remove_if_exists_and_new(seq_idx_: int, path_: Path):
else: if seq_idx_ == 0 and path_.exists():
path = Path("dir_listing.txt") os.remove(path_)
remove_if_exists_and_new(seq_idx, path)
pw.dlog(f"Compression option: {compressed}. Dumping file into dir_listing.txt") if compressed:
with open(path, "a") as listing_file: path = Path("dir_listing.txt.gz")
listing_file_str = custom_data[file_data_offset:].decode() remove_if_exists_and_new(seq_idx, path)
listing_file.write(listing_file_str) pw.dlog(
if seq_idx + 1 == total_chunks: f"Compression option: {compressed}. Dumping file into dir_listing.txt.gz"
pw.dlog("Full directory listing: ") )
with open("dir_listing.txt", "r") as listing_file: with open(path, "ab") as listing_file:
print(listing_file.read()) listing_file.write(custom_data[file_data_offset:])
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())

View File

@ -1,3 +1,5 @@
import struct
from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.tmtc.obj_prompt import prompt_object from eive_tmtc.tmtc.obj_prompt import prompt_object
from spacepackets.ecss import PusTelecommand from spacepackets.ecss import PusTelecommand

View File

@ -1,24 +0,0 @@
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))

View File

@ -1,7 +1,9 @@
from eive_tmtc.config.object_ids import ( from eive_tmtc.config.object_ids import (
ACS_SUBSYSTEM_ID, ACS_SUBSYSTEM_ID,
ACS_CONTROLLER,
IMTQ_HANDLER_ID, IMTQ_HANDLER_ID,
GPS_0_HEALTH_DEV, GPS_0_HEALTH_DEV,
GPS_1_HEALTH_DEV,
GYRO_0_ADIS_HANDLER_ID, GYRO_0_ADIS_HANDLER_ID,
GYRO_1_L3G_HANDLER_ID, GYRO_1_L3G_HANDLER_ID,
ACS_BOARD_ASS_ID, ACS_BOARD_ASS_ID,
@ -14,13 +16,6 @@ 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,
STR_ASSEMBLY,
STAR_TRACKER_ID,
) )
SUBSYSTEM_DICT = { SUBSYSTEM_DICT = {
@ -34,27 +29,20 @@ ACS_OBJ_DICT = {
1: ("SUS Assembly", SUS_BOARD_ASS_ID), 1: ("SUS Assembly", SUS_BOARD_ASS_ID),
2: ("ACS Board Assembly", ACS_BOARD_ASS_ID), 2: ("ACS Board Assembly", ACS_BOARD_ASS_ID),
3: ("RW Assembly", RW_ASSEMBLY), 3: ("RW Assembly", RW_ASSEMBLY),
4: ("STR Assembly", STR_ASSEMBLY), 4: ("iMTQ MGT", IMTQ_HANDLER_ID),
5: ("iMTQ MGT", IMTQ_HANDLER_ID), 5: ("GYR 0 ADIS", GYRO_0_ADIS_HANDLER_ID),
6: ("GYR 0 ADIS", GYRO_0_ADIS_HANDLER_ID), 6: ("GYR 1 L3G", GYRO_1_L3G_HANDLER_ID),
7: ("GYR 1 L3G", GYRO_1_L3G_HANDLER_ID), 7: ("MGM 0 LIS3", MGM_0_LIS3_HANDLER_ID),
8: ("MGM 0 LIS3", MGM_0_LIS3_HANDLER_ID), 8: ("MGM 1 RM3100", MGM_1_RM3100_HANDLER_ID),
9: ("MGM 1 RM3100", MGM_1_RM3100_HANDLER_ID), 9: ("GPS 0 Health Device", GPS_0_HEALTH_DEV),
10: ("GPS 0 Health Device", GPS_0_HEALTH_DEV), 10: ("SUS 0", SUS_0_N_LOC_XFYFZM_PT_XF),
11: ("SUS 0", SUS_0_N_LOC_XFYFZM_PT_XF), 11: ("SUS 6", SUS_6_R_LOC_XFYBZM_PT_XF),
12: ("SUS 6", SUS_6_R_LOC_XFYBZM_PT_XF), 12: ("RW 1", RW1_ID),
13: ("RW 1", RW1_ID), 13: ("RW 2", RW2_ID),
14: ("RW 2", RW2_ID),
15: ("STR", STAR_TRACKER_ID),
} }
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),
} }

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
@file ploc_memory_dumper.py @file ploc_memory_dumper.py
@brief This file implements the command to dump memory sectors of the PLOC. Memories of the PLOC @brief This file implements the command to dump memory sectors of the PLOC. Memories of the PLOC which can be dumped
which can be dumped are one MRAM, two flash memories and the SRAM. are one MRAM, two flash memories and the SRAM.
@author J. Meier @author J. Meier
@date 31.08.2021 @date 31.08.2021
""" """

View File

@ -25,29 +25,20 @@ from tmtccmd.tc.decorator import ServiceProviderParams
from eive_tmtc.utility.input_helper import InputHelper from eive_tmtc.utility.input_helper import InputHelper
from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode
from tmtccmd.tc.pus_8_fsfw_funccmd import create_action_cmd from tmtccmd.tc.pus_8_fsfw_funccmd import create_action_cmd
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
MANUAL_INPUT = "1" MANUAL_INPUT = "1"
OBC_WRITE_FILE_DICT = { FLASH_WRITE_FILE_DICT = {
MANUAL_INPUT: ("manual input", ""), MANUAL_INPUT: ("manual input", ""),
"2": ("/mnt/sd0/ploc/mpsoc/flash_write.bin", "/mnt/sd0/ploc/mpsoc/flash_write.bin"), "2": ("/mnt/sd0/ploc/mpsoc/flash_write.bin", "/mnt/sd0/ploc/mpsoc/flash_write.bin"),
} }
OBC_READ_FILE_DICT = { MPSOC_FILE_DICT = {
MANUAL_INPUT: ("manual input", ""), MANUAL_INPUT: ("manual input", ""),
"2": ("/mnt/sd0/ploc/mpsoc/flash_read.bin", "/mnt/sd0/ploc/mpsoc/flash_read.bin"), "2": ("0:/flash", "0:/flash"),
}
MPSOC_WRITE_FILE_DICT = {
MANUAL_INPUT: ("manual input", ""),
"2": ("0:/", "0:/"),
}
MPSOC_READ_FILE_DICT = {
MANUAL_INPUT: ("manual input", ""),
"2": ("0:/PICA", "0:/PICA"),
} }
SEQ_FILE_NAMES = ["0:/EM16/231", "0:/EQ04/E-75", "0:/EQ01/E130"] SEQ_FILE_NAMES = ["0:/EM16/231", "0:/EQ04/E-75", "0:/EQ01/E130"]
@ -175,9 +166,7 @@ def add_ploc_mpsoc_cmds(defs: TmtcDefinitionWrapper):
@service_provider(CustomServiceList.PLOC_MPSOC) @service_provider(CustomServiceList.PLOC_MPSOC)
def pack_ploc_mpsoc_commands( # noqa C901 def pack_ploc_mpsoc_commands(p: ServiceProviderParams):
p: ServiceProviderParams,
): # noqa C901: Complexity okay here.
object_id = get_object_ids().get(PLOC_MPSOC_ID) object_id = get_object_ids().get(PLOC_MPSOC_ID)
q = p.queue_helper q = p.queue_helper
prefix = "PLOC MPSoC" prefix = "PLOC MPSoC"
@ -348,39 +337,31 @@ def prepare_mem_read_command(object_id: bytes) -> bytearray:
return bytearray(command) return bytearray(command)
def prepare_flash_base_cmd( def prepare_flash_base_cmd(action_id: int, object_id: bytes) -> bytearray:
obc_filename: str, mpsoc_filename: str, action_id: int, object_id: bytes obc_file = get_obc_file()
) -> bytearray: mpsoc_file = get_mpsoc_file()
command = bytearray(object_id) command = bytearray(object_id)
command.extend(struct.pack("!I", action_id)) command.extend(struct.pack("!I", action_id))
command.extend(obc_filename.encode("utf-8")) command.extend(obc_file.encode("utf-8"))
command.append(0) command.append(0)
command.extend(mpsoc_filename.encode("utf-8")) command.extend(mpsoc_file.encode("utf-8"))
command.append(0) command.append(0)
return command return command
def prepare_flash_write_cmd(object_id: bytes) -> bytearray: def prepare_flash_write_cmd(object_id: bytes) -> bytearray:
obc_file = get_obc_file(OBC_WRITE_FILE_DICT) return prepare_flash_base_cmd(ActionId.TC_FLASH_WRITE_FULL_FILE, object_id)
mpsoc_file = get_mpsoc_file(MPSOC_WRITE_FILE_DICT)
return prepare_flash_base_cmd(
obc_file, mpsoc_file, ActionId.TC_FLASH_WRITE_FULL_FILE, object_id
)
def prepare_flash_read_cmd(object_id: bytes) -> bytearray: def prepare_flash_read_cmd(object_id: bytes) -> bytearray:
mpsoc_file = get_mpsoc_file(MPSOC_READ_FILE_DICT) cmd = prepare_flash_base_cmd(ActionId.TC_FLASH_READ_FULL_FILE, object_id)
obc_file = get_obc_file(OBC_READ_FILE_DICT)
cmd = prepare_flash_base_cmd(
obc_file, mpsoc_file, ActionId.TC_FLASH_READ_FULL_FILE, object_id
)
file_size = get_mpsoc_file_size() file_size = get_mpsoc_file_size()
cmd.extend(struct.pack("!I", file_size)) cmd.extend(struct.pack("!I", file_size))
return cmd return cmd
def prepare_flash_delete_cmd(object_id: bytes) -> bytearray: def prepare_flash_delete_cmd(object_id: bytes) -> bytearray:
file = get_mpsoc_file(MPSOC_READ_FILE_DICT) file = get_mpsoc_file()
command = ( command = (
object_id + struct.pack("!I", ActionId.TC_FLASH_DELETE) + file.encode("utf-8") object_id + struct.pack("!I", ActionId.TC_FLASH_DELETE) + file.encode("utf-8")
) )
@ -424,7 +405,7 @@ def prepare_replay_write_sequence_cmd(object_id: bytes) -> bytearray:
def prepare_cam_take_pic_cmd(object_id: bytes) -> bytearray: def prepare_cam_take_pic_cmd(object_id: bytes) -> bytearray:
selection = input("Use default parameter? (Y/N): ") selection = input("Use default parameter? (Y/N): ")
if selection.lower() in ["y", "1", "yes"]: if selection is "Y" or selection is "y":
filename = "0:/test" filename = "0:/test"
encoder_setting_y = 7 encoder_setting_y = 7
quantization_y = 0 quantization_y = 0
@ -485,30 +466,30 @@ def prepare_downlink_data_modulate_cmd(object_id: bytes) -> bytearray:
return bytearray(command) return bytearray(command)
def get_obc_file(input_dict: dict) -> str: def get_obc_file() -> str:
_LOGGER.info("Specify OBC filename") _LOGGER.info("Specify OBC file ")
input_helper = InputHelper(input_dict) input_helper = InputHelper(FLASH_WRITE_FILE_DICT)
key = input_helper.get_key() key = input_helper.get_key()
if key == MANUAL_INPUT: if key == MANUAL_INPUT:
file = input("Ploc MPSoC: Specify absolute name of flash file: ") file = input("Ploc MPSoC: Specify absolute name of flash file: ")
else: else:
file = input_dict[key][1] file = FLASH_WRITE_FILE_DICT[key][1]
return file return file
def get_mpsoc_file(input_dict: dict) -> str: def get_mpsoc_file() -> str:
_LOGGER.info("Specify MPSoC filename") _LOGGER.info("Specify MPSoC file")
input_helper = InputHelper(input_dict) input_helper = InputHelper(MPSOC_FILE_DICT)
key = input_helper.get_key() key = input_helper.get_key()
if key == MANUAL_INPUT: if key == MANUAL_INPUT:
file = input("Ploc MPSoC: Specify absolute name file: ") file = input("Ploc MPSoC: Specify absolute name file: ")
else: else:
file = input_dict[key][1] file = MPSOC_FILE_DICT[key][1]
return file return file
def get_mpsoc_file_size() -> int: def get_mpsoc_file_size() -> int:
file_size = int(input("Specify MPSoC file size: ")) file_size = int(input("Specify MPSoC file size"))
if file_size <= 0: if file_size <= 0:
raise ValueError("Invalid file size") raise ValueError("Invalid file size")
return file_size return file_size
@ -525,7 +506,8 @@ def get_sequence_file() -> str:
return file return file
def handle_ploc_mpsoc_hk_data(pw: PrintWrapper, hk_data: bytes, set_id: int): def handle_ploc_mpsoc_hk_data(printer: FsfwTmTcPrinter, hk_data: bytes, set_id: int):
pw = PrintWrapper(printer)
if set_id == SetId.HK_ID: if set_id == SetId.HK_ID:
fmt_str = "!IBBBBBBB" fmt_str = "!IBBBBBBB"
current_idx = 0 current_idx = 0
@ -570,12 +552,12 @@ def handle_ploc_mpsoc_hk_data(pw: PrintWrapper, hk_data: bytes, set_id: int):
pw.dlog(f"CAM SoC Temperature: {cam_soc_temp}") pw.dlog(f"CAM SoC Temperature: {cam_soc_temp}")
pw.dlog(f"System Monitor Temperature: {sysmon_temp}") pw.dlog(f"System Monitor Temperature: {sysmon_temp}")
pw.dlog( pw.dlog(
f"SYSMON VCC INT {sysmon_vcc_int:.3f} | SYSMON VCC AUX" f"SYSMON VCC INT {sysmon_vcc_int:.3f} | SYSMON VCC AUX {sysmon_vcc_aux:.3f} | "
f" {sysmon_vcc_aux:.3f} | SYSMON VCC BRAM {sysmon_vcc_bram:.3f}" f"SYSMON VCC BRAM {sysmon_vcc_bram:.3f}"
) )
pw.dlog( pw.dlog(
f"SYSMON VCC PAUX {sysmon_vcc_paux:.3f} | SYSMON VCC PINT" f"SYSMON VCC PAUX {sysmon_vcc_paux:.3f} | SYSMON VCC PINT {sysmon_vcc_pint:.3f} | "
f" {sysmon_vcc_pint:.3f} | SYSMON VCC PDRO {sysmon_vcc_pdro:.3f}" f"SYSMON VCC PDRO {sysmon_vcc_pdro:.3f}"
) )
fmt_str = "!fffffffffffff" fmt_str = "!fffffffffffff"
@ -602,9 +584,8 @@ def handle_ploc_mpsoc_hk_data(pw: PrintWrapper, hk_data: bytes, set_id: int):
f"SYSMON MBA 1V8 {sysmon_mb_1v8:.3f}" f"SYSMON MBA 1V8 {sysmon_mb_1v8:.3f}"
) )
pw.dlog( pw.dlog(
f"SYSMON VCC 12V {sysmon_vcc_12v:.3f} | SYSMON VCC 5V {sysmon_vcc_5v:.3f} |" f"SYSMON VCC 12V {sysmon_vcc_12v:.3f} | SYSMON VCC 5V {sysmon_vcc_5v:.3f} | "
f" SYSMON VCC 3V3 {sysmon_vcc_3v3:.3f} | SYSMON VCC 3V3VA" f"SYSMON VCC 3V3 {sysmon_vcc_3v3:.3f} | SYSMON VCC 3V3VA {sysmon_vcc_3v3va}"
f" {sysmon_vcc_3v3va}"
) )
pw.dlog( pw.dlog(
f"SYSMON VCC 2V5DDR {sysmon_vcc_2v5ddr:.3f} | " f"SYSMON VCC 2V5DDR {sysmon_vcc_2v5ddr:.3f} | "
@ -641,7 +622,10 @@ class DirElement:
size: int size: int
def handle_mpsoc_data_reply(action_id: int, pw: PrintWrapper, custom_data: bytearray): def handle_mpsoc_data_reply(
action_id: int, printer: FsfwTmTcPrinter, custom_data: bytearray
):
pw = PrintWrapper(printer)
if action_id == ActionId.TM_MEM_READ_RPT: if action_id == ActionId.TM_MEM_READ_RPT:
header_list = [ header_list = [
"PLOC Memory Address", "PLOC Memory Address",
@ -653,16 +637,20 @@ def handle_mpsoc_data_reply(action_id: int, pw: PrintWrapper, custom_data: bytea
struct.unpack("!H", custom_data[4:6])[0], struct.unpack("!H", custom_data[4:6])[0],
"0x" + custom_data[6:10].hex(), "0x" + custom_data[6:10].hex(),
] ]
pw.dlog(f"{header_list}") print(header_list)
pw.dlog(f"{content_list}") print(content_list)
printer.file_logger.info(header_list)
printer.file_logger.info(content_list)
elif action_id == ActionId.TM_CAM_CMD_RPT: elif action_id == ActionId.TM_CAM_CMD_RPT:
header_list = ["Camera reply string", "ACK"] header_list = ["Camera reply string", "ACK"]
content_list = [ content_list = [
custom_data[: len(custom_data) - 1].decode("utf-8"), custom_data[: len(custom_data) - 1].decode("utf-8"),
hex(custom_data[-1]), hex(custom_data[-1]),
] ]
pw.dlog(f"{header_list}") print(header_list)
pw.dlog(f"{content_list}") print(content_list)
printer.file_logger.info(header_list)
printer.file_logger.info(content_list)
elif action_id == ActionId.TM_FLASH_DIRECTORY_CONTENT: elif action_id == ActionId.TM_FLASH_DIRECTORY_CONTENT:
if len(custom_data) < 16: if len(custom_data) < 16:
_LOGGER.warning( _LOGGER.warning(

View File

@ -21,7 +21,7 @@ from tmtccmd.tc import service_provider
from tmtccmd.tc.decorator import ServiceProviderParams from tmtccmd.tc.decorator import ServiceProviderParams
from tmtccmd.pus.s200_fsfw_mode import pack_mode_data, Mode from tmtccmd.pus.s200_fsfw_mode import pack_mode_data, Mode
from tmtccmd.pus.s8_fsfw_funccmd import create_action_cmd from tmtccmd.pus.s8_fsfw_funccmd import create_action_cmd
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from eive_tmtc.utility.input_helper import InputHelper from eive_tmtc.utility.input_helper import InputHelper
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -172,6 +172,7 @@ 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)
@ -222,7 +223,7 @@ def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper):
@service_provider(CustomServiceList.PLOC_SUPV) @service_provider(CustomServiceList.PLOC_SUPV)
def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 def pack_ploc_supv_commands(p: ServiceProviderParams):
q = p.queue_helper q = p.queue_helper
op_code = p.op_code op_code = p.op_code
object_id = get_object_ids().get(PLOC_SUPV_ID) object_id = get_object_ids().get(PLOC_SUPV_ID)
@ -471,8 +472,8 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901
custom_data.extend(struct.pack("!B", memory_id)) custom_data.extend(struct.pack("!B", memory_id))
custom_data.extend(struct.pack("!I", start_address)) custom_data.extend(struct.pack("!I", start_address))
q.add_log_cmd( q.add_log_cmd(
f"{prefix}: {Info.MEM_CHECK} for file {update_file} at memory ID" f"{prefix}: {Info.MEM_CHECK} for file {update_file} at memory ID {memory_id} at start "
f" {memory_id} at start address {start_address}" f"address {start_address}"
) )
command = create_action_cmd( command = create_action_cmd(
object_id.as_bytes, SupvActionId.MEM_CHECK, custom_data object_id.as_bytes, SupvActionId.MEM_CHECK, custom_data
@ -483,9 +484,7 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901
def pack_sel_boot_image_cmd( def pack_sel_boot_image_cmd(
object_id: bytes, mem: int, bp0: int, bp1: int, bp2: int object_id: bytes, mem: int, bp0: int, bp1: int, bp2: int
) -> bytearray: ) -> bytearray:
"""This function can be used to generate the command to select the image from which the MPSoC """This function can be used to generate the command to select the image from which the MPSoC will boot
will boot.
@param object_id The object id of the PLOC supervisor handler. @param object_id The object id of the PLOC supervisor handler.
@param mem The memory from which the MPSoC shall boot (NVM0 - 0, NVM1 - 1) @param mem The memory from which the MPSoC shall boot (NVM0 - 0, NVM1 - 1)
@param bp0 Partition pin 0 @param bp0 Partition pin 0
@ -722,42 +721,11 @@ def get_event_buffer_path() -> str:
return file return file
class SocState(enum.IntEnum): def handle_supv_hk_data(set_id: int, hk_data: bytes, printer: FsfwTmTcPrinter):
OFF = 0 pw = PrintWrapper(printer)
BOOTING = 1
OPERATIONAL = 2
SHUTDOWN = 3
def handle_supv_hk_data(set_id: int, hk_data: bytes, pw: PrintWrapper):
current_idx = 0 current_idx = 0
if set_id == SetIds.HK_REPORT: if set_id == SetIds.HK_REPORT:
fmt_str = "!IIIQIIIIIBBBB" pass
inc_len = struct.calcsize(fmt_str)
(
temp_ps,
temp_pl,
temp_sup,
uptime,
cpu_load,
avail_heap,
num_tcs,
num_tms,
soc_state,
nvm_0_1_state,
nvm_3_state,
mission_io_state,
fmc_state,
) = struct.unpack(fmt_str, hk_data[:inc_len])
pw.dlog(f"Temp PS {temp_ps} C | Temp PL {temp_pl} C | Temp SUP {temp_sup} C")
pw.dlog(f"Uptime {uptime} | CPU Load {cpu_load} | Avail Heap {avail_heap}")
pw.dlog(f"Number TCs {num_tcs} | Number TMs {num_tms}")
pw.dlog(f"SOC state {SocState(soc_state)}")
pw.dlog(f"NVM 01 State {nvm_0_1_state}")
pw.dlog(f"NVM 3 State {nvm_3_state}")
pw.dlog(f"Mission IO state {mission_io_state}")
pw.dlog(f"FMC state {fmc_state}")
pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[inc_len:], 13))
elif set_id == SetIds.BOOT_STATUS_REPORT: elif set_id == SetIds.BOOT_STATUS_REPORT:
fmt_str = "!BBIIBBBBBB" fmt_str = "!BBIIBBBBBB"
inc_len = struct.calcsize(fmt_str) inc_len = struct.calcsize(fmt_str)
@ -775,8 +743,7 @@ def handle_supv_hk_data(set_id: int, hk_data: bytes, pw: PrintWrapper):
) = struct.unpack(fmt_str, hk_data[0 : 0 + inc_len]) ) = struct.unpack(fmt_str, hk_data[0 : 0 + inc_len])
current_idx += inc_len current_idx += inc_len
pw.dlog( pw.dlog(
"SoC state (0:off, 1:booting, 2:update, 3:operating, 4:shutdown, 5:reset):" f"SoC state (0:off, 1:booting, 2:update, 3:operating, 4:shutdown, 5:reset): {soc_state}"
f" {soc_state}"
) )
pw.dlog(f"Power Cycles {power_cycles}") pw.dlog(f"Power Cycles {power_cycles}")
pw.dlog(f"Boot after {boot_after_ms} ms | Boot timeout {boot_timeout_ms} ms") pw.dlog(f"Boot after {boot_after_ms} ms | Boot timeout {boot_timeout_ms} ms")
@ -785,7 +752,7 @@ def handle_supv_hk_data(set_id: int, hk_data: bytes, pw: PrintWrapper):
f"BP0 State {bp_0_state} | BP1 State {bp_1_state} | BP2 State {bp_2_state}" f"BP0 State {bp_0_state} | BP1 State {bp_1_state} | BP2 State {bp_2_state}"
) )
pw.dlog(f"Boot State {boot_state} | Boot Cycles {boot_cycles}") pw.dlog(f"Boot State {boot_state} | Boot Cycles {boot_cycles}")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], 10) pw.printer.print_validity_buffer(hk_data[current_idx:], 10)
else: else:
pw.dlog(f"PLOC SUPV: HK handling not implemented for set ID {set_id}") pw.dlog(f"PLOC SUPV: HK handling not implemented for set ID {set_id}")
pw.dlog(f"Raw Data: 0x[{hk_data.hex(sep=',')}]") pw.dlog(f"Raw Data: 0x[{hk_data.hex(sep=',')}]")

View File

@ -18,7 +18,7 @@ from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_200_fsfw_mode import Mode, pack_mode_data from tmtccmd.tc.pus_200_fsfw_mode import Mode, pack_mode_data
from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid
from tmtccmd.util import ObjectIdU32 from tmtccmd.util import ObjectIdU32
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class SetId(enum.IntEnum): class SetId(enum.IntEnum):
@ -100,8 +100,9 @@ def rad_sensor_mode_cmd(
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data)) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
def handle_rad_sensor_data(pw: PrintWrapper, set_id: int, hk_data: bytes): def handle_rad_sensor_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
if set_id == SetId.HK: if set_id == SetId.HK:
pw = PrintWrapper(printer)
current_idx = 0 current_idx = 0
pw.dlog("Received Radiation Sensor HK data") pw.dlog("Received Radiation Sensor HK data")
fmt_str = "!fHHHHHH" fmt_str = "!fHHHHHH"
@ -111,10 +112,8 @@ def handle_rad_sensor_data(pw: PrintWrapper, set_id: int, hk_data: bytes):
) )
ain_dict = {0: ain0, 1: ain1, 4: ain4, 5: ain5, 6: ain6, 7: ain7} ain_dict = {0: ain0, 1: ain1, 4: ain4, 5: ain5, 6: ain6, 7: ain7}
pw.dlog(f"Temperature: {temp} C") pw.dlog(f"Temperature: {temp} C")
pw.dlog("AIN Channel | Raw Value (hex) | Raw Value (dec)") pw.dlog(f"AIN Channel | Raw Value (hex) | Raw Value (dec)")
for idx, val in ain_dict.items(): for idx, val in ain_dict.items():
pw.dlog(f"{idx} | {val:#06x} | {str(val).ljust(5)}") pw.dlog(f"{idx} | {val:#06x} | {str(val).ljust(5)}")
current_idx += inc_len current_idx += inc_len
FsfwTmTcPrinter.get_validity_buffer( printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=7)
validity_buffer=hk_data[current_idx:], num_vars=7
)

View File

@ -17,20 +17,17 @@ USE_SCEX_CONF_FILE = True
class OpCode: class OpCode:
PING = "ping" PING = ["0", "ping"]
ION_CMD = "ion" ION_CMD = ["1", "ion"]
TEMP_CMD = "temp" TEMP_CMD = ["2", "temp"]
EXP_STATUS_CMD = "expstatus" EXP_STATUS_CMD = ["3", "expstatus"]
ONE_CELLS_CMD = "onecell" ONE_CELLS_CMD = ["4", "onecell"]
ALL_CELLS_CMD = "allcells" ALL_CELLS_CMD = ["5", "allcells"]
FRAM = "fram" FRAM = ["6", "fram"]
ON = "on" SWITCH_ON = ["7", "on"]
SWITCH_ON = "on" SWITCH_OFF = ["8", "off"]
OFF = "off"
SWITCH_OFF = OFF
NORMAL = "normal"
class ActionId(enum.IntEnum): class ActionId(enum.IntEnum):
@ -56,7 +53,6 @@ class Info:
SWITCH_ON = "Switch Scex on" SWITCH_ON = "Switch Scex on"
SWITCH_OFF = "Switch Scex off" SWITCH_OFF = "Switch Scex off"
NORMAL = "Switch SCEX to normal mode"
@tmtc_definitions_provider @tmtc_definitions_provider
@ -70,9 +66,8 @@ def add_scex_cmds(defs: TmtcDefinitionWrapper):
oce.add(keys=OpCode.ALL_CELLS_CMD, info=Info.ALL_CELLS_CMD) oce.add(keys=OpCode.ALL_CELLS_CMD, info=Info.ALL_CELLS_CMD)
oce.add(keys=OpCode.FRAM, info=Info.FRAM) oce.add(keys=OpCode.FRAM, info=Info.FRAM)
oce.add(keys=OpCode.ON, info=Info.SWITCH_ON) oce.add(keys=OpCode.SWITCH_ON, info=Info.SWITCH_ON)
oce.add(keys=OpCode.OFF, info=Info.SWITCH_OFF) oce.add(keys=OpCode.SWITCH_OFF, info=Info.SWITCH_OFF)
oce.add(keys=OpCode.NORMAL, info=Info.NORMAL)
defs.add_service( defs.add_service(
name=CustomServiceList.SCEX.value, info="SCEX Device", op_code_entry=oce name=CustomServiceList.SCEX.value, info="SCEX Device", op_code_entry=oce
@ -80,10 +75,10 @@ def add_scex_cmds(defs: TmtcDefinitionWrapper):
@service_provider(CustomServiceList.SCEX.value) @service_provider(CustomServiceList.SCEX.value)
def pack_scex_cmds(p: ServiceProviderParams): # noqa C901 def pack_scex_cmds(p: ServiceProviderParams):
op_code = p.op_code op_code = p.op_code
q = p.queue_helper q = p.queue_helper
if op_code == OpCode.ON: if op_code in OpCode.SWITCH_ON:
q.add_log_cmd(Info.SWITCH_ON) q.add_log_cmd(Info.SWITCH_ON)
q.add_pus_tc( q.add_pus_tc(
PusTelecommand( PusTelecommand(
@ -92,16 +87,7 @@ def pack_scex_cmds(p: ServiceProviderParams): # noqa C901
app_data=pack_mode_data(SCEX_HANDLER_ID, Mode.ON, 0), app_data=pack_mode_data(SCEX_HANDLER_ID, Mode.ON, 0),
) )
) )
if op_code == OpCode.NORMAL: if op_code in OpCode.SWITCH_OFF:
q.add_log_cmd(Info.NORMAL)
q.add_pus_tc(
PusTelecommand(
service=200,
subservice=Subservice.TC_MODE_COMMAND,
app_data=pack_mode_data(SCEX_HANDLER_ID, Mode.NORMAL, 0),
)
)
if op_code == OpCode.OFF:
q.add_log_cmd(Info.SWITCH_OFF) q.add_log_cmd(Info.SWITCH_OFF)
q.add_pus_tc( q.add_pus_tc(
PusTelecommand( PusTelecommand(
@ -110,20 +96,20 @@ def pack_scex_cmds(p: ServiceProviderParams): # noqa C901
app_data=pack_mode_data(SCEX_HANDLER_ID, Mode.OFF, 0), app_data=pack_mode_data(SCEX_HANDLER_ID, Mode.OFF, 0),
) )
) )
if op_code == OpCode.PING: if op_code in OpCode.PING:
q.add_log_cmd(Info.PING) q.add_log_cmd(Info.PING)
app_data = bytes([0]) app_data = bytes([0])
q.add_pus_tc(create_action_cmd(SCEX_HANDLER_ID, ActionId.PING, app_data)) q.add_pus_tc(create_action_cmd(SCEX_HANDLER_ID, ActionId.PING, app_data))
if op_code == OpCode.ION_CMD: if op_code in OpCode.ION_CMD:
q.add_log_cmd(Info.ION_CMD) q.add_log_cmd(Info.ION_CMD)
app_data = bytes([0]) app_data = bytes([0])
q.add_pus_tc(create_action_cmd(SCEX_HANDLER_ID, ActionId.ION_CMD, app_data)) q.add_pus_tc(create_action_cmd(SCEX_HANDLER_ID, ActionId.ION_CMD, app_data))
if op_code == OpCode.TEMP_CMD: if op_code in OpCode.TEMP_CMD:
q.add_log_cmd(Info.TEMP_CMD) q.add_log_cmd(Info.TEMP_CMD)
app_data = bytes([0]) app_data = bytes([0])
q.add_pus_tc(create_action_cmd(SCEX_HANDLER_ID, ActionId.TEMP_CMD, app_data)) q.add_pus_tc(create_action_cmd(SCEX_HANDLER_ID, ActionId.TEMP_CMD, app_data))
if op_code == OpCode.EXP_STATUS_CMD: if op_code in OpCode.EXP_STATUS_CMD:
q.add_log_cmd(Info.EXP_STATUS_CMD) q.add_log_cmd(Info.EXP_STATUS_CMD)
app_data = bytes([0]) app_data = bytes([0])
q.add_pus_tc( q.add_pus_tc(
@ -131,7 +117,7 @@ def pack_scex_cmds(p: ServiceProviderParams): # noqa C901
) )
# one cell # one cell
if op_code == OpCode.ONE_CELLS_CMD: if op_code in OpCode.ONE_CELLS_CMD:
q.add_log_cmd(Info.ONE_CELLS_CMD) q.add_log_cmd(Info.ONE_CELLS_CMD)
app_data = bytearray([0]) app_data = bytearray([0])
@ -145,7 +131,8 @@ def pack_scex_cmds(p: ServiceProviderParams): # noqa C901
cell_select = int(cell_select) cell_select = int(cell_select)
if cell_select < 1 or cell_select > 10: if cell_select < 1 or cell_select > 10:
print( print(
f"Invalid cell number {cell_select}, Please enter a valid number: " f"Invalid cell number {cell_select}, "
f"Please enter a valid number: "
) )
continue continue
cn = cell_select - 1 cn = cell_select - 1
@ -178,7 +165,7 @@ def pack_scex_cmds(p: ServiceProviderParams): # noqa C901
create_action_cmd(SCEX_HANDLER_ID, ActionId.ONE_CELLS_CMD, app_data) create_action_cmd(SCEX_HANDLER_ID, ActionId.ONE_CELLS_CMD, app_data)
) )
if op_code == OpCode.ALL_CELLS_CMD: if op_code in OpCode.ALL_CELLS_CMD:
q.add_log_cmd(Info.ALL_CELLS_CMD) q.add_log_cmd(Info.ALL_CELLS_CMD)
app_data = bytearray([0]) app_data = bytearray([0])
@ -210,7 +197,7 @@ def pack_scex_cmds(p: ServiceProviderParams): # noqa C901
create_action_cmd(SCEX_HANDLER_ID, ActionId.ALL_CELLS_CMD, app_data) create_action_cmd(SCEX_HANDLER_ID, ActionId.ALL_CELLS_CMD, app_data)
) )
if op_code == OpCode.FRAM: if op_code in OpCode.FRAM:
q.add_log_cmd(Info.FRAM) q.add_log_cmd(Info.FRAM)
app_data = bytes([0]) app_data = bytes([0])
q.add_pus_tc(create_action_cmd(SCEX_HANDLER_ID, ActionId.FRAM, app_data)) q.add_pus_tc(create_action_cmd(SCEX_HANDLER_ID, ActionId.FRAM, app_data))

View File

@ -12,7 +12,7 @@ from tmtccmd.tc.decorator import ServiceProviderParams
from tmtccmd.tc.pus_200_fsfw_mode import Subservice as ModeSubservice from tmtccmd.tc.pus_200_fsfw_mode import Subservice as ModeSubservice
class ModeId(enum.IntEnum): class ModeId:
OFF = 0 OFF = 0
SUPV_ONLY = 10 SUPV_ONLY = 10
MPSOC_STREAM = 11 MPSOC_STREAM = 11

View File

@ -1 +0,0 @@
from .subsystem import add_eps_subsystem_cmds

View File

@ -17,7 +17,7 @@ from tmtccmd.pus.s8_fsfw_funccmd import create_action_cmd
from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid
from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode
from tmtccmd.tc.pus_200_fsfw_mode import Subservice as ModeSubservices from tmtccmd.tc.pus_200_fsfw_mode import Subservice as ModeSubservices
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class BpxSetId(enum.IntEnum): class BpxSetId(enum.IntEnum):
@ -28,30 +28,18 @@ class BpxSetId(enum.IntEnum):
class BpxActionId: class BpxActionId:
REBOOT = 2 REBOOT = 2
RESET_COUNTERS = 3 RESET_COUNTERS = 3
CONFIG_CMD = 4 SET_CFG = 4
GET_CFG = 5 GET_CFG = 5
SET_CFG = 6
MAN_HEATER_ON = 10
MAN_HEATER_OFF = 11
class BpxHeaterModeSelect(enum.IntEnum):
OFF = 0
AUTO = 1
class BpxOpCode: class BpxOpCode:
HK = "hk" HK = ["0", "hk"]
OFF = "off" OFF = ["off"]
ON = "on" ON = ["on"]
RST_CFG = "reset_cfg" RST_BOOT_CNT = ["1", "rst_boot_cnt"]
SET_CFG = "set_cfg" REQUEST_CFG = ["2", "cfg"]
MAN_HEATER_ON = "man_heater_on" REQUEST_CFG_HK = ["3", "cfg_hk"]
MAN_HEATER_OFF = "man_heater_off" REBOOT = ["4", "reboot"]
RST_BOOT_CNT = "rst_boot_cnt"
REQUEST_CFG = "cfg"
REQUEST_CFG_HK = "cfg_hk"
REBOOT = "reboot"
@tmtc_definitions_provider @tmtc_definitions_provider
@ -61,10 +49,6 @@ def add_bpx_cmd_definitions(defs: TmtcDefinitionWrapper):
oce.add(keys=BpxOpCode.OFF, info="Off command") oce.add(keys=BpxOpCode.OFF, info="Off command")
oce.add(keys=BpxOpCode.HK, info="Request BPX HK") oce.add(keys=BpxOpCode.HK, info="Request BPX HK")
oce.add(keys=BpxOpCode.RST_BOOT_CNT, info="Reset Boot Count") oce.add(keys=BpxOpCode.RST_BOOT_CNT, info="Reset Boot Count")
oce.add(keys=BpxOpCode.RST_CFG, info="Reset Config to stored default settings")
oce.add(keys=BpxOpCode.SET_CFG, info="Set BPX configuration")
oce.add(keys=BpxOpCode.MAN_HEATER_ON, info="Manual heater on")
oce.add(keys=BpxOpCode.MAN_HEATER_OFF, info="Manual heater off")
oce.add(keys=BpxOpCode.REQUEST_CFG, info="Request Configuration Struct (Step 1)") oce.add(keys=BpxOpCode.REQUEST_CFG, info="Request Configuration Struct (Step 1)")
oce.add( oce.add(
keys=BpxOpCode.REQUEST_CFG_HK, info="Request Configuration Struct HK (Step 2)" keys=BpxOpCode.REQUEST_CFG_HK, info="Request Configuration Struct HK (Step 2)"
@ -78,14 +62,14 @@ def add_bpx_cmd_definitions(defs: TmtcDefinitionWrapper):
@service_provider(CustomServiceList.BPX_BATTERY.value) @service_provider(CustomServiceList.BPX_BATTERY.value)
def pack_bpx_commands(p: ServiceProviderParams): # noqa C901: Complexity is okay here. def pack_bpx_commands(p: ServiceProviderParams):
op_code = p.op_code op_code = p.op_code
q = p.queue_helper q = p.queue_helper
if op_code == BpxOpCode.HK: if op_code in BpxOpCode.HK:
q.add_log_cmd("Requesting BPX battery HK set") q.add_log_cmd("Requesting BPX battery HK set")
sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetId.GET_HK_SET) sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetId.GET_HK_SET)
q.add_pus_tc(generate_one_hk_command(sid=sid)) q.add_pus_tc(generate_one_hk_command(sid=sid))
if op_code == BpxOpCode.OFF: if op_code in BpxOpCode.OFF:
q.add_log_cmd("Off mode") q.add_log_cmd("Off mode")
mode_cmd = pack_mode_data(BPX_HANDLER_ID, Mode.OFF, 0) mode_cmd = pack_mode_data(BPX_HANDLER_ID, Mode.OFF, 0)
q.add_pus_tc( q.add_pus_tc(
@ -95,7 +79,7 @@ def pack_bpx_commands(p: ServiceProviderParams): # noqa C901: Complexity is oka
app_data=mode_cmd, app_data=mode_cmd,
) )
) )
if op_code == BpxOpCode.ON: if op_code in BpxOpCode.ON:
q.add_log_cmd("On mode") q.add_log_cmd("On mode")
mode_cmd = pack_mode_data(BPX_HANDLER_ID, Mode.ON, 0) mode_cmd = pack_mode_data(BPX_HANDLER_ID, Mode.ON, 0)
q.add_pus_tc( q.add_pus_tc(
@ -105,71 +89,27 @@ def pack_bpx_commands(p: ServiceProviderParams): # noqa C901: Complexity is oka
app_data=mode_cmd, app_data=mode_cmd,
) )
) )
if op_code == BpxOpCode.RST_BOOT_CNT: if op_code in BpxOpCode.RST_BOOT_CNT:
q.add_log_cmd("Resetting reboot counters") q.add_log_cmd("Resetting reboot counters")
q.add_pus_tc( q.add_pus_tc(
create_action_cmd( create_action_cmd(
object_id=BPX_HANDLER_ID, action_id=BpxActionId.RESET_COUNTERS object_id=BPX_HANDLER_ID, action_id=BpxActionId.RESET_COUNTERS
) )
) )
if op_code == BpxOpCode.RST_CFG: if op_code in BpxOpCode.REQUEST_CFG:
q.add_log_cmd("Reset BPX configuration")
q.add_pus_tc(
create_action_cmd(
object_id=BPX_HANDLER_ID, action_id=BpxActionId.CONFIG_CMD
)
)
if op_code == BpxOpCode.SET_CFG:
q.add_log_cmd("Setting BPX configuration")
user_data = bytearray()
batt_mode = BpxHeaterModeSelect(
int(input("BPX heater mode select, 0 for OFF 1 for AUTO: "))
)
user_data.append(batt_mode)
lower_limit = int(input("Lower heater limit (-2 default): "))
user_data.append(struct.pack("!b", lower_limit)[0])
upper_limit = int(input("Upper heater limit (3 default): "))
user_data.append(struct.pack("!b", upper_limit)[0])
q.add_pus_tc(
create_action_cmd(
object_id=BPX_HANDLER_ID,
action_id=BpxActionId.SET_CFG,
user_data=user_data,
)
)
if op_code == BpxOpCode.REQUEST_CFG:
q.add_log_cmd("Requesting configuration struct") q.add_log_cmd("Requesting configuration struct")
q.add_pus_tc( q.add_pus_tc(
create_action_cmd(object_id=BPX_HANDLER_ID, action_id=BpxActionId.GET_CFG) create_action_cmd(object_id=BPX_HANDLER_ID, action_id=BpxActionId.GET_CFG)
) )
if op_code == BpxOpCode.REQUEST_CFG_HK: if op_code in BpxOpCode.REQUEST_CFG_HK:
q.add_log_cmd("Requesting configuration struct HK") q.add_log_cmd("Requesting configuration struct HK")
sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetId.GET_CFG_SET) sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetId.GET_CFG_SET)
q.add_pus_tc(generate_one_hk_command(sid=sid)) q.add_pus_tc(generate_one_hk_command(sid=sid))
if op_code == BpxOpCode.REBOOT: if op_code in BpxOpCode.REBOOT:
q.add_log_cmd("Rebooting BPX battery") q.add_log_cmd("Rebooting BPX battery")
q.add_pus_tc( q.add_pus_tc(
create_action_cmd(object_id=BPX_HANDLER_ID, action_id=BpxActionId.REBOOT) create_action_cmd(object_id=BPX_HANDLER_ID, action_id=BpxActionId.REBOOT)
) )
if op_code == BpxOpCode.MAN_HEATER_ON:
q.add_log_cmd("BPX manual heater on with seconds burntime")
burn_time = int(input("BPX heater burn time in seconds [1-65535]: "))
if burn_time < 1 or burn_time > 65535:
raise ValueError("Invalid burntime, smaller than 0 or larger than 65535")
q.add_pus_tc(
create_action_cmd(
object_id=BPX_HANDLER_ID,
action_id=BpxActionId.MAN_HEATER_ON,
user_data=struct.pack("!H", burn_time),
)
)
if op_code == BpxOpCode.MAN_HEATER_OFF:
q.add_log_cmd("BPX manual heater off")
q.add_pus_tc(
create_action_cmd(
object_id=BPX_HANDLER_ID, action_id=BpxActionId.MAN_HEATER_OFF
)
)
HEADER_LIST = [ HEADER_LIST = [
@ -186,7 +126,8 @@ HEADER_LIST = [
] ]
def handle_bpx_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes): def handle_bpx_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
pw = PrintWrapper(printer)
if set_id == BpxSetId.GET_HK_SET: if set_id == BpxSetId.GET_HK_SET:
fmt_str = "!HHHHhhhhIB" fmt_str = "!HHHHhhhhIB"
inc_len = struct.calcsize(fmt_str) inc_len = struct.calcsize(fmt_str)
@ -217,9 +158,7 @@ def handle_bpx_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes):
validity_buffer = hk_data[inc_len:] validity_buffer = hk_data[inc_len:]
pw.dlog(str(HEADER_LIST)) pw.dlog(str(HEADER_LIST))
pw.dlog(str(content_list)) pw.dlog(str(content_list))
FsfwTmTcPrinter.get_validity_buffer( printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=10)
validity_buffer=validity_buffer, num_vars=10
)
elif set_id == BpxSetId.GET_CFG_SET: elif set_id == BpxSetId.GET_CFG_SET:
battheat_mode = hk_data[0] battheat_mode = hk_data[0]
battheat_low = struct.unpack("!b", hk_data[1:2])[0] battheat_low = struct.unpack("!b", hk_data[1:2])[0]
@ -233,6 +172,4 @@ def handle_bpx_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes):
validity_buffer = hk_data[3:] validity_buffer = hk_data[3:]
pw.dlog(str(header_list)) pw.dlog(str(header_list))
pw.dlog(str(content_list)) pw.dlog(str(content_list))
FsfwTmTcPrinter.get_validity_buffer( printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=10)
validity_buffer=validity_buffer, num_vars=10
)

View File

@ -140,7 +140,7 @@ def pack_common_power_cmds(
q.add_pus_tc(disable_periodic_hk_command(True, make_sid(objb, SetId.CORE))) q.add_pus_tc(disable_periodic_hk_command(True, make_sid(objb, SetId.CORE)))
def pack_common_gomspace_cmds( # noqa C901: Complexity is okay here. def pack_common_gomspace_cmds(
prefix: str, object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str prefix: str, object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
): ):
objb = object_id.as_bytes objb = object_id.as_bytes
@ -200,8 +200,7 @@ def pack_common_gomspace_cmds( # noqa C901: Complexity is okay here.
if op_code in GomspaceOpCode.SAVE_TABLE_DEFAULT: if op_code in GomspaceOpCode.SAVE_TABLE_DEFAULT:
source_table = int( source_table = int(
input( input(
"Source table [0: Board Config, 1: Module Config, 2: Calibration" "Source table [0: Board Config, 1: Module Config, 2: Calibration Parameter]: "
" Parameter]: "
) )
) )
if source_table not in [0, 1, 2]: if source_table not in [0, 1, 2]:
@ -216,8 +215,8 @@ def pack_common_gomspace_cmds( # noqa C901: Complexity is okay here.
if op_code in GomspaceOpCode.LOAD_TABLE: if op_code in GomspaceOpCode.LOAD_TABLE:
target_table = int( target_table = int(
input( input(
"Target table ID [0: Board Config, 1: Module Config, 2: Calibration" "Target table ID [0: Board Config, 1: Module Config, 2: Calibration Parameter, "
" Parameter, 4: HK TM]: " "4: HK TM]: "
) )
) )
if target_table not in [0, 1, 2, 4]: if target_table not in [0, 1, 2, 4]:
@ -225,8 +224,8 @@ def pack_common_gomspace_cmds( # noqa C901: Complexity is okay here.
if target_table != 4: if target_table != 4:
source_table = int( source_table = int(
input( input(
"Source table (file or default) [0: Board Config, 1: Module Config," "Source table (file or default) [0: Board Config, 1: Module Config, "
" 2: Calibration Parameter, value + 4 for default table]: " "2: Calibration Parameter, value + 4 for default table]: "
) )
) )
if source_table not in [0, 1, 2, 4, 5, 6]: if source_table not in [0, 1, 2, 4, 5, 6]:

View File

@ -98,9 +98,7 @@ class P60DockHkTable:
wdt_gnd_left = TableEntry(bytearray([0x00, 0xA8]), TableEntry.uint32_size) wdt_gnd_left = TableEntry(bytearray([0x00, 0xA8]), TableEntry.uint32_size)
def pack_p60dock_cmds( # noqa C901: Complexity okay here. def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str):
object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
):
objb = object_id.as_bytes objb = object_id.as_bytes
pack_common_power_cmds("P60 Dock", object_id, q, op_code) pack_common_power_cmds("P60 Dock", object_id, q, op_code)
pack_common_gomspace_cmds("P60 Dock", object_id, q, op_code) pack_common_gomspace_cmds("P60 Dock", object_id, q, op_code)

View File

@ -3,16 +3,8 @@
@author J. Meier @author J. Meier
@date 17.12.2020 @date 17.12.2020
""" """
import enum
from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.config.object_ids import PDU_1_HANDLER_ID from eive_tmtc.config.object_ids import PDU_1_HANDLER_ID
from eive_tmtc.gomspace.gomspace_common import (
pack_ping_command,
TableIds,
pack_get_param_command,
)
from eive_tmtc.gomspace.gomspace_pdu_definitions import PduHkTable
from eive_tmtc.tmtc.power.common_power import ( from eive_tmtc.tmtc.power.common_power import (
pack_common_gomspace_cmds, pack_common_gomspace_cmds,
req_hk_cmds, req_hk_cmds,
@ -25,15 +17,15 @@ from eive_tmtc.tmtc.power.common_power import (
pack_common_power_cmds, pack_common_power_cmds,
GomspaceOpCode, GomspaceOpCode,
GsInfo, GsInfo,
PowerInfo,
add_common_power_defs, add_common_power_defs,
SetId, SetId,
) )
from spacepackets.ecss import PusTelecommand
from eive_tmtc.gomspace.gomspace_common import *
from eive_tmtc.gomspace.gomspace_pdu_definitions import *
from tmtccmd.config import OpCodeEntry, TmtcDefinitionWrapper from tmtccmd.config import OpCodeEntry, TmtcDefinitionWrapper
from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.config.tmtc import tmtc_definitions_provider
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.util import ObjectIdU32
class Pdu1InfoBase: class Pdu1InfoBase:
@ -110,9 +102,7 @@ def info_off_pdu1(base: str) -> str:
return "PDU1: " + base + " off" return "PDU1: " + base + " off"
def pdu1_switch_cmds( # noqa C901: Complexity is okay here. def pdu1_switch_cmds(q: DefaultPusQueueHelper, op_code: str):
q: DefaultPusQueueHelper, op_code: str
): # noqa C901: Complexity okay here
if op_code in PowerOpCodes.TCS_ON: if op_code in PowerOpCodes.TCS_ON:
tcs_on_cmd(q) tcs_on_cmd(q)
elif op_code in PowerOpCodes.TCS_OFF: elif op_code in PowerOpCodes.TCS_OFF:
@ -191,7 +181,6 @@ PDU1_DICT = {
Pdu1ChIndex.SYRLINKS: Pdu1InfoBase.SYRLINKS, Pdu1ChIndex.SYRLINKS: Pdu1InfoBase.SYRLINKS,
Pdu1ChIndex.MGT: Pdu1InfoBase.MGT, Pdu1ChIndex.MGT: Pdu1InfoBase.MGT,
Pdu1ChIndex.SCEX: Pdu1InfoBase.SCEX, Pdu1ChIndex.SCEX: Pdu1InfoBase.SCEX,
Pdu1ChIndex.PLOC: Pdu1InfoBase.PLOC,
Pdu1ChIndex.ACS_A: Pdu1InfoBase.ACS_A, Pdu1ChIndex.ACS_A: Pdu1InfoBase.ACS_A,
Pdu1ChIndex.SUS_N: Pdu1InfoBase.SUS_N, Pdu1ChIndex.SUS_N: Pdu1InfoBase.SUS_N,
} }

View File

@ -6,18 +6,7 @@
@author J. Meier @author J. Meier
@date 17.12.2020 @date 17.12.2020
""" """
import enum
from eive_tmtc.config.object_ids import PDU_2_HANDLER_ID from eive_tmtc.config.object_ids import PDU_2_HANDLER_ID
from eive_tmtc.gomspace.gomspace_common import (
pack_reboot_command,
pack_ping_command,
pack_gnd_wdt_reset_command,
pack_get_param_command,
TableIds,
pack_request_full_hk_table_command,
)
from eive_tmtc.gomspace.gomspace_pdu_definitions import PduHkTable, PduConfigTable
from eive_tmtc.tmtc.power.common_power import ( from eive_tmtc.tmtc.power.common_power import (
pack_common_gomspace_cmds, pack_common_gomspace_cmds,
req_hk_cmds, req_hk_cmds,
@ -31,11 +20,10 @@ from eive_tmtc.tmtc.power.common_power import (
SetId, SetId,
add_common_power_defs, add_common_power_defs,
) )
from spacepackets.ecss import PusTelecommand from eive_tmtc.gomspace.gomspace_common import *
from eive_tmtc.gomspace.gomspace_pdu_definitions import *
from tmtccmd.config import OpCodeEntry, TmtcDefinitionWrapper from tmtccmd.config import OpCodeEntry, TmtcDefinitionWrapper
from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.config.tmtc import tmtc_definitions_provider
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.util import ObjectIdU32
class Pdu2InfoBase: class Pdu2InfoBase:
@ -171,7 +159,7 @@ def add_pdu2_cmds(defs: TmtcDefinitionWrapper):
) )
def pdu2_switch_cmds(q: DefaultPusQueueHelper, op_code: str): # noqa C901 def pdu2_switch_cmds(q: DefaultPusQueueHelper, op_code: str):
if op_code in PowerOpCodes.PL_PCDU_VBAT_NOM_ON: if op_code in PowerOpCodes.PL_PCDU_VBAT_NOM_ON:
pl_pcdu_bat_nom_on_cmd(q) pl_pcdu_bat_nom_on_cmd(q)
elif op_code in PowerOpCodes.PL_PCDU_VBAT_NOM_OFF: elif op_code in PowerOpCodes.PL_PCDU_VBAT_NOM_OFF:

View File

@ -22,13 +22,13 @@ from tmtccmd.tc.pus_11_tc_sched import (
) )
from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode, Subservice from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode, Subservice
from tmtccmd.tc.pus_20_fsfw_param import ( from tmtccmd.tc.pus_20_fsfw_param import (
create_scalar_double_parameter, pack_scalar_double_param_app_data,
create_load_param_cmd, create_load_param_cmd,
create_scalar_boolean_parameter, pack_boolean_parameter_app_data,
) )
from spacepackets.ecss.tc import PusTelecommand from spacepackets.ecss.tc import PusTelecommand
from eive_tmtc.config.object_ids import PL_PCDU_ID from eive_tmtc.config.object_ids import PL_PCDU_ID
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -85,40 +85,6 @@ class NormalSubmodesMask(enum.IntEnum):
HPA_ON = 5 HPA_ON = 5
class SubmodeForNormalMode(enum.IntEnum):
NONE = 0
SSR_ON = 1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON
DRO_ON = 1 << NormalSubmodesMask.DRO_ON | (
1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON
)
X8_ON = (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
)
TX_ON = (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
| (1 << NormalSubmodesMask.TX_ON)
)
MPA_ON = (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
| (1 << NormalSubmodesMask.TX_ON)
| (1 << NormalSubmodesMask.MPA_ON)
)
HPA_ON = (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
| (1 << NormalSubmodesMask.TX_ON)
| (1 << NormalSubmodesMask.MPA_ON)
| (1 << NormalSubmodesMask.HPA_ON)
)
class ParamIds(enum.IntEnum): class ParamIds(enum.IntEnum):
NEG_V_LOWER_BOUND = 0 NEG_V_LOWER_BOUND = 0
NEG_V_UPPER_BOUND = 1 NEG_V_UPPER_BOUND = 1
@ -195,9 +161,7 @@ def add_pl_pcdu_cmds(defs: TmtcDefinitionWrapper):
defs.add_service(CustomServiceList.PL_PCDU.value, "PL PCDU", oce) defs.add_service(CustomServiceList.PL_PCDU.value, "PL PCDU", oce)
def pack_pl_pcdu_commands( # noqa C901: Complexity is okay here. def pack_pl_pcdu_commands(q: DefaultPusQueueHelper, op_code: str):
q: DefaultPusQueueHelper, op_code: str
): # noqa C901: Complexity is okay here.
if op_code in OpCode.SWITCH_ON: if op_code in OpCode.SWITCH_ON:
pack_pl_pcdu_mode_cmd(q=q, info=Info.SWITCH_ON, mode=Mode.ON, submode=0) pack_pl_pcdu_mode_cmd(q=q, info=Info.SWITCH_ON, mode=Mode.ON, submode=0)
if op_code in OpCode.SWITCH_OFF: if op_code in OpCode.SWITCH_OFF:
@ -284,7 +248,7 @@ def hpa_on_procedure(q: DefaultPusQueueHelper):
if delay_dro_to_x8 is None: if delay_dro_to_x8 is None:
delay_dro_to_x8 = 900 delay_dro_to_x8 = 900
q.add_log_cmd( q.add_log_cmd(
"Starting procedure to switch on PL PCDU HPA with DRO to X8 " f"Starting procedure to switch on PL PCDU HPA with DRO to X8 "
f"delay of {delay_dro_to_x8} seconds" f"delay of {delay_dro_to_x8} seconds"
) )
pl_pcdu_on = PusTelecommand( pl_pcdu_on = PusTelecommand(
@ -417,17 +381,41 @@ def request_wait_time() -> Optional[float]:
def submode_mask_to_submode(on_tgt: NormalSubmodesMask) -> int: def submode_mask_to_submode(on_tgt: NormalSubmodesMask) -> int:
if on_tgt == NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON: if on_tgt == NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON:
return SubmodeForNormalMode.SSR_ON return 1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON
if on_tgt == NormalSubmodesMask.DRO_ON: if on_tgt == NormalSubmodesMask.DRO_ON:
return SubmodeForNormalMode.DRO_ON return 1 << NormalSubmodesMask.DRO_ON | (
1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON
)
if on_tgt == NormalSubmodesMask.X8_ON: if on_tgt == NormalSubmodesMask.X8_ON:
return SubmodeForNormalMode.X8_ON return (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
)
if on_tgt == NormalSubmodesMask.TX_ON: if on_tgt == NormalSubmodesMask.TX_ON:
return SubmodeForNormalMode.TX_ON return (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
| (1 << NormalSubmodesMask.TX_ON)
)
if on_tgt == NormalSubmodesMask.MPA_ON: if on_tgt == NormalSubmodesMask.MPA_ON:
return SubmodeForNormalMode.MPA_ON return (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
| (1 << NormalSubmodesMask.TX_ON)
| (1 << NormalSubmodesMask.MPA_ON)
)
if on_tgt == NormalSubmodesMask.HPA_ON: if on_tgt == NormalSubmodesMask.HPA_ON:
return SubmodeForNormalMode.HPA_ON return (
1 << NormalSubmodesMask.DRO_ON
| (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON)
| (1 << NormalSubmodesMask.X8_ON)
| (1 << NormalSubmodesMask.TX_ON)
| (1 << NormalSubmodesMask.MPA_ON)
| (1 << NormalSubmodesMask.HPA_ON)
)
def pack_wait_time_cmd(q: DefaultPusQueueHelper, param_id: int, print_str: str): def pack_wait_time_cmd(q: DefaultPusQueueHelper, param_id: int, print_str: str):
@ -435,21 +423,21 @@ def pack_wait_time_cmd(q: DefaultPusQueueHelper, param_id: int, print_str: str):
q.add_log_cmd(f"Updating {print_str} wait time to {wait_time}") q.add_log_cmd(f"Updating {print_str} wait time to {wait_time}")
if wait_time is None: if wait_time is None:
return return
param_data = create_scalar_double_parameter( param_data = pack_scalar_double_param_app_data(
object_id=PL_PCDU_ID, object_id=PL_PCDU_ID,
domain_id=0, domain_id=0,
unique_id=param_id, unique_id=param_id,
parameter=wait_time, parameter=wait_time,
) )
q.add_pus_tc(create_load_param_cmd(param_data)) q.add_pus_tc(create_load_param_cmd(app_data=param_data))
def pack_failure_injection_cmd(q: DefaultPusQueueHelper, param_id: int, print_str: str): def pack_failure_injection_cmd(q: DefaultPusQueueHelper, param_id: int, print_str: str):
q.add_log_cmd(f"Inserting {print_str} error") q.add_log_cmd(f"Inserting {print_str} error")
param_data = create_scalar_boolean_parameter( param_data = pack_boolean_parameter_app_data(
object_id=PL_PCDU_ID, domain_id=0, unique_id=param_id, parameter=True object_id=PL_PCDU_ID, domain_id=0, unique_id=param_id, parameter=True
) )
q.add_pus_tc(create_load_param_cmd(param_data)) q.add_pus_tc(create_load_param_cmd(app_data=param_data))
def pack_pl_pcdu_mode_cmd( def pack_pl_pcdu_mode_cmd(
@ -480,8 +468,9 @@ ADC_CHANNELS_NAMED = [
] ]
def handle_plpcdu_hk(pw: PrintWrapper, set_id: int, hk_data: bytes): def handle_plpcdu_hk(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
if set_id == SetId.ADC: if set_id == SetId.ADC:
pw = PrintWrapper(printer)
current_idx = 0 current_idx = 0
pw.dlog("Received PL PCDU ADC HK data") pw.dlog("Received PL PCDU ADC HK data")
channels = [] channels = []
@ -507,6 +496,4 @@ def handle_plpcdu_hk(pw: PrintWrapper, set_id: int, hk_data: bytes):
pw.dlog(ch_print) pw.dlog(ch_print)
for i in range(12): for i in range(12):
pw.dlog(f"{ADC_CHANNELS_NAMED[i].ljust(24)} | {processed_vals[i]}") pw.dlog(f"{ADC_CHANNELS_NAMED[i].ljust(24)} | {processed_vals[i]}")
FsfwTmTcPrinter.get_validity_buffer( printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=3)
validity_buffer=hk_data[current_idx:], num_vars=3
)

View File

@ -35,6 +35,7 @@ from eive_tmtc.tmtc.power.acu import add_acu_cmds, acu_req_hk_cmds
from tmtccmd.tc.pus_3_fsfw_hk import ( from tmtccmd.tc.pus_3_fsfw_hk import (
create_request_one_diag_command, create_request_one_diag_command,
make_sid, make_sid,
create_request_one_hk_command,
) )
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

View File

@ -1,302 +0,0 @@
import datetime
import enum
import logging
import struct
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.config.object_ids import PWR_CONTROLLER
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.config.tmtc import (
tmtc_definitions_provider,
TmtcDefinitionWrapper,
OpCodeEntry,
)
from tmtccmd.tc import service_provider
from tmtccmd.tc.queue import DefaultPusQueueHelper
from tmtccmd.tc.pus_200_fsfw_mode import Mode, pack_mode_command
from tmtccmd.tc.decorator import ServiceProviderParams
from tmtccmd.tc.pus_3_fsfw_hk import (
generate_one_hk_command,
make_sid,
enable_periodic_hk_command_with_interval,
disable_periodic_hk_command,
)
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter
from tmtccmd.tc.pus_20_fsfw_param import create_load_param_cmd
from tmtccmd.pus.s20_fsfw_param_defs import (
create_scalar_float_parameter,
create_scalar_double_parameter,
)
_LOGGER = logging.getLogger(__name__)
class SetId(enum.IntEnum):
CORE_HK_SET = 0
ENABLE_PL_SET = 1
# class ActionId(enum.IntEnum):
class ParamId(enum.IntEnum):
BATTERY_INTERNAL_RESISTANCE = 0
BATTERY_MAXIMUM_CAPACITY = 1
COULOMB_COUNTER_VOLTAGE_UPPER_THRESHOLD = 2
MAX_ALLOWED_TIME_DIFF = 3
PAYLOAD_OP_LIMIT_ON = 4
PAYLOAD_OP_LIMIT_LOW = 5
HIGHER_MODES_LIMIT = 6
class OpCodes:
OFF = ["mode_off"]
ON = ["mode_on"]
NML = ["mode_normal"]
SET_PARAMETER = ["set_parameter"]
REQUEST_CORE_HK = ["core_hk"]
ENABLE_CORE_HK = ["core_enable_hk"]
DISABLE_CORE_HK = ["core_disable_hk"]
REQUEST_ENABLE_PL_HK = ["enable_pl_hk"]
ENABLE_ENABLE_PL_HK = ["enable_pl_enable_hk"]
DISABLE_ENABLE_PL_HK = ["enable_pl_disable_hk"]
class Info:
OFF = "PWR Ctrl Mode to OFF"
ON = "PWR Ctrl Mode to ON"
NML = "PWR Ctrl Mode to NORMAL"
SET_PARAMETER = "Set Parameter"
REQUEST_CORE_HK = "Request Core HK once"
ENABLE_CORE_HK = "Enable Core HK Data Generation"
DISABLE_CORE_HK = "Disable Core HK Data Generation"
REQUEST_ENABLE_PL_HK = "Request Enable PL HK once"
ENABLE_ENABLE_PL_HK = "Enable Enable PL HK Data Generation"
DISABLE_ENABLE_PL_HK = "Disable Enable PL HK Data Generation"
@tmtc_definitions_provider
def acs_cmd_defs(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
oce.add(keys=OpCodes.OFF, info=Info.OFF)
oce.add(keys=OpCodes.ON, info=Info.ON)
oce.add(keys=OpCodes.NML, info=Info.NML)
oce.add(keys=OpCodes.SET_PARAMETER, info=Info.SET_PARAMETER)
oce.add(keys=OpCodes.REQUEST_CORE_HK, info=Info.REQUEST_CORE_HK)
oce.add(keys=OpCodes.ENABLE_CORE_HK, info=Info.ENABLE_CORE_HK)
oce.add(keys=OpCodes.DISABLE_CORE_HK, info=Info.DISABLE_CORE_HK)
oce.add(keys=OpCodes.REQUEST_ENABLE_PL_HK, info=Info.REQUEST_ENABLE_PL_HK)
oce.add(keys=OpCodes.ENABLE_ENABLE_PL_HK, info=Info.ENABLE_ENABLE_PL_HK)
oce.add(keys=OpCodes.DISABLE_ENABLE_PL_HK, info=Info.DISABLE_ENABLE_PL_HK)
defs.add_service(
name=CustomServiceList.PWR_CTRL.value, info="PWR Controller", op_code_entry=oce
)
@service_provider(CustomServiceList.PWR_CTRL.value)
def pack_acs_ctrl_command(p: ServiceProviderParams):
op_code = p.op_code
q = p.queue_helper
if op_code in OpCodes.OFF:
q.add_log_cmd(f"{Info.OFF}")
q.add_pus_tc(pack_mode_command(PWR_CONTROLLER, Mode.OFF, 0))
elif op_code in OpCodes.ON:
q.add_log_cmd(f"{Info.ON}")
q.add_pus_tc(pack_mode_command(PWR_CONTROLLER, Mode.ON, 0))
elif op_code in OpCodes.NML:
q.add_log_cmd(f"{Info.NML}")
q.add_pus_tc(pack_mode_command(PWR_CONTROLLER, Mode.NORMAL, 0))
elif op_code in OpCodes.SET_PARAMETER:
q.add_log_cmd(f"{Info.SET_PARAMETER}")
set_pwr_ctrl_param(q)
elif op_code in OpCodes.REQUEST_CORE_HK:
q.add_log_cmd(Info.REQUEST_CORE_HK)
q.add_pus_tc(
generate_one_hk_command(make_sid(PWR_CONTROLLER, SetId.CORE_HK_SET))
)
elif op_code in OpCodes.ENABLE_CORE_HK:
interval = float(input("Please specify interval in floating point seconds: "))
q.add_log_cmd(Info.ENABLE_CORE_HK)
cmd_tuple = enable_periodic_hk_command_with_interval(
False, make_sid(PWR_CONTROLLER, SetId.CORE_HK_SET), interval
)
q.add_pus_tc(cmd_tuple[0])
q.add_pus_tc(cmd_tuple[1])
elif op_code in OpCodes.DISABLE_CORE_HK:
q.add_log_cmd(Info.DISABLE_CORE_HK)
q.add_pus_tc(
disable_periodic_hk_command(
False, make_sid(PWR_CONTROLLER, SetId.CORE_HK_SET)
)
)
elif op_code in OpCodes.REQUEST_ENABLE_PL_HK:
q.add_log_cmd(Info.REQUEST_ENABLE_PL_HK)
q.add_pus_tc(
generate_one_hk_command(make_sid(PWR_CONTROLLER, SetId.ENABLE_PL_SET))
)
elif op_code in OpCodes.ENABLE_ENABLE_PL_HK:
interval = float(input("Please specify interval in floating point seconds: "))
q.add_log_cmd(Info.ENABLE_ENABLE_PL_HK)
cmd_tuple = enable_periodic_hk_command_with_interval(
False, make_sid(PWR_CONTROLLER, SetId.ENABLE_PL_SET), interval
)
q.add_pus_tc(cmd_tuple[0])
q.add_pus_tc(cmd_tuple[1])
elif op_code in OpCodes.DISABLE_ENABLE_PL_HK:
q.add_log_cmd(Info.DISABLE_ENABLE_PL_HK)
q.add_pus_tc(
disable_periodic_hk_command(
False, make_sid(PWR_CONTROLLER, SetId.ENABLE_PL_SET)
)
)
def set_pwr_ctrl_param(q: DefaultPusQueueHelper):
for val in ParamId:
print("{:<2}: {:<20}".format(val, val.name))
param = int(input("Specify parameter to set \n" ""))
match param:
case ParamId.BATTERY_INTERNAL_RESISTANCE:
value = float(input("Specify parameter value to set [Ohm]: "))
q.add_pus_tc(
create_load_param_cmd(
create_scalar_float_parameter(
object_id=PWR_CONTROLLER,
domain_id=0,
unique_id=ParamId.BATTERY_INTERNAL_RESISTANCE,
parameter=value,
)
)
)
case ParamId.BATTERY_MAXIMUM_CAPACITY:
value = float(input("Specify parameter value to set [Ah]: "))
q.add_pus_tc(
create_load_param_cmd(
create_scalar_float_parameter(
object_id=PWR_CONTROLLER,
domain_id=0,
unique_id=ParamId.BATTERY_MAXIMUM_CAPACITY,
parameter=value,
)
)
)
case ParamId.COULOMB_COUNTER_VOLTAGE_UPPER_THRESHOLD:
value = float(input("Specify parameter value to set [V]: "))
q.add_pus_tc(
create_load_param_cmd(
create_scalar_float_parameter(
object_id=PWR_CONTROLLER,
domain_id=0,
unique_id=ParamId.COULOMB_COUNTER_VOLTAGE_UPPER_THRESHOLD,
parameter=value,
)
)
)
case ParamId.MAX_ALLOWED_TIME_DIFF:
value = float(input("Specify parameter value to set [s]: "))
q.add_pus_tc(
create_load_param_cmd(
create_scalar_double_parameter(
object_id=PWR_CONTROLLER,
domain_id=0,
unique_id=ParamId.MAX_ALLOWED_TIME_DIFF,
parameter=value,
)
)
)
case ParamId.PAYLOAD_OP_LIMIT_ON:
value = float(input("Specify parameter value to set [1]: "))
q.add_pus_tc(
create_load_param_cmd(
create_scalar_float_parameter(
object_id=PWR_CONTROLLER,
domain_id=0,
unique_id=ParamId.PAYLOAD_OP_LIMIT_ON,
parameter=value,
)
)
)
case ParamId.PAYLOAD_OP_LIMIT_LOW:
value = float(input("Specify parameter value to set [1]: "))
q.add_pus_tc(
create_load_param_cmd(
create_scalar_float_parameter(
object_id=PWR_CONTROLLER,
domain_id=0,
unique_id=ParamId.PAYLOAD_OP_LIMIT_LOW,
parameter=value,
)
)
)
case ParamId.HIGHER_MODES_LIMIT:
value = float(input("Specify parameter value to set [1]: "))
q.add_pus_tc(
create_load_param_cmd(
create_scalar_float_parameter(
object_id=PWR_CONTROLLER,
domain_id=0,
unique_id=ParamId.HIGHER_MODES_LIMIT,
parameter=value,
)
)
)
def handle_pwr_ctrl_hk_data(
pw: PrintWrapper,
set_id: int,
hk_data: bytes,
packet_time: datetime.datetime,
):
pw.ilog(_LOGGER, f"Received PWR CTRL HK with packet time {packet_time}")
match set_id:
case SetId.CORE_HK_SET:
handle_core_hk_data(pw, hk_data)
case SetId.ENABLE_PL_SET:
handle_enable_pl_data(pw, hk_data)
def handle_core_hk_data(pw: PrintWrapper, hk_data: bytes):
pw.dlog("Received Core HK Set")
fmt_int16 = "!h"
fmt_float = "!f"
inc_len_int16 = struct.calcsize(fmt_int16)
inc_len_float = struct.calcsize(fmt_float)
if len(hk_data) < inc_len_int16 + 2 * inc_len_float:
pw.dlog("Received HK set too small")
return
current_idx = 0
total_battery_current = struct.unpack(
fmt_int16, hk_data[current_idx : current_idx + inc_len_int16]
)[0]
current_idx += inc_len_int16
open_circuit_voltage_charge = struct.unpack(
fmt_float, hk_data[current_idx : current_idx + inc_len_float]
)[0]
current_idx += inc_len_float
coulomb_counter_charge = struct.unpack(
fmt_float, hk_data[current_idx : current_idx + inc_len_float]
)[0]
current_idx += inc_len_float
pw.dlog(f"Total Battery Current: {total_battery_current} [mA]")
pw.dlog(f"Open Circuit Voltage Charge: {open_circuit_voltage_charge*100:8.3f} [%]")
pw.dlog(f"Coulomb Counter Charge: {coulomb_counter_charge*100:8.3f} [%]")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=3)
def handle_enable_pl_data(pw: PrintWrapper, hk_data: bytes):
pw.dlog("Received Enable PL HK Set")
fmt_uint16 = "!B"
inc_len_uint16 = struct.calcsize(fmt_uint16)
if len(hk_data) < inc_len_uint16:
pw.dlog("Received HK set too small")
return
current_idx = 0
pl_use_allowed = struct.unpack(
fmt_uint16, hk_data[current_idx : current_idx + inc_len_uint16]
)[0]
current_idx += inc_len_uint16
pw.dlog(f"PL Use Allowed: {pl_use_allowed}")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=1)

View File

@ -1,68 +0,0 @@
import enum
from typing import Tuple, Dict
from spacepackets.ecss import PusTelecommand
from eive_tmtc.tmtc.common import pack_mode_cmd_with_info
from eive_tmtc.config.object_ids import EPS_SUBSYSTEM_ID
from eive_tmtc.config.definitions import CustomServiceList
from tmtccmd.config.tmtc import (
tmtc_definitions_provider,
TmtcDefinitionWrapper,
OpCodeEntry,
)
from tmtccmd.tc.pus_200_fsfw_mode import Subservice as ModeSubservices, Mode
from tmtccmd.tc import service_provider
from tmtccmd.tc.decorator import ServiceProviderParams
class OpCode(str, enum.Enum):
OFF = "off"
NML = "normal"
REPORT_ALL_MODES = "all_modes"
class Info(str, enum.Enum):
OFF = "Off Mode Command"
NML = "Normal Mode Command"
REPORT_ALL_MODES = "Report All Modes Recursively"
HANDLER_LIST: Dict[str, Tuple[int, int, str]] = {
OpCode.OFF: (Mode.OFF, 0, Info.OFF),
OpCode.NML: (Mode.NORMAL, 0, Info.NML),
}
@service_provider(CustomServiceList.EPS_SS.value)
def build_eps_subsystem_cmd(p: ServiceProviderParams):
op_code = p.op_code
q = p.queue_helper
info_prefix = "EPS Subsystem"
if op_code in OpCode.REPORT_ALL_MODES:
q.add_log_cmd(f"{info_prefix}: {Info.REPORT_ALL_MODES}")
q.add_pus_tc(
PusTelecommand(
service=200,
subservice=ModeSubservices.TC_MODE_ANNOUNCE_RECURSIVE,
app_data=EPS_SUBSYSTEM_ID,
)
)
mode_info_tup = HANDLER_LIST.get(op_code)
if mode_info_tup is None:
return
pack_mode_cmd_with_info(
object_id=EPS_SUBSYSTEM_ID,
info=f"{info_prefix}: {mode_info_tup[2]}",
mode=mode_info_tup[0],
submode=mode_info_tup[1],
q=q,
)
@tmtc_definitions_provider
def add_eps_subsystem_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
for op_code, (_, _, info) in HANDLER_LIST.items():
oce.add(op_code, info)
oce.add(OpCode.REPORT_ALL_MODES, Info.REPORT_ALL_MODES)
defs.add_service(CustomServiceList.EPS_SS, "EPS Subsystem", oce)

View File

@ -9,7 +9,7 @@ from eive_tmtc.tmtc.power.common_power import (
) )
from eive_tmtc.tmtc.power.power import PcduSetIds from eive_tmtc.tmtc.power.power import PcduSetIds
from tmtccmd.util import ObjectIdBase from tmtccmd.util import ObjectIdBase
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from eive_tmtc.pus_tm.defs import PrintWrapper from eive_tmtc.pus_tm.defs import PrintWrapper
from eive_tmtc.gomspace.gomspace_common import GomspaceDeviceActionId from eive_tmtc.gomspace.gomspace_common import GomspaceDeviceActionId
from eive_tmtc.config.object_ids import ( from eive_tmtc.config.object_ids import (
@ -75,8 +75,8 @@ class WdtInfo:
self.pw.dlog(wdt_info) self.pw.dlog(wdt_info)
for idx in range(len(self.wdt_reboots_list)): for idx in range(len(self.wdt_reboots_list)):
self.pw.dlog( self.pw.dlog(
f"{WDT_LIST[idx].ljust(5)} | {self.wdt_reboots_list[idx]:010} |" f"{WDT_LIST[idx].ljust(5)} | "
f" {self.time_pings_left_list[idx]:010}", f"{self.wdt_reboots_list[idx]:010} | {self.time_pings_left_list[idx]:010}",
) )
def parse(self, wdt_data: bytes, current_idx: int) -> int: def parse(self, wdt_data: bytes, current_idx: int) -> int:
@ -119,7 +119,7 @@ class DevicesInfoParser:
return current_idx return current_idx
def print(self, pw: PrintWrapper): def print(self, pw: PrintWrapper):
pw.dlog("Device Type | Device State (0:None | 1:OK | 3:ERROR | 4:NOT FOUND)") pw.dlog(f"Device Type | Device State (0:None | 1:OK | 3:ERROR | 4:NOT FOUND)")
for i in range(len(self.dev_types)): for i in range(len(self.dev_types)):
pw.dlog( pw.dlog(
f"{self.map_idx_to_type(self.dev_types[i])} | {self.dev_statuses[i]}" f"{self.map_idx_to_type(self.dev_types[i])} | {self.dev_statuses[i]}"
@ -146,13 +146,18 @@ class DevicesInfoParser:
return "Unknown Type" return "Unknown Type"
def handle_pdu_data(pw: PrintWrapper, pdu_idx: int, set_id: int, hk_data: bytes): def handle_pdu_data(
printer: FsfwTmTcPrinter, pdu_idx: int, set_id: int, hk_data: bytes
):
pw = PrintWrapper(printer=printer)
current_idx = 0 current_idx = 0
priv_idx = pdu_idx - 1 priv_idx = pdu_idx - 1
if set_id == SetId.AUX or set_id == SetId.AUX: if set_id == SetId.AUX or set_id == SetId.AUX:
fmt_str = "!BBBIIH" fmt_str = "!hhBBBIIH"
inc_len = struct.calcsize(fmt_str) inc_len = struct.calcsize(fmt_str)
( (
vcc,
vbat,
conv_enb_0, conv_enb_0,
conv_enb_1, conv_enb_1,
conv_enb_2, conv_enb_2,
@ -160,6 +165,7 @@ def handle_pdu_data(pw: PrintWrapper, pdu_idx: int, set_id: int, hk_data: bytes)
uptime, uptime,
reset_cause, reset_cause,
) = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len]) ) = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
pw.dlog(f"VCC {vcc} mV | VBAT {vbat} mV")
pw.dlog(f"Converter Enables [{conv_enb_0},{conv_enb_1},{conv_enb_2}]") pw.dlog(f"Converter Enables [{conv_enb_0},{conv_enb_1},{conv_enb_2}]")
pw.dlog( pw.dlog(
f"Boot Cause {boot_cause} | Uptime {uptime} | Reset Cause {reset_cause}", f"Boot Cause {boot_cause} | Uptime {uptime} | Reset Cause {reset_cause}",
@ -181,7 +187,7 @@ def handle_pdu_data(pw: PrintWrapper, pdu_idx: int, set_id: int, hk_data: bytes)
wdt = WdtInfo(pw=pw) wdt = WdtInfo(pw=pw)
current_idx = wdt.parse(wdt_data=hk_data[current_idx:], current_idx=current_idx) current_idx = wdt.parse(wdt_data=hk_data[current_idx:], current_idx=current_idx)
wdt.print() wdt.print()
pw.dlog("PDU Device Types: 0:FRAM|1:ADC|2:ADC|3:TempSens|4,5,6,7:Reserved") pw.dlog(f"PDU Device Types: 0:FRAM|1:ADC|2:ADC|3:TempSens|4,5,6,7:Reserved")
dev_parser.print(pw=pw) dev_parser.print(pw=pw)
if set_id == SetId.CORE or set_id == SetId.CORE: if set_id == SetId.CORE or set_id == SetId.CORE:
pw.dlog(f"Received PDU HK from PDU {pdu_idx}") pw.dlog(f"Received PDU HK from PDU {pdu_idx}")
@ -210,19 +216,20 @@ def handle_pdu_data(pw: PrintWrapper, pdu_idx: int, set_id: int, hk_data: bytes)
f"{voltage_list[idx]:05} | {current_list[idx]:04}" f"{voltage_list[idx]:05} | {current_list[idx]:04}"
) )
pw.dlog(content_line) pw.dlog(content_line)
fmt_str = "!IBfhh" fmt_str = "!IBf"
inc_len = struct.calcsize(fmt_str) inc_len = struct.calcsize(fmt_str)
(boot_count, batt_mode, temperature, vcc, vbat) = struct.unpack( (boot_count, batt_mode, temperature) = struct.unpack(
fmt_str, hk_data[current_idx : current_idx + inc_len] fmt_str, hk_data[current_idx : current_idx + inc_len]
) )
info = ( info = (
f"Boot Count {boot_count} | Battery Mode {batt_mode} | " f"Boot Count {boot_count} | Battery Mode {batt_mode} | "
f"Temperature {temperature} | VCC {vcc} | VBAT {vbat}" f"Temperature {temperature}"
) )
pw.dlog(info) pw.dlog(info)
def handle_p60_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes): def handle_p60_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
pw = PrintWrapper(printer=printer)
if set_id == SetId.CORE: if set_id == SetId.CORE:
pw.dlog("Received P60 Core HK. Voltages in mV, currents in mA") pw.dlog("Received P60 Core HK. Voltages in mV, currents in mA")
current_idx = 0 current_idx = 0
@ -269,9 +276,7 @@ def handle_p60_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes):
temps = f"In C: Temp 0 {temp_0} | Temp 1 {temp_1} | " temps = f"In C: Temp 0 {temp_0} | Temp 1 {temp_1} | "
pw.dlog(temps) pw.dlog(temps)
pw.dlog(batt_info) pw.dlog(batt_info)
FsfwTmTcPrinter.get_validity_buffer( printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=9)
validity_buffer=hk_data[current_idx:], num_vars=9
)
if set_id == SetId.AUX: if set_id == SetId.AUX:
pw.dlog("Received P60 AUX HK. Voltages in mV, currents in mA") pw.dlog("Received P60 AUX HK. Voltages in mV, currents in mA")
current_idx = 0 current_idx = 0
@ -327,9 +332,8 @@ def handle_p60_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes):
) )
pw.dlog(misc_info) pw.dlog(misc_info)
batt_info = ( batt_info = (
f"Batt Temp 0 {batt_temp_0 / 10.0} | Batt Temp 1 {batt_temp_1 / 10.0} |" f"Batt Temp 0 {batt_temp_0 / 10.0} | Batt Temp 1 {batt_temp_1 / 10.0} | "
f" Charge Current {batt_charge_current} | Discharge Current" f"Charge Current {batt_charge_current} | Discharge Current {batt_discharge_current}"
f" {batt_discharge_current}"
) )
pw.dlog(batt_info) pw.dlog(batt_info)
pw.dlog( pw.dlog(
@ -337,7 +341,7 @@ def handle_p60_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes):
"6:TempSens(BatPack)|7:TempSens(BatPack)" "6:TempSens(BatPack)|7:TempSens(BatPack)"
) )
dev_parser.print(pw=pw) dev_parser.print(pw=pw)
FsfwTmTcPrinter.get_validity_buffer( printer.print_validity_buffer(
validity_buffer=hk_data[current_idx:], num_vars=27 validity_buffer=hk_data[current_idx:], num_vars=27
) )
@ -350,7 +354,8 @@ def gen_six_entry_u16_list(hk_data: bytes, current_idx: int) -> Tuple[int, List[
return current_idx, u16_list return current_idx, u16_list
def handle_acu_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes): def handle_acu_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
pw = PrintWrapper(printer=printer)
if set_id == SetId.CORE: if set_id == SetId.CORE:
mppt_mode = hk_data[0] mppt_mode = hk_data[0]
current_idx = 1 current_idx = 1
@ -378,7 +383,9 @@ def handle_acu_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes):
current_idx += inc_len current_idx += inc_len
pw.dlog("Received ACU Core HK. Voltages in mV, currents in mA") pw.dlog("Received ACU Core HK. Voltages in mV, currents in mA")
pw.dlog(f"VCC {vcc} mV | VBAT {vbat} mV | MPPT Mode {mppt_mode}") pw.dlog(f"VCC {vcc} mV | VBAT {vbat} mV | MPPT Mode {mppt_mode}")
header_str = "Channel | Input U [mV] | Input I [mA] | U Boost [mV] | Power [mW]" header_str = (
f"Channel | Input U [mV] | Input I [mA] | U Boost [mV] | Power [mW]"
)
pw.dlog(header_str) pw.dlog(header_str)
for i in range(6): for i in range(6):
pw.dlog( pw.dlog(
@ -390,7 +397,7 @@ def handle_acu_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes):
f"Boot Count {bootcnt} | Uptime {uptime} sec | " f"Boot Count {bootcnt} | Uptime {uptime} sec | "
f"MPPT Time {mppt_time} msec | MPPT Period {mppt_period} msec" f"MPPT Time {mppt_time} msec | MPPT Period {mppt_period} msec"
) )
FsfwTmTcPrinter.get_validity_buffer( printer.print_validity_buffer(
validity_buffer=hk_data[current_idx:], num_vars=12 validity_buffer=hk_data[current_idx:], num_vars=12
) )
if set_id == SetId.AUX: if set_id == SetId.AUX:
@ -415,22 +422,19 @@ def handle_acu_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes):
pw.dlog("Received ACU Aux HK. Voltages in mV, currents in mA") pw.dlog("Received ACU Aux HK. Voltages in mV, currents in mA")
pw.dlog( pw.dlog(
f"DAC Enable States: DAC 0 {dac_enb_str[0]} | DAC 1 {dac_enb_str[1]} | " f"DAC Enable States: DAC 0 {dac_enb_str[0]} | DAC 1 {dac_enb_str[1]} | DAC 2 {dac_enb_str[2]}"
f"DAC 2 {dac_enb_str[2]}"
) )
pw.dlog(f"Boot Cause {boot_cause} | Reset Cause {reset_cause}") pw.dlog(f"Boot Cause {boot_cause} | Reset Cause {reset_cause}")
pw.dlog( pw.dlog(
f"Ground WDT: Reboot Count {wdt_cnt_gnd} | Time Left" f"Ground WDT: Reboot Count {wdt_cnt_gnd} | Time Left {wdt_gnd_time_left} sec"
f" {wdt_gnd_time_left} sec"
) )
pw.dlog( pw.dlog(
"ACU Dev Types: 0:FRAM|1:ADC|2:ADC|3:DAC|4:DAC|5:DAC|6:TempSens|7:Reserved" f"ACU Dev Types: 0:FRAM|1:ADC|2:ADC|3:DAC|4:DAC|"
f"5:DAC|6:TempSens|7:Reserved"
) )
dev_parser.print(pw=pw) dev_parser.print(pw=pw)
FsfwTmTcPrinter.get_validity_buffer( printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=8)
validity_buffer=hk_data[current_idx:], num_vars=8
)
def handle_get_param_data_reply( def handle_get_param_data_reply(
@ -475,8 +479,7 @@ def pdu_config_table_handler(
pw.dlog("[tcs, syrlinks, str, mgt, sus-n, scex, ploc, acs-a, unused]") pw.dlog("[tcs, syrlinks, str, mgt, sus-n, scex, ploc, acs-a, unused]")
elif obj_id.as_bytes == PDU_2_HANDLER_ID: elif obj_id.as_bytes == PDU_2_HANDLER_ID:
pw.dlog( pw.dlog(
"[obc, pl-pcdu-bat-nom, rw, heaters, sus-r, sa-depl, pl-pcdu-bat-red," "[obc, pl-pcdu-bat-nom, rw, heaters, sus-r, sa-depl, pl-pcdu-bat-red, acs-b, pl-cam]"
" acs-b, pl-cam]"
) )
out_on_cnt = unpack_array_in_data(custom_data, 0x52, 2, 9, "H") out_on_cnt = unpack_array_in_data(custom_data, 0x52, 2, 9, "H")
out_off_cnt = unpack_array_in_data(custom_data, 0x64, 2, 9, "H") out_off_cnt = unpack_array_in_data(custom_data, 0x64, 2, 9, "H")
@ -554,7 +557,8 @@ def parse_name_list(data: bytes, name_len: int):
return ch_list return ch_list
def handle_pcdu_hk(pw: PrintWrapper, set_id: int, hk_data: bytes): def handle_pcdu_hk(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
pw = PrintWrapper(printer)
pw.dlog("Received PCDU HK") pw.dlog("Received PCDU HK")
if set_id == PcduSetIds.SWITCHER_SET: if set_id == PcduSetIds.SWITCHER_SET:
current_idx = 0 current_idx = 0
@ -574,4 +578,4 @@ def handle_pcdu_hk(pw: PrintWrapper, set_id: int, hk_data: bytes):
pw.dlog(f"{name.ljust(25)}: {val}") pw.dlog(f"{name.ljust(25)}: {val}")
pw.dlog(f"{'P60 Dock 5V Stack'.ljust(25)}: {p60_stack_5v_val}") pw.dlog(f"{'P60 Dock 5V Stack'.ljust(25)}: {p60_stack_5v_val}")
pw.dlog(f"{'P60 Dock 3V3 Stack'.ljust(25)}: {p60_stack_3v3_val}") pw.dlog(f"{'P60 Dock 3V3 Stack'.ljust(25)}: {p60_stack_3v3_val}")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], 4) pw.printer.print_validity_buffer(hk_data[current_idx:], 4)

View File

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
@file solar_array_deployment.py @file solar_array_deployment.py
@brief The test function in this file simply returns a command which triggers the solar array @brief The test function in this file simply returns a command which triggers the solar array deployment.
deployment.
@author J. Meier @author J. Meier
@date 15.02.2021 @date 15.02.2021
""" """

View File

@ -11,6 +11,7 @@ from tmtccmd.tc import service_provider
from eive_tmtc.config.object_ids import EIVE_SYSTEM_ID from eive_tmtc.config.object_ids import EIVE_SYSTEM_ID
from tmtccmd.tc.pus_200_fsfw_mode import ( from tmtccmd.tc.pus_200_fsfw_mode import (
create_mode_command, create_mode_command,
Mode,
create_announce_mode_recursive_command, create_announce_mode_recursive_command,
) )
from tmtccmd.tc.pus_8_fsfw_funccmd import create_action_cmd from tmtccmd.tc.pus_8_fsfw_funccmd import create_action_cmd

View File

@ -1,2 +1 @@
from .tm import * # noqa from .tm import * # noqa
from .tmp1075 import add_tmp_sens_cmds

View File

@ -1,92 +0,0 @@
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_request_one_hk_command,
create_enable_periodic_hk_command_with_interval_with_diag,
)
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_with_diag(
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,
)

View File

@ -6,22 +6,3 @@ 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

View File

@ -7,7 +7,6 @@ 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
@ -21,6 +20,18 @@ 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",

View File

@ -13,7 +13,7 @@ from tmtccmd.util import ObjectIdU32
from tmtccmd.tc.pus_200_fsfw_mode import Mode, pack_mode_data, Subservice from tmtccmd.tc.pus_200_fsfw_mode import Mode, pack_mode_data, Subservice
import eive_tmtc.config.object_ids as oids import eive_tmtc.config.object_ids as oids
from eive_tmtc.config.object_ids import get_object_ids from eive_tmtc.config.object_ids import get_object_ids
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
RTD_IDS = [ RTD_IDS = [
oids.RTD_0_PLOC_HSPD, oids.RTD_0_PLOC_HSPD,
@ -147,7 +147,8 @@ def pack_rtd_commands(
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
def handle_rtd_hk(object_id: bytes, hk_data: bytes, pw: PrintWrapper): def handle_rtd_hk(object_id: bytes, hk_data: bytes, printer: FsfwTmTcPrinter):
pw = PrintWrapper(printer)
rtd_name = RTD_NAMES.get(object_id) rtd_name = RTD_NAMES.get(object_id)
if rtd_name is None: if rtd_name is None:
rtd_name = "unknown RTD device" rtd_name = "unknown RTD device"
@ -161,7 +162,7 @@ def handle_rtd_hk(object_id: bytes, hk_data: bytes, pw: PrintWrapper):
pw.dlog(f"RTD Value: {rtd_val}") pw.dlog(f"RTD Value: {rtd_val}")
pw.dlog(f"Error Byte: {error_byte}") pw.dlog(f"Error Byte: {error_byte}")
pw.dlog(f"Last Error Byte: {last_err_byte}") pw.dlog(f"Last Error Byte: {last_err_byte}")
FsfwTmTcPrinter.get_validity_buffer(hk_data[fmt_len:], 4) pw.printer.print_validity_buffer(hk_data[fmt_len:], 4)
def prompt_rtd_idx(): def prompt_rtd_idx():

View File

@ -1,5 +1,6 @@
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_SUBSYSTEM_ID from eive_tmtc.config.object_ids import TCS_CONTROLLER, 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 (
@ -9,28 +10,64 @@ 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 OpCode: class OpCodeSys:
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 == OpCode.OFF: if op_code in OpCodeSys.REQUEST_PRIMARY_TEMP_SET:
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 == OpCode.NML: if op_code in OpCodeSys.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 == OpCode.ANNOUNCE_MODES: if op_code == OpCodeSys.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)
@ -39,11 +76,19 @@ 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=OpCode.OFF, info=InfoSys.OFF) oce.add(keys=OpCodeSys.OFF, info=InfoSys.OFF)
oce.add(keys=OpCode.NML, info=InfoSys.NML) oce.add(keys=OpCodeSys.NML, info=InfoSys.NML)
oce.add(keys=OpCode.ANNOUNCE_MODES, info=InfoSys.ANNOUNCE_MODES) oce.add(
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_SS, name=CustomServiceList.TCS,
info="TCS subsystem", info="TCS Board",
op_code_entry=oce, op_code_entry=oce,
) )

View File

@ -1,13 +1,11 @@
import dataclasses
import datetime
import enum
import logging import logging
import pprint
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 tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from .defs import CtrlSetId from .defs import CtrlSetId
from .heater import HEATER_LOCATION from .heater import HEATER_LOCATION
@ -15,47 +13,8 @@ from .heater import HEATER_LOCATION
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
class ThermalComponent(enum.IntEnum): def handle_thermal_controller_hk_data(
NONE = 0 object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
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
): ):
# need a better solutuon for this is this is used again.. # need a better solutuon for this is this is used again..
""" """
@ -65,6 +24,7 @@ def handle_thermal_controller_hk_data( # noqa C901: complexity is okay.
TCP_TEMP_DEV_SERVER = TmTcpServer("localhost", 7306) TCP_TEMP_DEV_SERVER = TmTcpServer("localhost", 7306)
""" """
if set_id == CtrlSetId.PRIMARY_SENSORS: if set_id == CtrlSetId.PRIMARY_SENSORS:
pw = PrintWrapper(printer)
pw.dlog("Received sensor temperature data") pw.dlog("Received sensor temperature data")
# get all the floats # get all the floats
@ -98,6 +58,7 @@ def handle_thermal_controller_hk_data( # noqa C901: complexity is okay.
for idx, (k, v) in enumerate(parsed_data.items()): for idx, (k, v) in enumerate(parsed_data.items()):
print(f"{str(k).ljust(30)}: Valid: {valid_list[idx]}, Value: {v}") print(f"{str(k).ljust(30)}: Valid: {valid_list[idx]}, Value: {v}")
elif set_id == CtrlSetId.DEVICE_SENSORS: elif set_id == CtrlSetId.DEVICE_SENSORS:
pw = PrintWrapper(printer)
pw.dlog("Received device temperature data") pw.dlog("Received device temperature data")
fmt_str = "!fhhhhiiiifffhffffffffffffff" fmt_str = "!fhhhhiiiifffhffffffffffffff"
fmt_len = struct.calcsize(fmt_str) fmt_len = struct.calcsize(fmt_str)
@ -133,6 +94,7 @@ def handle_thermal_controller_hk_data( # noqa C901: complexity is okay.
for idx, (k, v) in enumerate(parsed_data.items()): for idx, (k, v) in enumerate(parsed_data.items()):
print(f"{str(k).ljust(30)}: Valid: {valid_list[idx]}, Value: {v}") print(f"{str(k).ljust(30)}: Valid: {valid_list[idx]}, Value: {v}")
elif set_id == CtrlSetId.SUS_TEMP_SENSORS: elif set_id == CtrlSetId.SUS_TEMP_SENSORS:
pw = PrintWrapper(printer)
pw.dlog("Received SUS temperature data") pw.dlog("Received SUS temperature data")
fmt_str = "!ffffffffffff" fmt_str = "!ffffffffffff"
fmt_len = struct.calcsize(fmt_str) fmt_len = struct.calcsize(fmt_str)
@ -162,50 +124,5 @@ def handle_thermal_controller_hk_data( # noqa C901: complexity is okay.
) )
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}")

View File

@ -6,17 +6,14 @@
@date 06.01.2021 @date 06.01.2021
""" """
import enum import enum
import struct
from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.pus_tm.defs import PrintWrapper
from spacepackets.ecss.tc import PusTelecommand from spacepackets.ecss.tc import PusTelecommand
from tmtccmd.config.tmtc import ( from tmtccmd.config.tmtc import (
tmtc_definitions_provider, tmtc_definitions_provider,
TmtcDefinitionWrapper, TmtcDefinitionWrapper,
OpCodeEntry, OpCodeEntry,
) )
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter
from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_200_fsfw_mode import Mode, pack_mode_data from tmtccmd.tc.pus_200_fsfw_mode import Mode, pack_mode_data
from tmtccmd.tc.pus_3_fsfw_hk import create_request_one_hk_command, make_sid from tmtccmd.tc.pus_3_fsfw_hk import create_request_one_hk_command, make_sid
@ -79,10 +76,3 @@ def add_tmp_sens_cmds(defs: TmtcDefinitionWrapper):
oce.add(OpCode.NML, Info.NML) oce.add(OpCode.NML, Info.NML)
oce.add(OpCode.HK, Info.HK) oce.add(OpCode.HK, Info.HK)
defs.add_service(CustomServiceList.TMP1075.value, "TMP1075 Temperature Sensor", oce) defs.add_service(CustomServiceList.TMP1075.value, "TMP1075 Temperature Sensor", oce)
def handle_tmp_1075_hk_data(set_id: int, hk_data: bytes, pw: PrintWrapper):
if set_id == SetId.TEMPERATURE:
temp = struct.unpack("!f", hk_data[0:4])[0]
pw.dlog(f"TMP1075 Temperature: {temp}")
pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[4:], 1))

View File

@ -148,8 +148,7 @@ def time_prompt_offset_from_now() -> datetime.datetime:
seconds_offset = math.floor( seconds_offset = math.floor(
float( float(
input( input(
"Please enter the time as a offset from now in seconds. Negative offset" "Please enter the time as a offset from now in seconds. Negative offset is allowed: "
" is allowed: "
) )
) )
) )

View File

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
@file input_helper.py @file input_helper.py
@brief This class can be used to get user input. A dictionary must be provided which describes the @brief This class can be used to get user input. A dictionary must be provided which describes the input options.
input options.
@author J. Meier @author J. Meier
@date 13.02.2021 @date 13.02.2021
""" """

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

42
lint.py Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env python3
import os
import sys
def main():
exclude_dirs_flag = ""
if not os.path.exists("setup.cfg"):
exclude_dirs_flag = (
"--exclude .git,__pycache__,docs/conf.py,old,build,dist,venv"
)
additional_flags_both_steps = "--count --statistics"
additional_flags_first_step = "--select=E9,F63,F7,F82 --show-source"
python_exe = ""
if os.name == "nt":
python_exe = "py -m"
flake8_first_step_cmd = (
f"{python_exe} flake8 . {additional_flags_both_steps} "
f"{additional_flags_first_step} {exclude_dirs_flag}"
)
status = os.system(flake8_first_step_cmd)
if os.name == "nt":
if status != 0:
print(f"Flake8 linter errors with status {status}")
else:
if os.WEXITSTATUS(status) != 0:
print(f"Flake8 linter errors with status {status}")
sys.exit(0)
additional_flags_second_step = (
'--exit-zero --max-complexity=10 --per-file-ignores="__init__.py:F401"'
)
if not os.path.exists("setup.cfg"):
additional_flags_second_step += " --max-line-length=100"
flake8_second_step_cmd = (
f"{python_exe} flake8 . {additional_flags_both_steps} {additional_flags_second_step}"
f" {exclude_dirs_flag}"
)
os.system(flake8_second_step_cmd)
if __name__ == "__main__":
main()

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
name = "eive-tmtc" name = "eive-tmtc"
description = "TMTC Commander EIVE" description = "TMTC Commander EIVE"
readme = "README.md" readme = "README.md"
version = "5.7.1" dynamic = ["version"]
requires-python = ">=3.10" requires-python = ">=3.10"
license = {text = "Apache-2.0"} license = {text = "Apache-2.0"}
authors = [ authors = [
@ -29,9 +29,9 @@ classifiers = [
"Topic :: Scientific/Engineering" "Topic :: Scientific/Engineering"
] ]
dependencies = [ dependencies = [
"tmtccmd ~= 6.0", "tmtccmd ~= 4.1",
"python-dateutil ~= 2.8", "python-dateutil ~= 2.8",
# "tmtccmd @ git+https://github.com/robamu-org/tmtccmd@main" # tmtccmd @ git+https://github.com/robamu-org/tmtccmd@<gitRev>#egg=tmtccmd
] ]
[project.urls] [project.urls]
@ -40,11 +40,9 @@ dependencies = [
[tool.setuptools] [tool.setuptools]
include-package-data = true include-package-data = true
[tool.setuptools.dynamic]
version = {attr = "eive_tmtc.__version__"}
# Auto-Discovery is problematic for some reason, so use custom-discovery # Auto-Discovery is problematic for some reason, so use custom-discovery
[tool.setuptools.packages] [tool.setuptools.packages]
find = {} find = {}
[tool.ruff]
ignore = ["E501"]
[tool.ruff.extend-per-file-ignores]
"__init__.py" = ["F401"]

View File

@ -1,15 +0,0 @@
Checklist for new releases
========
# Pre-Release
1. Bump version inside the `pyproject.toml` file.
2. Update `CHANGELOG.md`: Convert `unreleased` section into version section
with date and new `unreleased`section.
3. Run auto-formatter with `black .`
4. Run linter with `ruff .`
# Post-Release
1. Create new release on `EGit` based on the release branch. This also creates
a tag.

12
setup.py Normal file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env python3
"""
We do the package handling in the static setup.cfg but include an empty setup.py
to allow editable installs https://packaging.python.org/tutorials/packaging-projects/
and provide extensibility
"""
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup()

317
tmtcc.py
View File

@ -2,30 +2,61 @@
import logging import logging
import sys import sys
import time import time
import traceback
from pathlib import Path from pathlib import Path
from typing import cast
import tmtccmd from spacepackets.ccsds import SPACE_PACKET_HEADER_SIZE
from eive_tmtc.cfdp.fault_handler import EiveCfdpFaultHandler
from eive_tmtc.cfdp.tm import CfdpInCcsdsWrapper
from eive_tmtc.cfdp.user import EiveCfdpUser
from spacepackets.ecss import PusVerificator
from spacepackets.version import get_version as get_sp_version
from spacepackets.cfdp import ( from spacepackets.cfdp import (
ConditionCode,
ChecksumType, ChecksumType,
TransmissionMode, TransmissionMode,
PduHolder,
DirectiveType,
PduFactory,
PduType,
) )
from eive_tmtc.pus_tc.tc_handler import TcHandler
from tmtccmd.logging import add_colorlog_console_logger from tmtccmd.logging import add_colorlog_console_logger
from tmtccmd.cfdp import CfdpUserBase, TransactionId
from tmtccmd.cfdp.defs import CfdpRequestType
from tmtccmd.cfdp.handler import CfdpInCcsdsHandler from tmtccmd.cfdp.handler import CfdpInCcsdsHandler
from tmtccmd.cfdp.mib import ( from tmtccmd.cfdp.mib import (
DefaultFaultHandlerBase,
LocalEntityCfg, LocalEntityCfg,
IndicationCfg, IndicationCfg,
RemoteEntityCfg, RemoteEntityCfg,
) )
from tmtccmd import BackendBase from tmtccmd.cfdp.user import (
TransactionFinishedParams,
MetadataRecvParams,
FileSegmentRecvdParams,
)
from tmtccmd.tc.handler import SendCbParams
try:
import spacepackets
except ImportError as error:
print(error)
print("Python spacepackets module could not be imported")
print(
'Install with "cd spacepackets && python3 -m pip intall -e ." for interative installation'
)
sys.exit(1)
try:
import tmtccmd
except ImportError as error:
run_tmtc_commander = None
initialize_tmtc_commander = None
tb = traceback.format_exc()
print(tb)
print("Python tmtccmd submodule could not be imported")
sys.exit(1)
from spacepackets.ecss import PusVerificator
from tmtccmd import TcHandlerBase, BackendBase
from tmtccmd.util import FileSeqCountProvider, PusFileSeqCountProvider from tmtccmd.util import FileSeqCountProvider, PusFileSeqCountProvider
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from tmtccmd.logging.pus import ( from tmtccmd.logging.pus import (
RawTmtcTimedLogWrapper, RawTmtcTimedLogWrapper,
@ -35,6 +66,15 @@ from tmtccmd.logging.pus import (
from tmtccmd.pus import VerificationWrapper from tmtccmd.pus import VerificationWrapper
from tmtccmd.tm import SpecificApidHandlerBase, GenericApidHandlerBase, CcsdsTmHandler from tmtccmd.tm import SpecificApidHandlerBase, GenericApidHandlerBase, CcsdsTmHandler
from tmtccmd.core import BackendRequest from tmtccmd.core import BackendRequest
from tmtccmd.logging import get_current_time_string
from tmtccmd.tc import (
ProcedureWrapper,
FeedWrapper,
TcProcedureType,
TcQueueEntryType,
DefaultPusQueueHelper,
QueueWrapper,
)
from tmtccmd.config import ( from tmtccmd.config import (
default_json_path, default_json_path,
SetupWrapper, SetupWrapper,
@ -46,7 +86,7 @@ from tmtccmd.config.args import (
ProcedureParamsWrapper, ProcedureParamsWrapper,
) )
from eive_tmtc import APP_LOGGER from eive_tmtc import APP_LOGGER
from importlib.metadata import version from eive_tmtc import __version__
from eive_tmtc.config.definitions import ( from eive_tmtc.config.definitions import (
PUS_APID, PUS_APID,
CFDP_APID, CFDP_APID,
@ -54,7 +94,8 @@ 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.pus_demux import pus_factory_hook from eive_tmtc.pus_tm.factory_hook import pus_factory_hook
from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure
_LOGGER = APP_LOGGER _LOGGER = APP_LOGGER
_LOG_LEVEL = logging.INFO _LOG_LEVEL = logging.INFO
@ -64,26 +105,77 @@ ROTATING_TIMED_LOGGER_INTERVAL_WHEN = TimedLogWhen.PER_MINUTE
ROTATING_TIMED_LOGGER_INTERVAL = 30 ROTATING_TIMED_LOGGER_INTERVAL = 30
class EiveCfdpFaultHandler(DefaultFaultHandlerBase):
def notice_of_suspension_cb(self, cond: ConditionCode):
pass
def notice_of_cancellation_cb(self, cond: ConditionCode):
pass
def abandoned_cb(self, cond: ConditionCode):
pass
def ignore_cb(self, cond: ConditionCode):
pass
class EiveCfdpUser(CfdpUserBase):
def transaction_indication(self, transaction_id: TransactionId):
_LOGGER.info(f"CFDP User: Start of File {transaction_id}")
def eof_sent_indication(self, transaction_id: TransactionId):
_LOGGER.info(f"CFDP User: EOF sent for {transaction_id}")
def transaction_finished_indication(self, params: TransactionFinishedParams):
_LOGGER.info(f"CFDP User: {params.transaction_id} finished")
def metadata_recv_indication(self, params: MetadataRecvParams):
pass
def file_segment_recv_indication(self, params: FileSegmentRecvdParams):
pass
def report_indication(self, transaction_id: TransactionId, status_report: any):
pass
def suspended_indication(
self, transaction_id: TransactionId, cond_code: ConditionCode
):
pass
def resumed_indication(self, transaction_id: TransactionId, progress: int):
pass
def fault_indication(
self, transaction_id: TransactionId, cond_code: ConditionCode, progress: int
):
pass
def abandoned_indication(
self, transaction_id: TransactionId, cond_code: ConditionCode, progress: int
):
pass
def eof_recv_indication(self, transaction_id: TransactionId):
pass
class PusHandler(SpecificApidHandlerBase): class PusHandler(SpecificApidHandlerBase):
def __init__( def __init__(
self, self,
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( pus_factory_hook(packet, self.verif_wrapper, self.printer, self.raw_logger)
packet, self.verif_wrapper, self.printer, self.raw_logger, self.hk_level
)
class UnknownApidHandler(GenericApidHandlerBase): class UnknownApidHandler(GenericApidHandlerBase):
@ -98,18 +190,158 @@ class CustomCcsdsTmHandler(CcsdsTmHandler):
_LOGGER.debug(f"Received packet {packet.hex(sep=',')} with APID {apid}") _LOGGER.debug(f"Received packet {packet.hex(sep=',')} with APID {apid}")
def setup_params() -> (SetupWrapper, int): class CfdpInCcsdsWrapper(SpecificApidHandlerBase):
def __init__(self, cfdp_in_ccsds_handler: CfdpInCcsdsHandler):
super().__init__(CFDP_APID, None)
self.handler = cfdp_in_ccsds_handler
def handle_tm(self, packet: bytes, _user_args: any):
# Ignore the space packet header. Its only purpose is to use the same protocol and
# have a seaprate APID for space packets. If this function is called, the APID is correct.
pdu = packet[SPACE_PACKET_HEADER_SIZE:]
pdu_base = PduFactory.from_raw(pdu)
if pdu_base.pdu_type == PduType.FILE_DATA:
_LOGGER.info("Received File Data PDU TM")
else:
if pdu_base.directive_type == DirectiveType.FINISHED_PDU:
_LOGGER.info(f"Received Finished PDU TM")
else:
_LOGGER.info(
f"Received File Directive PDU with type {pdu_base.directive_type!r} TM"
)
self.handler.pass_pdu_packet(pdu_base)
class TcHandler(TcHandlerBase):
def __init__(
self,
seq_count_provider: FileSeqCountProvider,
cfdp_in_ccsds_wrapper: CfdpInCcsdsWrapper,
pus_verificator: PusVerificator,
high_level_file_logger: logging.Logger,
raw_pus_logger: RawTmtcTimedLogWrapper,
gui: bool,
):
super().__init__()
self.cfdp_handler_started = False
self.cfdp_dest_id = CFDP_REMOTE_ENTITY_ID
self.seq_count_provider = seq_count_provider
self.pus_verificator = pus_verificator
self.high_level_file_logger = high_level_file_logger
self.pus_raw_logger = raw_pus_logger
self.gui = gui
self.queue_helper = DefaultPusQueueHelper(
queue_wrapper=QueueWrapper.empty(),
default_pus_apid=PUS_APID,
seq_cnt_provider=seq_count_provider,
pus_verificator=pus_verificator,
tc_sched_timestamp_len=4,
)
self.cfdp_in_ccsds_wrapper = cfdp_in_ccsds_wrapper
def cfdp_done(self) -> bool:
if self.cfdp_handler_started:
if not self.cfdp_in_ccsds_wrapper.handler.put_request_pending():
self.cfdp_handler_started = False
return True
return False
def feed_cb(self, info: ProcedureWrapper, wrapper: FeedWrapper):
self.queue_helper.queue_wrapper = wrapper.queue_wrapper
if info.proc_type == TcProcedureType.DEFAULT:
handle_default_procedure(self, info.to_def_procedure(), self.queue_helper)
elif info.proc_type == TcProcedureType.CFDP:
self.handle_cfdp_procedure(info)
def send_cb(self, send_params: SendCbParams):
entry_helper = send_params.entry
if entry_helper.is_tc:
if entry_helper.entry_type == TcQueueEntryType.PUS_TC:
pus_tc_wrapper = entry_helper.to_pus_tc_entry()
# pus_tc_wrapper.pus_tc.apid = PUS_APID
raw_tc = pus_tc_wrapper.pus_tc.pack()
self.pus_raw_logger.log_tc(pus_tc_wrapper.pus_tc)
tc_info_string = f"Sent {pus_tc_wrapper.pus_tc}"
_LOGGER.info(tc_info_string)
self.high_level_file_logger.info(
f"{get_current_time_string(True)}: {tc_info_string}"
)
# with open("tc.bin", "wb") as of:
# of.write(raw_tc)
send_params.com_if.send(raw_tc)
elif entry_helper.entry_type == TcQueueEntryType.CCSDS_TC:
cfdp_packet_in_ccsds = entry_helper.to_space_packet_entry()
send_params.com_if.send(cfdp_packet_in_ccsds.space_packet.pack())
# TODO: Log raw CFDP packets similarly to how PUS packets are logged.
# - Log full raw format including space packet wrapper
# - Log context information: Transaction ID, and PDU type and directive
# Could re-use file logger. Should probably do that
# print(f"sending packet: [{cfdp_packet_in_ccsds.space_packet.pack()}]")
# with open(f"cfdp_packet_{self.cfdp_counter}", "wb") as of:
# of.write(cfdp_packet_in_ccsds.space_packet.pack())
# self.cfdp_counter += 1
elif entry_helper.entry_type == TcQueueEntryType.LOG:
log_entry = entry_helper.to_log_entry()
_LOGGER.info(log_entry.log_str)
self.high_level_file_logger.info(log_entry.log_str)
def handle_cfdp_procedure(self, info: ProcedureWrapper):
cfdp_procedure = info.to_cfdp_procedure()
if cfdp_procedure.cfdp_request_type == CfdpRequestType.PUT:
if (
not self.cfdp_in_ccsds_wrapper.handler.put_request_pending()
and not self.cfdp_handler_started
):
put_req = cfdp_procedure.request_wrapper.to_put_request()
put_req.cfg.destination_id = self.cfdp_dest_id
_LOGGER.info(
f"CFDP: Starting file put request with parameters:\n{put_req}"
)
self.cfdp_in_ccsds_wrapper.handler.cfdp_handler.put_request(put_req)
self.cfdp_handler_started = True
for source_pair, dest_pair in self.cfdp_in_ccsds_wrapper.handler:
pdu, sp = source_pair
pdu = cast(PduHolder, pdu)
if pdu.is_file_directive:
if pdu.pdu_directive_type == DirectiveType.METADATA_PDU:
metadata = pdu.to_metadata_pdu()
self.queue_helper.add_log_cmd(
f"CFDP Source: Sending Metadata PDU for file with size "
f"{metadata.file_size}"
)
elif pdu.pdu_directive_type == DirectiveType.EOF_PDU:
self.queue_helper.add_log_cmd(
f"CFDP Source: Sending EOF PDU"
)
else:
fd_pdu = pdu.to_file_data_pdu()
self.queue_helper.add_log_cmd(
f"CFDP Source: Sending File Data PDU for segment at offset "
f"{fd_pdu.offset} with length {len(fd_pdu.file_data)}"
)
self.queue_helper.add_ccsds_tc(sp)
self.cfdp_in_ccsds_wrapper.handler.confirm_source_packet_sent()
self.cfdp_in_ccsds_wrapper.handler.source_handler.state_machine()
def queue_finished_cb(self, info: ProcedureWrapper):
if info is not None:
if info.proc_type == TcQueueEntryType.PUS_TC:
def_proc = info.to_def_procedure()
_LOGGER.info(
f"Finished queue for service {def_proc.service} and op code {def_proc.op_code}"
)
elif info.proc_type == TcProcedureType.CFDP:
_LOGGER.info(f"Finished CFDP queue")
def setup_params() -> SetupWrapper:
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()
tmtc_parser, cfdp_parser = parser_wrapper.add_def_proc_and_cfdp_as_subparsers() 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
) )
@ -120,17 +352,13 @@ def setup_params() -> (SetupWrapper, int):
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)
if hasattr(post_arg_parsing_wrapper.args_raw, "hk"):
hk_level = int(post_arg_parsing_wrapper.args_raw.hk)
else:
hk_level = 0
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, hk_level return setup_wrapper
def setup_cfdp_handler() -> CfdpInCcsdsWrapper: def setup_cfdp_handler() -> CfdpInCcsdsWrapper:
@ -140,15 +368,6 @@ def setup_cfdp_handler() -> CfdpInCcsdsWrapper:
indication_cfg=IndicationCfg(), indication_cfg=IndicationCfg(),
default_fault_handlers=fh_base, default_fault_handlers=fh_base,
) )
self_as_remote = RemoteEntityCfg(
closure_requested=False,
entity_id=CFDP_LOCAL_ENTITY_ID,
max_file_segment_len=990,
check_limit=None,
crc_on_transmission=False,
crc_type=ChecksumType.CRC_32,
default_transmission_mode=TransmissionMode.UNACKNOWLEDGED,
)
remote_cfg = RemoteEntityCfg( remote_cfg = RemoteEntityCfg(
closure_requested=False, closure_requested=False,
entity_id=CFDP_REMOTE_ENTITY_ID, entity_id=CFDP_REMOTE_ENTITY_ID,
@ -167,7 +386,7 @@ def setup_cfdp_handler() -> CfdpInCcsdsWrapper:
cfdp_user = EiveCfdpUser() cfdp_user = EiveCfdpUser()
cfdp_in_ccsds_handler = CfdpInCcsdsHandler( cfdp_in_ccsds_handler = CfdpInCcsdsHandler(
cfg=cfdp_cfg, cfg=cfdp_cfg,
remote_cfgs=[remote_cfg, self_as_remote], remote_cfgs=[remote_cfg],
ccsds_apid=CFDP_APID, ccsds_apid=CFDP_APID,
ccsds_seq_cnt_provider=cfdp_ccsds_seq_count_provider, ccsds_seq_cnt_provider=cfdp_ccsds_seq_count_provider,
cfdp_seq_cnt_provider=cfdp_seq_count_provider, cfdp_seq_cnt_provider=cfdp_seq_count_provider,
@ -181,13 +400,12 @@ 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, hk_level) pus_handler = PusHandler(verification_wrapper, printer, raw_logger)
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)
@ -198,7 +416,7 @@ def setup_tmtc_handlers(
high_level_file_logger=printer.file_logger, high_level_file_logger=printer.file_logger,
raw_pus_logger=raw_logger, raw_pus_logger=raw_logger,
gui=gui, gui=gui,
cfdp_in_ccsds_handler=cfdp_in_ccsds_wrapper.handler, cfdp_in_ccsds_wrapper=cfdp_in_ccsds_wrapper,
) )
return ccsds_handler, tc_handler return ccsds_handler, tc_handler
@ -219,14 +437,14 @@ def setup_backend(
return tmtc_backend return tmtc_backend
def main(): # noqa C901: Complexity okay here. def main():
print(f"-- eive tmtc v{version('eive-tmtc')} --") print(f"-- eive tmtc v{__version__} --")
print(f"-- spacepackets v{get_sp_version()} --") print(f"-- spacepackets v{spacepackets.__version__} --")
add_colorlog_console_logger(_LOGGER) add_colorlog_console_logger(_LOGGER)
# 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, hk_level = setup_params() setup_wrapper = 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)
@ -239,7 +457,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, hk_level pus_verificator, printer, raw_logger, setup_wrapper.params.use_gui
) )
tmtccmd.setup(setup_wrapper) tmtccmd.setup(setup_wrapper)
@ -249,16 +467,13 @@ def main(): # noqa C901: Complexity okay here.
try: try:
while True: while True:
state = tmtc_backend.periodic_op(None) state = tmtc_backend.periodic_op(None)
tc_handler.cfdp_in_ccsds_handler.state_machine() tc_handler.cfdp_in_ccsds_wrapper.handler.fsm()
if state.request == BackendRequest.TERMINATION_NO_ERROR: if state.request == BackendRequest.TERMINATION_NO_ERROR:
sys.exit(0) sys.exit(0)
elif state.request == BackendRequest.DELAY_IDLE: elif state.request == BackendRequest.DELAY_IDLE:
_LOGGER.info("TMTC Client in IDLE mode") _LOGGER.info("TMTC Client in IDLE mode")
time.sleep(3.0) time.sleep(3.0)
elif state.request == BackendRequest.DELAY_LISTENER: elif state.request == BackendRequest.DELAY_LISTENER:
if tc_handler.proxy_op:
time.sleep(0.1)
continue
if tc_handler.cfdp_done(): if tc_handler.cfdp_done():
_LOGGER.info("CFDP transaction done, closing client") _LOGGER.info("CFDP transaction done, closing client")
sys.exit(0) sys.exit(0)

87
tmtcloop.py Executable file
View File

@ -0,0 +1,87 @@
#!/usr/bin/env python3
"""EIVE TMTC Commander"""
import sys
import traceback
try:
import tmtccmd.runner as tmtccmd
from tmtccmd.config import default_json_path, SetupArgs, CoreGlobalIds
from tmtccmd.config.definitions import CoreModeList
from tmtccmd.config.args import (
create_default_args_parser,
add_default_tmtccmd_args,
parse_default_input_arguments,
handle_unspecified_args,
)
from tmtccmd.ccsds.handler import CcsdsTmHandler, ApidHandler
from tmtccmd.logging import get_console_logger
from tmtccmd.logging.pus import create_tmtc_logger
except ImportError as error:
run_tmtc_commander = None
initialize_tmtc_commander = None
tb = traceback.format_exc()
print(tb)
print("Python tmtccmd submodule could not be imported")
sys.exit(1)
try:
import spacepackets
except ImportError as error:
print(error)
print("Python spacepackets module could not be imported")
print(
'Install with "cd spacepackets && python3 -m pip intall -e ." for interative installation'
)
sys.exit(1)
from config.definitions import PUS_APID
from pus_tc.procedure_packer import pre_tc_send_cb
from pus_tm.factory_hook import ccsds_tm_handler
from tmtcc import tmtcc_pre_args
def main():
hook_obj = tmtcc_pre_args()
arg_parser = create_default_args_parser()
add_default_tmtccmd_args(arg_parser)
args = parse_default_input_arguments(arg_parser, hook_obj)
setup_args = SetupArgs(
hook_obj=hook_obj, use_gui=False, apid=PUS_APID, cli_args=args
)
apid_handler = ApidHandler(cb=ccsds_tm_handler, queue_len=50, user_args=None)
ccsds_handler = CcsdsTmHandler()
ccsds_handler.add_tm_handler(apid=PUS_APID, handler=apid_handler)
tmtccmd.setup(setup_args=setup_args)
tmtccmd.add_ccsds_handler(ccsds_handler)
tmtc_backend = tmtccmd.create_default_tmtc_backend(
setup_args=setup_args,
tm_handler=ccsds_handler,
)
tmtc_file_logger = create_tmtc_logger()
tmtc_backend.usr_send_wrapper = (pre_tc_send_cb, tmtc_file_logger)
tmtc_backend.set_mode(CoreModeList.CONTINUOUS_MODE)
# get_console_logger().info("Disabling console logger for continuous operation")
# get_console_logger().setLevel("ERROR")
tmtccmd.init_and_start_daemons(tmtc_backend=tmtc_backend)
tmtc_backend.perform_operation()
# remove cmdline args so that we can reuse code
sys.argv = sys.argv[:1]
while True:
args.service = None
args.op_code = None
handle_unspecified_args(args, hook_obj.get_service_op_code_dictionary())
tmtc_backend.set_service(args.service)
tmtc_backend.set_opcode(args.op_code)
tmtc_backend.set_mode(CoreModeList.CONTINUOUS_MODE)
tmtc_backend.perform_operation()
if __name__ == "__main__":
main()