Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I would like to know what techniques are there to determine if a port is connected to a device and not to a serial port emulator .
Is it possible to check the timing of the data arrivals and determine if it from the device or not .. ??

What I have tried:

I couldn't try anything else but check the data arrival times but that yielded nothing .
Posted
Updated 1-May-16 21:31pm

If a device is connected you can communicate using the device specific protocol. If this fails, there is no device connected or it is a different kind of device.

What do you mean by serial port emulator?

If you mean a kind of software that emulates a specific device you can usually not determine by communication and timing if a software emulation or a real device is used because the goal of such emulators is to simulate the behaviour of a real device including the timings.

Or do you refer to a converter like an USB to serial converter?

In both cases (software emulator and converter) you can query the system information for the serial port to check if it is a "real" port or a virtual one. The CodeProject article A Useful WMI Tool & How To Find USB to Serial Adaptors[^] provides an example application to query the information which can be used to decide if a port is "real" or virtual.

The above uses WMI to query the information. See c# - How to open a serial port by friendly name? - Stack Overflow[^] for a solution using the SetupAPI. The SPDRP_SERVICE property will contain "Serial" for physical ports and other strings for virtual ones.
 
Share this answer
 
Serial port is not designed to support any kind of check up. You can only check up that a computer's serial port is not connected to certain kind of device which would support some well-defined response to certain well-defined input.

Timing, strictly speaking, is also not a remedy, because an emulator, too, can support some timing which would mimic quite realistic behavior. I don't think you should even pose the problem this way. If you use the emulator in your product, supply the emulator which behave in certain way different from the behavior of your device. Unfortunately, I don't know your working scenarios to advise something more concrete, but the main idea is that you cannot protect your product from a totally unreasonable behavior of a customer anyway, but you can devise a way to protect from random mistakes.

—SA
 
Share this answer
 
Comments
CPallini 2-May-16 3:21am    
5.
Sergey Alexandrovich Kryukov 2-May-16 3:26am    
Thank you, Carlo.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900