Problem With Non-blocking Uart I/o

Discussion in 'General Software' started by Sogogi110, Jul 13, 2016.

  1. Sogogi110

    Sogogi110 Guest

    Hi guys,
    I'm struggling with non-blocking UART (RS-232) I/O these days.
    I'm using the 9.1 suite with Software Build Tools for Eclipse, but it seems that the very same problem was also in previous releases (8.0SP1 for sure).

    When I enter main() I already have stdin,stdout,stderr already open, and I use them to do my I/O on a serial port.
    Then, I set the stdin to the non-blocking mode with

    if (fcntl(STDIN_FILENO,F_SETFL,O_NONBLOCK)==-1) // set stdin to non-blocking mode
    printf("fcntl() error\n");

    and I have no errors.
    Then, I try to get chars from the UART with getc(stdin) inside a while(1) loop, but it always returns -1, even when I send chars from the terminal.

    I also tried setting the interrupt control register in the UART core with IOWR_16DIRECT(UART_0_BASE,12,128); which should enable the "interrupt on read ready", but nothing changed.
    I have no such problem using JTAG_UART, and that's ok while prototyping the system, but soon I need to go with the RS232, so I need to find a solution.

    Anyone of you had problem with this and got a way to solve it?

    Thank you very much in advance,
    ________________________________________________________
    tags: color switch online and riddle school 2 or Crappy Bird Game
     
    Last edited by a moderator: Nov 4, 2016

Share This Page