如何从键盘输入,而在同一时间做其他的事情? [英] How to get input from keyboard while doing other things at the same time?

查看:175
本文介绍了如何从键盘输入,而在同一时间做其他的事情?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用C(GCC)和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...

但问题就在这里:

如何从键盘读取输入,(因为残培()冻结程序,直到它得到一个输入),并在同一时间读取来自端口的信息?

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!

推荐答案

残培使用的 NODELAY 选项非阻塞的电话。

make getch a non-blocking call using nodelay option.

nodelay(stdscr,TRUE);

更多信息可以在 HTTP上找到://www.gsp。 COM / cgi-bin目录/ man.cgi?主题= NODELAY

这篇关于如何从键盘输入,而在同一时间做其他的事情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆