mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-02-11 07:03:07 +01:00
add some helper tools for converting candumps
This commit is contained in:
29
tools/getPgnType.py
Executable file
29
tools/getPgnType.py
Executable file
@@ -0,0 +1,29 @@
|
||||
#! /usr/bin/env python3
|
||||
import sys
|
||||
import json
|
||||
|
||||
def err(txt):
|
||||
print(txt,file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
HDR='''
|
||||
PGNM_Fast=0
|
||||
PGNM_Single=1
|
||||
PGNM_ISO=2
|
||||
PGN_MODES={
|
||||
'''
|
||||
FOOTER='''
|
||||
}
|
||||
'''
|
||||
with open(sys.argv[1],"r") as ih:
|
||||
data=json.load(ih)
|
||||
pgns=data.get('PGNs')
|
||||
if pgns is None:
|
||||
err("no pgns")
|
||||
print(HDR)
|
||||
for p in pgns:
|
||||
t=p['Type']
|
||||
pgn=p['PGN']
|
||||
if t and pgn:
|
||||
print(f" {pgn}: PGNM_{t},")
|
||||
print(FOOTER)
|
||||
Reference in New Issue
Block a user