LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-15-2012, 05:04 AM   #1
dilbert_uk
Member
 
Registered: Aug 2011
Location: Lima, Peru
Distribution: Debian 10.4, xubuntu 20.04, Ubuntu 20.04 LTS
Posts: 83

Rep: Reputation: 4
Testing UART redirection


Hi all,

I want to redirect traffic from one UART to another and I want to see how it is working.

For example,

1)
On an embedded board running busybox, I want to connect to /dev/ttyS0 (the only connector with pins on that board) and redirect to traffic to /dev/ttyS2 (where I can speak to another chip on that board).

I found solutions like this:
/bin/sh < /dev/ttyS0 > /dev/ttyS2 2> /dev/ttyS2 &

but at the moment it doesn't work.

How can test this on that embededded board or on a standard Linux PC?

I had the impression that I once did some simple test like having two xterm windows and doing in one "cat < / dev/ttyS1" and in the other "echo '123' > /dev/ttyS1" and I saw the string "123" appear in the window with the "cat" command.

Somehow that doesn't work not on the board (using two different telnet seesions) nor on the Linux PC.

(I looked after the permissions on thesse device nodes. I changed them with "chmod o+rw /dev/ttyS1" and I used sudo.)

I thought that somehow I got a poor understanding how an xterm window attaches to a tty device. Probably, the redirection works, only the xterm windows don't show it.

Can someone give me some specific reading to what I am probably missing or is there another way to test UART redirection without watching strings in xterm windows?

2)
Second problem is the program "ser2net" where I connect with a telnet session to different tty device nodes. The same thing here. How to test it?

I want to test it simply to know it's working and apply the working redirection solution, script, or program [I did one with open("dev/ttyS0"), read, and write] to the unresponding chip.
 
Old 02-15-2012, 10:07 AM   #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
It is a bit hard to understand exactly what you're trying to accomplish. If I understand correctly, you have some onboard device which 'looks like' serial port /dev/ttyS2. You want to be able to connect to the device from some other actual serial device/terminal by physically connecting to the host's /dev/ttyS0 serial port (an actual serial port), and are looking for some method that transparently relays data between the respective serial ports. If this is not correct, please try to re-phrase your question, and perhaps provide more information about why you want to do this, and the underlying objective.
If this is correct, my best suggestion is either a fairly simple bit of C code to open each port, and perform the data relay through them that way. The existing program, socat, may be able to do this for you, but I'm not sure it works with serial ports.
--- rod.
EDIT: socat does evidently work with serial ports.

Last edited by theNbomr; 02-15-2012 at 10:16 AM.
 
Old 02-15-2012, 11:21 AM   #3
dilbert_uk
Member
 
Registered: Aug 2011
Location: Lima, Peru
Distribution: Debian 10.4, xubuntu 20.04, Ubuntu 20.04 LTS
Posts: 83

Original Poster
Rep: Reputation: 4
Thanks for your reply.

I found actually a method to reset this chip by shortening two pins and inside this chip is a test software with a welcome message that I can read with "cat < /dev/ttyS2".

I am still struggling with my C program and setting parameters with stty but I will give socat a go. Version 2.0.0 didn't compile for my MIPS processor (minor issues with "#if" and "&&" and an unknown definition) but version 1.7.2.0 did compile without problems.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Where does uart console get its value of uart port membase? unifoxz Linux - Kernel 1 12-20-2011 02:28 PM
LPC47M10x UART Niraj Kulkarni Linux - Hardware 0 02-07-2011 04:08 AM
LPC47M10x for UART Niraj Kulkarni Linux - Newbie 0 02-02-2011 03:12 AM
testing UART ports Jurrian Linux - Newbie 5 10-14-2008 08:05 AM
uart pantera Programming 5 05-21-2005 06:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:13 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