non blocking serial I/O

In the online help it states that you can open a serial port for non blocking I/O by using O_NON_BLOCK however after a few compile errors followed by a grep of the entire NET+OS source tree , it appears that O_NON_BLOCK is not defined anywhere.

Mark

ah after getting some sleep I woke up and remembered to use O_NONBLOCK instead of what the doc says O_NON_BLOCK

Greetings,

Do you have a bi-directional serial-ethernet bridge sample that operates at 230K Baud?

I appreciate the tip for the thread safe non-blocking.

However, the point of using select is to get away from threads.

Blocking threads do not scale to hundreds of sockets, for example, a web server, so you push all sockets onto the select list.

I am using select for sockets. I have different socket ports representing different services, But what do I do for the serial ports?

I am using non-blocking serial ports now (and non-blocking sockets) however, when I first ran into performance problems, I was reading one character at a time in blocking mode, digi tech support told me to turn on non-blocking mode (in order to ask for more than one character at a time) to increase performance.

I guess I would have to try a definitive test, but I could have sworn that I observed blocking behavior by default, i.e. the last set of bytes never got out because it was less than the requested number of bytes.

Anyway thanks for any tips,

Dave

Mark,

An open(), by default in NET+OS, is a non-blocking operation.

And as you have already stated the proper value is O_NONBLOCK

Cameron

Are you sure this is true. Default is non-blocking?

Yes, but if I were you, I would use select() anyway. It solved several issues for me. Remember to use a thread safe version (see http://www.digi.com/support/forum/viewthread_thread,1408#5221 ).

-Erik

I use a tcgetbuffers() to control my serial I/O - that essentially makes it safely non-blocking no matter what the port is set at.

I also use a NADeltaTicks() to determine if the last I/O was more than three seconds, and if so I do a tcflush(), a tcsendbreak(), and a tcflow() to reset the I/O.

-Erik

P.S. The code is too complex to show it here. There is a lot of other stuff that is done in conjunction (like multiple thread fifos) that complicate my code.

Okay, so suppose you do a tcgetbuffers and there is no data.

What do you do then? Do you sleep(). Or do you continually poll? My concern was using up all the CPU busy waiting.

My email is listed in my profile if you wanted to take this to email.

Thanks in advance,

David

If I have data I process it, otherwise I do a tx_thread_sleep(5). (50 milliseconds)

Do you know what kind of performance you get when sleeping for 50 milliseconds?

Can you get 230K going into the serial port and passed through to the ethernet port?