[clue] [TECH] setting the baud rate on a USB serial port

Jim Ockers ockers at ockers.net
Mon Mar 28 16:57:04 MDT 2011


Hi CLUEbies,

I'm back in Colorado, yay.  But I'm on the Western Slope so not sure I 
can be physically present at many meetings.

Hey I'm having some trouble with qcserial and setting the baud rate.  
The ioctl() fails.  I'm using OpenWRT Backfire and kernel version "Linux 
OpenWrt 2.6.32.27 #1 Mon Mar 28 12:05:44 MDT 2011 armv5teb GNU/Linux".

The device/module chain to load this serial device driver is usbcore -> 
usbserial -> usb_wwan -> option -> qcserial

The kernel dmesg when those modules are loaded is:
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
USB Serial support registered for Qualcomm USB modem
qcserial 1-2:1.1: Qualcomm USB modem converter detected
usb 1-2: Qualcomm USB modem converter now attached to ttyUSB0
usbcore: registered new interface driver qcserial

I don't get the /dev/ttyUSB0 device until AFTER the qcserial driver is 
loaded.  The problem is that the port is set to 9600 baud and this can't 
be changed.  The ioctl() doesn't work, see strace output below.  I'm 
trolling through the modules code to try to figure out where the stty 
ioctl TCSETSW is supposed to be handled and it's quite convoluted.  Do 
any of you know or have any ideas?

Here is the stty output:

root at OpenWrt:~#   stty -F /dev/ttyUSB0 -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; 
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z;
rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon 
-ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 
vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop 
-echoprt echoctl echoke

Here's 2 attempts to change the baud rate:

root at OpenWrt:~#   stty -F /dev/ttyUSB0 speed 38400
9600
stty: /dev/ttyUSB0: unable to perform all requested operations
root at OpenWrt:~#   stty -F /dev/ttyUSB0 speed 38400
9600
stty: /dev/ttyUSB0: unable to perform all requested operations

Here's the part of the strace output showing the ioctl TCSETSW returns 
zero (success) but the TCGETS right after shows that the baud rate is 
still B9600.  Every baud rate other than 9600 fails the same way, I 
tried them all.  I guess I can have any baud rate I want as long as it's 
9600 baud.  Unfortunately I have 10MB of data (gobi chipset files) that 
I need to write to the USB serial port and it all takes a veeerrrryy 
long time at 9600 baud.

open("/dev/ttyUSB0", O_RDONLY|O_NONBLOCK|O_LARGEFILE) = 3
dup2(3, 0)                              = 0
close(3)                                = 0
fcntl64(0, F_GETFL)                     = 0x20800 (flags 
O_RDONLY|O_NONBLOCK|O_LARGEFILE)
fcntl64(0, F_SETFL, O_RDONLY|O_LARGEFILE) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 opost isig icanon echo 
...}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=59, ws_col=143, ws_xpixel=1001, 
ws_ypixel=826}) = 0
write(1, "9600\n", 59600
)                   = 5
ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B115200 opost isig icanon echo 
...}) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 opost isig icanon echo 
...}) = 0
write(2, "stty", 4stty)                     = 4
write(2, ": ", 2: )                       = 2
write(2, "/dev/ttyUSB0", 12/dev/ttyUSB0)            = 12
write(2, ": unable to perform all requeste"..., 44: unable to perform 
all requested operations) = 44
write(2, "\n", 1

What should I do or what could I try to make my USB serial port be more 
fasterer? :) Thanks for any ideas.

Jim

-- 
Jim Ockers, P.Eng. (ockers at ockers.net)
Contact info: http://www.ockers.net/msi.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cluedenver.org/pipermail/clue/attachments/20110328/0d0c2ff7/attachment.html 


More information about the clue mailing list