Altera_Forum
Honored Contributor
15 years agoProblem with reading data from UART
Hi!
Below are my C codes using NIOS 2 IDE to send and read data using DE2 board through UART by RS232 port. Also, I build my own GUI to receive and send data to UART. After I read the data from my GUI and store the data in array prompt [10], I decide to display the array prompt [10] to my GUI by using several type of function calling, as shown coding below in bold style. However, from my GUI I cannot read the data sending. may i know how to solve it? Thanks! int main () { FILE* fp1; char prompt[10] ; fp1 = fopen(UART_0_NAME , "r+"); if (fp1) { while (1) { //I get the data from my GUI fgets(prompt, 8, fp1); // I send data to be displayed in my GUI fwrite (prompt , 1 , sizeof(prompt) , fp1 );cout<< prompt;
fputs (prompt,fp1); } fclose (fp1); } return 0; }