From e6e4a00f47e0533b022f18da208fe67de0fdda3a Mon Sep 17 00:00:00 2001 From: FLo-ABB Date: Fri, 30 May 2025 20:35:32 +0200 Subject: [PATCH] Fix checksum formatting to always return 4-digit uppercase hex string with leading zeros --- src/CognexNativePy/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CognexNativePy/utils.py b/src/CognexNativePy/utils.py index b0747c2..7726fdf 100644 --- a/src/CognexNativePy/utils.py +++ b/src/CognexNativePy/utils.py @@ -184,7 +184,7 @@ def calculate_checksum(buffer: bytes) -> int: cword <<= 1 # Shift left without XOR cword &= 0xFFFF # Ensure cword stays within 16 bits ch <<= 1 # Shift ch to the left - return hex(cword).upper()[2:] + return "{:04X}".format(cword) def hex_to_ascii_hex(buffer: bytes) -> bytes: