1
\$\begingroup\$

This s a newbie question.

When receiving serial data from a microcontroller by a PC program I need the microcontroller to be nearby and it needs to be connected to a USB port and send the data via this USB port to the PC program.

But I want to send and test a PC program by a virtual port program which sends data to a specified port without a microcontroller is around. So one can test the received data by a PC program without an actual device sending data to the PC.

How is it done? Is there such emulator program electrical engineers use?

I know how to use hyperTerminal but it is used for sending or receiving data from a real device like a microcontroller.

\$\endgroup\$
11
  • \$\begingroup\$ Is it possible to send data by a software virtual port to another program? \$\endgroup\$
    – GNZ
    Mar 14 '18 at 19:37
  • \$\begingroup\$ Divide the problem in two subproblems: receiving data from the mcu, doing stuff with that data. The first part should be trivial to do. The second part is probably what you actually want to test. Divide your software so that it does the two parts indipendently. Then test each part with ad hoc tests or procedures. \$\endgroup\$
    – Lelesquiz
    Mar 14 '18 at 19:45
  • \$\begingroup\$ I want two PC programs to communicate each other through a virtual port. On one side hyperTerminal sending data, on the other side another program like MATLAB or Python will receive this data. But I need to create a virtual port I guess. I don't have any experience with this kind of use. \$\endgroup\$
    – GNZ
    Mar 14 '18 at 19:49
  • \$\begingroup\$ There are two options here. One is to send data out of one real USB port back into another. This needs a device with a micro in it to but you don't have to develop one you can buy one. Option 2 is a fully software virtual port which may exist. I'm not sure but you need to be asking on a programming site for your OS of choice. I'm guessing you are a Windows user so SuperUser may be a starting point. \$\endgroup\$ Mar 14 '18 at 19:50
  • 3
    \$\begingroup\$ Did you google "virtual COM port"? I found this in 10 seconds: com0com.sourceforge.net. Looks like what you want. \$\endgroup\$
    – dim
    Mar 14 '18 at 19:56
2
\$\begingroup\$

I have used Com0COM

But, there is nothing wrong with getting two USB serial adaptors and connecting them with a null-modem plug. (from the same place that sells the usb-serial). The Com0COM / Virtual serial port can take 10x longer to actually get working sometimes, and you just wish you had used wires (which are also a cross-platform solution)

If you are using binary data, Realterm may be more useful than hyperterm. It is good for sending your test data, and displaying binary data.

If your task is along the data collection lines, then you might consider making your program capture serial data to file, and process data from the file. This makes development very easy, and when there are problems, it is very easy to debug as the serial comms has always been captured in a file.

\$\endgroup\$
1
  • \$\begingroup\$ I got how it is done now. You create two virtual ports COM1 and COM2. Then this virtual port program will stay open. Then you open two other programs to communicate and set their baud rates ect properly. It works that way. \$\endgroup\$
    – GNZ
    Mar 14 '18 at 20:24
0
\$\begingroup\$

I did development without the final hardware by simply connecting two USB<->UART cables together. A piece of software was connected to the first port, another software module to the second.

I also did that with USB<->RS-485 cables to simulate a bus with many devices.

It saved me countless debug hours, because it was much easier to compile and run 3 instances of the communication code simulating the device network, than to flash and set up 3 boards.

The communication code had an abstraction layer so that it could run on a PC and on a microcontroller.

\$\endgroup\$
0
\$\begingroup\$

Well, if you need to use 2 programs to access the same COM port or 2 COM ports to the program, then you need a serial splitter for such actions. You need to choose either split or join.

You create virtual COM ports and can create the connection you need and use the terminal to check the correctness of data transfer.

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ Please list your affiliation with serial splitter.com (it's spam if your affiliation is NOT listed. You can post answers with links to commercial sites, but your affiliation must be listed and the answer must be a valid answer for the question) Thanks \$\endgroup\$
    – Voltage Spike
    Aug 10 '21 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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