Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulate serial port

I am writing a C program in Linux which will read/write to/from a serial port. I know the data that needs to be read and written on the port but I don't have a serial port to currently test this with.

Is there any way to simulate a serial port? Would reading/writing to a file be sufficient? I can have one process write to the file while another process reads that data and writes back other data to the file. Or are there others tools that can be used to simulate a port?

Thanks

like image 919
Trevor Avatar asked Aug 11 '10 11:08

Trevor


People also ask

How do you emulate a serial port?

Download Virtual Serial Port Driver on your Windows machine. Install the application on your system and launch it. Choose “Pair” in the application's main window. Click the “Add a new pair” button to create a pair of virtual serial ports.

How do I create a virtual COM port?

In the device “Properties”, open the “Advanced” tab and check whether the “Load VCP” option is enabled. Then, click OK. Unplug your USB device and connect it to your PC again. Now your operating system should be able to recognize the device, and Virtual COM Port Driver should be loaded.

What is virtual serial port emulator?

Virtual Serial Port Emulator allows you to create an unlimited number of virtual COM ports. The software emulates serial port functionality connected by virtual null modem cable in such a way that the system does not see the difference between virtual and real hardware ports.


2 Answers

Serial ports on Linux are terminal devices. A close simulation is to create a pseudo-terminal pair; the program that normally talks to the serial port is instead told to open the slave side of the pseudo-terminal, and the simulator writes and reads from the master side.

The pty(7) man page has more information.

like image 199
caf Avatar answered Sep 19 '22 17:09

caf


Despite being an old topic, and my answer is not exactly something the OP was looking for, I decided to share my experience, as someone else might come across it like I did. Instead of straightforward simulation, I used the software called Serial to Ethernet Connector to gain access to the specific device I needed to test the app with. Worked nicely for me.

like image 41
Seth Garey Avatar answered Sep 18 '22 17:09

Seth Garey