Solved

Setting Baud rate in a serial port

Posted on 2007-03-29
6
506 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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

856 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