LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

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

Rep: Reputation: 15
Serial port reading


Hi,

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?

Thanks,
Dhanesh.
 
Old 05-18-2009, 01:45 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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, 01:43 AM   #3
jayadhanesh
Member
 
Registered: Feb 2009
Location: Bangalore
Posts: 61

Original Poster
Rep: Reputation: 15
Hi,
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.

Thanks,
Dhanesh.
 
Old 05-19-2009, 07:54 PM   #4
Jerre Cope
Member
 
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.
 
  


Reply

Tags
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 10:16 AM
reading from serial port IC009562 Linux - Software 2 11-09-2007 12:25 AM
Having trouble reading from serial port glo Linux - Newbie 0 02-09-2007 11:42 AM
help reading data from a serial port skydemon Linux - General 1 08-10-2006 09:48 AM
reading data from a serial port mchitrakar Linux - Networking 3 12-04-2004 02:24 PM


All times are GMT -5. The time now is 10:21 PM.

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