Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get input from keyboard while doing other things at the same time?

Tags:

c

ncurses

I'm using C (gcc) and ncurses, to make a program that will be monitoring data coming from the serial port. The program has a big while, where it reads the data coming from the port and at the same time, it prints that info in the screen...

But the problem is here:

How can it read input from my keyboard, (since getch() freezes the program until it gets an input) and at the same time read info coming from the port?

Maybe I have to use another way (not the big while), so ideas are welcome!

like image 513
Tomas Avatar asked Oct 15 '10 06:10

Tomas


1 Answers

make getch a non-blocking call using nodelay option.

nodelay(stdscr,TRUE);

More info can be found at http://www.gsp.com/cgi-bin/man.cgi?topic=nodelay

like image 113
Rozuur Avatar answered Oct 23 '22 10:10

Rozuur