-
Key hit interupt?
I'm programing this little user interface. I would like it to be able to receive and display data received on the serial port, and I would also like to have the user hit keys to various different things when ever he wants to.
I've got the program execution waiting for user input using the mygetch() function from the FAQ. (by the way, I'm on a unix terminal... well, unix command line on OSX to be specific)
Anyway I want to read the data off the serial port when ever it is there to read.
In micro controller world, I wold simply catch the interups... data is waiting on the serial port, and user hit a key. But I don't know how to do this in the unix command line world.
I think that I can pole the serial port for data, can I pole stdin as well? Or can I use interups for both... or is there an entirely different solution I should consider.
thanks.
B
-
If this is x86-based the keyboard handler is interrupt 09h. Write your own handler for it.
-
On a unix or unix-like platform, use select() with whatever file descriptors you're interested in watching.
It will tell you when there's anything available to be read on a number of fd's, then you can go and read them.