small fixes

This commit is contained in:
Martin Quarda 2025-04-01 20:14:05 +02:00
parent c59b24a561
commit 03d8045990
2 changed files with 5 additions and 4 deletions

View File

@ -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

View File

@ -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: