Browse Source

Time tweak..

pyserial_fix
Scott Petersen 11 years ago
parent
commit
714feeb145
2 changed files with 32 additions and 1 deletions
  1. +2
    -0
      pyad2usb/devices.py
  2. +30
    -1
      test.py

+ 2
- 0
pyad2usb/devices.py View File

@@ -231,6 +231,8 @@ class USBDevice(Device):
if timeout > 0 and time.time() - start_time > timeout:
raise util.TimeoutError('Timeout while waiting for line terminator.')

time.sleep(0.1)

except (usb.core.USBError, FtdiError), err:
raise util.CommError('Error reading from AD2USB device: {0}'.format(str(err)))
else:


+ 30
- 1
test.py View File

@@ -240,10 +240,37 @@ def test_serial_grep():
for x in re:
print x

def test_double_panel_write():
dev = pyad2usb.ad2usb.devices.SerialDevice(interface='/dev/ttyUSB4')
dev2 = pyad2usb.ad2usb.devices.SerialDevice(interface='/dev/ttyUSB5')

dev.open(no_reader_thread=True)
print dev._device

dev2.open(no_reader_thread=True)
print dev2._device
#print a2u._device.read_line()
#dev.open()

print 'Writing characters..'
dev.write('*****')
dev2.write('*****')

print 'Reading..'

dev_res = dev.read_line()
print dev.id, dev_res

dev2_res = dev2.read_line()
print dev2.id, dev2_res

dev.close()
dev2.close()

try:
signal.signal(signal.SIGINT, signal_handler)

test_serial()
#test_serial()
#upload_serial()

#test_usb()
@@ -259,5 +286,7 @@ try:
#test_no_read_thread()
#test_serial_grep()

test_double_panel_write()

except Exception, err:
traceback.print_exc(err)

Loading…
Cancel
Save