Serial Port Complete - Latest Microcontroller projects

(lily) #1

Chapter 3


   "
 !"
A device interface GUID identifies devices that applications can access in the
same way. During device installation, a driver registers the device as an instance
of a device interface class and associates a symbolic link name with the device.
The device interface GUID used by internal serial ports is
GUID_DEVINTERFACE_COMPORT defined in ntddser.h. (Some older
software uses GUID_CLASS_COMPORT instead.) The symbolic link name
has the form COM<n>, where n is a unique number.
Applications can use SetupDi API functions to retrieve the symbolic link names
of all ports whose drivers have registered the port using
GUID_DEVINTERFACE_COMPORT. Applications that use the .NET
Framework and other programming tools typically use higher-level functions to
find ports and thus don’t need to use the GUID directly.


 



  • 4 


Windows provides a COM-port database that helps ensure a unique number
for each port. Application programming interface (API) functions provide a
way for applications to claim and release port numbers. (See the pnpports exam-
ple in the WDK for example code.) Uninstalling a port from within the Device
Manager releases the port number for use by other port hardware.
To prevent unwanted “COM-port proliferation,” include a serial number in a
string descriptor in any USB virtual COM port you design. A device that con-
tains a serial number retains its COM-port number even if moved to a different
USB port on the system. A device that doesn’t contain a serial number gets a
new port number on each attachment to a different port on the system. (Two
devices with identical USB descriptors and no serial numbers will get the same
COM-port number if they attach to the same port at different times.) Chapter
16 has more about storing serial numbers in USB devices.

*
 


Windows uses INF files to match a device setup class to a device. Devices in the
Ports class use the INF file msports.inf (in WINDOWS\inf), which contains the
device setup GUID for the Ports class. A USB virtual COM-port device must
also have a device-specific INF file as explained in Chapter 16.
Free download pdf