diff --git a/pyad2usb/devices.py b/pyad2usb/devices.py index ddecc6a..8a0fbb6 100644 --- a/pyad2usb/devices.py +++ b/pyad2usb/devices.py @@ -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: diff --git a/test.py b/test.py index b0969df..28ba817 100755 --- a/test.py +++ b/test.py @@ -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)