Ideally I would like to call a function when the USB port is disconnected while open, but I can't find if such thing is possible. While my python program runs, its opens up serial port self._serial = serial.Serial(self._serialPort, 9600, timeout=1)
where self._port = '/dev/tty.usbserial-FTBNNWBM'
when the device is disconnected nothing happens, until the program tries to send a command and fails.
I would like to be able to call disconnectHandler()
when the device is disconnected.