Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.