'INTERNAL ERROR with power switch detection', 4) state = WAIT_TO_RESET first_time_here_flag = True return state, first_time_here_flag if __name__ == "__main__": IDLE = 0 # ready for the card to be swiped WAIT_FOR_FIRST_DATABASE_RESPONSE = 1 # database has been quiried, waiting for it to respond WAIT_TO_RESET = 2 DATABASE_QUERY_TIMED_OUT = 3 SUPERVISOR_NEEDED = 4 TIMEING_ACCESS = 5 EXTEND_TIME_PROMPT = 6 CHECK_FOR_CLOSED_POWER_SWITCH = 7 # SerConn = SerialConnection.SerialClass() Data = DataBase.DataBase() timeoutTimer1 = timeoutTimer.timeoutTimer() timeoutTimer2 = timeoutTimer.timeoutTimer() displayscreen = tk.Tk() displayscreen.overrideredirect(True) Dis = DisplayStuff.Display(displayscreen) state = IDLE flag = True while True: SerConn.attempt_to_get_readings() if flag: print("STATE=", state) (s, f) = mainloop(state, flag) if f: print("newstate=", s)
return OK def send_relay_mainpowerOFF(self): OK = self.initiate_arduino_command("write", str(self.MAINPOWER_RELAY_PIN), "1") return OK def send_relay_mainpowerON(self): OK = self.initiate_arduino_command("write", str(self.MAINPOWER_RELAY_PIN), "0") return OK if __name__ == "__main__": print('HI there') # define the serial port sport = SerialConnection.SerialClass() sio = io.TextIOWrapper(io.BufferedRWPair(sport.ser, sport.ser)) sio.write(("hello\n")) sio.flush() # it is buffering. required to get the data out *now* # define the command processor ACommandProc = ArdCommandResponse(sport) stophere = True while stophere: sport.attempt_to_get_readings() if sport.cardID_available: print("cardID=", sport.get_cardID()) if sport.alive_available: print("alive=", sport.get_alive()) stophere = False print('Arduino is alive ') i = 0