def Connect_clicked(self): if self.connected: self.ui.AutoRead.setChecked(False) self.sportiduino.disconnect() self.log('\n' + self.tr("Master station is disconnected")) self.connected = False self.ui.Connect.setText(_translate("MainWindow", "Connect")) else: port = self.ui.choiseCom.currentText() try: if (port == QCoreApplication.translate("MainWindow", "auto")): self.sportiduino = Sportiduino( debug=True, translator=QCoreApplication.translate) else: self.sportiduino = Sportiduino(port, debug=True) curPass = (self.ui.sbCurPwd1.value(), self.ui.sbCurPwd2.value(), self.ui.sbCurPwd3.value()) self._apply_pwd(curPass) #self.sportiduino.beep_ok() self.log( '\n' + self.tr("Master station {} on port {} is connected"). format(self.sportiduino.version, self.sportiduino.port)) self.ui.Connect.setText(_translate("MainWindow", "Disconn.")) self.connected = True self.read_ms_config() except Exception as err: self._process_error(err)
#!/usr/bin/env python import sys sys.path.append('..') from sportiduino import Sportiduino from time import sleep import serial if len(sys.argv) > 1: port = sys.argv[1] sportiduino = Sportiduino(port=port, debug=True) else: sportiduino = Sportiduino(debug=True) print('Read card loop') while True: while not sportiduino.poll_card(): sleep(0.5) data = sportiduino.card_data print("Punches:", data) sportiduino.beep_ok() sleep(1)