Browse Source

Updates for name change.

pyserial_fix
Scott Petersen 11 years ago
parent
commit
89d0f3bef8
3 changed files with 13 additions and 12 deletions
  1. +1
    -0
      .gitignore
  2. +9
    -9
      bin/ad2-firmwareupload
  3. +3
    -3
      bin/ad2-sslterm

+ 1
- 0
.gitignore View File

@@ -1,3 +1,4 @@
*.pyc *.pyc
tmp tmp
bin/ad2-test bin/ad2-test
*.egg-info

+ 9
- 9
bin/ad2-firmwareupload View File

@@ -1,25 +1,25 @@
#!/usr/bin/env python #!/usr/bin/env python


import sys, time import sys, time
import pyad2usb.ad2usb
import pyad2.ad2


def handle_firmware(stage): def handle_firmware(stage):
if stage == pyad2usb.ad2usb.util.Firmware.STAGE_START:
if stage == pyad2.ad2.util.Firmware.STAGE_START:
handle_firmware.wait_tick = 0 handle_firmware.wait_tick = 0
handle_firmware.upload_tick = 0 handle_firmware.upload_tick = 0
elif stage == pyad2usb.ad2usb.util.Firmware.STAGE_WAITING:
elif stage == pyad2.ad2.util.Firmware.STAGE_WAITING:
if handle_firmware.wait_tick == 0: if handle_firmware.wait_tick == 0:
sys.stdout.write('Waiting for device.') sys.stdout.write('Waiting for device.')
handle_firmware.wait_tick += 1 handle_firmware.wait_tick += 1


sys.stdout.write('.') sys.stdout.write('.')
sys.stdout.flush() sys.stdout.flush()
elif stage == pyad2usb.ad2usb.util.Firmware.STAGE_BOOT:
elif stage == pyad2.ad2.util.Firmware.STAGE_BOOT:
if handle_firmware.wait_tick > 0: print "" if handle_firmware.wait_tick > 0: print ""
print "Rebooting device.." print "Rebooting device.."
elif stage == pyad2usb.ad2usb.util.Firmware.STAGE_LOAD:
elif stage == pyad2.ad2.util.Firmware.STAGE_LOAD:
print 'Waiting for boot loader..' print 'Waiting for boot loader..'
elif stage == pyad2usb.ad2usb.util.Firmware.STAGE_UPLOADING:
elif stage == pyad2.ad2.util.Firmware.STAGE_UPLOADING:
if handle_firmware.upload_tick == 0: if handle_firmware.upload_tick == 0:
sys.stdout.write('Uploading firmware.') sys.stdout.write('Uploading firmware.')


@@ -28,7 +28,7 @@ def handle_firmware(stage):
if handle_firmware.upload_tick % 30 == 0: if handle_firmware.upload_tick % 30 == 0:
sys.stdout.write('.') sys.stdout.write('.')
sys.stdout.flush() sys.stdout.flush()
elif stage == pyad2usb.ad2usb.util.Firmware.STAGE_DONE:
elif stage == pyad2.ad2.util.Firmware.STAGE_DONE:
print "\r\nDone!" print "\r\nDone!"


def main(): def main():
@@ -45,11 +45,11 @@ def main():


print "Flashing device: {0}\r\nFirmware: {1}".format(device, firmware) print "Flashing device: {0}\r\nFirmware: {1}".format(device, firmware)


dev = pyad2usb.ad2usb.devices.SerialDevice(interface=device)
dev = pyad2.ad2.devices.SerialDevice(interface=device)
dev.open(baudrate=19200) dev.open(baudrate=19200)


time.sleep(3) time.sleep(3)
pyad2usb.ad2usb.util.Firmware.upload(dev, firmware, handle_firmware)
pyad2.ad2.util.Firmware.upload(dev, firmware, handle_firmware)


dev.close() dev.close()




+ 3
- 3
bin/ad2-sslterm View File

@@ -1,13 +1,13 @@
#!/usr/bin/env python #!/usr/bin/env python


import pyad2usb.ad2usb
import pyad2.ad2
import sys, select import sys, select
import termios, tty import termios, tty
import time import time


def main(): def main():
if len(sys.argv) != 5: if len(sys.argv) != 5:
print "Syntax: sslterm.py [host:port] [ca cert] [client cert] [client key]\r"
print "Syntax: {0} [host:port] [ca cert] [client cert] [client key]\r".format(sys.argv[0])
return 1 return 1


host, port = sys.argv[1].split(':') host, port = sys.argv[1].split(':')
@@ -23,7 +23,7 @@ def main():
try: try:
print "Opening connection to {0}:{1}\r".format(host, port) print "Opening connection to {0}:{1}\r".format(host, port)


dev = pyad2usb.ad2usb.devices.SocketDevice(interface=(host, int(port)))
dev = pyad2.ad2.devices.SocketDevice(interface=(host, int(port)))
dev.ssl = True dev.ssl = True
dev.ssl_certificate = client_cert dev.ssl_certificate = client_cert
dev.ssl_key = client_key dev.ssl_key = client_key


Loading…
Cancel
Save