0

I want read on stdout to be non-blocking. I was using the newlib-lpc library in WINarm to do this. But even though it is set as non-Blocking, the code stops at read every time and waits for a character to be received.

Here is my read line:

read(fileno(stdout), &inchar, 1);

Here is the code to set stdout to non-blocking using newlib-lpc

blocking=BLOCKING_IO_NO;
ioctl( fileno(stdout), BLOCKING_SETUP, &blocking);

When that didn't work, I decided to forget using the library and do it myself with this line

fcntl(fileno(stdout), F_SETFL,fcntl(fileno(stdout), F_GETFL) |O_NONBLOCK);

But that didn't work either.

Could anyone give me some advice?

Thanks!

edit: Someone asked if I really meant stdout. Yes, I am resurrecting some old code, and the stdout has been set as the socket for UART communication between my board and the computer.

sp.baud   = 115200uL;
sp.length = UART_WORD_LEN_8;
sp.parity = UART_PARITY_NONE;
sp.stop   = UART_STOP_BITS_1;
ioctl( fileno(stdout), UART_SETUP, &sp);

irq.FIQ = 0;
irq.pri = (INT_PRIORITY)10;
ioctl( fileno(stdout), INTERRUPT_SETUP, &irq);

edit2: They used stdout this way so that printf works. When it tries to print to stdout, it gets redirected to the UART serial stream.

edit3: The error I get when calling

 ioctl( fileno(stdout), BLOCKING_SETUP, &blocking);

is

errno88 function not implemented
ej_01
  • 51
  • 4

0 Answers0