LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   echo to ttyS0 not working (https://www.linuxquestions.org/questions/linux-newbie-8/echo-to-ttys0-not-working-708935/)

dan12345 03-03-2009 05:50 PM

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

theNbomr 03-03-2009 06:22 PM

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.

frieza 03-03-2009 06:51 PM

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

dan12345 03-03-2009 09:18 PM

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

frieza 03-03-2009 09:45 PM

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

dan12345 03-03-2009 10:12 PM

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

theNbomr 03-03-2009 10:27 PM

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.


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