HKhandler p60dock

This commit is contained in:
Robin Mueller 2022-04-04 18:46:52 +02:00
parent 0fc8369bbc
commit 923929ca55
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
7 changed files with 153 additions and 78 deletions

View File

@ -23,11 +23,11 @@ class GomspaceDeviceActionIds(enum.IntEnum):
PRINT_LATCHUPS = 33
class GomspaceOpCodes(enum.Enum):
class GomspaceOpCodes:
# Request HK
REQUEST_HK_ONCE = "128"
PRINT_SWITCH_V_I = "129"
PRINT_LATCHUPS = "130"
REQUEST_HK_ONCE = ["req-hk-once", "128"]
PRINT_SWITCH_V_I = ["print-switch-vi", "129"]
PRINT_LATCHUPS = ["print-latchups", "130"]
class SetIds:

View File

@ -180,47 +180,47 @@ def add_pl_pcdu_cmds(cmd_dict: ServiceOpCodeDictT):
def add_pcdu_cmds(cmd_dict: ServiceOpCodeDictT):
from pus_tc.devs.p60dock import P60OpCodes, GomspaceOpCodes
from pus_tc.devs.p60dock import P60OpCodes, GomspaceOpCodes, Info
from pus_tc.devs.pdu1 import Pdu1OpCodes
from pus_tc.devs.pdu2 import Pdu2OpCodes
op_code_dict = dict()
add_op_code_entry(op_code_dict=op_code_dict, keys="0", info="P60 Tests")
add_op_code_entry(
op_code_dict=op_code_dict,
keys=P60OpCodes.STACK_3V3_ON.value,
info="P60 Dock: Turn stack 3V3 on",
keys=P60OpCodes.STACK_3V3_ON,
info=Info.STACK_3V3_ON,
)
add_op_code_entry(
op_code_dict=op_code_dict,
keys=P60OpCodes.STACK_3V3_OFF.value,
info="P60 Dock: Turn stack 3V3 off",
keys=P60OpCodes.STACK_3V3_OFF,
info=Info.STACK_3V3_OFF,
)
add_op_code_entry(
op_code_dict=op_code_dict,
keys=P60OpCodes.STACK_5V_ON.value,
info="P60 Dock: Turn stack 5V on",
keys=P60OpCodes.STACK_5V_ON,
info=Info.STACK_5V_ON,
)
add_op_code_entry(
op_code_dict=op_code_dict,
keys=P60OpCodes.STACK_5V_OFF.value,
info="P60 Dock: Turn stack 5V off",
keys=P60OpCodes.STACK_5V_OFF,
info=Info.STACK_5V_OFF,
)
add_op_code_entry(
op_code_dict=op_code_dict,
keys=GomspaceOpCodes.REQUEST_HK_ONCE.value,
keys=GomspaceOpCodes.REQUEST_HK_ONCE,
info="P60 Dock: Request HK once",
)
add_op_code_entry(
op_code_dict=op_code_dict,
keys=GomspaceOpCodes.PRINT_SWITCH_V_I.value,
keys=GomspaceOpCodes.PRINT_SWITCH_V_I,
info="P60 Dock: Print Switches, Voltages, Currents",
)
add_op_code_entry(
op_code_dict=op_code_dict,
keys=GomspaceOpCodes.PRINT_LATCHUPS.value,
keys=GomspaceOpCodes.PRINT_LATCHUPS,
info="P60 Dock: Print Latchups",
)
add_op_code_entry(op_code_dict=op_code_dict, keys=P60OpCodes.TEST, info="P60 Tests")
add_service_op_code_entry(
srv_op_code_dict=cmd_dict,
name=CustomServiceList.P60DOCK.value,
@ -311,17 +311,17 @@ def add_pcdu_cmds(cmd_dict: ServiceOpCodeDictT):
)
add_op_code_entry(
op_code_dict=op_code_dict,
keys=GomspaceOpCodes.REQUEST_HK_ONCE.value,
keys=GomspaceOpCodes.REQUEST_HK_ONCE,
info="PDU1: Request HK once",
)
add_op_code_entry(
op_code_dict=op_code_dict,
keys=GomspaceOpCodes.PRINT_SWITCH_V_I.value,
keys=GomspaceOpCodes.PRINT_SWITCH_V_I,
info="PDU1: Print Switches, Voltages, Currents",
)
add_op_code_entry(
op_code_dict=op_code_dict,
keys=GomspaceOpCodes.PRINT_LATCHUPS.value,
keys=GomspaceOpCodes.PRINT_LATCHUPS,
info="PDU1: Print Latchups",
)
add_op_code_entry(
@ -418,18 +418,18 @@ def add_pcdu_cmds(cmd_dict: ServiceOpCodeDictT):
)
add_op_code_entry(
op_code_dict=op_code_dict,
keys=GomspaceOpCodes.REQUEST_HK_ONCE.value,
keys=GomspaceOpCodes.REQUEST_HK_ONCE,
info="PDU2: Request HK once",
)
add_op_code_entry(
op_code_dict=op_code_dict,
keys=GomspaceOpCodes.PRINT_SWITCH_V_I.value,
keys=GomspaceOpCodes.PRINT_SWITCH_V_I,
info="PDU2: Print Switches, Voltages, Currents",
options={OpCodeDictKeys.TIMEOUT: 2.0},
)
add_op_code_entry(
op_code_dict=op_code_dict,
keys=GomspaceOpCodes.PRINT_LATCHUPS.value,
keys=GomspaceOpCodes.PRINT_LATCHUPS,
info="PDU2: Print Latchups",
)
add_service_op_code_entry(

View File

@ -12,12 +12,23 @@ from gomspace.gomspace_common import *
from config.object_ids import P60_DOCK_HANDLER
class P60OpCodes(enum.Enum):
TEST = "0"
STACK_3V3_ON = "1"
STACK_3V3_OFF = "2"
STACK_5V_ON = "3"
STACK_5V_OFF = "4"
HK_SET_ID = 0x3
class P60OpCodes:
STACK_3V3_ON = ["stack-3v3-on", "1"]
STACK_3V3_OFF = ["stack-3v3-off", "2"]
STACK_5V_ON = ["stack-5v-on", "3"]
STACK_5V_OFF = ["stack-5v-off", "4"]
TEST = ["test", "0"]
class Info:
PREFIX = "P60 Dock"
STACK_3V3_ON = f"{PREFIX}: Turn Stack 3V3 on"
STACK_3V3_OFF = f"{PREFIX}: Turn Stack 3V3 off"
STACK_5V_ON = f"{PREFIX}: Turn Stack 5V on"
STACK_5V_OFF = f"{PREFIX}: Turn Stack 5V off"
class P60DockTestProcedure:
@ -76,8 +87,8 @@ class P60DockHkTable:
def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
if op_code == P60OpCodes.STACK_3V3_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Turning stack 3V3 on"))
if op_code in P60OpCodes.STACK_3V3_ON:
tc_queue.appendleft((QueueCommands.PRINT, Info.STACK_3V3_ON))
command = pack_set_param_command(
object_id,
P60DockConfigTable.out_en_9.parameter_address,
@ -85,8 +96,8 @@ def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: st
Channel.on,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == P60OpCodes.STACK_3V3_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Turning stack 3V3 off"))
if op_code in P60OpCodes.STACK_3V3_OFF:
tc_queue.appendleft((QueueCommands.PRINT, Info.STACK_3V3_OFF))
command = pack_set_param_command(
object_id,
P60DockConfigTable.out_en_9.parameter_address,
@ -94,8 +105,8 @@ def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: st
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == P60OpCodes.STACK_5V_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Turning stack 5V on"))
if op_code in P60OpCodes.STACK_5V_ON:
tc_queue.appendleft((QueueCommands.PRINT, Info.STACK_5V_ON))
command = pack_set_param_command(
object_id,
P60DockConfigTable.out_en_10.parameter_address,
@ -103,8 +114,8 @@ def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: st
Channel.on,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == P60OpCodes.STACK_5V_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Turning stack 5V off"))
if op_code in P60OpCodes.STACK_5V_OFF:
tc_queue.appendleft((QueueCommands.PRINT, Info.STACK_5V_OFF))
command = pack_set_param_command(
object_id,
P60DockConfigTable.out_en_10.parameter_address,
@ -112,12 +123,12 @@ def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: st
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == GomspaceOpCodes.REQUEST_HK_ONCE.value:
if op_code in GomspaceOpCodes.REQUEST_HK_ONCE:
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Requesting HK Table Once"))
hk_sid = make_sid(object_id=P60_DOCK_HANDLER, set_id=SetIds.P60_DOCK)
command = generate_one_hk_command(sid=hk_sid, ssc=0)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == GomspaceOpCodes.PRINT_SWITCH_V_I.value:
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
tc_queue.appendleft(
(QueueCommands.PRINT, "P60 Dock: Print Switches, Voltages, Currents")
)
@ -125,7 +136,7 @@ def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: st
object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == GomspaceOpCodes.PRINT_LATCHUPS.value:
if op_code in GomspaceOpCodes.PRINT_LATCHUPS:
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Print Latchups"))
command = generate_action_command(
object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS

View File

@ -210,12 +210,12 @@ def pack_pdu1_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == GomspaceOpCodes.REQUEST_HK_ONCE.value:
if op_code in GomspaceOpCodes.REQUEST_HK_ONCE:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Requesting HK Table Once"))
hk_sid = make_sid(object_id=PDU_1_HANDLER_ID, set_id=SetIds.PDU_1)
command = generate_one_hk_command(sid=hk_sid, ssc=0)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == GomspaceOpCodes.PRINT_SWITCH_V_I.value:
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU1: Print Switches, Voltages, Currents")
)
@ -223,7 +223,7 @@ def pack_pdu1_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == GomspaceOpCodes.PRINT_LATCHUPS.value:
if op_code in GomspaceOpCodes.PRINT_LATCHUPS:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Print Latchups"))
command = generate_action_command(
object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS

View File

@ -232,12 +232,12 @@ def pack_pdu2_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
Channel.off,
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == GomspaceOpCodes.REQUEST_HK_ONCE.value:
if op_code in GomspaceOpCodes.REQUEST_HK_ONCE:
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Requesting HK Table Once"))
hk_sid = make_sid(object_id=PDU_2_HANDLER_ID, set_id=SetIds.PDU_2)
command = generate_one_hk_command(sid=hk_sid, ssc=0)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == GomspaceOpCodes.PRINT_SWITCH_V_I.value:
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU2: Print Switches, Currents, Voltahes")
)
@ -245,7 +245,7 @@ def pack_pdu2_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == GomspaceOpCodes.PRINT_LATCHUPS.value:
if op_code in GomspaceOpCodes.PRINT_LATCHUPS:
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Print Latchups"))
command = generate_action_command(
object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS

View File

@ -16,7 +16,7 @@ from config.object_ids import (
GPS_HANDLER_1_ID,
BPX_HANDLER_ID,
CORE_CONTROLLER_ID,
P60_DOCK_HANDLER
P60_DOCK_HANDLER,
)
LOGGER = get_console_logger()
@ -361,9 +361,19 @@ def handle_core_hk_data(hk_data: bytes, set_id: int) -> HkReplyUnpacked:
P60_INDEX_LIST = [
"ACU VCC", "PDU1 VCC", "X3 IDLE", "PDU2 VCC", "ACU VBAT", "PDU1 VBAT",
"X3 IDLE VBAT", "PDU2 VBAT", "STACK VBAT", "STACK 3V3", "STACK 5V",
"GS3V3", "GS5V"
"ACU VCC",
"PDU1 VCC",
"X3 IDLE",
"PDU2 VCC",
"ACU VBAT",
"PDU1 VBAT",
"X3 IDLE VBAT",
"PDU2 VBAT",
"STACK VBAT",
"STACK 3V3",
"STACK 5V",
"GS3V3",
"GS5V",
]
@ -376,36 +386,52 @@ def handle_p60_hk_data(hk_data: bytes) -> HkReplyUnpacked:
else:
reply.header_list.append(f"I {P60_INDEX_LIST[idx]}")
reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0])
reply.content_list.append(
struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
for idx in range(0, 13):
if idx == 0:
reply.header_list.append(f"U [mV] {P60_INDEX_LIST[idx]}")
else:
reply.header_list.append(f"U {P60_INDEX_LIST[idx]}")
reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 2])[0])
reply.content_list.append(
struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
for idx in range(0, 13):
reply.header_list.append(f"OutEnb {P60_INDEX_LIST[idx]}")
reply.content_list.append(hk_data[current_idx])
current_idx += 1
reply.header_list.append("Temp 0 [C]")
reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0])
reply.content_list.append(
struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
reply.header_list.append("Temp 1 [C]")
reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0])
reply.content_list.append(
struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
reply.header_list.append("Boot Cause")
reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0])
reply.content_list.append(
struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
)
current_idx += 4
reply.header_list.append("Boot Count")
reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0])
reply.content_list.append(
struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
)
current_idx += 4
reply.header_list.append("Uptime")
reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0])
reply.content_list.append(
struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
)
current_idx += 4
reply.header_list.append("Reset Cause")
reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 4])[0])
reply.content_list.append(
struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
reply.header_list.append("Battery Mode")
reply.content_list.append(hk_data[current_idx])
@ -418,25 +444,39 @@ def handle_p60_hk_data(hk_data: bytes) -> HkReplyUnpacked:
current_idx += 1
for idx in range(0, 13):
reply.header_list.append(f"Latchup {P60_INDEX_LIST[idx]}")
reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 2])[0])
reply.content_list.append(
struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
reply.header_list.append("Dock VBAT [mV]")
reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 2])[0])
reply.content_list.append(
struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
reply.header_list.append("Dock VCC Current [mA]")
reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0])
reply.content_list.append(
struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
reply.header_list.append("Batt Charge [mA]")
reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0])
reply.content_list.append(
struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
reply.header_list.append("Batt Voltage [mV]")
reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 2])[0])
reply.content_list.append(
struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
reply.header_list.append("Batt Temp 0 [C]")
reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0])
reply.content_list.append(
struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
reply.header_list.append("Batt Temp 1 [C]")
reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0])
reply.content_list.append(
struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
for idx in range(0, 7):
reply.header_list.append(f"Device {idx} type")
@ -450,28 +490,44 @@ def handle_p60_hk_data(hk_data: bytes) -> HkReplyUnpacked:
reply.content_list.append(hk_data[current_idx])
current_idx += 1
reply.header_list.append("GND WDT Reboots")
reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0])
reply.content_list.append(
struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
)
current_idx += 4
reply.header_list.append("I2C WDT Reboots")
reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0])
reply.content_list.append(
struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
)
current_idx += 4
reply.header_list.append("CAN WDT Reboots")
reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0])
reply.content_list.append(
struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
)
current_idx += 4
reply.header_list.append("CSP0 WDT Reboots")
reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0])
reply.content_list.append(
struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
)
current_idx += 4
reply.header_list.append("CSP1 WDT Reboots")
reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0])
reply.content_list.append(
struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
)
current_idx += 4
reply.header_list.append("GND WDT time left [s]")
reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0])
reply.content_list.append(
struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
)
current_idx += 4
reply.header_list.append("I2C WDT time left [s]")
reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0])
reply.content_list.append(
struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
)
current_idx += 4
reply.header_list.append("CAN WDT time left [s]")
reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0])
reply.content_list.append(
struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
)
current_idx += 4
reply.header_list.append("CSP0 WDT Pings Left")
reply.content_list.append(hk_data[current_idx])
@ -480,15 +536,23 @@ def handle_p60_hk_data(hk_data: bytes) -> HkReplyUnpacked:
reply.content_list.append(hk_data[current_idx])
current_idx += 1
reply.header_list.append("Batt Charge Current")
reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0])
reply.content_list.append(
struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
reply.header_list.append("Batt Discharge Current")
reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0])
reply.content_list.append(
struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0]
)
current_idx += 2
reply.header_list.append("ANT6 Depl Status")
reply.content_list.append(struct.unpack("!b", hk_data[current_idx: current_idx + 1])[0])
reply.content_list.append(
struct.unpack("!b", hk_data[current_idx : current_idx + 1])[0]
)
current_idx += 1
reply.header_list.append("AR6 Depl Status")
reply.content_list.append(struct.unpack("!b", hk_data[current_idx: current_idx + 1])[0])
reply.content_list.append(
struct.unpack("!b", hk_data[current_idx : current_idx + 1])[0]
)
current_idx += 1
return reply

@ -1 +1 @@
Subproject commit 06aed2f309a105f8f0e183d359a432301eb6947d
Subproject commit 3cda2df79d2b3eb29855a29ff33df8e4d6f18ae1