Jump to content
Dave Nottage

"Simulating" a com port with data arriving

Recommended Posts

I figured this would be easy..

 

I'm working on an app that needs to read data from a com port - this I have code for. I'm having trouble finding something (that actually works), that can "simulate" data being sent to the port so that it can be read from the app. Simulation is needed because I'm remoting to the machine in question and I'd rather avoid having to (or for someone else to) go to where the machine is to connect a device that might not even be suitable. 

 

I have come across this: https://www.aggsoft.com/com-port-emulator.htm, however I'm unable to work out exactly how it is supposed to emulate (when clicking "Start", it prevents anything else from accessing the port) or it's just not suitable anyway.

 

I used to work on apps over 20 years ago (using Delphi 3) that did this kind of thing, but we had the luxury of having the actual hardware with us. That's about how long it has been since I've done this kind of thing.

 

 

Share this post


Link to post

Com0Com works for me (on Windows XP and 8.1 (haven't tested Windows 7 or 10), or simply a serial null modem cable that connects two serial ports, native or USB serial adapters.

Edited by dummzeuch
  • Like 1

Share this post


Link to post

Com0Com works fine on Windows 10, you need the 64-bit version with code signed driver.  By default it uses alphabetic port names CNCA0 and CNCB0 which some async components don't support (only numeric), but I fixed Async Pro 15 years ago to accept them. 

 

Angus

 

Share this post


Link to post

VMWare workstation will let you do this.

 

Just add two virtual serial ports to the VM, in the field "connection" specify "named pipe".  Both COM ports must use the same name for the named pipe (just call it "serialportpipe") and one port must be configured to be "server", the other must be "client".  That way, the two COM ports are crosswired.

 

Now you can start 2 applications, connect them up to the two COM ports and let them talk to each other.

 

 

  • Like 1
  • Thanks 1

Share this post


Link to post
4 hours ago, A.M. Hoornweg said:

VMWare workstation will let you do this

Thanks I was not aware of this.
But the documentation is somewhat hidden, here I found some older info.

 

@Dave Nottage

Not sure what you need exactly for "simulation", if you mean the remote access then the above recommendations are fine.

Maybe you only want to simulate some test-cases, to check and proof your application code and functionality.

What I use sometimes is a somewhat brute method:

Usually I have a serial component that I know and trust well, so I know its functionality, or I can test this separately in my office.

 

There should be a callback somewhere, which maybe fired in a thread, like EvOnRead and a function for a command to write.

Sometimes, if the connection is not very critical its OK for me to  build a mockup around those core Read/Write functions.
Of coarse timings, baudrate, flow.control, etc. is a little more difficult or even impossible to simulate,
but in the end those callbacks will present the data to me.
I can make stress-tests with the hardware callbacks, to simulate chunked frames, timeouts, etc.

 

For for a basic simulation of read/write flow for the data, such mockup helped me many times.

 

With that approach I'm even able to write a simulation page, in the very same application, send/receive specific commands,

and see how the application reacts to it.

I know its a little crude, but its just an idea. 
Maybe this might be good enough for your case too.

 

Of course there will be the day when you need to move to the real hardware ...

 

 

 

 

 

 

 

 

 

Share this post


Link to post
On 9/29/2020 at 6:09 PM, dummzeuch said:

Com0Com works for me (on Windows XP and 8.1 (haven't tested Windows 7 or 10)

Com0Com works great, thanks! I'm using it on Windows 10.

 

Thanks also to everyone else for replying

 

  • Like 1

Share this post


Link to post
13 hours ago, Dave Nottage said:

Com0Com works great, thanks!

Yup, that is the one I use, too.

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×