- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
I use NIOS II to implement a program.
The program is loading 'In Place' [at EPCS16 memory].
The "scanf" function does not work properly if it wants to get more than 4-byte at once.
For example
...
unsigned char RX[8];
scanf("%c%c%c%c%c%c%c%c", &RX[0], &RX[1], &RX[2], &RX[3], &RX[4], &RX[5], &RX[6], &RX[7]);
...
This code sometimes does not fill "RX" when I send 8-byte from PC terminal (yes! I trusted the terminal).
However if I reduce the input length to 4-byte at once the problem is vanished.
Do have any idea what is wrong?
Is there any suggestion?
Is that related to 'In Place' execution things?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
First of all the scanf() family of routines is supported in the Normal C but NOT in the Small C library, so please make sure to use the normal C library. Using the execute in place on an EPCS16 may cause some delay, I do suspect the delay to be the cause but there is no evidence. Any way can you please re-write it as the following and see the result? getting a string should be more efficient.
#include <stdio.h>
int main()
{
char RX[8];
scanf("%s", &RX);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks you for sharing your opinion.
Yes, normal C is used here.
scanf with string also was not working. But for sake of curiosity, would you please explain why string is more efficient than character?
BTW, an important note is that serial communication sends out a binary value in each bytes in packet. Therefore, working with string maybe have some problems because of unwanted termination.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I would like to see if the string will arrive missing any thing or not. The Char cannot show you what is going on, I am still suspecting the EXP delay.
Regards,

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page