diff --git a/pyad2usb/devices.py b/pyad2usb/devices.py index 058578e..a579182 100644 --- a/pyad2usb/devices.py +++ b/pyad2usb/devices.py @@ -38,7 +38,8 @@ class Device(object): try: self._device.read_line() except util.CommError, err: - self.stop() + #self.stop() + pass time.sleep(0.01) @@ -226,6 +227,9 @@ class SerialDevice(Device): self.on_close() + def close_reader(self): + self._read_thread.stop() + def write(self, data): try: self._device.write(data) @@ -234,6 +238,9 @@ class SerialDevice(Device): else: self.on_write(data) + def read(self): + return self._device.read(1) + def read_line(self, timeout=0.0): start_time = time.time() got_line = False @@ -260,11 +267,7 @@ class SerialDevice(Device): if timeout > 0 and time.time() - start_time > timeout: break - - time.sleep(0.01) except serial.SerialException, err: - self.close() - raise util.CommError('Error reading from AD2SERIAL device: {0}'.format(str(err))) else: if got_line: