0

I have a Raspberry Pi for which I wrote a program that reads and writes to the GPIO serial port (/dev/ttyS0)

I need to run a set of unit tests on the device, sending several commands and reading what the Raspberry replies, so I make sure my program runs correcly.

The difficulty is that I don't want to physically use the serial port for the tests (I have a lot of raspberries and I want to avoid connecting cables to all of them for the test.

The raspberries are connected to the network and I'm accessing them via ssh.

Is there a way I can redirect the serial port communication, so I can send and receive that data from my computer via ethernet?

Like connecting to ssh, but instead of getting the console I want to directly access the serial port

1 Answer 1

2

Check out ttybus which lets you create virtual serial devices which can be attached to physical serial devices or TTYs, e.g. the TTY of your SSH session.

Alternatively, rewrite your program to work with stdin/stdout and connect it to serial devices, regular files or pipes using input redirection (program >/dev/ttyS0 <&1).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.