Simulate serial port

I am writing a C program on Linux that will read / write to / from the serial port. I know the data that needs to be read and written to the port, but I do not have a serial port to verify this.

Is there a way to simulate a serial port? Would it be enough to read / write to a file? I can write one process to a file, while another process reads this data and writes other data to the file. Or are there other tools you can use to simulate a port?

thanks

+6
c linux serial-port
source share
3 answers

Serial ports on Linux are terminal devices. Close modeling is to create a pseudo-terminal pair; A program that usually talks to the serial port is instead offered to open the slave side of the pseudo-terminal, and the simulator writes and reads from the side of the wizard.

The pty(7) manual page has more information.

+4
source share

Despite the old topic, and my answer is not exactly what the OP was looking for, I decided to share my experience, since someone else could meet it like me. Instead of just simulating, I used software called Serial for Ethernet Connector to access the specific device that I need to test the application. Worked well for me.

+4
source share

A character device, even something as simple as usual, stdin and stdout should work if you don't like the attributes specific to port devices.

0
source share

All Articles