Hi NiosII users,
I also need a nonblocking uart read, but I am having some trouble with the defined switches.
// if I open a stream in this way:
fp = fopen("/dev/uart1","r+");
//then
fread(buff,sizeof(char),1,fp);
// it works OK but blocks until a character is available.
// but if I use the defined switch (from fcntl.h)
fp = fopen("/dev/uart1","O_RDWR");
// it dosnt read or write!
I wish to use:
fp = fopen("/dev/uart1","O_RDWR|O_NONBLOCK");
By the way, the second argument to fopen should be of type 'const char*' (eg. "O_RDWR|O_NONBLOCK"), no
t an integer produced by: O_RDWR|O_NONBLOCK
fp = fopen("/dev/uart1",O_RDWR);
The above line will compile with a (implicit cast) warning, but should not give correct operation.
Any ideas?