Altera_Forum
Honored Contributor
19 years agoUnable to read all information from Nios II UART
Hello All,
I am using Nios II cyclone development kit as part of my research. I am listening to uart1 in order to receive character-based information from another device. My code is simple. However, I am always getting the following error after 4 characters: Starting process. Waiting for a new character. ~ Still open the UART 2 file. Waiting for a new character. B Still open the UART 2 file. Waiting for a new character. ÿ Still open the UART 2 file. Waiting for a new character. ÿ Still open the UART 2 file. Waiting for a new character. nios2-terminal: exiting due to ^D on remote Any help to fix this issue is very appreciated. Best Regards, Julia. PS: that the communication between the device and PC is working perfectly when through the com port. CODE: # include <stdio.h># include <string.h># include <stdlib.h> int main () { FILE* fp1; char prompt = 'L'; fp1 = fopen("/dev/uart1", "r+"); printf("Starting process.\n"); if (fp1) { for(;;) // Loop forever { printf("Waiting for a new character.\n"); prompt = getc(fp1); // Get a character from the UART1. printf("%c \n", prompt); printf("Waiting for a new character.\n"); } printf("Closing the UART 1 file.\n"); fclose (fp1); } return 0; }