nonblocking write(2) 512K to /dev/ttyS0

B

Bernhard Kuemel

Hi clc!

Can I write(2) much data (512K) to /dev/ttyS0 on Linux without blocking?
I want to be able to abort/flush the write if the microcontroller which
receives the data reports an error.

At first I planned to write byte wise, but select_tut recommends against
this [1] ... although at 115200 bps this might be acceptable. If I write
byte wise, how long could write() block once the buffer filled up? Until
a character has been transmitted, or is there a hysteresis?

Also I could try to abort/flush the write if a signal handler receives
the error. I would, however, like to keep the program simple, for the
moment.

Thanks, Bernhard

[1]
6. Never read/write only in single bytes at a time unless you
are really sure
that you have a small amount of data to process. It is
extremely inefficient
not to read/write as much data as you can buffer each time.
The buffers in
the example below are 1024 bytes although they could easily
be made larger.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top