handling for bpx cfg set

This commit is contained in:
Robin Müller 2022-02-03 15:30:58 +01:00
parent 1702d89576
commit 890a20a078
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 66 additions and 38 deletions

View File

@ -28,4 +28,15 @@ def pack_bpx_commands(tc_queue: TcQueueT, op_code: str):
object_id=BPX_HANDLER_ID, action_id=BpxActionIds.RESET_COUNTERS object_id=BPX_HANDLER_ID, action_id=BpxActionIds.RESET_COUNTERS
) )
tc_queue.appendleft(cmd.pack_command_tuple()) tc_queue.appendleft(cmd.pack_command_tuple())
if op_code in ["2", "cfg"]:
tc_queue.appendleft((QueueCommands.PRINT, "Resetting reboot counters"))
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"))
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())
pass pass

View File

@ -6,6 +6,7 @@ import datetime
from tmtccmd.config.definitions import HkReplyUnpacked from tmtccmd.config.definitions import HkReplyUnpacked
from tmtccmd.tm.service_3_housekeeping import Service3Base from tmtccmd.tm.service_3_housekeeping import Service3Base
from tmtccmd.utility.logger import get_console_logger from tmtccmd.utility.logger import get_console_logger
from pus_tc.bpx_batt import BpxSetIds
from pus_tc.syrlinks_hk_handler import SetIds from pus_tc.syrlinks_hk_handler import SetIds
from pus_tc.imtq import ImtqSetIds from pus_tc.imtq import ImtqSetIds
from config.object_ids import ( from config.object_ids import (
@ -40,7 +41,7 @@ def handle_user_hk_packet(
elif object_id == GPS_HANDLER_0_ID or object_id == GPS_HANDLER_1_ID: elif object_id == GPS_HANDLER_0_ID or object_id == GPS_HANDLER_1_ID:
return handle_gps_data(hk_data=hk_data) return handle_gps_data(hk_data=hk_data)
elif object_id == BPX_HANDLER_ID: elif object_id == BPX_HANDLER_ID:
return handle_bpx_hk_data(hk_data=hk_data) return handle_bpx_hk_data(hk_data=hk_data, set_id=set_id)
else: else:
LOGGER.info("Service 3 TM: Parsing for this SID has not been implemented.") LOGGER.info("Service 3 TM: Parsing for this SID has not been implemented.")
return HkReplyUnpacked() return HkReplyUnpacked()
@ -285,42 +286,58 @@ def handle_gps_data(hk_data: bytearray) -> HkReplyUnpacked:
return reply return reply
def handle_bpx_hk_data(hk_data: bytes) -> HkReplyUnpacked: def handle_bpx_hk_data(hk_data: bytes, set_id: int) -> HkReplyUnpacked:
LOGGER.info(f"Received BPX data, HK data length {len(hk_data)}") LOGGER.info(f"Received BPX data, HK data length {len(hk_data)}")
reply = HkReplyUnpacked() reply = HkReplyUnpacked()
charge_current = struct.unpack('!H', hk_data[0:2])[0] if set_id == BpxSetIds.GET_HK_SET:
discharge_current = struct.unpack('!H', hk_data[2:4])[0] charge_current = struct.unpack('!H', hk_data[0:2])[0]
heater_current = struct.unpack('!H', hk_data[4:6])[0] discharge_current = struct.unpack('!H', hk_data[2:4])[0]
batt_voltage = struct.unpack('!H', hk_data[6:8])[0] heater_current = struct.unpack('!H', hk_data[4:6])[0]
batt_temp_1 = struct.unpack('!h', hk_data[8:10])[0] batt_voltage = struct.unpack('!H', hk_data[6:8])[0]
batt_temp_2 = struct.unpack('!h', hk_data[10:12])[0] batt_temp_1 = struct.unpack('!h', hk_data[8:10])[0]
batt_temp_3 = struct.unpack('!h', hk_data[12:14])[0] batt_temp_2 = struct.unpack('!h', hk_data[10:12])[0]
batt_temp_4 = struct.unpack('!h', hk_data[14:16])[0] batt_temp_3 = struct.unpack('!h', hk_data[12:14])[0]
reboot_cntr = struct.unpack('!I', hk_data[16:20])[0] batt_temp_4 = struct.unpack('!h', hk_data[14:16])[0]
boot_cause = hk_data[20] reboot_cntr = struct.unpack('!I', hk_data[16:20])[0]
reply.header_list = [ boot_cause = hk_data[20]
"Charge Current", reply.header_list = [
"Discharge Current", "Charge Current",
"Heater Current", "Discharge Current",
"Battery Voltage", "Heater Current",
"Batt Temp 1", "Battery Voltage",
"Batt Temp 2", "Batt Temp 1",
"Batt Temp 3", "Batt Temp 2",
"Batt Temp 4", "Batt Temp 3",
"Reboot Counter", "Batt Temp 4",
"Boot Cause" "Reboot Counter",
] "Boot Cause"
reply.content_list = [ ]
charge_current, reply.content_list = [
discharge_current, charge_current,
heater_current, discharge_current,
batt_voltage, heater_current,
batt_temp_1, batt_voltage,
batt_temp_2, batt_temp_1,
batt_temp_3, batt_temp_2,
batt_temp_4, batt_temp_3,
reboot_cntr, batt_temp_4,
boot_cause reboot_cntr,
] boot_cause
reply.validity_buffer = hk_data[21:] ]
reply.validity_buffer = hk_data[21:]
elif set_id == BpxSetIds.GET_CFG_SET:
battheat_mode = hk_data[0]
battheat_low = struct.unpack('!b', hk_data[1:2])[0]
battheat_high = struct.unpack('!b', hk_data[2:3])[0]
reply.header_list = [
"Battery Heater Mode",
"Battery Heater Low Limit",
"Battery Heater High Limit"
]
reply.content_list = [
battheat_mode,
battheat_low,
battheat_high
]
reply.validity_buffer = hk_data[3:]
return reply return reply

@ -1 +1 @@
Subproject commit 683ae401c7b4b2503bd91f23c3e069ced1b0db9c Subproject commit 892d13117f0e3c6d598f157668bff9ed6b31574d