• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1386
  • Last Modified:

Mock serial port communication C#

I have written a c# application designed to receive and send data to and from a COM port. Unfortunately I am awaiting the arrival of the COM device I need to test this application, so what I am looking for is a way to simulate the COM port.

This should allow me to connect to the 'mock' serial port send messages to it and send messages back. I dont want to use a third party application for this if possible - i.e. if I can write a C# application to acheive this that would be ideal as I would need to customise it very heavily.

Whatever the solution is I am sure it will be a new concept for me so a simple solution with a step by step approach would be appreciated!
0
Blowfelt82
Asked:
Blowfelt82
1 Solution
 
käµfm³d 👽Commented:
Without using a 3rd-party emulator, the closest you can get would be to create a new class that exposes the same properties and methods that the SerialPort class exposes. Once your device arrives, simply swap in the SerialPort class for your mock class.

I think an emulator would be more flexible and easier to set up, but if you want to keep it all in .NET, then I think this would be your only recourse.
0
 
Blowfelt82Author Commented:
Ok sounds good, do you have a cose sample of how this might be done? Also out of curiosity what third party tool might you recommend?
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now