''' PGNs verarbeiten ''' import struct def parse_126996(buf, source, device): # Product information n2kvers = (buf[0] + buf[1] * 256) / 1000 prodcode = buf[2] + buf[3] * 256 modelid = buf[4:36] # 256bit modelid ascii text softvers = buf[36:68] # 256bit software version code ascii text modelvers = buf[68:100] # 256bit model version ascii text serial = buf[100:132] # 256bit model serial code ascii text # Füllzeichen entfernen. 0x20, 0xff, '@' für AIS # Die N2K-Bibliothek von ttlappalainen liefert 0xff modelid = modelid.rstrip(b'\xff') softvers = softvers.rstrip(b'\xff') modelvers = modelvers.rstrip(b'\xff') serial = serial.rstrip(b'\xff') # Übertragen in die Geräteliste devices[source].n2kvers = n2kvers devices[source].productcode = prodcode devices[source].modelvers = modelvers.decode('ascii').rstrip() devices[source].softvers = softvers.decode('ascii').rstrip() devices[source].product = modelid.decode('ascii').rstrip() devices[source].serial = serial.decode('ascii').rstrip() devices[source].certlevel = buf[132] devices[source].loadequiv = buf[133] def parse_126998(buf, source, device): # Configuration information # Installation Description 1 txtlen = buf[0] if txtlen > 2: device.instdesc1 = buf[2:txtlen].decode('ascii') p = txtlen else: device.instdesc1 = "" p = 2 # Installation Description 2 txtlen = buf[p] if txtlen > 2: device.instdesc2 = buf[p+2:p+txtlen].decode('ascii') p += txtlen else: device.instdesc2 = "" p += 2 # Manufacturer Info txtlen = buf[p] if txtlen > 2: device.manufinfo = buf[p+2:p+txtlen].decode('ascii') else: device.manufinfo = "" def parse_127257(buf, boatdata): # Attitude sid = buf[0] yaw = struct.unpack_from('> 4 boatdata.tank[instance].capacity = struct.unpack_from('> 6 # 0: true, 1: magnetic, 2: error cog = struct.unpack_from('> 4 navterm = buf[1] & 0x03 xte = struct.unpack_from('