Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

getc() and 0x00 bytes

Hi,

I am having a problem reading data from an UART core. The incoming data should look like

0A 00 00 00 D6 00 0D

but using getc(fp) or fgetc(fp) I only get the NOT_ZERO bytes

0A D6 0D

This is my function:


INT8U prompt = 0;
INT8U i = 0;
FILE* fp;
fp= fopen(UART_BU_NAME, "r");
if (fp == NULL) {
  fprintf(stderr, "open failed\n");
  return;
}
i = 0;
while(prompt = fgetc(fp)){
  i++;
  printf("0x:%02X",prompt);
}
printf("\n\rCounted %d characters\n\r", i);   //returns value 3 (instead of 7)

Am I using the wrong function? Since it only happens with 0 bytes, I tend to believe it has nothing to do with overflows/task priority, but only with the way how the data is interpreted.

==== LE =====

With SignalTap I was able to see a read request on AvalonMM bus from the RXDATA register with value 0x00...
No RepliesBe the first to reply