def crc8_sae_j1850_zero( data) :
crc = 0x00
polynomial = 0x1D
for byte in data:
crc ^= byte
for _ in range ( 8 ) :
if crc & 0x80 :
crc = ( crc << 1 ) ^ polynomial
else :
crc <<= 1
crc &= 0xFF # Ensure 8-bit CRC
return crc
# Example usage with your provided data:
data = [ 0xF2 , 0x00 , 0x0D , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ]
calculated_crc = crc8_sae_j1850_zero( data)
print ( hex ( calculated_crc) ) # Output the calculated CRC in hexadecimal format
ZGVmIGNyYzhfc2FlX2oxODUwX3plcm8oZGF0YSk6CiAgICBjcmMgPSAweDAwCiAgICBwb2x5bm9taWFsID0gMHgxRAoKICAgIGZvciBieXRlIGluIGRhdGE6CiAgICAgICAgY3JjIF49IGJ5dGUKICAgICAgICBmb3IgXyBpbiByYW5nZSg4KToKICAgICAgICAgICAgaWYgY3JjICYgMHg4MDoKICAgICAgICAgICAgICAgIGNyYyA9IChjcmMgPDwgMSkgXiBwb2x5bm9taWFsCiAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICBjcmMgPDw9IDEKICAgICAgICBjcmMgJj0gMHhGRiAgIyBFbnN1cmUgOC1iaXQgQ1JDCgogICAgcmV0dXJuIGNyYwoKIyBFeGFtcGxlIHVzYWdlIHdpdGggeW91ciBwcm92aWRlZCBkYXRhOgpkYXRhID0gWzB4RjIsIDB4MDAsIDB4MEQsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDAsIDB4MDBdCmNhbGN1bGF0ZWRfY3JjID0gY3JjOF9zYWVfajE4NTBfemVybyhkYXRhKQpwcmludChoZXgoY2FsY3VsYXRlZF9jcmMpKSAgIyBPdXRwdXQgdGhlIGNhbGN1bGF0ZWQgQ1JDIGluIGhleGFkZWNpbWFsIGZvcm1hdAoKCg==