From 04bbe057e7a0ca24b7d0a2d3c620d422ca15f59a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 16:24:45 +0200 Subject: [PATCH] flash c ontent report works now --- eive_tmtc/tmtc/payload/ploc_mpsoc.py | 29 ++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/eive_tmtc/tmtc/payload/ploc_mpsoc.py b/eive_tmtc/tmtc/payload/ploc_mpsoc.py index b2f2c95..255669c 100644 --- a/eive_tmtc/tmtc/payload/ploc_mpsoc.py +++ b/eive_tmtc/tmtc/payload/ploc_mpsoc.py @@ -652,19 +652,20 @@ def handle_mpsoc_data_reply( printer.file_logger.info(header_list) printer.file_logger.info(content_list) elif action_id == ActionId.TM_FLASH_DIRECTORY_CONTENT: - print(custom_data.hex(sep=",")) if len(custom_data) < 16: _LOGGER.warning( "PLOC MPSoC flash directory data shorter than minimum 16 bytes" ) current_idx = 0 - dir_name_short = custom_data[current_idx : current_idx + 12] + dir_name_short = custom_data[current_idx : current_idx + 12].decode("utf-8") current_idx += 12 num_elements = struct.unpack("!I", custom_data[current_idx : current_idx + 4])[ 0 ] current_idx += 4 - elems = [] + elem_names = [] + elem_attrs = [] + elem_sizes = [] expected_size = 16 + num_elements * 17 if len(custom_data) < expected_size: _LOGGER.warning( @@ -674,13 +675,21 @@ def handle_mpsoc_data_reply( f"Received PLOC MPSoC flash directory content for path {dir_name_short} " f"with {num_elements} elements" ) - for i in range(num_elements): - elem_name = custom_data[current_idx : current_idx + 12].decode("utf-8") + # It is as weird as it looks.. + for _ in range(num_elements): + end_of_str = custom_data[current_idx : current_idx + 12].index(b"\x00") + elem_name = custom_data[current_idx : current_idx + end_of_str].decode( + "utf-8" + ) current_idx += 12 - elem_attr = custom_data[current_idx] + elem_names.append(elem_name) + for _ in range(num_elements): + elem_attrs.append(custom_data[current_idx]) current_idx += 1 - elem_size = current_idx[current_idx : current_idx + 4] + for _ in range(num_elements): + elem_sizes.append( + struct.unpack("!I", custom_data[current_idx : current_idx + 4])[0] + ) current_idx += 4 - elems.append(DirElement(elem_name, elem_attr, elem_size)) - for elem in elems: - pw.dlog(f"{elem}") + for i in range(num_elements): + pw.dlog(f"{DirElement(elem_names[i], elem_attrs[i], elem_sizes[i])}")