Forum Discussion
Altera_Forum
Honored Contributor
11 years agoHey Dave
I got pulled off on something else and am getting back to this. I was able to use the eclipse ide niosII console to use the jtag_uart to send data to nios and nios interprets it correctly and performs the operation i specify. But im having issues with the bytestream service in system console and nios terminal (working on that in parallel with altera), so i switched gears to the usb-uart. I have implemented the usb-uart and instantiated it in the top level as you instructed. Im having issues with getting either putty or system console (using a variation of your tcl code above) to communicate with the nios. Im using this code in my nios: fp = fopen ("/dev/uart_0", "rw+"); //Open file for reading and writing while(1) { printf("waiting for trigger...Send 't' for trigger\n"); if (fp) { //char prompt = 0; char *prompt = NULL; printf("uart has been opened\n"); while (strcmp(prompt,"t") != 0) //while (prompt != 't') { //prompt = getc(fp); // Get a character from the UART. //string prompt = gets(fp); //printf("char received %c, but need a 't' to proceed\n", prompt); printf("string received %s, but need a 't' to proceed\n", prompt); } } } Again, it works with the jtag_uart, so i would think transitioning to the usb-uart would be fairly straightforward. Inside the nios ide bsp_editor, ive tried every combination of stdin/out/err, switching between jtag_uart, uart_0 and none. Using putty, the characters that are printed from reading the com port are messed up. special ascii chars and such. Its like the encoding or interpretation is wrong. Ive tried a few solutions on the web, but none helped. Some questions for you: 1)Seems like there are many different ways to access the uart data. ive seen gets, scanf, and several altera specific macros like altera_avalon_uart_rxData. Is one way better than the other? 2)Is the data held in a uart buffer until i read it? using something like altera_avalon_uart_RXData would imply that it is. but maybe without flow control, that is not possible and polling is needed? 3)Do i need to check status register of the uart before trying to read it? 4)Any ideas on the funny characters being printed out to putty? thanks Dave!!!