Closed etherfi closed 8 years ago
Redacting this pull request. I have a superior version that substantially reduces CPU usage that I will submit once testing is complete.
Hi etherfi,
I was keeping an eye on your PR with interest as it looked like it crossed a few paths with some improvements I have been attempting in a branch of mine here: https://github.com/jamesleesaunders/python-xbee/tree/serial-re-init
The aim of this improvement is supposed to be to make the serial port a little more resilient to failures. The added code (inspired by @thom-nic) is supposed to attempt to re-initialise the serial port if/when it fails or is physically unplugged and plugged back in.
It is intended to, upon detection of a Serial port closure first attempt an simply re-open the port and then if this fails attempt to completely re-initialise the port. It almost works but only 50% of the time, and have I have seen some positive results with the code re-initialising the port after un-plugging and back in again.
The reason I have brought this to your attention is a) If may be interesting for the work you are doing for your timeout code change. b) or I wonder if you are interested in helping me get this working 100%?
I am fairly new to Python so still learning some of its intricacies.
Thanks,
Jim
This function is dangerous because in the absence of an active XBee network (e.g. while debugging code) it is literally a black hole; Once the interpreter goes in, it will never come out. Adding a timeout here simplifies testing. It also makes it safer to call the function in an externally-managed thread.