Altera_Forum
Honored Contributor
20 years agoCommunication with RS232 UART
Hello,
I am just trying to see some activity out of the Avalon RS232 UART. I have instrumented my board's TX and RX lines on my 232 device ands am running the simple example below( Took from Software Handbook and then modified for just writes): I get the error at runtime: nios2-terminal: can't open uart: Permission denied Any tips or thoughts? Thanks. /* A simple program that recognizes the characters 't' and 'v' */# include <stdio.h># include <string.h># include "system.h" int main() { char* msg = "Detected the character 't'. \n"; FILE* fp; char prompt = 0; //fp = fopen ("/dev/uart_1", "r+"); // Open file for reading and writing fp = fopen ("/dev/uart_1", "w"); // Open file for reading and writing //print a message to console //printf(" I am starting UART Test \n "); fprintf(fp, "Open the UART \n"); //printf(" Should have written to UART .\n"); if(fp) { fprintf(fp, "%s",msg); fclose(fp); } /* if(fp) { while(prompt != 'v') { // Loop until we receive a 'v'. prompt = getc(fp); // Get a character from the UART if(prompt == 't') { // print a message if character is 't'. fwrite(msg, strlen(msg), 1, fp); } } fprintf(fp, "Closing the UART file. \n"); fclose (fp); } */ return 0; }