Solved

Setting Baud rate in a serial port

Posted on 2007-03-29
6
518 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SonarQube on Linux vs Windows 3 82
linux SFTP 8 82
expand ext4 on centos 6 5 57
database connection error mysql stops 7 38
How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

696 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