- added Msg frame work with Msg container , Msg sources, Msg sinks
- added filter by message type to nmea receiver - show case new features in MultiClient.main()
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
from urllib.parse import to_bytes
|
||||
|
||||
from msg_montainer import MsgContainer
|
||||
from msg_sink import MsgSink
|
||||
import re
|
||||
|
||||
class NmeaReceiver(MsgSink):
|
||||
def __init__(self):
|
||||
MsgSink.__init__(self)
|
||||
self.filters_msg_type = []
|
||||
|
||||
def filter_by_msg_type(self, msg_type: str):
|
||||
self.filters_msg_type.append(msg_type)
|
||||
|
||||
def on_recv(self, msg: MsgContainer):
|
||||
data = msg.data.decode(encoding="utf-8")
|
||||
for pattern in self.filters_msg_type:
|
||||
if re.match(pattern, data):
|
||||
print(f"{self}: on_receive: {msg}")
|
||||
|
||||
Reference in New Issue
Block a user