How to use the urh.constants function in urh

To help you get started, we’ve selected a few urh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jopohl / urh / tests / test_auto_assignments.py View on Github external
for i, message in enumerate(self.protocol.messages):
            if i in alice_indices:
                message.participant = alice
            else:
                message.participant = bob

        self.assertEqual(self.protocol.num_messages, 42)
        self.assertEqual(self.protocol.plain_hex_str[0][16:18], "2d")

        self.decodings = []
        self.decodings.append(Encoding(['Non Return To Zero (NRZ)']))
        self.decodings.append(Encoding(['Non Return To Zero Inverted (NRZ-I)', 'Invert']))
        self.decodings.append(Encoding(['Manchester I', 'Edge Trigger']))
        self.decodings.append(Encoding(['Manchester II', 'Edge Trigger', 'Invert']))
        self.decodings.append(Encoding(['Differential Manchester', 'Edge Trigger', 'Differential Encoding', ]))
        self.decodings.append(Encoding(['DeWhitening Special', constants.DECODING_DATAWHITENING, '0x9a7d9a7d;0x21;0']))
        self.decodings.append(Encoding(['DeWhitening', constants.DECODING_DATAWHITENING, '0x67686768;0x21;0']))
github jopohl / urh / tests / test_util.py View on Github external
def test_set_icon_theme(self):
        constants.SETTINGS.setValue("icon_theme_index", 0)
        util.set_icon_theme()

        self.assertEqual(QIcon.themeName(), "oxy")

        constants.SETTINGS.setValue("icon_theme_index", 1)
        util.set_icon_theme()

        if sys.platform == "linux":
            self.assertNotEqual(QIcon.themeName(), "oxy")
        else:
            self.assertEqual(QIcon.themeName(), "oxy")
github jopohl / urh / tests / test_encoding.py View on Github external
def test_external(self):
        encoder = get_path_for_data_file("encode.py")
        decoder = get_path_for_data_file("decode.py")
        e = Encoding(["test external", constants.DECODING_EXTERNAL, decoder + ";" + encoder])

        data = array.array("B", [1, 0, 1, 0, 0, 1, 1])
        encoded = e.encode(data)
        self.assertEqual(encoded, array.array("B", [1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]))

        decoded = e.decode(encoded)
        self.assertEqual(decoded, data)
github jopohl / urh / src / urh / signalprocessing / Encoding.py View on Github external
elif self.code_edge == self.chain[i]:
                chainstr.append(constants.DECODING_EDGE)
            elif self.code_substitution == self.chain[i]:
                chainstr.append(constants.DECODING_SUBSTITUTION)
                i += 1
                chainstr.append(self.get_subst_string(self.chain[i]))
            elif self.code_externalprogram == self.chain[i]:
                chainstr.append(constants.DECODING_EXTERNAL)
                i += 1
                chainstr.append(self.chain[i])
            elif self.code_cut == self.chain[i]:
                chainstr.append(constants.DECODING_CUT)
                i += 1
                chainstr.append(self.chain[i])
            elif self.code_morse == self.chain[i]:
                chainstr.append(constants.DECODING_MORSE)
                i += 1
                chainstr.append(self.chain[i])
            i += 1

        return chainstr
github jopohl / urh / src / urh / ui / views / ParticipantTableView.py View on Github external
def refresh_participant_table(self):
        n = len(self.model().participants)
        items = [str(i) for i in range(n)]
        if len(items) >= 2:
            items[0] += " (low)"
            items[-1] += " (high)"

        for row in range(n):
            self.closePersistentEditor(self.model().index(row, 3))

        self.setItemDelegateForColumn(2, ComboBoxDelegate([""] * len(constants.PARTICIPANT_COLORS),
                                                          colors=constants.PARTICIPANT_COLORS,
                                                          parent=self))
        self.setItemDelegateForColumn(3, ComboBoxDelegate(items, parent=self))

        for row in range(n):
            self.openPersistentEditor(self.model().index(row, 2))
            self.openPersistentEditor(self.model().index(row, 3))
github jopohl / urh / src / urh / signalprocessing / Encoding.py View on Github external
i += 1
                chainstr.append(self.chain[i])
            elif self.code_data_whitening == self.chain[i]:
                chainstr.append(constants.DECODING_DATAWHITENING)
                i += 1
                chainstr.append(self.chain[i])
            elif self.code_carrier == self.chain[i]:
                chainstr.append(constants.DECODING_CARRIER)
                i += 1
                chainstr.append(self.chain[i])
            elif self.code_lsb_first == self.chain[i]:
                chainstr.append(constants.DECODING_BITORDER)
            elif self.code_edge == self.chain[i]:
                chainstr.append(constants.DECODING_EDGE)
            elif self.code_substitution == self.chain[i]:
                chainstr.append(constants.DECODING_SUBSTITUTION)
                i += 1
                chainstr.append(self.get_subst_string(self.chain[i]))
            elif self.code_externalprogram == self.chain[i]:
                chainstr.append(constants.DECODING_EXTERNAL)
                i += 1
                chainstr.append(self.chain[i])
            elif self.code_cut == self.chain[i]:
                chainstr.append(constants.DECODING_CUT)
                i += 1
                chainstr.append(self.chain[i])
            elif self.code_morse == self.chain[i]:
                chainstr.append(constants.DECODING_MORSE)
                i += 1
                chainstr.append(self.chain[i])
            i += 1
github jopohl / urh / src / urh / signalprocessing / Encoding.py View on Github external
def get_chain(self):
        chainstr = [self.name]

        i = 1
        while i < len(self.chain):
            if self.code_invert == self.chain[i]:
                chainstr.append(constants.DECODING_INVERT)
            elif self.code_enocean == self.chain[i]:
                chainstr.append(constants.DECODING_ENOCEAN)
            elif self.code_differential == self.chain[i]:
                chainstr.append(constants.DECODING_DIFFERENTIAL)
            elif self.code_redundancy == self.chain[i]:
                chainstr.append(constants.DECODING_REDUNDANCY)
                i += 1
                chainstr.append(self.chain[i])
            elif self.code_data_whitening == self.chain[i]:
                chainstr.append(constants.DECODING_DATAWHITENING)
                i += 1
                chainstr.append(self.chain[i])
            elif self.code_carrier == self.chain[i]:
                chainstr.append(constants.DECODING_CARRIER)
                i += 1
                chainstr.append(self.chain[i])
            elif self.code_lsb_first == self.chain[i]:
                chainstr.append(constants.DECODING_BITORDER)
            elif self.code_edge == self.chain[i]:
                chainstr.append(constants.DECODING_EDGE)
github jopohl / urh / src / urh / ui / painting / ZoomableScene.py View on Github external
y = self.sceneRect().y()
        h = self.sceneRect().height()
        w = self.sceneRect().width()

        num_areas = len(centers) + 1
        if num_areas != len(self.separation_areas):
            for area in self.separation_areas:
                self.removeItem(area)
            self.separation_areas.clear()

            for i in range(num_areas):
                area = QGraphicsRectItem(0, 0, 0, 0)
                if i % 2 == 0:
                    area.setBrush(constants.ZEROS_AREA_COLOR)
                else:
                    area.setBrush(constants.ONES_AREA_COLOR)
                area.setOpacity(constants.SEPARATION_OPACITY)
                area.setPen(QPen(constants.TRANSPARENT_COLOR, 0))
                self.addItem(area)
                self.separation_areas.append(area)

        start = y + h

        for i, area in enumerate(self.separation_areas):
            area.show()
            try:
                self.separation_areas[i].setRect(x, start, w, -(start - centers[i]))
                start -= (start - centers[i])
            except IndexError:
                self.separation_areas[i].setRect(x, start, w, -(start - y))

        if self.noise_area is not None:
github jopohl / urh / src / urh / controller / widgets / ModulationSettingsWidget.py View on Github external
def __init__(self, modulators, selected_index=0, signal_tree_model=None, parent=None):
        """

        :type modulators: list of Modulator
        :param parent:
        """
        super().__init__(parent)
        self.ui = Ui_ModulationSettings()
        self.ui.setupUi(self)

        self.ui.labelModulationProfile.setVisible(constants.SETTINGS.value("multiple_modulations", False, bool))
        self.ui.comboBoxModulationProfiles.setVisible(constants.SETTINGS.value("multiple_modulations", False, bool))

        self.signal_tree_model = signal_tree_model
        self.modulators = modulators  # type: list[Modulator]
        for modulator in self.modulators:
            self.ui.comboBoxModulationProfiles.addItem(modulator.name)

        self.ui.comboBoxModulationProfiles.setCurrentIndex(selected_index)

        self.show_selected_modulation_infos()
        self.create_connects()
github jopohl / urh / src / urh / ui / painting / ZoomableScene.py View on Github external
super().__init__(parent)
        self.noise_area = None

        self.separation_areas = []  # type: list[QGraphicsRectItem]
        self.captions = []  # type: list[QGraphicsSimpleTextItem]

        self.centers = [0]

        self.always_show_symbols_legend = False

        self.ones_caption = None
        self.zeros_caption = None

        self.ones_arrow = None
        self.zeros_arrow = None
        self.selection_area = HorizontalSelection(0, 0, 0, 0, fillcolor=constants.SELECTION_COLOR,
                                                  opacity=constants.SELECTION_OPACITY)
        self.addItem(self.selection_area)