LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 03-03-2009, 05:50 PM   #1
dan12345
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Rep: Reputation: 0
echo to ttyS0 not working


Hi,

I am new to linux.
I try to send some data to the ttyS0 from terminal. It seems not working.

I open one terminal, and typed: cat < /dev/ttyS0.
I open the second terminal, and typed: echo hello > /dev/ttyS0.

I did not see "hello" displayed on the first terminal.

Please let me know what is wrong here.

P.S. If I connect my device to the ttys0, I can see data be displayed on the first terminal.

Thanks /dan
 
Old 03-03-2009, 06:22 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Did you try jumpering the TTY Rx & Tx pins? Your TTY is a real device, and so the Tx & Rx channels carry actual data. If the Rx pin has no signal on it, you shouldn't expect to see any data.
--- rod.
 
Old 03-03-2009, 06:51 PM   #3
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
what kind of device/terminal? a wyse terminal or similer device?

serial port 1 is /dev/ttyS0
serial port 2 is /dev/ttyS1
if you have terminal1 connected to serial port1 and and terminal2 connected to serial port2

then
echo "hello" > /dev/ttyS0 will send the data to terminal 1
and
echo "hello" > /dev/ttyS1 will send the data to terminal 2
 
Old 03-03-2009, 09:18 PM   #4
dan12345
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Hi,

My program get the device ( a simulator)data(text data) from ttyS0.
I am trying to send data(using "cat filename > /dev/ttyS0") from the command line(gnome-terminal) to ttyS0, so that the program can use this data sent through "cat" for testing purpose.

However, this does not work. The program can not get the data and I open the gtkTerm on port ttyS0, which does not have any data displayed either.

I used "echo" in my original post to test out data can be sent to ttyS0 from command line.

This is all new to me. Thanks for the help. /dan
 
Old 03-03-2009, 09:45 PM   #5
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
well for starters ttySX devices are usually reserved for physical serial ports which means that unless you get a loopback adapter for your serial port then /dev/ttyS0 is useless
 
Old 03-03-2009, 10:12 PM   #6
dan12345
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Is there any other way to achieve what I need: send text data to a serial port that my program can use for testing?

Thanks /dan
 
Old 03-03-2009, 10:27 PM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Unless your program is written entirely as a shell script, you should read up on serial ports, and the programming of them.
Serial HOWTO
Serial Programming HOWTO

In the short term though, you can achieve somewhat what you are attempting by simply looping back the Tx pin to the Rx pin on the serial port. On a female connector, all you need is a paper clip or short piece of wire. The relevant conductors are normally pins 2 & 3 on a standard 9-pin or 25-pin serial connector (although the roles are typically reversed between the two formats). If this is a USB <==> serial converter, you must first have a suitable Linux driver to support it.

--- rod.
 
  


Reply



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
Cat /dev/ttyS0 not working ToLive Linux - Hardware 2 12-14-2008 01:58 AM
echo $chr(1) > /dev/ttyS0 got error rapsatol Programming 1 03-12-2007 10:26 AM
/dev/ttyS0 on nc6000 not working jthors Linux - Hardware 4 02-26-2007 09:45 AM
ttyS0 not working in upper runlevels The00Dustin Linux - Software 5 03-13-2006 11:37 AM
Trying to get COM (ttyS0) working!! mattp Linux - Hardware 6 10-25-2005 02:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:35 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration