Beispiel #1
0
    def test_if_raw_message_is_decoded(self):
        reader = RFIDReader(0x08ff, 0x0009, 84, 16, should_reset=False)
        raw_data = [0, 0, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

        result = reader.decode_raw_data(raw_data)
        expected = '0027314141\n'
        self.assertEqual(expected, result)
    def test_if_neuftech_raw_message_is_decoded(self):
        reader = RFIDReader(0x16c0, 0x27db, 42, 3, should_reset=False)
        raw_data = [
            1, 0, 39, 1, 0, 0, 1, 0, 39, 1, 0, 0, 1, 0, 39, 1, 0, 31, 1, 0, 30,
            1, 0, 31, 1, 0, 37, 1, 0, 33, 1, 0, 36, 1, 0, 34, 1, 0, 40, 1, 0, 0
        ]

        result = reader.decode_raw_data(raw_data)
        expected = '0002128475\n'
        self.assertEqual(expected, result)
Beispiel #3
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self._set_initial_usb_values()

        self.rfidreader = RFIDReader(0x08ff,
                                     0x0009,
                                     84,
                                     16,
                                     should_reset=False)
        self.rfidreader.initialize()

        self._start_reader_thread()
Beispiel #4
0
class StartQT4(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self._set_initial_usb_values()

        self.rfidreader = RFIDReader(0x08ff,
                                     0x0009,
                                     84,
                                     16,
                                     should_reset=False)
        self.rfidreader.initialize()

        self._start_reader_thread()

    def _set_initial_usb_values(self):
        self.usb_read_value = None
        self.usb_exception = None
        self.usb_exception_counter = 0

    def _start_reader_thread(self):
        thread = ReadFromUSB(self)
        thread.start()
        thread.finished.connect(self._receive_data)

    def _receive_data(self):
        if not self.usb_read_value:
            print('* Ups, no data')
        else:
            print(self.usb_read_value)
            self.ui.dataList.addItem(self.usb_read_value)
            self._set_initial_usb_values()

        if self.usb_exception_counter >= 3:
            print(self.usb_exception)
            self.rfidreader.disconnect()
            QtGui.QApplication.quit()
        else:
            if self.usb_exception:
                print(self.usb_exception)
                self.usb_exception = None
            self._start_reader_thread()
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self._set_initial_usb_values()

        self.rfidreader = RFIDReader(0x08ff, 0x0009, 84, 16, should_reset=False)
        self.rfidreader.initialize()

        self._start_reader_thread()
class StartQT4(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self._set_initial_usb_values()

        self.rfidreader = RFIDReader(0x08ff, 0x0009, 84, 16, should_reset=False)
        self.rfidreader.initialize()

        self._start_reader_thread()

    def _set_initial_usb_values(self):
        self.usb_read_value = None
        self.usb_exception = None
        self.usb_exception_counter = 0

    def _start_reader_thread(self):
        thread = ReadFromUSB(self)
        thread.start()
        thread.finished.connect(self._receive_data)

    def _receive_data(self):
        if not self.usb_read_value:
            print('* Ups, no data')
        else:
            print(self.usb_read_value)
            self.ui.dataList.addItem(self.usb_read_value)
            self._set_initial_usb_values()

        if self.usb_exception_counter >= 3:
            print(self.usb_exception)
            self.rfidreader.disconnect()
            QtGui.QApplication.quit()
        else:
            if self.usb_exception:
                print(self.usb_exception)
                self.usb_exception = None
            self._start_reader_thread()