There is a file which I can cat in linux, and it tells me the state of a pin based on the new device tree overlay. Using C++, I can stream the pin state to it when I configure it as an output. But if I fopen and read from the file, it gives me a character, then a newline I think, then an end of file, I think. So basically, whatever the software is doing to deliver me some reading as reading from a file, it only delivers it once per file open.
The pin reading I assume is a field-effect transistor with a bunch of resistors in there or something, to tell me if there is more than 2 volts on it relative to its ground. So of course I want to know when this changes every few microseconds (without a USART middleman).
But opening files takes a lot of time, and I have other things to do apart from go into the linux source code and find out why. So I need to read from this file, this device-as-a-file over and over, without it taking 300 microseconds to close and reopen the file so that the device gives me a new character. Reading from an open file takes a few microseconds max. But it won't give me the new state value unless I close and reopen it.
So I am looking into using fcntl or freopen or something. What can I do?