Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-18-2009, 12:11 AM   #1
Registered: Feb 2009
Location: Bangalore
Posts: 61

Rep: Reputation: 15
Serial port reading


I have to write and read from a serial port. Iam able to write
to the port /dev/ttyS1 but not able to read from the same port.
What configuration should I set to enable reading from the port?

Old 05-18-2009, 12:45 AM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
How have you tried reading from the serial port? What have you done to verify that serial data is being sent to the port? What do you know about the incoming serial data (baud, parity, data format, etc)? When you say 'not able to read from the same port', what exactly are you doing to try to read the data? Have you made a loopback connection on the port? Are you using some serial communications software such as minicom, or are you writing your own code? If the latter, posting some sample code (use [code] tags to preserve formatting, please) would be helpful.
More information is required.
--- rod.
Old 05-19-2009, 12:43 AM   #3
Registered: Feb 2009
Location: Bangalore
Posts: 61

Original Poster
Rep: Reputation: 15
I used to minicom and it worked fine. Iam using the same baud rate.
I tried to do a echo $val > /dev/ttyS1. I was able to recive the same back on read.

Old 05-19-2009, 06:54 PM   #4
Jerre Cope
Registered: Oct 2003
Location: Texas (central)
Distribution: ubuntu,Slackware,knoppix
Posts: 323

Rep: Reputation: 37
From perl perspective, something like this:

my $tty_cmd = "stty 9600 cs8 ignpar -echo -echok -icrnl -ixon -ixoff ixany -icanon -opost -onlcr time 12 min 0 <";

open( TTY,"+<",$serial_line ) || die( "open serial line error: $serial_line $?")

Adopt the stty command in linux/unix to suit.


port, serial

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading and Writing to a Serial Port without SU Steef223 Programming 2 06-16-2008 09:16 AM
reading from serial port IC009562 Linux - Software 2 11-08-2007 11:25 PM
Having trouble reading from serial port glo Linux - Newbie 0 02-09-2007 10:42 AM
help reading data from a serial port skydemon Linux - General 1 08-10-2006 08:48 AM
reading data from a serial port mchitrakar Linux - Networking 3 12-04-2004 01:24 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:26 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration