adafruit / Adafruit_BLESniffer_Python

Python API for Adafruit's Bluefruit LE Sniffer
Other
101 stars 51 forks source link

Avoid leaving serial port open on exit #1

Closed pizthewiz closed 8 years ago

pizthewiz commented 9 years ago

It would appear as though the serial port is left open in some uses requiring a device unplug and replug before it can be used again, which is also called out in the README. Digging into the code to investigate, the UART's serial port is closed in a few error handling situations and in the UART destructor. In the CTRL+C/onExit handling, apparently the UART destructor isn't always called, so this adds an explicit call to it in the PacketReader's doExit.

pizthewiz commented 9 years ago

I should have also mentioned that I tested this on OS X 10.10.3 with the system Python 2.7.6 and pyserial 2.7.

pizthewiz commented 9 years ago

Hmm, I still run into the port use issue from time to time, but I think the explicit close in onExit is a good idea yet.