compute_version_hash: normalize Windows line endings (#2383)

* compute_version_hash: normalize Windows line endings

* also update function in SConscript
This commit is contained in:
Willem Melching
2026-04-08 18:34:21 +02:00
committed by GitHub
parent 7c0c1d956b
commit 18f37937cc
2 changed files with 4 additions and 2 deletions

View File

@@ -154,7 +154,8 @@ with open("board/obj/cert.h", "w") as f:
# Packet version defines: SHA hash of the struct header files
def version_hash(path):
with open(path, "rb") as f:
return int.from_bytes(hashlib.sha256(f.read()).digest()[:4], 'little')
# Normalize line endings on Windows
return int.from_bytes(hashlib.sha256(f.read().replace(b'\r', b'')).digest()[:4], 'little')
hh, ch, jh = version_hash("board/health.h"), version_hash(os.path.join(opendbc.INCLUDE_PATH, "opendbc/safety/can.h")), version_hash("board/jungle/jungle_health.h")
common_flags += [f"-DHEALTH_PACKET_VERSION=0x{hh:08X}U", f"-DCAN_PACKET_VERSION_HASH=0x{ch:08X}U",
f"-DJUNGLE_HEALTH_PACKET_VERSION=0x{jh:08X}U"]

View File

@@ -8,7 +8,8 @@ FW_PATH = os.path.join(BASEDIR, "board/obj/")
def compute_version_hash(filepath):
with open(filepath, "rb") as f:
return int.from_bytes(hashlib.sha256(f.read()).digest()[:4], 'little')
# Normalize line endings on Windows
return int.from_bytes(hashlib.sha256(f.read().replace(b'\r', b'')).digest()[:4], 'little')
USBPACKET_MAX_SIZE = 0x40