Skip to content

Commit da7afc3

Browse files
committed
Inject Settings packing
1 parent 20afa83 commit da7afc3

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

source/Settings/lib/settings_cli.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ def handle_input_file(args, settings) -> Tuple[Settings, int]:
9999

100100
# Add common default values that might be missing from the BSP config
101101
if "QC_VOLTAGE_MAX" not in bsp_config:
102-
bsp_config["QC_VOLTAGE_MAX"] = 120
103-
102+
bsp_config["QC_VOLTAGE_MAX"] = 90
104103
except Exception as e:
105104
print(f"Error loading BSP configuration: {e}")
106105
print("Will use YAML defaults instead")
@@ -179,6 +178,11 @@ def run_editing_settings_file_cli():
179178
else:
180179
print("Running in non-interactive mode, using loaded/default values")
181180

181+
182+
versionMarker = 0x55AA
183+
if args.model == "Pinecilv2":
184+
versionMarker = 0x55AB # Special version marker for Pinecil v2
185+
182186
# Check if output is hex and we need intelhex module
183187
if args.output.lower().endswith(".hex"):
184188
if not HEX_SUPPORT:
@@ -199,7 +203,7 @@ def run_editing_settings_file_cli():
199203

200204
# Save settings to binary or hex file
201205
print(f"\nSaving settings to {args.output}")
202-
if not settings.save_to_binary(args.output, base_address):
206+
if not settings.save_to_binary(args.output, base_address,versionMarker):
203207
print("Failed to save settings")
204208
sys.exit(1)
205209

source/Settings/lib/settings_model.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def load_from_binary(self, file_path: str) -> Tuple[bool, int]:
166166
print(f"Error loading settings from file: {e}")
167167
return False, 0
168168

169-
def save_to_binary(self, file_path: str, base_address: int = 0) -> bool:
169+
def save_to_binary(self, file_path: str, base_address:int, versionMarker:int) -> bool:
170170
"""Save settings to a binary or hex file
171171
172172
Args:
@@ -186,10 +186,14 @@ def save_to_binary(self, file_path: str, base_address: int = 0) -> bool:
186186

187187
# Create binary data
188188
binary_data = bytearray()
189+
binary_data.extend(struct.pack("<H", versionMarker))
190+
binary_data.extend(struct.pack("<H", len(self.values))) # Number of settings
189191
for value in self.values:
190192
# Pack as 16-bit little-endian
191193
binary_data.extend(struct.pack("<H", value))
192-
194+
# Add u32 padding at the end
195+
binary_data.extend(struct.pack("<H", 0))
196+
binary_data.extend(struct.pack("<H", 0))
193197
# Check file extension to determine format
194198
is_hex_file = file_path.lower().endswith(".hex")
195199

0 commit comments

Comments
 (0)