FaradayRF / faradayio

FaradayRF TUN/TAP adapter
https://www.faradayrf.com
GNU General Public License v3.0
15 stars 6 forks source link

Properly Catch exceptions when USB is Removed #54

Open kb1lqc opened 6 years ago

kb1lqc commented 6 years ago

While running the faradayio-cli program with the lates development branch code of faradayio I obtain the following error when I remove the USB cable while the program is running. Note, this does not exit the program.

bryce@bryce-ubuntu:~/Documents/git/faradayio-cli$ sudo .venv/bin/faradayio-cli KB1LQC 1
[sudo] password for bryce: 
Executing faradayio-cli version 0.0.1
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/home/bryce/Documents/git/faradayio-cli/.venv/lib/python3.5/site-packages/serial/serialposix.py", line 501, in read
    'device reports readiness to read but returned no data '
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/home/bryce/Documents/git/faradayio-cli/.venv/lib/python3.5/site-packages/faradayio/faraday.py", line 238, in run
    self.checkSerial()
  File "/home/bryce/Documents/git/faradayio-cli/.venv/lib/python3.5/site-packages/faradayio/faraday.py", line 211, in checkSerial
    for item in self.rxSerial(self._TUN._tun.mtu):
  File "/home/bryce/Documents/git/faradayio-cli/.venv/lib/python3.5/site-packages/faradayio/faraday.py", line 193, in rxSerial
    return(self._faraday.receive(length))
  File "/home/bryce/Documents/git/faradayio-cli/.venv/lib/python3.5/site-packages/faradayio/faraday.py", line 77, in receive
    ret = self._serialPort.read(length)
  File "/home/bryce/Documents/git/faradayio-cli/.venv/lib/python3.5/site-packages/serial/serialposix.py", line 509, in read
    raise SerialException('read failed: {}'.format(e))
serial.serialutil.SerialException: read failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?)