Browse Source

Fixed typo. Cleaned up firmware callbacks a bit.

pyserial_fix
Scott Petersen 12 years ago
parent
commit
395d5990b7
3 changed files with 12 additions and 16 deletions
  1. +1
    -1
      pyad2usb/ad2usb.py
  2. +9
    -13
      pyad2usb/util.py
  3. +2
    -2
      test.py

+ 1
- 1
pyad2usb/ad2usb.py View File

@@ -480,7 +480,7 @@ class Message(object):
""" """
return self._raw return self._raw


@raw_text.setter
@raw.setter
def raw(self, value): def raw(self, value):
""" """
Sets the raw representation of the message data from the panel. Sets the raw representation of the message data from the panel.


+ 9
- 13
pyad2usb/util.py View File

@@ -99,41 +99,37 @@ class Firmware(object):
if timeout > 0 and time.time() - start_time > timeout: if timeout > 0 and time.time() - start_time > timeout:
raise TimeoutError('Timed out waiting for pattern: {0}'.format(pattern)) 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: if dev is None:
raise NoDeviceError('No device specified for firmware upload.') 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 # Close the reader thread and wait for it to die, otherwise
# it interferes with our reading. # it interferes with our reading.
dev.close_reader() dev.close_reader()
while dev._read_thread.is_alive(): 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) time.sleep(1)


try: try:
if progress_callback is not None:
progress_callback(Firmware.STAGE_BOOT)

# Reboot the device and wait for the boot loader. # Reboot the device and wait for the boot loader.
stage_callback(Firmware.STAGE_BOOT)
dev.write("=") dev.write("=")
read_until('!boot', timeout=10.0) 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 # Get ourselves into the boot loader and wait for indication
# that it's ready for the firmware upload. # that it's ready for the firmware upload.
stage_callback(Firmware.STAGE_LOAD)
dev.write("=") dev.write("=")
read_until('!load', timeout=10.0) read_until('!load', timeout=10.0)


# And finally do the upload. # And finally do the upload.
do_upload() do_upload()
if progress_callback is not None:
progress_callback(Firmware.STAGE_DONE)
stage_callback(Firmware.STAGE_DONE)


except TimeoutError, err: except TimeoutError, err:
print traceback.print_exc(err) # TEMP print traceback.print_exc(err) # TEMP


+ 2
- 2
test.py View File

@@ -166,11 +166,11 @@ try:
#test_serial() #test_serial()
#upload_serial() #upload_serial()


test_usb()
#test_usb()
#test_usb_serial() #test_usb_serial()
#test_factory() #test_factory()
#test_factory_watcher() #test_factory_watcher()
#upload_usb()
upload_usb()
#upload_usb_serial() #upload_usb_serial()


except Exception, err: except Exception, err:


Loading…
Cancel
Save