@@ -120,18 +120,14 @@ def blue_to_sigmf_type_str(h_fixed):
120120 return datatype
121121
122122
123- def detect_endian (data , probe_fields = ( "data_size" , "version" ) ):
123+ def detect_endian (data ):
124124 """
125125 Detect endianness of a Bluefile header.
126126
127- TODO: Look at this code and see if can be improved and possibly simplified.
128-
129127 Parameters
130128 ----------
131129 data : bytes
132130 Raw header data.
133- probe_fields : tuple of str, optional
134- Field names to test for sanity checks.
135131
136132 Returns
137133 -------
@@ -144,36 +140,13 @@ def detect_endian(data, probe_fields=("data_size", "version")):
144140 If the endianness is unexpected.
145141 """
146142 endianness = data [8 :12 ].decode ("ascii" )
147- if endianness not in ("EEEI" , "IEEE" ):
143+ if endianness == "EEEI" :
144+ return "<"
145+ elif endianness == "IEEE" :
146+ return ">"
147+ else :
148148 raise SigMFConversionError (f"Unexpected endianness: { endianness } " )
149149
150- for endian in ("<" , ">" ):
151- ok = True
152- for key , offset , size , fmt , _ in FIXED_LAYOUT :
153- if key not in probe_fields :
154- continue
155- raw = data [offset : offset + size ]
156- try :
157- val = struct .unpack (endian + fmt , raw )[0 ]
158- # sanity checks
159- MAX_DATA_SIZE_FACTOR = 100
160-
161- if key == "data_size" :
162- if val < 0 or val > lenf (data ) * MAX_DATA_SIZE_FACTOR :
163- ok = False
164- break
165- elif key == "version" :
166- if not 0 < val < 10 : # expect small version number
167- ok = False
168- break
169- except (struct .error , ValueError , IndexError ):
170- ok = False
171- break
172- if ok :
173- return endian
174- # fallback
175- return "<"
176-
177150
178151def read_hcb (file_path ):
179152 """
@@ -268,8 +241,6 @@ def read_extended_header(file_path, h_fixed):
268241 Path to the BLUE file.
269242 h_fixed : dict
270243 Fixed Header containing 'ext_size' and 'ext_start'.
271- endian : str, optional
272- Endianness ('<' for little-endian, '>' for big-endian).
273244
274245 Returns
275246 -------
@@ -522,8 +493,7 @@ def get_tag(tag):
522493 capture_info [SigMFFile .FREQUENCY_KEY ] = float (get_tag ("RF_FREQ" ))
523494
524495 # actually write to SigMF
525- filenames = get_sigmf_filenames (out_path .stem )
526- print ("dbug" , filenames )
496+ filenames = get_sigmf_filenames (out_path )
527497
528498 # for metadata-only files, don't specify data_file and skip checksum
529499 if is_metadata_only :
0 commit comments