patchAVR Downloader/UploaDEr - Patches: patch #5008, Patch for (5.1) ser_posix.c for...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #5008: Patch for (5.1) ser_posix.c for O_NONBLOCK open and restoring serial port state on close

Submitter:  None
Submitted:  Mon 03 Apr 2006 09:18:13 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  joerg_wunsch Originator Email:  -email is unavailable-
Open/Closed:  Closed

Mon 03 Apr 2006 09:18:13 PM UTC, original submission:  

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.


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #9700:  patch-ser_posix.c added by None (3KiB - text/plain - the patch.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 4 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2006-08-28 joerg_wunsch StatusNone Done
    Assigned toNone joerg_wunsch
    Open/ClosedOpen Closed
2006-04-03 None Attached File- Added patch-ser_posix.c, #9700

Back to the top

Powered by Savane 3.13-d3ae.
Corresponding source code