Ankerseite und mehr NMEA0183 code

This commit is contained in:
2025-07-20 21:29:22 +02:00
parent 5d8b33b086
commit 664d6c7d49
3 changed files with 102 additions and 30 deletions

View File

@@ -13,6 +13,13 @@ def DBT(boatdata, msg):
pass
#boatdata.setValue("DBT", msg.depth)
def DPT(boatdata, msg):
# Depth
print("-> DPT")
print(msg.fields)
print(msg.data)
#boatdata.setValue("DBT", msg.depth)
def GBS(boatdata, msg):
# GNSS satellite fault detection
"""
@@ -42,9 +49,20 @@ def GGA(boatdata, msg):
boatdata.setValue("HDOP", msg.horizontal_dil)
def GLL(boatdata, msg):
print("-> GLL")
boatdata.setValue("LAT", msg.latitude)
boatdata.setValue("LON", msg.longitude)
# Position data: position fix, time of position fix, and status
# UTC of position ignored
print(msg.data)
if not msg.status == 'A':
return
lat_fac = 1 if msg.lat_dir == 'N' else -1
lat_deg = int(msg.lat[0:2])
lat_min = float(msg.lat[2:])
print(lat_deg, lat_min)
boatdata.setValue("LAT", lat_fac * lat_deg + lat_min / 60)
lon_fac = 1 if msg.lon_dir == 'E' else -1
lon_deg = int(msg.lon[0:3])
lon_min = float(msg.lon[3:])
boatdata.setValue("LON", lon_fac * lon_deg + lon_min / 60)
def GSA(boatdata, msg):
# Satellites
@@ -113,8 +131,10 @@ def HDM(boatdata, msg):
def HDT(boatdata, msg):
# Heading True
print("-> HDT")
print(msg.fields)
if msg.hdg_true == 'T':
boatdata.setValue("HDT", msg.heading)
else:
print("HDT: T not set!")
def HTD(boatdata, msg):
# Heading/Track control data
@@ -141,20 +161,25 @@ def RMB(boatdata, msg):
def RMC(boatdata, msg):
# Recommended Minimum Navigation Information
# print("-> RMC")
#print("-> RMC")
# print(msg.timestamp, msg.datestamp)
# print(msg.status) # V=Warning, P=Precise, A=?
# print(msg.status) # V=Warning, P=Precise, A=OK
# mag_variation, mag_var_dir E/W
# true_course
if msg.lat_dir == 'N':
boatdata.setValue("LAT", msg.lat)
else:
boatdata.setValue("LAT", msg.lat) * -1
if msg.lon_dir == 'E':
boatdata.setValue("LON", msg.lon)
else:
boatdata.setValue("LON", msg.lon) * -1
boatdata.setValue("SOG", msg.spd_over_grnd)
# TODO nav_status welche Bedeutung?
if not msg.status == 'A':
return
lat_fac = 1 if msg.lat_dir == 'N' else -1
lat_deg = int(msg.lat[0:2])
lat_min = float(msg.lat[2:])
boatdata.setValue("LAT", lat_fac * lat_deg + lat_min / 60)
lon_fac = 1 if msg.lon_dir == 'E' else -1
lon_deg = int(msg.lon[0:3])
lon_min = float(msg.lon[3:])
boatdata.setValue("LON", lon_fac * lon_deg + lon_min / 60)
if msg.spd_over_grnd:
boatdata.setValue("SOG", float(msg.spd_over_grnd))
if msg.true_course:
boatdata.setValue("COG", float(msg.true_course))
def ROT(boatdata, msg):
# Rate Of Turn
@@ -242,7 +267,13 @@ def XDR(boatdata, msg):
# units: D
# id: Yaw
if msg.id.lower() == 'yaw':
boatdata.setValue("YAW", msg.value)
boatdata.setValue("YAW", float(msg.value))
elif msg.id.lower() == 'ptch':
boatdata.setValue("PTCH", float(msg.value))
elif msg.id.lower() == 'roll':
boatdata.setValue("ROLL", float(msg.value))
elif msg.id.lower() == 'barometer':
boatdata.setValue("xdrPress", float(msg.value))
else:
print(f"-> XDR: {msg.type}, {msg.value}, {msg.units}, {msg.id}")
@@ -275,6 +306,7 @@ def VDO(boatdata, msg):
decoder = {
"DBS": DBS,
"DBT": DBT,
"DPT": DPT,
"GBS": GBS,
"GGA": GGA,
"GLL": GLL,
@@ -282,6 +314,7 @@ decoder = {
"GSV": GSV,
"HDG": HDG,
"HDM": HDM,
"HDT": HDT,
"HTD": HTD,
"MWV": MWV,
"MTW": MTW,