Browse Source

Firmware upload needs totally reworked but this helps a bit for now.

pyserial_fix
Scott Petersen 11 years ago
parent
commit
fbc22932fa
2 changed files with 8 additions and 5 deletions
  1. +4
    -2
      pyad2usb/util.py
  2. +4
    -3
      test.py

+ 4
- 2
pyad2usb/util.py View File

@@ -77,7 +77,7 @@ class Firmware(object):
if progress_callback is not None: if progress_callback is not None:
progress_callback(Firmware.STAGE_UPLOADING) progress_callback(Firmware.STAGE_UPLOADING)


time.sleep(0.05)
time.sleep(0.0)


def read_until(pattern, timeout=0.0): def read_until(pattern, timeout=0.0):
""" """
@@ -134,10 +134,12 @@ class Firmware(object):
stage_callback(Firmware.STAGE_WAITING) stage_callback(Firmware.STAGE_WAITING)
time.sleep(1) time.sleep(1)


time.sleep(1)

# Reboot the device and wait for the boot loader. # Reboot the device and wait for the boot loader.
stage_callback(Firmware.STAGE_BOOT) stage_callback(Firmware.STAGE_BOOT)
dev.write("=") dev.write("=")
read_until('!boot', timeout=15.0)
read_until('......', timeout=15.0)


# 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.


+ 4
- 3
test.py View File

@@ -75,14 +75,15 @@ def upload_usb():
dev = pyad2usb.ad2usb.devices.USBDevice() dev = pyad2usb.ad2usb.devices.USBDevice()


dev.open(no_reader_thread=True) dev.open(no_reader_thread=True)
pyad2usb.ad2usb.util.Firmware.upload(dev, 'tmp/ademcoemu_V2_2a_6.hex', handle_firmware)
#pyad2usb.ad2usb.util.Firmware.upload(dev, 'tmp/ademcoemu_V2_2a_6.hex', handle_firmware)
dev.close() dev.close()


def upload_serial(): def upload_serial():
dev = pyad2usb.ad2usb.devices.SerialDevice(interface='/dev/ttyUSB2')
dev = pyad2usb.ad2usb.devices.SerialDevice(interface='/dev/ttyUSB0')


dev.open()
dev.open(no_reader_thread=True)
pyad2usb.ad2usb.util.Firmware.upload(dev, 'tmp/ademcoemu_V2_2a_6.hex', handle_firmware) pyad2usb.ad2usb.util.Firmware.upload(dev, 'tmp/ademcoemu_V2_2a_6.hex', handle_firmware)
#pyad2usb.ad2usb.util.Firmware.upload(dev, 'tmp/ademcoemu-V2-2a-5-beta20-C4.hex', handle_firmware)
dev.close() dev.close()


def upload_usb_serial(): def upload_usb_serial():


Loading…
Cancel
Save