From c45e778dc7293cfd218e73f4e61abe7e0a48b6be Mon Sep 17 00:00:00 2001 From: Arnaud Taffanel Date: Tue, 21 Mar 2017 12:26:39 +0100 Subject: [PATCH] #269: Fix toolboxes crash on close --- src/cfclient/ui/toolboxes/ConsoleToolbox.py | 8 ++++-- src/cfclient/ui/toolboxes/CrtpSharkToolbox.py | 25 +++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/cfclient/ui/toolboxes/ConsoleToolbox.py b/src/cfclient/ui/toolboxes/ConsoleToolbox.py index b5adb72a..7dae68fa 100644 --- a/src/cfclient/ui/toolboxes/ConsoleToolbox.py +++ b/src/cfclient/ui/toolboxes/ConsoleToolbox.py @@ -55,11 +55,15 @@ def __init__(self, helper, *args): def getName(self): return 'Console' + def _console_updated(self, data): + self.update.emit(data) + def enable(self): - self.helper.cf.console.receivedChar.add_callback(self.update.emit) + self.helper.cf.console.receivedChar.add_callback(self._console_updated) def disable(self): - self.helper.cf.console.receivedChar.remove_callback(self.update.emit) + self.helper.cf.console.receivedChar.remove_callback( + self._console_updated) def preferedDockArea(self): return Qt.BottomDockWidgetArea diff --git a/src/cfclient/ui/toolboxes/CrtpSharkToolbox.py b/src/cfclient/ui/toolboxes/CrtpSharkToolbox.py index 3d0a4750..f70ae253 100644 --- a/src/cfclient/ui/toolboxes/CrtpSharkToolbox.py +++ b/src/cfclient/ui/toolboxes/CrtpSharkToolbox.py @@ -29,6 +29,7 @@ """ import os from time import time +from binascii import hexlify from PyQt5 import QtWidgets from PyQt5 import uic @@ -71,17 +72,21 @@ def __init__(self, helper, *args): self._data = [] def _packet(self, dir, pk): - if self.masterCheck.isChecked(): + if self.masterCheck.isChecked() and \ + not (pk.port == 15 and pk.channel == 3): line = QtWidgets.QTreeWidgetItem() ms_diff = int(round(time() * 1000)) - self._ms_offset line.setData(0, Qt.DisplayRole, "%d" % ms_diff) line.setData(1, Qt.DisplayRole, "%s" % dir) line.setData(2, Qt.DisplayRole, "%d/%d" % (pk.port, pk.channel)) - line.setData(3, Qt.DisplayRole, pk.data.decode("UTF-8")) + + line.setData(3, Qt.DisplayRole, hexlify(pk.data).decode('utf8')) + print(pk.data) + print(hexlify(pk.data)) s = "%d, %s, %d/%d, %s" % (ms_diff, dir, pk.port, pk.channel, - pk.data.decode("UTF-8")) + hexlify(pk.data).decode('utf8')) self._data.append(s) self.logTree.addTopLevelItem(line) @@ -98,17 +103,23 @@ def getName(self): def getTabName(self): return 'Crtp sniffer' + def _incoming_packet(self, pk): + self._incoming_packet_signal.emit(pk) + + def _outgoing_packet(self, pk): + self._outgoing_packet_signal.emit(pk) + def enable(self): self.helper.cf.packet_received.add_callback( - self._incoming_packet_signal.emit) + self._incoming_packet) self.helper.cf.packet_sent.add_callback( - self._outgoing_packet_signal.emit) + self._outgoing_packet) def disable(self): self.helper.cf.packet_received.remove_callback( - self._incoming_packet_signal.emit) + self._incoming_packet) self.helper.cf.packet_sent.remove_callback( - self._outgoing_packet_signal.emit) + self._outgoing_packet) def preferedDockArea(self): return Qt.RightDockWidgetArea