some fixes for rw ass commanding

This commit is contained in:
2022-05-10 18:34:15 +02:00
parent 8891908afa
commit a648b7f76f
4 changed files with 48 additions and 23 deletions

View File

@ -11,27 +11,30 @@ def handle_rw_hk_data(
pw = PrintWrapper(printer)
current_idx = 0
if set_id == RwSetIds.TEMPERATURE_SET_ID:
pw.dlog(
f"Received Temperature HK (ID {set_id}) from Reaction Wheel {object_id.name}"
)
temp = struct.unpack("!I", hk_data[0:4])
pw.dlog(f"Temperature {temp}")
current_idx += 4
if set_id == RwSetIds.STATUS_SET_ID:
pw.dlog(
f"Received Status HK (ID {set_id}) from Reaction Wheel {object_id.name}"
)
fmt_str = "!iiBB"
fmt_str = "!IiiBB"
inc_len = struct.calcsize(fmt_str)
(speed, ref_speed, state, clc_mode) = struct.unpack(
(temp, speed, ref_speed, state, clc_mode) = struct.unpack(
fmt_str, hk_data[current_idx : current_idx + inc_len]
)
current_idx += inc_len
speed_rpm = speed / 10.0
ref_speed_rpm = ref_speed / 10.0
pw.dlog(
f"Speed {speed} rpm | Reference Speed {ref_speed} rpm | State {state} | "
f"CLC Mode {clc_mode}"
f"Temperature {temp} C | Speed {speed_rpm} rpm | Reference Speed {ref_speed_rpm} rpm"
)
pw.dlog(
f"State {state}. 0: Error, 1: Idle, 2: Coasting, 3: Running, speed stable, "
f"4: Running, speed changing"
)
pw.dlog(
f"Current Limit Control mode {clc_mode}. 0: Low Current Mode (0.3 A), "
f"1: High Current Mode (0.6 A)"
)
printer.print_validity_buffer(hk_data[current_idx:], 5)
if set_id == RwSetIds.LAST_RESET:
pw.dlog(
f"Received Last Reset HK (ID {set_id}) from Reaction Wheel {object_id.name}"
@ -115,7 +118,7 @@ def handle_rw_hk_data(
f"{spi_num_bytes_written} | {spi_num_bytes_read} | {spi_num_reg_overrun_errors} | "
f"{spi_total_num_errors}"
)
if current_idx > 0:
printer.print_validity_buffer(
validity_buffer=hk_data[current_idx:], num_vars=27
)
if current_idx > 0:
printer.print_validity_buffer(
validity_buffer=hk_data[current_idx:], num_vars=27
)