added UBX reception

This commit is contained in:
2026-03-16 16:12:11 +01:00
parent 2e83aeeb62
commit e004b71f3e
4 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
class MsgContainer: class MsgContainer:
def __init__(self, name: str, timestamp: float = 0, data: bytes = b''): def __init__(self, name: str, timestamp: float = 0, data = b''):
self.timestamp : float = timestamp self.timestamp : float = timestamp
self.name : str= name self.name : str= name
self.data: bytes = data self.data: bytes = data
+1 -1
View File
@@ -104,7 +104,7 @@ if __name__ == "__main__":
Gga(grm, 'GN'), Gga(grm, 'GN'),
] ]
ubx_rx_list = [ ubx_rx_list = [
UbxReceiver(grm, 0x0a, 0x36), UbxReceiver(grm, 0x01, 0x43),
] ]
# Topology # Topology
+4 -4
View File
@@ -2,7 +2,7 @@ import struct
from msg_container import MsgContainer from msg_container import MsgContainer
from msg_sink import MsgSink from msg_sink import MsgSink
from msg_source import MsgSource from msg_source import MsgSource
from ubx.ubx import UBX_SYNC_WORD, frame_parse_hdr, frame_create from ubx.ubx import UBX_SYNC_WORD, frame_parse, frame_create
from receiver.ubx_receiver import UbxReceiver from receiver.ubx_receiver import UbxReceiver
class UbxPacketizer(MsgSink, MsgSource): class UbxPacketizer(MsgSink, MsgSource):
@@ -34,9 +34,9 @@ class UbxPacketizer(MsgSink, MsgSource):
else: else:
if not self.wait_sync: if not self.wait_sync:
self.packet += struct.pack('B', d) self.packet += struct.pack('B', d)
hdr = frame_parse_hdr(self.packet) data, hdr = frame_parse(self.packet)
if hdr is not None: if data is not None:
if (6 + hdr.length) == len(self.packet): if hdr.length == len(data):
self.call_sinks(MsgContainer(name, timestamp, self.packet)) self.call_sinks(MsgContainer(name, timestamp, self.packet))
self.packet = b'' self.packet = b''
+2 -2
View File
@@ -3,11 +3,11 @@ from msg_sink import MsgSink
from ubx.ubx import frame_parse, frame_parse_hdr from ubx.ubx import frame_parse, frame_parse_hdr
class UbxReceiver(MsgSink): class UbxReceiver(MsgSink):
def __init__(self, name: str, mid: int, mclass: int): def __init__(self, name: str, mclass: int, mid: int):
MsgSink.__init__(self) MsgSink.__init__(self)
self.name = name self.name = name
self.mid = mid
self.mclass = mclass self.mclass = mclass
self.mid = mid
def on_recv(self, msg: MsgContainer): def on_recv(self, msg: MsgContainer):
data, hdr = frame_parse(msg.data) data, hdr = frame_parse(msg.data)