12-17-2008 09:21 AM
I try to input character from console, I use standard C function, getchar(), but it does not works properly,
first, it is especially large, second, it can get character back only after I push return key, It is not the way as in standard C.
What is wrong, and how can I input character? Must I use XUartLite_RecvByte() ? I'd like to use standard C functions to make the program easy.
test_id = getchar();
Solved! Go to Solution.
12-17-2008 09:24 AM
Your terminal program might not send the characters until it sees that you've hit ENTER.
Yes, I do this for a living.
12-17-2008 09:49 AM
my terminal program is SecureCRT, and it works well with others embedded system. Also I tried HyperTerminal, it works in same way.
so, do anyone use getchar() successfuly before? and Must I turn to xilinx uart api? Thanks.
(My tools and envirorment is Microblaze, EDK92, uartlite v1.0)
12-17-2008 10:09 AM - edited 12-17-2008 10:17 AM
I did a search on getchar and EDK. Other people have been using it according to search in Xilinx Forum.
Try increasing Heap and Stack Size a lot to see if that is the problem.
12-18-2008 08:24 AM
I had the same problem.
You can change the buffering behaviour of stdin by calling
setvbuf() before calling getchar();
setvbuf(stdin, NULL, _IONBF, 0);
Input = getchar();
if (Input != EOF)
You may omit the line with EOF, I never got that value.
I have tested the code above with XMK, it should work
in a standalone version too.
BTW: Hyperterminal sends each character as soon as you type it.
It does not wait for the <RETURN> key.
Hope this helps
12-18-2008 09:30 AM
Your method works. But it seems that the getchar() function is huge! I decided to use xilinx's api, and deal with all the input myself.
Still, many thanks for your reply.