Forum Discussion
Altera_Forum
Honored Contributor
21 years agoRead from UART
Good morning! I´m a NIOSII starter and trying to get first results. My question: Why can´t i read anything from the UART? I can write to it, but i don´t receive anything or i receive and don´t ...
Altera_Forum
Honored Contributor
21 years agoThanks for your help!
I modified my UART in SOPC-Builder, now it has the same properties (i took the values of jmastron) as my Hyperterminal (is there a better alternative?). Also i modified my source code , i took Fischers code example in the other thread about nonblocking stdin as base: int fdterm; // FILEDESCRIPTOR RETURNED BY OPEN FILE * fpterm; // FILE pointer returned by fdopen int uart1_rxcount = 0; char uart1_rxbuffer[255]; int main() { fdterm = open("/dev/uart1", O_RDWR | O_NONBLOCK | O_NOCTTY); fpterm = fdopen(fdterm,"rw+"); uart1_rxcount=read(fdterm, &uart1_rxbuffer, sizeof(uart1_rxbuffer)); if(uart1_rxcount>0) { fprintf(fpterm,"received:%s\r\n",uart1_rxbuffer); } Now: my debugger says uart1_rxcount is always NULL http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/dry.gif , still nothing happens... Do i have to implement interrupts from the uart? And whats about this EPP port Jeroen was talking about? Anyway, it´s funny to see that something happens with my board http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/biggrin.gif Hope to hear you... Max