extracted some command definitions

This commit is contained in:
2022-02-03 16:02:55 +01:00
parent 890a20a078
commit 2b89a7f269
9 changed files with 367 additions and 241 deletions

View File

@ -16,27 +16,41 @@ class BpxActionIds:
GET_CFG = 5
class BpxOpCodes:
HK = ["0", "hk"]
RST_BOOT_CNT = ["1", "rst_boot_cnt"]
REQUEST_CFG = ["2", "cfg"]
REQUEST_CFG_HK = ["3", "cfg_hk"]
REBOOT = ["4", "reboot"]
def pack_bpx_commands(tc_queue: TcQueueT, op_code: str):
if op_code in ["0", "hk"]:
if op_code in BpxOpCodes.HK:
tc_queue.appendleft((QueueCommands.PRINT, "Requesting BPX battery HK set"))
sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetIds.GET_HK_SET)
cmd = generate_one_hk_command(sid=sid, ssc=0)
tc_queue.appendleft(cmd.pack_command_tuple())
if op_code in ["1", "rst_boot_cnt"]:
if op_code in BpxOpCodes.RST_BOOT_CNT:
tc_queue.appendleft((QueueCommands.PRINT, "Resetting reboot counters"))
cmd = generate_action_command(
object_id=BPX_HANDLER_ID, action_id=BpxActionIds.RESET_COUNTERS
)
tc_queue.appendleft(cmd.pack_command_tuple())
if op_code in ["2", "cfg"]:
tc_queue.appendleft((QueueCommands.PRINT, "Resetting reboot counters"))
if op_code in BpxOpCodes.REQUEST_CFG:
tc_queue.appendleft((QueueCommands.PRINT, "Requesting configuration struct"))
cmd = generate_action_command(
object_id=BPX_HANDLER_ID, action_id=BpxActionIds.GET_CFG
)
tc_queue.appendleft(cmd.pack_command_tuple())
if op_code in ["3", "cfg_hk"]:
tc_queue.appendleft((QueueCommands.PRINT, "Requesting BPX Configuration Struct"))
if op_code in BpxOpCodes.REQUEST_CFG_HK:
tc_queue.appendleft((QueueCommands.PRINT, "Requesting configuration struct HK"))
sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetIds.GET_CFG_SET)
cmd = generate_one_hk_command(sid=sid, ssc=0)
tc_queue.appendleft(cmd.pack_command_tuple())
if op_code in BpxOpCodes.REBOOT:
tc_queue.appendleft((QueueCommands.PRINT, "Rebooting BPX battery"))
cmd = generate_action_command(
object_id=BPX_HANDLER_ID, action_id=BpxActionIds.REBOOT
)
tc_queue.appendleft(cmd.pack_command_tuple())
pass

View File

@ -43,22 +43,26 @@ def pack_ccsds_handler_test(
)
if op_code == "0":
tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Set low rate"))
command = object_id + struct.pack('!I', CommandIds.SET_LOW_RATE)
command = object_id + struct.pack("!I", CommandIds.SET_LOW_RATE)
command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "1":
tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Set high rate"))
command = object_id + struct.pack('!I', CommandIds.SET_HIGH_RATE)
command = object_id + struct.pack("!I", CommandIds.SET_HIGH_RATE)
command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "2":
tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Enables the transmitter"))
command = object_id + struct.pack('!I', CommandIds.EN_TRANSMITTER)
tc_queue.appendleft(
(QueueCommands.PRINT, "CCSDS Handler: Enables the transmitter")
)
command = object_id + struct.pack("!I", CommandIds.EN_TRANSMITTER)
command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "3":
tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Disables the transmitter"))
command = object_id + struct.pack('!I', CommandIds.DIS_TRANSMITTER)
tc_queue.appendleft(
(QueueCommands.PRINT, "CCSDS Handler: Disables the transmitter")
)
command = object_id + struct.pack("!I", CommandIds.DIS_TRANSMITTER)
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "4":
@ -66,27 +70,45 @@ def pack_ccsds_handler_test(
(QueueCommands.PRINT, "CCSDS Handler: Set arbitrary bitrate")
)
bitrate = int(input("Specify bit rate (bps): "))
command = object_id + struct.pack('!I', CommandIds.ARBITRARY_BITRATE) + struct.pack('!I', bitrate)
command = (
object_id
+ struct.pack("!I", CommandIds.ARBITRARY_BITRATE)
+ struct.pack("!I", bitrate)
)
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "5":
tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Enable tx clock manipulator"))
command = object_id + struct.pack('!I', CommandIds.ENABLE_TX_CLK_MANIPULATOR)
tc_queue.appendleft(
(QueueCommands.PRINT, "CCSDS Handler: Enable tx clock manipulator")
)
command = object_id + struct.pack("!I", CommandIds.ENABLE_TX_CLK_MANIPULATOR)
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "6":
tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Disable tx clock manipulator"))
command = object_id + struct.pack('!I', CommandIds.DISABLE_TX_CLK_MANIPULATOR)
tc_queue.appendleft(
(QueueCommands.PRINT, "CCSDS Handler: Disable tx clock manipulator")
)
command = object_id + struct.pack("!I", CommandIds.DISABLE_TX_CLK_MANIPULATOR)
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "7":
tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Update tx data on rising edge of tx clock"))
command = object_id + struct.pack('!I', CommandIds.UPDATE_ON_RISING_EDGE)
tc_queue.appendleft(
(
QueueCommands.PRINT,
"CCSDS Handler: Update tx data on rising edge of tx clock",
)
)
command = object_id + struct.pack("!I", CommandIds.UPDATE_ON_RISING_EDGE)
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "8":
tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Update tx data on falling edge of tx clock"))
command = object_id + struct.pack('!I', CommandIds.UPDATE_ON_FALLING_EDGE)
tc_queue.appendleft(
(
QueueCommands.PRINT,
"CCSDS Handler: Update tx data on falling edge of tx clock",
)
)
command = object_id + struct.pack("!I", CommandIds.UPDATE_ON_FALLING_EDGE)
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())

View File

@ -501,9 +501,14 @@ def pack_star_tracker_commands(
command = PusTelecommand(service=8, subservice=128, ssc=73, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "51":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set image processor parameters"))
command = object_id + struct.pack('!I', StarTrackerActionIds.IMAGE_PROCESSOR) + \
bytearray(ImagePathDefs.jsonFile, 'utf-8')
tc_queue.appendleft(
(QueueCommands.PRINT, "Star tracker: Set image processor parameters")
)
command = (
object_id
+ struct.pack("!I", StarTrackerActionIds.IMAGE_PROCESSOR)
+ bytearray(ImagePathDefs.jsonFile, "utf-8")
)
command = PusTelecommand(service=8, subservice=128, ssc=70, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())