From 03d8045990b6f46d41c5c8da6610f4ab1e145cd2 Mon Sep 17 00:00:00 2001 From: Martin Quarda Date: Tue, 1 Apr 2025 20:14:05 +0200 Subject: [PATCH] small fixes --- SW/PC/Stopwatch/registrace.py | 2 +- SW/PC/Stopwatch/usbcardreader.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/SW/PC/Stopwatch/registrace.py b/SW/PC/Stopwatch/registrace.py index c7f386c..92867fd 100644 --- a/SW/PC/Stopwatch/registrace.py +++ b/SW/PC/Stopwatch/registrace.py @@ -62,7 +62,7 @@ threading.Thread(target=worker).start() def register_racer(): card_id = last_card index = window.racers.currentIndex() - if not index: + if not index.data(): mb = QtWidgets.QMessageBox(text='Prosím vyberte závodníka!') mb.exec() return diff --git a/SW/PC/Stopwatch/usbcardreader.py b/SW/PC/Stopwatch/usbcardreader.py index c149192..39f4619 100644 --- a/SW/PC/Stopwatch/usbcardreader.py +++ b/SW/PC/Stopwatch/usbcardreader.py @@ -1,6 +1,7 @@ import usb.core import usb.util - +import threading +import time USB_IF = 0 # Interface @@ -33,13 +34,13 @@ class UsbCardReader: control = None try: control = self.dev.read(self.endpoint.bEndpointAddress, self.endpoint.wMaxPacketSize, USB_TIMEOUT) - if (control[2] != 40) & (control[2] != 0): + if (control[2] != 40) and (control[2] != 0): receivedDigit = control[2] - 29 if receivedDigit == 10: receivedDigit = 0 receivedNumber = 10 * receivedNumber + receivedDigit - if (( control[0] == 0 )) & (( control[2] == 40 )) & (( not receivedNumber == 0 )): + if ( control[0] == 0 ) and ( control[2] == 40 ) and ( not receivedNumber == 0 ): self.callback(receivedNumber) receivedNumber = 0 except KeyboardInterrupt: