TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Microsoft > Microsoft Device Drivers

Determining a virtual COM port of an USB device

Microsoft Device Drivers

 
 
Thread Tools Display Modes
Unread 04-04-2008, 08:33 PM   #1
Dilip
Guest
 
Posts: n/a
Determining a virtual COM port of an USB device

Howdy Gurus

I am not a low-level developer -- more of an application programmer,
so I might've gotten some of my terminology wrong here. Do bear with
me.

We have a USB printer that we use in our application to print receipts
and such. The drivers for this printer also create a virtual COM port
for applications to communicate with it. Is there a way by which I
can enumerate all the devices that are on the USB ports and determine
what virtual COM port # they are sitting on? I know its possible to
blindly open all the available COM ports (virtual or otherwise) one by
one and query the device for its status and determine if its indeed a
printer or not. However I don't want to go down this route because if
by chance another device is sitting on one of the COM ports and I try
to send some printer-specific control characters it kinda messes up
that device.

I did read up a lot of stuff on the internet and even came across this
tiny program that displays all the USB devices connected to your PC --
(beware its a .PDF document containing CPP code)
http://www.intel.com/intelpress/usb/examples/DUSBVC.PDF
I managed to get that code to compile and it even printed information
regarding my printer but I wasn't able to determine its COM port from
that info.

Any way out of this?
 
Unread 04-04-2008, 10:30 PM   #2
chris.aseltine@gmail.com
Guest
 
Posts: n/a
Re: Determining a virtual COM port of an USB device

On Apr 4, 2:59 pm, Dilip <rdil...@lycos.com> wrote:

> We have a USB printer that we use in our application to print receipts
> and such. The drivers for this printer also create a virtual COM port
> for applications to communicate with it. Is there a way by which I
> can enumerate all the devices that are on the USB ports and determine
> what virtual COM port # they are sitting on?


My advice is to drop the idea of looking for COM ports altogether and
look for device interfaces. Use SetupDiEnumDeviceInterfaces() to
enumerate all instances of the COM port GUID (i.e.
{86e0d1e0-8089-11d0-9ce4-08003e301f73}) and then look for your
device's VID and PID in the symbolic link.
 
Unread 04-04-2008, 10:30 PM   #3
Maxim S. Shatskih
Guest
 
Posts: n/a
Re: Determining a virtual COM port of an USB device

Add a proprietary IOCTL to your COM port implementation.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

"Dilip" <rdilipk@lycos.com> wrote in message
news:7b98a98a-0187-4da4-b3a2-6d37f3ab769a@a70g2000hsh.googlegroups.com...
> Howdy Gurus
>
> I am not a low-level developer -- more of an application programmer,
> so I might've gotten some of my terminology wrong here. Do bear with
> me.
>
> We have a USB printer that we use in our application to print receipts
> and such. The drivers for this printer also create a virtual COM port
> for applications to communicate with it. Is there a way by which I
> can enumerate all the devices that are on the USB ports and determine
> what virtual COM port # they are sitting on? I know its possible to
> blindly open all the available COM ports (virtual or otherwise) one by
> one and query the device for its status and determine if its indeed a
> printer or not. However I don't want to go down this route because if
> by chance another device is sitting on one of the COM ports and I try
> to send some printer-specific control characters it kinda messes up
> that device.
>
> I did read up a lot of stuff on the internet and even came across this
> tiny program that displays all the USB devices connected to your PC --
> (beware its a .PDF document containing CPP code)
> http://www.intel.com/intelpress/usb/examples/DUSBVC.PDF
> I managed to get that code to compile and it even printed information
> regarding my printer but I wasn't able to determine its COM port from
> that info.
>
> Any way out of this?


 
Unread 05-04-2008, 05:21 AM   #4
abei
Guest
 
Posts: n/a
Re: Determining a virtual COM port of an USB device

My advice is to enumrate all COM port by COM class GUID then pick up your
device by device name.


"Dilip" <rdilipk@lycos.com>
??????:7b98a98a-0187-4da4-b3a2-6d37f3ab769a@a70g2000hsh.googlegroups.com...
> Howdy Gurus
>
> I am not a low-level developer -- more of an application programmer,
> so I might've gotten some of my terminology wrong here. Do bear with
> me.
>
> We have a USB printer that we use in our application to print receipts
> and such. The drivers for this printer also create a virtual COM port
> for applications to communicate with it. Is there a way by which I
> can enumerate all the devices that are on the USB ports and determine
> what virtual COM port # they are sitting on? I know its possible to
> blindly open all the available COM ports (virtual or otherwise) one by
> one and query the device for its status and determine if its indeed a
> printer or not. However I don't want to go down this route because if
> by chance another device is sitting on one of the COM ports and I try
> to send some printer-specific control characters it kinda messes up
> that device.
>
> I did read up a lot of stuff on the internet and even came across this
> tiny program that displays all the USB devices connected to your PC --
> (beware its a .PDF document containing CPP code)
> http://www.intel.com/intelpress/usb/examples/DUSBVC.PDF
> I managed to get that code to compile and it even printed information
> regarding my printer but I wasn't able to determine its COM port from
> that info.
>
> Any way out of this?
>



 
Unread 05-04-2008, 01:22 PM   #5
chris.aseltine@gmail.com
Guest
 
Posts: n/a
Re: Determining a virtual COM port of an USB device

On Apr 4, 4:41 pm, "Maxim S. Shatskih" <ma...@storagecraft.com> wrote:

> Add a proprietary IOCTL to your COM port implementation.


I think he wants to avoid communicating with unknown devices on the
system altogether. What if a customer's system has a buggy COM port
driver that crashes on unknown IOCTLs?
 
 

Thread Tools
Display Modes



< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 07:13 PM.


vBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2013, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional