avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avrdude-dev] [patch #5008] Patch for (5.1) ser_posix.c for O_NONBLOCK o


From: anonymous
Subject: [avrdude-dev] [patch #5008] Patch for (5.1) ser_posix.c for O_NONBLOCK open and restoring serial port state on close
Date: Mon, 3 Apr 2006 21:18:13 +0000
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1

URL:
  <http://savannah.nongnu.org/patch/?func=detailitem&item_id=5008>

                 Summary: Patch for (5.1) ser_posix.c for O_NONBLOCK open and
restoring serial port state on close
                 Project: AVR Downloader/UploaDEr
            Submitted by: None
            Submitted on: Monday 04/03/06 at 21:18 UTC
                Category: None
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: address@hidden
             Open/Closed: Open

    _______________________________________________________

Details:

The attached patch for ser_posix.c (from the avrdude-5.1 distribution) does
the following things, all of which I consider to be improvements <g>:

* Adds the O_NONBLOCK flag to the open arguments. I (and others) have found
that this prevents blocking at open using certain USB to serial adapters. The
problem is that if the CLOCAL flag happens to be clear (previously, which we
have no control over), then the open will wait (forever, on the jtagmkII) for
the carrier detect.

This won't affect reads or writes, because we're using select() to wait till
the fd is ready to read or write.

* Saves the original termios structure, before we start modifying it from
ser_open().
* Restores the original termios structure at ser_close() time.

* Changes the printf spec for "long baud" in serial_baud_lookup() to be "%ld"
instead of "%d"

* Factors reporting of strerror(errno) out of ser_setspeed(); we're already
returning a value of -errno, so we can just call strerror() once, in
ser_open() where we see that ser_setspeed returned with an error code.

* Ensures that if we try to open a non-tty that we get an explanatory error
message ("inappropriate ioctl for device").

* Ensures that the termios structure is properly set to raw mode by calling
cfmakeraw() instead of trying to set individual struct fields manually.

* Makes sure that the CSIZE bits in the termios.c_cflag are all reset before
or'ing CS8 into them.

* Adds TCSAFLUSH to the tcsetattr() call in ser_setspeed() to throw away any
pending input garbage

* Adds TCSADRAIN to the tcsetattr() call in ser_close() to wait for output to
complete before changing data rate and other flags.






    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Monday 04/03/06 at 21:18 UTC  Name: patch-ser_posix.c  Size: 3KB   By:
None
the patch.
<http://savannah.nongnu.org/patch/download.php?file_id=9700>

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?func=detailitem&item_id=5008>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]