2

I have a c# app that connects pc to a device, through a serial port.

When I send data to the device, if the device sends data back, the datareceived event fires.

And I want to ask this. Is there a way to simulate the data sending of the device?

I mean, i want to fire datareceived event not only when the device send data.

Is this possible?

menjaraz
  • 7,551
  • 4
  • 41
  • 81
sgkin
  • 113
  • 2
  • 7

1 Answers1

3

You must have an additional free serial port.

If need be, you may:

  • just add another new one or
  • install a virtual COM port solution (such as com0com).

You can harness your C# program using a software emulator of the device through Null modem.

menjaraz
  • 7,551
  • 4
  • 41
  • 81
  • Thanks for the reply. I took a quick look at the com0com, but i dont think its what i want. What i want is if it is possible through my code to simulate the datareceiving from a device. For example I have one app and when i press a button, this app simulates the data sending from a serial port, in order to fire SerialPort.DataReceived that exists in another app. – sgkin Dec 17 '11 at 09:24
  • That's what emulator are for. It's supposed to emulate the device. In your usecase, communication is made through serial port and using com0com is just another way to emulate a serial port if you don't have another extra one. Otherwise, how could you fire a *serial* DataReceived event ? – menjaraz Dec 17 '11 at 09:36
  • Yes, you were right. I had it different in my mind. When i read it more carefully, i found the solution. Thanks – sgkin Dec 19 '11 at 09:26
  • Glad to help you. As you are a fresh beginner on Stackoverflow, I remind you that you may accept the answer by clicking on the rigth button (whose icon is like a tickmark). Take time to visit all sections of the [FAQ](http://stackoverflow.com/faq). It helps you a lot to make plenty of progress. – menjaraz Dec 19 '11 at 09:45
  • I'll take a look at FAQ's. Let me ask you one more question. I'ce created a pair of virtual COMs, to use to my app. When i created them, i can use them without problem. But when i restart my pc, the app gives me an error that COM port doesnot exits. Why is this happening? – sgkin Dec 19 '11 at 10:06
  • I did not have trouble at all trying Com0Com 6 months ago: It is a kernel-mode virtual serial port driver for Windows. Installing must be made carefully. You must observe a strict adherence to what is said in the ReadMe.txt (see Install & FAQs & HOWTOs sections). Uninstall it and try again. – menjaraz Dec 20 '11 at 07:31