Solved

Setting Baud rate in a serial port

Posted on 2007-03-29
6
449 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 125 total points
ID: 18817876
Something like, stty -F /dev/ttyS0 9600
0
 
LVL 20

Accepted Solution

by:
nedvis earned 125 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now