read() can't get any data & nonblock.

I have a program that has two different threads: first one runs telnet server and another writes MODBUS-requests through serial port and receives answers and then transfers them to database server using tcp. Everything works fine but read() function can’t get any data even if i make a loop that waits. I’ve opened the serial port with O_NONBLOCK but it really doesn’t help, read() jams the both threads anyway. It always gets an error “No more processes” = EAGAIN. I found one solution that should work but it didn’t help either (you’ve to replace netos_serl.c line 3745-> with nonblock code so it’s always on). Any ideas for solution to get read() work properly? I’m using NET+OS Build

Why don’t you use select() to wait for data? After select tells you that data is available, you can use read even blocking. A good (and even very amusing) guide to sockets basics can be found here:

Check out tcgetbuffers().

The problem occurs when using read() with serial port. Sockets works just fine.

I’ve experienced similar problems but was able to get around it by using “tcflush()” before I instigated any transfer.