INNER CODE UNIT · Python
parse_hex_data
zhinkgit/embeddedskills · can/scripts/can_decode.py:9
def parse_hex_data(s):
s = s.replace(" ", "").replace(",", "")
return bytes.fromhex(s)
def output_json(result):
sys.stdout.buffer.write(json.dumps(result, ensure_ascii=False, indent=2).encode("utf-8"))
sys.stdout.buffer.write(b"\n")
sys.stdout.buffer.flush()
def load_database(db_path, db_format="auto"):
"""加载数据库文件"""
import cantools
path = Path(db_path)
if not path.exists():
return None, f"数据库文件不存在: {db_path}"