[ale] setting non-standard baud rate on serial port

Steven A. DuChene linux-clusters at mindspring.com
Tue Apr 26 18:09:48 EDT 2011


OK, but the program I am running to do this is a windows program I am trying to run in Linux with Wine and it is just going to read from the serial port. I don't believe there is anyway to tell it to open the port at 38400 which from what I understand from the info I have read on this spd_cust & divisor flag is necessary. I.E. if I am understanding what I have read from the doc on setserial, it tricks the system into using the baud_base / divisor to calculate the baud rate when the app requests 38400.

Or am I misunderstanding the stuff I have read on setserial?

-----Original Message-----
>From: Byron Jeff <byronjeff at mail.clayton.edu>
>Sent: Apr 26, 2011 3:33 PM
>To: "Steven A. DuChene" <linux-clusters at mindspring.com>, Atlanta Linux Enthusiasts <ale at ale.org>
>Subject: Re: [ale] setting non-standard baud rate on serial port
>
>On Tue, Apr 26, 2011 at 05:31:47PM -0400, Steven A. DuChene wrote:
>> I have an automotive diagnostic device that seems to only want to communicate
>> across the serial port at a baud rate of 8192 which is a non-standard baud rate.
>> When I try to use setserial or stty to set this baud rate on the port both
>> programs tell me "Invalid Argument"
>> 
>> stty -F /dev/ttyS0 8192
>> stty: invalid argument `8192'
>> Try `stty --help' for more information.
>> 
>> Anyone have any idea how to set baud rate on a serial port to a non-standard baud rate like this?
>
>It took a minute for me to remember how to do this. The command you need is
>setserial. It configures your serial port from the command line.
>
>The trick setserial used was to replace the standard 38400 BPS rate with a
>one of a set of nonstandard bit rates. These include:
>
>	  spd_hi        use 56kb instead of 38.4kb
>          spd_vhi       use 115kb instead of 38.4kb
>          spd_shi       use 230kb instead of 38.4kb
>          spd_warp      use 460kb instead of 38.4kb
>          spd_cust      use the custom divisor to set the speed at 38.4kb
>                                (baud rate = baud_base / custom_divisor)
>          spd_normal    use 38.4kb when a baud rate of 38.4kb is selected
>
>It's the spd_cust that you are interested in. It will take the base speed
>of the UART and divide it by a custom divider. I just ran setserial on a
>local serial port and got this:
>
>$ setserial -a /dev/ttyS0
>/dev/ttyS0, Line 0, UART: 16550A, Port: 0x03f8, IRQ: 4
>Baud_base: 115200, close_delay: 50, divisor: 0
>closing_wait: 3000
>Flags: spd_normal skip_test
>
>So the Baud_base is 115200. Quick calcuation:
>
>$ bc
>bc 1.06.95
>Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation,
>Inc.
>This is free software with ABSOLUTELY NO WARRANTY.
>For details type `warranty'. 
>scale=5
>115200/8192
>14.06250
>
>setserial has a divisor command to set the divisor. So if the divisor is
>set to 14 the speed will be 115200/14 = 8228 BPS. Another quick
>calculation:
>
>8228/8192
>1.00439
>
>Any bit rate that's within 2 percent of nominal generally will work. With
>the error here being less than 0.5 percent, it should work like a champ.
>
>Hope this helps. It's been 10 years since I've looked at setserial. I used
>it to talk to one of my modems at 230 Kb/s
>
>BAJ
>
>
>
>> --
>> Steven DuChene
>> 
>> 
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>
>-- 
>Byron A. Jeff
>Department Chair: IT/CS/CNET
>College of Information and Mathematical Sciences
>Clayton State University
>http://cims.clayton.edu/bjeff





More information about the Ale mailing list