I am writing custom code to use the serial port to receive data from a sensor. This works fine when it’s plugged in, however I wanted to change an LED if there was no data coming from the sensor. When I unplug the serial connection however, or power down the sensor, my serial read blocks indefinitely.
I am using tcsetattr() to configure the port for a 0.1s timeout, at least I think I am. I’m trying to follow the same serial configuration settings as the GPS.
conifg.c_cc[VMIN] = 0;
config.c_cc[VTIME] = 10;
I am reading one character at a time, and after 0.1s if there is no character I want read() to return a 0.
Is there something else I need to do? I can pull out the proprietary portions of my code and post if that helps. Just looking for some guidance on maybe some of the other configurations that may be causing this.