diff --git a/pyad2usb/ad2usb.py b/pyad2usb/ad2usb.py index 5346b7e..1cec668 100644 --- a/pyad2usb/ad2usb.py +++ b/pyad2usb/ad2usb.py @@ -480,7 +480,7 @@ class Message(object): """ return self._raw - @raw_text.setter + @raw.setter def raw(self, value): """ Sets the raw representation of the message data from the panel. diff --git a/pyad2usb/util.py b/pyad2usb/util.py index eed7dba..2e85e98 100644 --- a/pyad2usb/util.py +++ b/pyad2usb/util.py @@ -99,41 +99,37 @@ class Firmware(object): if timeout > 0 and time.time() - start_time > timeout: raise TimeoutError('Timed out waiting for pattern: {0}'.format(pattern)) + def stage_callback(stage): + if progress_callback is not None: + progress_callback(stage) + if dev is None: raise NoDeviceError('No device specified for firmware upload.') - if progress_callback is not None: - progress_callback(Firmware.STAGE_START) + stage_callback(Firmware.STAGE_START) # Close the reader thread and wait for it to die, otherwise # it interferes with our reading. dev.close_reader() while dev._read_thread.is_alive(): - if progress_callback is not None: - progress_callback(Firmware.STAGE_WAITING) - + stage_callback(Firmware.STAGE_WAITING) time.sleep(1) try: - if progress_callback is not None: - progress_callback(Firmware.STAGE_BOOT) - # Reboot the device and wait for the boot loader. + stage_callback(Firmware.STAGE_BOOT) dev.write("=") read_until('!boot', timeout=10.0) - if progress_callback is not None: - progress_callback(Firmware.STAGE_LOAD) - # Get ourselves into the boot loader and wait for indication # that it's ready for the firmware upload. + stage_callback(Firmware.STAGE_LOAD) dev.write("=") read_until('!load', timeout=10.0) # And finally do the upload. do_upload() - if progress_callback is not None: - progress_callback(Firmware.STAGE_DONE) + stage_callback(Firmware.STAGE_DONE) except TimeoutError, err: print traceback.print_exc(err) # TEMP diff --git a/test.py b/test.py index 2c7ec60..8ce786d 100755 --- a/test.py +++ b/test.py @@ -166,11 +166,11 @@ try: #test_serial() #upload_serial() - test_usb() + #test_usb() #test_usb_serial() #test_factory() #test_factory_watcher() - #upload_usb() + upload_usb() #upload_usb_serial() except Exception, err: