Solved

Mock serial port communication C#

Posted on 2013-12-12
2
1,225 Views
Last Modified: 2014-04-22
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
Comment
Question by:Blowfelt82
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39715823
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
 

Author Comment

by:Blowfelt82
ID: 39715908
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
This article outlines why you need to choose a backup solution that protects your entire environment – including your VMware ESXi and Microsoft Hyper-V virtualization hosts – not just your virtual machines.
Teach the user how to edit .vmx files to add advanced configuration options Open vSphere Web Client: Edit Settings for a VM: Choose VM Options -> Advanced: Add Configuration Parameters:
Advanced tutorial on how to run the esxtop command to capture a batch file in csv format in order to export the file and use it for performance analysis. He demonstrates how to download the file using a vSphere web client (or vSphere client) and exp…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question