Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Setting Baud rate in a serial port

Posted on 2007-03-29
6
Medium Priority
?
608 Views
Last Modified: 2015-06-08
how to setup the baud rate in a serial port in a Linux system?
0
Comment
Question by:ehausltd
  • 2
6 Comments
 
LVL 4

Assisted Solution

by:infleadorix
infleadorix earned 500 total points
ID: 18817876
Something like, stty -F /dev/ttyS0 9600
0
 
LVL 20

Accepted Solution

by:
nedvis earned 500 total points
ID: 18820698
You acctually have to set data flaw ( baud rate )
http://www.tldp.org/HOWTO/Serial-HOWTO-4.html#ss4.5
http://www.tldp.org/HOWTO/Serial-HOWTO.html
You will need setserail tool installed to configure your serial port:
usage:   setserial serial-device -abqvVWz [cmd1 [arg]] ...
               setserial /dev/ttySx port y irq z autoconfig
What you have to define is actually   baud_base   parameter.
baud_base sets the base baud rate, which  is  the  clock  frequency  divided  by 16.  Normally this value is 115200, which is also the fastest baud rate which the UART can support.
--------------------------------------------------------------------------
Type command :
setserial -g /dev/ttyS*
 to get a list of serial devices, and their port and irq assignments.
You can use this list to help you decide which devices are available to use with setserial either because they are unused (they will be listed as "No such device") or because they are configured to a device that is not really there (the UART will be listed as "unknown").

See also :   man setserial
0
 
LVL 20

Expert Comment

by:nedvis
ID: 18820920
If you want to retreive current baud rate for you e.g. serial port know in Windows as COM1 type this command:
setserial -a /dev/ttyS0
It will give you something like this on my computer:
# 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

And if you want to change baud rate type this :

setserial   /dev/ttyS0   Baud_base   38400

NOTE: that uppercase "B" in baud
or type the baud rate you want your port set to.

( valid baud rate values are : 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600 , 19200
38400, 57600, 76800, 115200 )
0
 
LVL 3

Expert Comment

by:brycen
ID: 18987031
When you're just starting, running "minicom" is helpful.  That has an easy console interface, and can help you determine if you're connected to the right port at the right baud rate.  Then start messing with setserial.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month10 days, 1 hour left to enroll

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question