def main(hexfile, port, baudrate, erase, load, verify, version): if version: logger.info('version {}'.format(__version__)) return if not erase and not load and not verify: logger.error('no operations specified - exiting') return sp = create_serial_port(port, baudrate) blt = create_blt(sp) # allow time for threads and hardware to spin up time.sleep(0.1) if not blt.device_identified: logger.error('device not responding') return if erase: logger.info('erasing the device...') result = erase_device(blt) if result: logger.info('device successfully erased!') else: logger.warning('device erase failed') if load: logger.info('loading...') result = load_hex(blt, hexfile) if result: logger.info('device successfully loaded!') else: logger.warning('device load failed') else: result = True if verify and result: logger.info('verifying...') result = verify_hex(blt, hexfile) if result: logger.info('device verified!') else: logger.warning('device verification failed')
def erase_device(self): baudrate = int(self.ser_baud_entry.get()) sp = create_serial_port(self.port_name, baudrate) blt = create_blt(sp) self.update_console(clear=True) # allow time for threads and hardware to spin up time.sleep(0.5) self.update_console('loading...') if erase_device(blt): self.update_console('device erased!') else: self.update_console('device erase failed') blt.end_thread() time.sleep(0.01) sp.close()
def verify_device(self): baudrate = int(self.ser_baud_entry.get()) sp = create_serial_port(self.port_name, baudrate) blt = create_blt(sp) self.update_console(clear=True) # allow time for threads and hardware to spin up time.sleep(0.5) self.update_console('verifying...') if verify_hex(blt, self.hex_file_path): self.update_console('device verified!') else: self.update_console('device verification failed') blt.end_thread() time.sleep(0.01) sp.close()