diff options
Diffstat (limited to 'recipes-extended/rxtx/files/usb_38400.patch')
| -rw-r--r-- | recipes-extended/rxtx/files/usb_38400.patch | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/recipes-extended/rxtx/files/usb_38400.patch b/recipes-extended/rxtx/files/usb_38400.patch new file mode 100644 index 0000000..fffe4c5 --- /dev/null +++ b/recipes-extended/rxtx/files/usb_38400.patch | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | From: Jan Niehusmann <jan@gondor.com> | ||
| 2 | Subject: Patch to fix setting USB-serial adapters to 38400 bps | ||
| 3 | Bug-Debian: http://bugs.debian.org/740098 | ||
| 4 | Forwarded: no | ||
| 5 | Description: The following patch should fix the reported issue. | ||
| 6 | . | ||
| 7 | On serial ports not supporting the TIOCGSERIAL/TIOCSSERIAL mechanism, | ||
| 8 | this still means that the custom baud rates do not work, but at least | ||
| 9 | 38400 works, again. | ||
| 10 | . | ||
| 11 | Perhaps an even better fix would be switching to the newer termios2 API, | ||
| 12 | as described here: | ||
| 13 | https://mail.python.org/pipermail/python-list/2012-October/633871.html | ||
| 14 | . | ||
| 15 | That API allows setting custom baud rates on the USB serial adapters I | ||
| 16 | have tested, where TIOCGSERIAL/TIOCSSERIAL was not supported. | ||
| 17 | . | ||
| 18 | But unfortunately, termios2 is not available through glibc, so one would | ||
| 19 | need to call linux-specific ioctls directly, which wouldn't be portable | ||
| 20 | at all, and I don't know how it interacts with the BSD / Hurd ports. | ||
| 21 | . | ||
| 22 | Therefore this is the minimal fix, for now. | ||
| 23 | Upstream-Status: Pending | ||
| 24 | |||
| 25 | --- a/src/SerialImp.c | ||
| 26 | +++ b/src/SerialImp.c | ||
| 27 | @@ -872,10 +872,14 @@ | ||
| 28 | out and select baud rates 38400 then 28800 then 38400, you will get | ||
| 29 | a final baud rate of 28800 because you did not update the divisor. | ||
| 30 | |||
| 31 | + However, if the serial port doesn't support TIOCGSERIAL or custom speeds, | ||
| 32 | + don't fail: In this case, just use B38400 and assume that there is no way | ||
| 33 | + to set a custom speed on this port. | ||
| 34 | + | ||
| 35 | See the next ifdef below for the divisor. | ||
| 36 | */ | ||
| 37 | #if defined(TIOCGSERIAL) | ||
| 38 | - if ( cspeed == B38400 ) | ||
| 39 | + if ( cspeed == B38400 && ioctl( fd, TIOCGSERIAL, &sstruct ) == 0 ) | ||
| 40 | cspeed = 38400; | ||
| 41 | #endif /* TIOCGSERIAL */ | ||
| 42 | if( cfsetispeed( &ttyset, cspeed ) < 0 || | ||
| 43 | @@ -905,10 +909,9 @@ | ||
| 44 | return(1); | ||
| 45 | } | ||
| 46 | sstruct.custom_divisor = ( sstruct.baud_base/cspeed ); | ||
| 47 | - cspeed = B38400; | ||
| 48 | #endif /* TIOCGSERIAL */ | ||
| 49 | - if( cfsetispeed( &ttyset, cspeed ) < 0 || | ||
| 50 | - cfsetospeed( &ttyset, cspeed ) < 0 ) | ||
| 51 | + if( cfsetispeed( &ttyset, B38400 ) < 0 || | ||
| 52 | + cfsetospeed( &ttyset, B38400 ) < 0 ) | ||
| 53 | { | ||
| 54 | /* OK, we tried everything */ | ||
| 55 | report( "nativeSetSerialPortParams: Cannot Set Speed\n" ); | ||
| 56 | @@ -916,8 +919,11 @@ | ||
| 57 | } | ||
| 58 | #if defined(TIOCSSERIAL) | ||
| 59 | /* It is assumed Win32 does this for us */ | ||
| 60 | + /* Ignore errors if the target speed is 38400: In this case, | ||
| 61 | + * just assume TIOCSSERIAL is not supported and custom speeds are | ||
| 62 | + * not available. */ | ||
| 63 | if ( sstruct.baud_base < 1 || | ||
| 64 | - ioctl( fd, TIOCSSERIAL, &sstruct ) < 0 ) | ||
| 65 | + ioctl( fd, TIOCSSERIAL, &sstruct ) < 0 && cspeed != 38400 ) | ||
| 66 | { | ||
| 67 | return( 1 ); | ||
| 68 | } | ||
