This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to check the input of STDIN channel?


I use the console channel to configure the product at runtime.
When I try to get input from STDIN, the standard "getchar()" call will BLOCK
until get input, which also block other threads.
So I am asking how to check whether there is a input pended on the console
channel before call "getchar()" (to avoid BLOCK)?
On the WIN32 platform, I use the _kbhit() for this purpose.

I used "cyg_fs_fgetinfo(,CYG_IO_GET_CONFIG_SERIAL_BUFFER_INFO, , )", but
since the "/dev/ttydiag" device is not interrupt driven and has no buffer,
it always return "rx_count == 0".
I also used "select()", but it also failed because of no buffer.
However, the above methods work well on other "/dev/ttyx" devices with tx/rx
buffer.

Then, I used the " CYGACC_COMM_IF_GETC_TIMEOUT()". It does can return when
timeout, but it wastes long waiting time in it before timeout.

Finally, I have to use the HAL's "cyg_hal_plf_serial_getc_nonblock()". It
try read once and return result without any delay. It works, but I don't
think it's a good solution, because it's very HAL dependent.


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]