Last active
April 3, 2025 12:40
-
-
Save bkralik/5115ab131125371354f59b6840de1102 to your computer and use it in GitHub Desktop.
Read Racelogic REF file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from loguru import logger | |
| import zlib | |
| filename = "Dodge-Charger-LD-2018.REF" | |
| f = open(filename, "rb") | |
| l = f.readline().decode("utf-8").rstrip() | |
| logger.debug("First line read: {}", l) | |
| valid_headers = [ | |
| "Racelogic Can Data File V1", | |
| "Racelogic Can Data File V2", | |
| "Racelogic Can Data File V1a", | |
| "Racelogic Can Data File V2a" | |
| ] | |
| if not (l in valid_headers): | |
| logger.error("Valid header not found") | |
| quit(1) | |
| l2 = f.readline().decode("utf-8").rstrip() | |
| logger.debug("Second line read: {}", l2) | |
| def getCodedDataLength(f): | |
| buf = f.read(2) | |
| return buf[0] << 8 | buf[1] | |
| l3 = getCodedDataLength(f) | |
| logger.debug("Coded data length 1: {}", l3) | |
| d3 = f.read(l3) | |
| d3d = zlib.decompress(d3) | |
| l4 = getCodedDataLength(f) | |
| logger.debug("Coded data length 2: {}", l4) | |
| logger.debug("SignalName,ID,Units,StartBit,Length,Offset,Scale,Maximum,Minimum,Dataformat,ByteOrder,DLC") | |
| logger.debug("if ByteOrder == Motorola, StartBit = 56 - StartBit / 8 * 16 + StartBit") | |
| for i in range(0, l4): | |
| l5 = getCodedDataLength(f) | |
| d5 = f.read(l5) | |
| d5d = zlib.decompress(d5).decode() | |
| logger.info(d5d) |
al-locke1
commented
Apr 3, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment