def connectPort(self, defaultPort=None): if self.portStatus == 'disconnected': if defaultPort: self.selPort = defaultPort # updates class variable as well else: self.selPort = self.combo.get() # if disconnected, then connect to selected port self.portHandle = self.comm.connect( self.selPort) self.combo.set(self.selPort) self.setSerialParams() self.btn2.config(text='Disconnect') # change button label # self.btn2['text'] = 'Disconnect' self.portStatus = 'connected' # update connection status serParams = f'Connected: {self.comPort} ({self.comBaudrate},{self.comBytesize},{self.comParity},{self.comStopbits},{self.comXonXoff})' serParams = serParams + ' Device: ' + du.get_part_number(comm) stsBarComm.config(text=serParams) elif self.portStatus == 'connected': # if connected, then disconnect from the port connected to self.disconnectPort(self.selPort) self.btn2['text'] = 'Connect' # update button label self.portStatus = 'disconnected' # update connection status stsBarComm.config(text='Disconnected') else: print('No such port. Try again!!!')
from dubLibs import boardcom from dubLibs import dubrovnik as du # *************************** # ***** M A I N ***** # *************************** # ***** CONNECT ***** comm = boardcom.BoardComm() # create an instance of class BoardComm connectedPort = comm.find_and_connect(echo=1) config = du.get_config(comm) print(config) partNumber = du.get_part_number(comm) print(partNumber) # ADD YOUR CODE HERE # comm.send('b 0 100') # print(comm.response()) # erase_time = du.block_erase(comm, block_size=64, start_addr=0x10000, echo=0) # print(f'Erase time: {erase_time}') t_wait = du.pattern_program(comm, start_addr=0x10025, length=0x100, increment=1, echo=1) print(t_wait)