Skip to content
Snippets Groups Projects
Commit 4a37bedb authored by Robin Mueller's avatar Robin Mueller
Browse files

added print function to tm creator

parent 2f133cc2
No related merge requests found
......@@ -7,13 +7,12 @@ from tm.obsw_pus_tm_base import PusTelemetry, PusTelemetryTimestamp
from utility.obsw_logger import get_logger
LOGGER = get_logger()
#pylint: disable=too-many-instance-attributes
#pylint: disable=too-many-arguments
class PusTelemetryCreator(PusTelemetry):
# pylint: disable=too-many-instance-attributes
# pylint: disable=too-many-arguments
class PusTelemetryCreator:
"""
Alternative way to create a PUS Telemetry packet by specifying telemetry parameters,
similarly to the way telecommands are created. This can be used to create telemetry
......@@ -25,7 +24,6 @@ class PusTelemetryCreator(PusTelemetry):
"""
Initiates the unserialized data fields for the PUS telemetry packet.
"""
super().__init__()
# packet type for telemetry is 0 as specified in standard
packet_type = 0
# specified in standard
......@@ -50,6 +48,18 @@ class PusTelemetryCreator(PusTelemetry):
self.source_data = source_data
def print(self):
""" Print the raw command in a clean format. """
packet = self.pack()
print_out = "Telemetry in Hexadecimal: ["
for counter in range(len(packet)):
if counter == len(packet) - 1:
print_out += str(hex(packet[counter]))
else:
print_out += str(hex(packet[counter])) + ", "
print_out += "]"
LOGGER.info(print_out)
def pack(self) -> bytearray:
"""
Serializes the PUS telemetry into a raw packet.
......@@ -86,7 +96,7 @@ class PusTelemetryCreator(PusTelemetry):
length of the CRC16 checksum - 1
"""
try:
data_length = 4 + PusTelemetry.PUS_TIMESTAMP_SIZE + len(self.source_data) + 1
data_length = 4 + PusTelemetry.PUS_TIMESTAMP_SIZE + len(self.source_data) + 1
return data_length
except TypeError:
LOGGER.error("PusTelecommand: Invalid type of application data!")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment