Skip to content

Commit

Permalink
Fix msgpack compatibility issues
Browse files Browse the repository at this point in the history
  • Loading branch information
svpcom committed Oct 1, 2024
1 parent 397faaf commit cd9153c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion wfb_ng/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class AntennaStat(Int32StringReceiver):
temp_overheat_warning = settings.common.temp_overheat_warning

def stringReceived(self, string):
attrs = msgpack.unpackb(string, strict_map_key=False, use_list=False)
attrs = msgpack.unpackb(string, strict_map_key=False, use_list=False, raw=False)

if attrs['type'] == 'rx':
self.draw_rx(attrs)
Expand Down
2 changes: 1 addition & 1 deletion wfb_ng/log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def main():
if len(data) < data_len:
break

msg = msgpack.unpackb(data, strict_map_key=False, use_list=False)
msg = msgpack.unpackb(data, strict_map_key=False, use_list=False, raw=False)
ts = msg.pop('timestamp')
mtype = msg.pop('type')

Expand Down
5 changes: 3 additions & 2 deletions wfb_ng/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def connectionMade(self):
cli_title=self.factory.cli_title or "",
is_cluster=self.factory.is_cluster,
log_interval=settings.common.log_interval,
temp_overheat_warning=settings.common.temp_overheat_warning)))
temp_overheat_warning=settings.common.temp_overheat_warning),
use_bin_type=True))

self.factory.ui_sessions.append(self)

Expand All @@ -65,7 +66,7 @@ def connectionLost(self, reason):
self.factory.ui_sessions.remove(self)

def send_stats(self, data):
self.sendString(msgpack.packb(data))
self.sendString(msgpack.packb(data, use_bin_type=True))


class RFTempMeter(object):
Expand Down
2 changes: 1 addition & 1 deletion wfb_ng/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BinLogger(ErrorSafeLogFile):
log_cls = BinLogFile

def send_stats(self, data):
data = msgpack.packb(data)
data = msgpack.packb(data, use_bin_type=True)
self.write(b''.join((struct.pack('!I', len(data)), data)))


Expand Down
7 changes: 6 additions & 1 deletion wfb_ng/tests/test_twisted.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from twisted.trial import unittest
from twisted.internet import reactor

import msgpack

class ClockTestCase(unittest.TestCase):
def test_reactor_has_monitonic_clock(self):
self.assertLess(reactor.seconds(), 1000000000)

def test_msgpack(self):
a = ({(1, '2') : (b'spam', 'eggs')},)
b = msgpack.unpackb(msgpack.packb(a, use_bin_type=True), raw=False, strict_map_key=False, use_list=False)
self.assertEqual(a, b)

0 comments on commit cd9153c

Please sign in to comment.