rPi Python,seatalk1至nmea 0183
你好,我是编程新手 下面的数据报来自 这些是我必须翻译成nmea0183的一些样本。 有人能用python做一些解析吗 最终程序将在发送时获取seatalk1数据,并将其转换为nmea0183,然后在屏幕上显示。 seatalk1数据将来自 多谢各位rPi Python,seatalk1至nmea 0183,python,parsing,Python,Parsing,你好,我是编程新手 下面的数据报来自 这些是我必须翻译成nmea0183的一些样本。 有人能用python做一些解析吗 最终程序将在发送时获取seatalk1数据,并将其转换为nmea0183,然后在屏幕上显示。 seatalk1数据将来自 多谢各位 00 02 YZ XX XX Depth below transducer: XXXX/10 feet Flags in Y: Y&8 = 8: Anchor Alarm is active
00 02 YZ XX XX Depth below transducer: XXXX/10 feet
Flags in Y: Y&8 = 8: Anchor Alarm is active
Y&4 = 4: Metric display units or
Fathom display units if followed by command 65
Y&2 = 2: Used, unknown meaning
Flags in Z: Z&4 = 4: Transducer defective
Z&2 = 2: Deep Alarm is active
Z&1 = 1: Shallow Depth Alarm is active
Corresponding NMEA sentences: DPT, DBT
或
或
或
或
我就是这样解决的
## AWS, Apparent Wind Speed
elif st_header == '11':
try:
a1,a2,a3,a4,a5 = st_data.split(',')
except ValueError: a1="none"
else:
xx = int(a4, 16)
y = (int(a5, 16)) & 15 # 0Y - & with 0x0F (15) to ensure that we get rid of first octet, it might be unnecessary
isInKnots = (xx & 128 == 128)
speed = float(xx & 127) + y/10
if (isInKnots) :
aws_read = speed * 0.514444691
else :
aws_read = speed
print('aws_read',aws_read)
11 01 XX 0Y Apparent Wind Speed: (XX & 0x7F) + Y/10 Knots
Units flag: XX&0x80=0 => Display value in Knots
XX&0x80=0x80 => Display value in Meter/Second
Corresponding NMEA sentence: MWV
50 Z2 XX YY YY LAT position: XX degrees, (YYYY & 0x7FFF)/100 minutes
MSB of Y = YYYY & 0x8000 = South if set, North if cleared
Z= 0xA or 0x0 (reported for Raystar 120 GPS), meaning unknown
Stable filtered position, for raw data use command 58
Corresponding NMEA sentences: RMC, GAA, GLL
53 U0 VW Course over Ground (COG) in degrees:
The two lower bits of U * 90 +
the six lower bits of VW * 2 +
the two higher bits of U / 2 =
(U & 0x3) * 90 + (VW & 0x3F) * 2 + (U & 0xC) / 8
The Magnetic Course may be offset by the Compass Variation (see datagram 99) to get the Course Over Ground (COG).
Corresponding NMEA sentences: RMC, VTG
## AWS, Apparent Wind Speed
elif st_header == '11':
try:
a1,a2,a3,a4,a5 = st_data.split(',')
except ValueError: a1="none"
else:
xx = int(a4, 16)
y = (int(a5, 16)) & 15 # 0Y - & with 0x0F (15) to ensure that we get rid of first octet, it might be unnecessary
isInKnots = (xx & 128 == 128)
speed = float(xx & 127) + y/10
if (isInKnots) :
aws_read = speed * 0.514444691
else :
aws_read = speed
print('aws_read',aws_read)