Altera_Forum
Honored Contributor
16 years agoDE2 -- UART transmit and receive compiling error
Hi all,
I'm using the DE2 kit, with Quartus II (using SOPC) and NIOS IDE software to make an UART communication. But the compilation was always failed. Does anyone know how I can work around it? Thanks in advance The example code from the NIOS handbook was: # include "sys/alt_stdio.h"# include "stdio.h"# include "string.h"# include "system.h" int main() { char* msg = "Detected character\n"; FILE* fp; char prompt = 0; printf("Testing begin\n"); fp = fopen ("/dev/uart_0","r+"); if (fp) { while (prompt!=0) { prompt = getc(fp); if (prompt=='t') { fwrite (msg,strlen(msg),1,fp); } } fprintf(fp,"closing\n"); fclose(fp); } return 0; } The error of the compilation was: /cygdrive/c/altera/91/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.6/../../../../nios2-elf/lib/libc.a(closer.o) In function `_close_r': /cygdrive/c/altera/91/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.6/../../../../nios2-elf/lib/libc.a(lseekr.o) In function `_lseek_r': /cygdrive/c/altera/91/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.6/../../../../nios2-elf/lib/libc.a(openr.o) In function `_open_r':