(1) Adding a flag to tell the reader thread that the device is open or closed. (1) Moving device configs to defines at the top.
Moved defines around to make it easier to find where to config the device.
Adding check of device status in thread. Removed ugly global variable used for thread signalling.