From a23820d393bfe6f5775f7dd21c7f808a7a9266bd Mon Sep 17 00:00:00 2001 From: seimit Date: Thu, 25 Nov 2021 21:23:05 +0200 Subject: [PATCH] Fix for issue #11 --- Metis/tools/STDFHelper.py | 8 ++++---- Metis/tools/stdf2csv.py | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Metis/tools/STDFHelper.py b/Metis/tools/STDFHelper.py index 39090736..85facf2e 100644 --- a/Metis/tools/STDFHelper.py +++ b/Metis/tools/STDFHelper.py @@ -71,9 +71,9 @@ def is_plain_stdf(stdf_file): if rec_sub != b'\x0A': return False - if bo == 1: + if bo == b'\x01': byteorder = 'big' - elif bo == 2: + elif bo == b'\x02': byteorder = 'little' else: byteorder = sys.byteorder @@ -107,9 +107,9 @@ def get_byteorder(stdf_file): # Skip the first 4 bytes f.read(4) bo = f.read(1) - if bo == 1: + if bo == b'\x01': byteorder = 'big' - elif bo == 2: + elif bo == b'\x02': byteorder = 'little' else: byteorder = sys.byteorder diff --git a/Metis/tools/stdf2csv.py b/Metis/tools/stdf2csv.py index e621a318..2294bda0 100644 --- a/Metis/tools/stdf2csv.py +++ b/Metis/tools/stdf2csv.py @@ -177,6 +177,12 @@ def convert(self, input_stdf_file, output_folder): progress.update(1) stdf_record = STDFHelper.get_stdf_record(ver, byteorder, rec_len, rec_typ, rec_sub, rec) + + if stdf_record == None: + rt = int.from_bytes(rec_typ, byteorder) + rs = int.from_bytes(rec_sub, byteorder) + print(f"Unknown STDF record with record type {rt} and sub-type {rs}.") + continue rec_name = type(stdf_record).__name__