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

Discussion in 'C Programming' started by Bernhard Kuemel, May 30, 2010.

  1. 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.
     
    Bernhard Kuemel, May 30, 2010
    #1
    1. Advertising

  2. Bernhard Kuemel

    Eric Sosman Guest

    On 5/30/2010 10:08 AM, Bernhard Kuemel wrote:
    > Hi clc!
    >
    > Can I write(2) much data (512K) to /dev/ttyS0 on Linux without blocking?
    >[...]


    Try comp.unix.programmer or a Linux forum.

    --
    Eric Sosman
    lid
     
    Eric Sosman, May 30, 2010
    #2
    1. Advertising

  3. Eric Sosman wrote:
    > On 5/30/2010 10:08 AM, Bernhard Kuemel wrote:
    >> Hi clc!
    >>
    >> Can I write(2) much data (512K) to /dev/ttyS0 on Linux without blocking?
    >> [...]

    >
    > Try comp.unix.programmer or a Linux forum.


    Thanks.
     
    Bernhard Kuemel, May 30, 2010
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KimTaehwan

    setSoTimeout in nonblocking mode?

    KimTaehwan, Nov 16, 2003, in forum: Java
    Replies:
    0
    Views:
    1,152
    KimTaehwan
    Nov 16, 2003
  2. nonblocking sockets

    , Apr 7, 2006, in forum: Java
    Replies:
    2
    Views:
    1,112
    Gordon Beaton
    Apr 8, 2006
  3. Peter Ammon

    nonblocking read()

    Peter Ammon, Nov 16, 2004, in forum: Python
    Replies:
    3
    Views:
    583
    Donn Cave
    Nov 17, 2004
  4. anki
    Replies:
    3
    Views:
    327
  5. Mohammed Gad
    Replies:
    0
    Views:
    110
    Mohammed Gad
    Oct 31, 2008
Loading...

Share This Page