scanf and printf in EDK's BSP

I am working on a PPC405 system using EDK9.2 and its BSP. The system uses an uartlite as stdin and stdout. I am unable to have scanf and printf functions to work as they should with strings. Per instance: scanf("%s",string_array) only reads one character. And printf("%s", string_array) prints a bunch of symbols but not the string I want. Is this due to a "smaller" version of the functions scanf and printf that are included on the BSP? Am I missing something on the configuration? The project is as simple as it can get. Any comment would be appreciated. Alonzo

Reply to
rha_x
Loading thread data ...

The smaller ones included in the BSP have the prefix "xil_" attached. For example, if you wanted the special version of printf you should try to use xil_printf(). I have used it in previous projects and I know it works. If you still have problems, check the serial settings on both sides to make sure that they match. If you are getting ackward characters, it is likely to be a speed mismatch. This will also impact your ability to read characters.

---Matthew Hicks

Reply to
Matthew Hicks

Reply to
rha_x

So the printf works in other scenarios? I just tried printf("%s") in EDK

9.1 and it worked for me, sorry I can't be of more help.

---Matthew Hicks

Reply to
Matthew Hicks

rha snipped-for-privacy@yahoo.com schrieb:

Have you tried to increase your stack size? Somewhere in the Xilinx documentation is stated that these full featured printf/scanf functions may require large amounts of stack.

Best regards, Andreas

Reply to
Andreas Hofmann

My stupid question is... There couldn't be a level of indirection missing, could there? I would expect something called string_array to be an array of pointers, not actual strings. Does the code work correctly elsewhere (under any other C compiler?)

(by the way, both printf and xil_printf worked fine for me)

- Brian

Reply to
Brian Drummond

Hello All, Thank you so much for your answers. We solved it. Here are the facts:

1.- I try the same little silly program in a linux computer just to discard different kind of errors (as Brian suggested). It worked ok. The test code is like this:

char str[80] printf("Enter a name: "); scanf("%s"); printf("the name entered is: $s",str);

2.- Going back to EDK. I couldn't try EDK9.1 Don't have it right now. So I couldn't confirm Matthews test. 3.- Followed Andreas suggesti> > >I am working on a PPC405 system using EDK9.2 and its BSP. The system
Reply to
rha_x

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.