diff --git a/data/ui/send_recv.ui b/data/ui/send_recv.ui index 8eef3bd1dd..43a574d721 100644 --- a/data/ui/send_recv.ui +++ b/data/ui/send_recv.ui @@ -47,8 +47,8 @@ image: url(:/icons/icons/splitter_handle_vertical.svg); 0 0 - 664 - 1343 + 624 + 1550 @@ -84,7 +84,7 @@ QGroupBox::indicator:checked { } - Sniff settings + Sniff settin&gs true @@ -107,38 +107,31 @@ QGroupBox::indicator:checked { 0 - - - - - Error Tolerance: + + + + + 1 - - - - - - Center: + + 999999999 - - - - - 0 - 0 - - + + 4 + + -3.140000000000000 + - 1.000000000000000 + 3.140000000000000 - + View: @@ -164,36 +157,19 @@ QGroupBox::indicator:checked { - - + + + + + 0 + 0 + + 4 - - -3.140000000000000 - - 3.140000000000000 - - - - - - - 1 - - - 999999999 - - - - - - - - - - Write bitstream to file: + 1.000000000000000 @@ -204,32 +180,6 @@ QGroupBox::indicator:checked { - - - - Encoding: - - - - - - - - Bit - - - - - Hex - - - - - ASCII - - - - @@ -240,6 +190,20 @@ QGroupBox::indicator:checked { + + + + Write bitstream to file: + + + + + + + Center: + + + @@ -247,7 +211,7 @@ QGroupBox::indicator:checked { - + @@ -273,6 +237,53 @@ QGroupBox::indicator:checked { + + + + Error Tolerance: + + + + + + + + + + Bit + + + + + Hex + + + + + ASCII + + + + + + + + Show timestamp + + + + + + + + + Encoding: + + + + + + @@ -660,7 +671,7 @@ QGroupBox::indicator:checked { } - Device settings + De&vice settings true @@ -1272,8 +1283,8 @@ QGroupBox::indicator:checked { - scrollArea groupBoxDeviceSettings + scrollArea cbDevice lineEditDeviceArgs comboBoxChannel @@ -1299,23 +1310,24 @@ QGroupBox::indicator:checked { spinbox_sniff_BitLen spinbox_sniff_ErrorTolerance combox_sniff_Modulation - comboBox_sniff_viewtype comboBox_sniff_encoding + comboBox_sniff_viewtype + checkBox_sniff_Timestamp lineEdit_sniff_OutputFile btnStart btnStop btnSave btnClear - btnAccept - graphicsViewReceive - txtEditErrors + graphicsView_sniff_Preview txtEd_sniff_Preview - graphicsViewSend - sliderYscale + btnAccept graphicsViewContinuousSend graphicsViewFFT graphicsViewSpectrogram - graphicsView_sniff_Preview + graphicsViewSend + txtEditErrors + sliderYscale + graphicsViewReceive diff --git a/src/urh/controller/ProtocolSniffDialogController.py b/src/urh/controller/ProtocolSniffDialogController.py index 56829bd221..c118c40bcf 100644 --- a/src/urh/controller/ProtocolSniffDialogController.py +++ b/src/urh/controller/ProtocolSniffDialogController.py @@ -1,7 +1,7 @@ import numpy as np from PyQt5.QtCore import pyqtSlot, pyqtSignal -from PyQt5.QtGui import QIcon -from PyQt5.QtWidgets import QCompleter, QDirModel +from PyQt5.QtGui import QIcon, QFontDatabase +from PyQt5.QtWidgets import QCompleter, QDirModel, QApplication from urh.ui.painting.SniffSceneManager import SniffSceneManager from urh import constants @@ -9,6 +9,7 @@ from urh.plugins.NetworkSDRInterface.NetworkSDRInterfacePlugin import NetworkSDRInterfacePlugin from urh.signalprocessing.ProtocolSniffer import ProtocolSniffer from urh.ui.painting.LiveSceneManager import LiveSceneManager +from urh.util import util class ProtocolSniffDialogController(SendRecvDialogController): @@ -63,6 +64,7 @@ def __init__(self, project_manager, noise, self.ui.comboBox_sniff_encoding.setCurrentIndex(encoding_index) self.ui.comboBox_sniff_viewtype.setCurrentIndex(constants.SETTINGS.value('default_view', 0, int)) + self.ui.txtEd_sniff_Preview.setFont(util.get_monospace_font()) @property def device(self): @@ -82,6 +84,10 @@ def device(self, value): def view_type(self): return self.ui.comboBox_sniff_viewtype.currentIndex() + @property + def include_timestamps(self): + return self.ui.checkBox_sniff_Timestamp.isChecked() + def create_connects(self): super().create_connects() self.ui.btnAccept.clicked.connect(self.on_btn_accept_clicked) @@ -97,6 +103,7 @@ def create_connects(self): self.ui.comboBox_sniff_viewtype.currentIndexChanged.connect(self.on_view_type_changed) self.ui.lineEdit_sniff_OutputFile.editingFinished.connect(self.on_line_edit_output_file_editing_finished) self.ui.comboBox_sniff_encoding.currentIndexChanged.connect(self.on_combobox_sniff_encoding_index_changed) + self.ui.checkBox_sniff_Timestamp.clicked.connect(self.on_checkbox_sniff_timestamp_clicked) def set_device_ui_items_visibility(self, device_name: str, adjust_gains=True): super().set_device_ui_items_visibility(device_name, adjust_gains) @@ -139,27 +146,32 @@ def on_device_started(self): @pyqtSlot() def on_noise_edited(self): self.sniffer.signal._noise_threshold = self.ui.spinbox_sniff_Noise.value() - self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(self.view_type)) + self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(self.view_type, + include_timestamps=self.include_timestamps)) @pyqtSlot() def on_center_edited(self): self.sniffer.signal.qad_center = self.ui.spinbox_sniff_Center.value() - self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(self.view_type)) + self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(self.view_type, + include_timestamps=self.include_timestamps)) @pyqtSlot() def on_bit_len_edited(self): self.sniffer.signal.bit_len = self.ui.spinbox_sniff_BitLen.value() - self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(self.view_type)) + self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(self.view_type, + include_timestamps=self.include_timestamps)) @pyqtSlot() def on_tolerance_edited(self): self.sniffer.signal.tolerance = self.ui.spinbox_sniff_ErrorTolerance.value() - self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(self.view_type)) + self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(self.view_type, + include_timestamps=self.include_timestamps)) @pyqtSlot(int) def on_modulation_changed(self, new_index: int): self.sniffer.signal.silent_set_modulation_type(new_index) - self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(self.view_type)) + self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(self.view_type, + include_timestamps=self.include_timestamps)) @pyqtSlot() def on_start_clicked(self): @@ -180,14 +192,14 @@ def on_clear_clicked(self): @pyqtSlot(int) def on_data_sniffed(self, from_index: int): - new_data = self.sniffer.decoded_to_string(self.view_type, start=from_index) + new_data = self.sniffer.decoded_to_string(self.view_type, start=from_index, include_timestamps=self.include_timestamps) if new_data.strip(): self.ui.txtEd_sniff_Preview.appendPlainText(new_data) self.ui.txtEd_sniff_Preview.verticalScrollBar().setValue(self.ui.txtEd_sniff_Preview.verticalScrollBar().maximum()) @pyqtSlot(int) def on_view_type_changed(self, new_index: int): - self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(new_index)) + self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(new_index, include_timestamps=self.include_timestamps)) @pyqtSlot() def on_btn_accept_clicked(self): @@ -213,4 +225,8 @@ def on_combobox_sniff_encoding_index_changed(self, index: int): if self.sniffer.decoder != self.encodings[index]: self.sniffer.set_decoder_for_messages(self.encodings[index]) self.sniffer.decoder = self.encodings[index] - self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(self.view_type)) + self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(self.view_type, include_timestamps=self.include_timestamps)) + + @pyqtSlot(bool) + def on_checkbox_sniff_timestamp_clicked(self, checked: bool): + self.ui.txtEd_sniff_Preview.setPlainText(self.sniffer.decoded_to_string(self.view_type, include_timestamps=checked)) \ No newline at end of file diff --git a/src/urh/controller/SignalFrameController.py b/src/urh/controller/SignalFrameController.py index a0b9db4350..27cd3eb744 100644 --- a/src/urh/controller/SignalFrameController.py +++ b/src/urh/controller/SignalFrameController.py @@ -22,7 +22,7 @@ from urh.ui.painting.LegendScene import LegendScene from urh.ui.painting.SignalSceneManager import SignalSceneManager from urh.ui.ui_signal_frame import Ui_SignalFrame -from urh.util import FileOperator +from urh.util import FileOperator, util from urh.util.Errors import Errors from urh.util.Formatter import Formatter from urh.util.Logger import logger @@ -60,9 +60,7 @@ def __init__(self, proto_analyzer: ProtocolAnalyzer, undo_stack: QUndoStack, self.__set_spectrogram_adjust_widgets_visibility() self.ui.gvSignal.init_undo_stack(self.undo_stack) - fixed_font = QFontDatabase.systemFont(QFontDatabase.FixedFont) - fixed_font.setPointSize(QApplication.instance().font().pointSize()) - self.ui.txtEdProto.setFont(fixed_font) + self.ui.txtEdProto.setFont(util.get_monospace_font()) self.ui.txtEdProto.participants = project_manager.participants self.ui.txtEdProto.messages = proto_analyzer.messages diff --git a/src/urh/signalprocessing/Message.py b/src/urh/signalprocessing/Message.py index a03a9aa3cc..f827571056 100644 --- a/src/urh/signalprocessing/Message.py +++ b/src/urh/signalprocessing/Message.py @@ -3,6 +3,8 @@ import math import xml.etree.ElementTree as ET +import time + from urh.signalprocessing.Encoding import Encoding from urh.signalprocessing.MessageType import MessageType from urh.signalprocessing.ProtocoLabel import ProtocolLabel @@ -16,7 +18,7 @@ class Message(object): """ __slots__ = ["__plain_bits", "__bit_alignments", "pause", "modulator_index", "rssi", "participant", "message_type", - "absolute_time", "relative_time", "__decoder", "align_labels", "decoding_state", + "absolute_time", "relative_time", "__decoder", "align_labels", "decoding_state", "timestamp", "fuzz_created", "__decoded_bits", "__encoded_bits", "decoding_errors", "bit_len", "bit_sample_pos"] def __init__(self, plain_bits, pause: int, message_type: MessageType, rssi=0, modulator_index=0, decoder=None, @@ -39,6 +41,7 @@ def __init__(self, plain_bits, pause: int, message_type: MessageType, rssi=0, mo self.participant = participant # type: Participant self.message_type = message_type # type: MessageType + self.timestamp = time.time() self.absolute_time = 0 # set in Compare Frame self.relative_time = 0 # set in Compare Frame diff --git a/src/urh/signalprocessing/ProtocolSniffer.py b/src/urh/signalprocessing/ProtocolSniffer.py index 6775cd5b91..53603480c2 100644 --- a/src/urh/signalprocessing/ProtocolSniffer.py +++ b/src/urh/signalprocessing/ProtocolSniffer.py @@ -1,4 +1,5 @@ import os +from datetime import datetime import numpy as np from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject @@ -47,8 +48,16 @@ def __init__(self, bit_len: int, center: float, noise: float, tolerance: int, self.__sniff_file = "" self.__store_data = True - def decoded_to_string(self, view: int, start=0): - return '\n'.join(msg.view_to_string(view, decoded=True, show_pauses=False) for msg in self.messages[start:]) + def decoded_to_string(self, view: int, start=0, include_timestamps=True): + result = [] + for msg in self.messages[start:]: + msg_str_data = [] + if include_timestamps: + msg_date = datetime.fromtimestamp(msg.timestamp) + msg_str_data.append(msg_date.strftime("[%Y-%m-%d %H:%M:%S.%f]")) + msg_str_data.append(msg.view_to_string(view, decoded=True, show_pauses=False)) + result.append(" ".join(msg_str_data)) + return "\n".join(result) @property def sniff_file(self): diff --git a/src/urh/ui/ui_send_recv.py b/src/urh/ui/ui_send_recv.py index 9a70fcb11d..ee549aa683 100644 --- a/src/urh/ui/ui_send_recv.py +++ b/src/urh/ui/ui_send_recv.py @@ -30,7 +30,7 @@ def setupUi(self, SendRecvDialog): self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents_2 = QtWidgets.QWidget() - self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 664, 1343)) + self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 624, 1550)) self.scrollAreaWidgetContents_2.setObjectName("scrollAreaWidgetContents_2") self.gridLayout = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_2) self.gridLayout.setObjectName("gridLayout") @@ -70,12 +70,26 @@ def setupUi(self, SendRecvDialog): self.frame.setObjectName("frame") self.gridLayout_4 = QtWidgets.QGridLayout(self.frame) self.gridLayout_4.setObjectName("gridLayout_4") - self.label_sniff_Tolerance = QtWidgets.QLabel(self.frame) - self.label_sniff_Tolerance.setObjectName("label_sniff_Tolerance") - self.gridLayout_4.addWidget(self.label_sniff_Tolerance, 3, 0, 1, 1) - self.label_sniff_Center = QtWidgets.QLabel(self.frame) - self.label_sniff_Center.setObjectName("label_sniff_Center") - self.gridLayout_4.addWidget(self.label_sniff_Center, 1, 0, 1, 1) + self.spinbox_sniff_BitLen = QtWidgets.QSpinBox(self.frame) + self.spinbox_sniff_BitLen.setMinimum(1) + self.spinbox_sniff_BitLen.setMaximum(999999999) + self.spinbox_sniff_BitLen.setObjectName("spinbox_sniff_BitLen") + self.gridLayout_4.addWidget(self.spinbox_sniff_BitLen, 2, 1, 1, 1) + self.spinbox_sniff_Center = QtWidgets.QDoubleSpinBox(self.frame) + self.spinbox_sniff_Center.setDecimals(4) + self.spinbox_sniff_Center.setMinimum(-3.14) + self.spinbox_sniff_Center.setMaximum(3.14) + self.spinbox_sniff_Center.setObjectName("spinbox_sniff_Center") + self.gridLayout_4.addWidget(self.spinbox_sniff_Center, 1, 1, 1, 1) + self.label_sniff_viewtype = QtWidgets.QLabel(self.frame) + self.label_sniff_viewtype.setObjectName("label_sniff_viewtype") + self.gridLayout_4.addWidget(self.label_sniff_viewtype, 6, 0, 1, 1) + self.combox_sniff_Modulation = QtWidgets.QComboBox(self.frame) + self.combox_sniff_Modulation.setObjectName("combox_sniff_Modulation") + self.combox_sniff_Modulation.addItem("") + self.combox_sniff_Modulation.addItem("") + self.combox_sniff_Modulation.addItem("") + self.gridLayout_4.addWidget(self.combox_sniff_Modulation, 4, 1, 1, 1) self.spinbox_sniff_Noise = QtWidgets.QDoubleSpinBox(self.frame) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) @@ -86,49 +100,20 @@ def setupUi(self, SendRecvDialog): self.spinbox_sniff_Noise.setMaximum(1.0) self.spinbox_sniff_Noise.setObjectName("spinbox_sniff_Noise") self.gridLayout_4.addWidget(self.spinbox_sniff_Noise, 0, 1, 1, 1) - self.label_sniff_viewtype = QtWidgets.QLabel(self.frame) - self.label_sniff_viewtype.setObjectName("label_sniff_viewtype") - self.gridLayout_4.addWidget(self.label_sniff_viewtype, 5, 0, 1, 1) - self.combox_sniff_Modulation = QtWidgets.QComboBox(self.frame) - self.combox_sniff_Modulation.setObjectName("combox_sniff_Modulation") - self.combox_sniff_Modulation.addItem("") - self.combox_sniff_Modulation.addItem("") - self.combox_sniff_Modulation.addItem("") - self.gridLayout_4.addWidget(self.combox_sniff_Modulation, 4, 1, 1, 1) - self.spinbox_sniff_Center = QtWidgets.QDoubleSpinBox(self.frame) - self.spinbox_sniff_Center.setDecimals(4) - self.spinbox_sniff_Center.setMinimum(-3.14) - self.spinbox_sniff_Center.setMaximum(3.14) - self.spinbox_sniff_Center.setObjectName("spinbox_sniff_Center") - self.gridLayout_4.addWidget(self.spinbox_sniff_Center, 1, 1, 1, 1) - self.spinbox_sniff_BitLen = QtWidgets.QSpinBox(self.frame) - self.spinbox_sniff_BitLen.setMinimum(1) - self.spinbox_sniff_BitLen.setMaximum(999999999) - self.spinbox_sniff_BitLen.setObjectName("spinbox_sniff_BitLen") - self.gridLayout_4.addWidget(self.spinbox_sniff_BitLen, 2, 1, 1, 1) - self.comboBox_sniff_encoding = QtWidgets.QComboBox(self.frame) - self.comboBox_sniff_encoding.setObjectName("comboBox_sniff_encoding") - self.gridLayout_4.addWidget(self.comboBox_sniff_encoding, 6, 1, 1, 1) - self.label_sniff_OutputFile = QtWidgets.QLabel(self.frame) - self.label_sniff_OutputFile.setObjectName("label_sniff_OutputFile") - self.gridLayout_4.addWidget(self.label_sniff_OutputFile, 7, 0, 1, 1) self.label_sniff_Modulation = QtWidgets.QLabel(self.frame) self.label_sniff_Modulation.setObjectName("label_sniff_Modulation") self.gridLayout_4.addWidget(self.label_sniff_Modulation, 4, 0, 1, 1) - self.label_sniff_encoding = QtWidgets.QLabel(self.frame) - self.label_sniff_encoding.setObjectName("label_sniff_encoding") - self.gridLayout_4.addWidget(self.label_sniff_encoding, 6, 0, 1, 1) - self.comboBox_sniff_viewtype = QtWidgets.QComboBox(self.frame) - self.comboBox_sniff_viewtype.setObjectName("comboBox_sniff_viewtype") - self.comboBox_sniff_viewtype.addItem("") - self.comboBox_sniff_viewtype.addItem("") - self.comboBox_sniff_viewtype.addItem("") - self.gridLayout_4.addWidget(self.comboBox_sniff_viewtype, 5, 1, 1, 1) self.spinbox_sniff_ErrorTolerance = QtWidgets.QSpinBox(self.frame) self.spinbox_sniff_ErrorTolerance.setMaximum(999999) self.spinbox_sniff_ErrorTolerance.setProperty("value", 5) self.spinbox_sniff_ErrorTolerance.setObjectName("spinbox_sniff_ErrorTolerance") self.gridLayout_4.addWidget(self.spinbox_sniff_ErrorTolerance, 3, 1, 1, 1) + self.label_sniff_OutputFile = QtWidgets.QLabel(self.frame) + self.label_sniff_OutputFile.setObjectName("label_sniff_OutputFile") + self.gridLayout_4.addWidget(self.label_sniff_OutputFile, 8, 0, 1, 1) + self.label_sniff_Center = QtWidgets.QLabel(self.frame) + self.label_sniff_Center.setObjectName("label_sniff_Center") + self.gridLayout_4.addWidget(self.label_sniff_Center, 1, 0, 1, 1) self.label_sniff_BitLength = QtWidgets.QLabel(self.frame) self.label_sniff_BitLength.setObjectName("label_sniff_BitLength") self.gridLayout_4.addWidget(self.label_sniff_BitLength, 2, 0, 1, 1) @@ -141,11 +126,31 @@ def setupUi(self, SendRecvDialog): self.lineEdit_sniff_OutputFile.setReadOnly(False) self.lineEdit_sniff_OutputFile.setClearButtonEnabled(True) self.lineEdit_sniff_OutputFile.setObjectName("lineEdit_sniff_OutputFile") - self.gridLayout_4.addWidget(self.lineEdit_sniff_OutputFile, 7, 1, 1, 1) + self.gridLayout_4.addWidget(self.lineEdit_sniff_OutputFile, 8, 1, 1, 1) self.label_sniff_Noise = QtWidgets.QLabel(self.frame) self.label_sniff_Noise.setObjectName("label_sniff_Noise") self.gridLayout_4.addWidget(self.label_sniff_Noise, 0, 0, 1, 1) - self.gridLayout_4.setColumnMinimumWidth(0, 150) + self.label_sniff_Tolerance = QtWidgets.QLabel(self.frame) + self.label_sniff_Tolerance.setObjectName("label_sniff_Tolerance") + self.gridLayout_4.addWidget(self.label_sniff_Tolerance, 3, 0, 1, 1) + self.horizontalLayout_3 = QtWidgets.QHBoxLayout() + self.horizontalLayout_3.setObjectName("horizontalLayout_3") + self.comboBox_sniff_viewtype = QtWidgets.QComboBox(self.frame) + self.comboBox_sniff_viewtype.setObjectName("comboBox_sniff_viewtype") + self.comboBox_sniff_viewtype.addItem("") + self.comboBox_sniff_viewtype.addItem("") + self.comboBox_sniff_viewtype.addItem("") + self.horizontalLayout_3.addWidget(self.comboBox_sniff_viewtype) + self.checkBox_sniff_Timestamp = QtWidgets.QCheckBox(self.frame) + self.checkBox_sniff_Timestamp.setObjectName("checkBox_sniff_Timestamp") + self.horizontalLayout_3.addWidget(self.checkBox_sniff_Timestamp) + self.gridLayout_4.addLayout(self.horizontalLayout_3, 6, 1, 1, 1) + self.label_sniff_encoding = QtWidgets.QLabel(self.frame) + self.label_sniff_encoding.setObjectName("label_sniff_encoding") + self.gridLayout_4.addWidget(self.label_sniff_encoding, 5, 0, 1, 1) + self.comboBox_sniff_encoding = QtWidgets.QComboBox(self.frame) + self.comboBox_sniff_encoding.setObjectName("comboBox_sniff_encoding") + self.gridLayout_4.addWidget(self.comboBox_sniff_encoding, 5, 1, 1, 1) self.gridLayout_3.addWidget(self.frame, 0, 0, 1, 1) self.gridLayout.addWidget(self.groupBoxSniffSettings, 1, 0, 1, 3) self.groupBox = QtWidgets.QGroupBox(self.scrollAreaWidgetContents_2) @@ -614,8 +619,8 @@ def setupUi(self, SendRecvDialog): self.groupBoxSniffSettings.toggled['bool'].connect(self.frame.setVisible) self.groupBoxDeviceSettings.toggled['bool'].connect(self.frame_2.setVisible) QtCore.QMetaObject.connectSlotsByName(SendRecvDialog) - SendRecvDialog.setTabOrder(self.scrollArea, self.groupBoxDeviceSettings) - SendRecvDialog.setTabOrder(self.groupBoxDeviceSettings, self.cbDevice) + SendRecvDialog.setTabOrder(self.groupBoxDeviceSettings, self.scrollArea) + SendRecvDialog.setTabOrder(self.scrollArea, self.cbDevice) SendRecvDialog.setTabOrder(self.cbDevice, self.lineEditDeviceArgs) SendRecvDialog.setTabOrder(self.lineEditDeviceArgs, self.comboBoxChannel) SendRecvDialog.setTabOrder(self.comboBoxChannel, self.comboBoxAntenna) @@ -640,43 +645,45 @@ def setupUi(self, SendRecvDialog): SendRecvDialog.setTabOrder(self.spinbox_sniff_Center, self.spinbox_sniff_BitLen) SendRecvDialog.setTabOrder(self.spinbox_sniff_BitLen, self.spinbox_sniff_ErrorTolerance) SendRecvDialog.setTabOrder(self.spinbox_sniff_ErrorTolerance, self.combox_sniff_Modulation) - SendRecvDialog.setTabOrder(self.combox_sniff_Modulation, self.comboBox_sniff_viewtype) - SendRecvDialog.setTabOrder(self.comboBox_sniff_viewtype, self.comboBox_sniff_encoding) - SendRecvDialog.setTabOrder(self.comboBox_sniff_encoding, self.lineEdit_sniff_OutputFile) + SendRecvDialog.setTabOrder(self.combox_sniff_Modulation, self.comboBox_sniff_encoding) + SendRecvDialog.setTabOrder(self.comboBox_sniff_encoding, self.comboBox_sniff_viewtype) + SendRecvDialog.setTabOrder(self.comboBox_sniff_viewtype, self.checkBox_sniff_Timestamp) + SendRecvDialog.setTabOrder(self.checkBox_sniff_Timestamp, self.lineEdit_sniff_OutputFile) SendRecvDialog.setTabOrder(self.lineEdit_sniff_OutputFile, self.btnStart) SendRecvDialog.setTabOrder(self.btnStart, self.btnStop) SendRecvDialog.setTabOrder(self.btnStop, self.btnSave) SendRecvDialog.setTabOrder(self.btnSave, self.btnClear) - SendRecvDialog.setTabOrder(self.btnClear, self.btnAccept) - SendRecvDialog.setTabOrder(self.btnAccept, self.graphicsViewReceive) - SendRecvDialog.setTabOrder(self.graphicsViewReceive, self.txtEditErrors) - SendRecvDialog.setTabOrder(self.txtEditErrors, self.txtEd_sniff_Preview) - SendRecvDialog.setTabOrder(self.txtEd_sniff_Preview, self.graphicsViewSend) - SendRecvDialog.setTabOrder(self.graphicsViewSend, self.sliderYscale) - SendRecvDialog.setTabOrder(self.sliderYscale, self.graphicsViewContinuousSend) + SendRecvDialog.setTabOrder(self.btnClear, self.graphicsView_sniff_Preview) + SendRecvDialog.setTabOrder(self.graphicsView_sniff_Preview, self.txtEd_sniff_Preview) + SendRecvDialog.setTabOrder(self.txtEd_sniff_Preview, self.btnAccept) + SendRecvDialog.setTabOrder(self.btnAccept, self.graphicsViewContinuousSend) SendRecvDialog.setTabOrder(self.graphicsViewContinuousSend, self.graphicsViewFFT) SendRecvDialog.setTabOrder(self.graphicsViewFFT, self.graphicsViewSpectrogram) - SendRecvDialog.setTabOrder(self.graphicsViewSpectrogram, self.graphicsView_sniff_Preview) + SendRecvDialog.setTabOrder(self.graphicsViewSpectrogram, self.graphicsViewSend) + SendRecvDialog.setTabOrder(self.graphicsViewSend, self.txtEditErrors) + SendRecvDialog.setTabOrder(self.txtEditErrors, self.sliderYscale) + SendRecvDialog.setTabOrder(self.sliderYscale, self.graphicsViewReceive) def retranslateUi(self, SendRecvDialog): _translate = QtCore.QCoreApplication.translate SendRecvDialog.setWindowTitle(_translate("SendRecvDialog", "Record Signal")) - self.groupBoxSniffSettings.setTitle(_translate("SendRecvDialog", "Sniff settings")) - self.label_sniff_Tolerance.setText(_translate("SendRecvDialog", "Error Tolerance:")) - self.label_sniff_Center.setText(_translate("SendRecvDialog", "Center:")) + self.groupBoxSniffSettings.setTitle(_translate("SendRecvDialog", "Sniff settin&gs")) self.label_sniff_viewtype.setText(_translate("SendRecvDialog", "View:")) self.combox_sniff_Modulation.setItemText(0, _translate("SendRecvDialog", "ASK")) self.combox_sniff_Modulation.setItemText(1, _translate("SendRecvDialog", "FSK")) self.combox_sniff_Modulation.setItemText(2, _translate("SendRecvDialog", "PSK")) - self.label_sniff_OutputFile.setText(_translate("SendRecvDialog", "Write bitstream to file:")) self.label_sniff_Modulation.setText(_translate("SendRecvDialog", "Modulation:")) - self.label_sniff_encoding.setText(_translate("SendRecvDialog", "Encoding:")) - self.comboBox_sniff_viewtype.setItemText(0, _translate("SendRecvDialog", "Bit")) - self.comboBox_sniff_viewtype.setItemText(1, _translate("SendRecvDialog", "Hex")) - self.comboBox_sniff_viewtype.setItemText(2, _translate("SendRecvDialog", "ASCII")) + self.label_sniff_OutputFile.setText(_translate("SendRecvDialog", "Write bitstream to file:")) + self.label_sniff_Center.setText(_translate("SendRecvDialog", "Center:")) self.label_sniff_BitLength.setText(_translate("SendRecvDialog", "Bit Length:")) self.lineEdit_sniff_OutputFile.setPlaceholderText(_translate("SendRecvDialog", "None")) self.label_sniff_Noise.setText(_translate("SendRecvDialog", "Noise:")) + self.label_sniff_Tolerance.setText(_translate("SendRecvDialog", "Error Tolerance:")) + self.comboBox_sniff_viewtype.setItemText(0, _translate("SendRecvDialog", "Bit")) + self.comboBox_sniff_viewtype.setItemText(1, _translate("SendRecvDialog", "Hex")) + self.comboBox_sniff_viewtype.setItemText(2, _translate("SendRecvDialog", "ASCII")) + self.checkBox_sniff_Timestamp.setText(_translate("SendRecvDialog", "Show timestamp")) + self.label_sniff_encoding.setText(_translate("SendRecvDialog", "Encoding:")) self.progressBarMessage.setFormat(_translate("SendRecvDialog", "%v/%m")) self.labelCurrentMessage.setText(_translate("SendRecvDialog", "Current message:")) self.lReceiveBufferFullText.setText(_translate("SendRecvDialog", "Receive buffer full:")) @@ -698,7 +705,7 @@ def retranslateUi(self, SendRecvDialog): self.btnSave.setText(_translate("SendRecvDialog", "Save...")) self.btnClear.setToolTip(_translate("SendRecvDialog", "Clear")) self.btnClear.setText(_translate("SendRecvDialog", "Clear")) - self.groupBoxDeviceSettings.setTitle(_translate("SendRecvDialog", "Device settings")) + self.groupBoxDeviceSettings.setTitle(_translate("SendRecvDialog", "De&vice settings")) self.label_3.setText(_translate("SendRecvDialog", "Device:")) self.cbDevice.setItemText(0, _translate("SendRecvDialog", "USRP")) self.cbDevice.setItemText(1, _translate("SendRecvDialog", "HackRF")) diff --git a/src/urh/util/util.py b/src/urh/util/util.py index 6deba4af36..c2ca95ce52 100644 --- a/src/urh/util/util.py +++ b/src/urh/util/util.py @@ -3,8 +3,8 @@ import sys from PyQt5.QtCore import Qt -from PyQt5.QtGui import QIcon -from PyQt5.QtWidgets import QDialog, QVBoxLayout, QPlainTextEdit, QTableWidgetItem +from PyQt5.QtGui import QIcon, QFontDatabase, QFont +from PyQt5.QtWidgets import QDialog, QVBoxLayout, QPlainTextEdit, QTableWidgetItem, QApplication from urh import constants from urh.util.Logger import logger @@ -167,3 +167,9 @@ def create_table_item(content): item = QTableWidgetItem(str(content)) item.setFlags(item.flags() & ~Qt.ItemIsEditable) return item + + +def get_monospace_font() -> QFont: + fixed_font = QFontDatabase.systemFont(QFontDatabase.FixedFont) + fixed_font.setPointSize(QApplication.instance().font().pointSize()) + return fixed_font diff --git a/tests/test_send_recv_dialog_gui.py b/tests/test_send_recv_dialog_gui.py index b316607d4a..bf0faaafe4 100644 --- a/tests/test_send_recv_dialog_gui.py +++ b/tests/test_send_recv_dialog_gui.py @@ -290,6 +290,7 @@ def test_sniff(self): QApplication.instance().processEvents() sniff_dialog = self.__get_sniff_dialog() + sniff_dialog.ui.checkBox_sniff_Timestamp.setChecked(False) self.assertEqual(sniff_dialog.device.name, NetworkSDRInterfacePlugin.NETWORK_SDR_NAME) sniff_dialog.ui.comboBox_sniff_viewtype.setCurrentIndex(0) @@ -312,6 +313,11 @@ def test_sniff(self): self.assertEqual(received, orig + "0" * pad) sniff_dialog.ui.btnStop.click() + sniff_dialog.ui.checkBox_sniff_Timestamp.click() + self.assertTrue(sniff_dialog.ui.txtEd_sniff_Preview.toPlainText().startswith("[")) + sniff_dialog.ui.checkBox_sniff_Timestamp.click() + self.assertFalse(sniff_dialog.ui.txtEd_sniff_Preview.toPlainText().startswith("[")) + target_file = os.path.join(QDir.tempPath(), "sniff_file.txt") self.assertFalse(os.path.isfile(target_file))