I am attempting to interface to a piece of equipment which
provides serial port emulation via its driver for USB. When it
is plugged into different USB ports, it appears at different
com port addresses - i.e. COM8: or COM12: (on my machine).

I have two specific quistions:

1) How do I open a COM port greater than COM9:? When I try to use the
recommended procedure (open as a file), it fails if the COM port number
is greater than 9.

2) How do I find which COM port number the device is connected to?
It manifests as a modem, and has a specific device name which I can
see in Hardware Manager. If I examine the advanced port properties,
I can see which COM port number it has assigned. I need to find the
device by name (or see if it's not there). How do I do this?

I am using Visual Studio 2005 and writing in ANSI C.

Thanks,

--
Al Jewer
Alcomp, Inc

Re: Interfacing to Com port driver by Maxim

Maxim
Mon Jul 31 15:33:15 CDT 2006

> 1) How do I open a COM port greater than COM9:? When I try to use the
> recommended procedure (open as a file), it fails if the COM port number
> is greater than 9.

\\.\COM10

> 2) How do I find which COM port number the device is connected to?
> It manifests as a modem, and has a specific device name which I can
> see in Hardware Manager. If I examine the advanced port properties,

You can enumerate all modems via SetupDiGetClassDevs.

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


RE: Interfacing to Com port driver by alcompinc

alcompinc
Mon Jul 31 15:53:02 CDT 2006

Thanks! Do you know where I can find example
code using this technique? (SetupDiGetClassDevs).

--
Al Jewer
Alcomp, Inc



"alcompinc" wrote:

> I am attempting to interface to a piece of equipment which
> provides serial port emulation via its driver for USB. When it
> is plugged into different USB ports, it appears at different
> com port addresses - i.e. COM8: or COM12: (on my machine).
>
> I have two specific quistions:
>
> 1) How do I open a COM port greater than COM9:? When I try to use the
> recommended procedure (open as a file), it fails if the COM port number
> is greater than 9.
>
> 2) How do I find which COM port number the device is connected to?
> It manifests as a modem, and has a specific device name which I can
> see in Hardware Manager. If I examine the advanced port properties,
> I can see which COM port number it has assigned. I need to find the
> device by name (or see if it's not there). How do I do this?
>
> I am using Visual Studio 2005 and writing in ANSI C.
>
> Thanks,
>
> --
> Al Jewer
> Alcomp, Inc
>

Re: Interfacing to Com port driver by Gary

Gary
Mon Jul 31 16:01:39 CDT 2006

Check the DevCon source in the DDK.

The personal opinion of
Gary G. Little

"alcompinc" <alcompinc@discussions.microsoft.com> wrote in message
news:236B9CBF-851B-41D2-B3FE-D26568BE09F9@microsoft.com...
> Thanks! Do you know where I can find example
> code using this technique? (SetupDiGetClassDevs).
>
> --
> Al Jewer
> Alcomp, Inc
>
>
>
> "alcompinc" wrote:
>
>> I am attempting to interface to a piece of equipment which
>> provides serial port emulation via its driver for USB. When it
>> is plugged into different USB ports, it appears at different
>> com port addresses - i.e. COM8: or COM12: (on my machine).
>>
>> I have two specific quistions:
>>
>> 1) How do I open a COM port greater than COM9:? When I try to use the
>> recommended procedure (open as a file), it fails if the COM port number
>> is greater than 9.
>>
>> 2) How do I find which COM port number the device is connected to?
>> It manifests as a modem, and has a specific device name which I can
>> see in Hardware Manager. If I examine the advanced port properties,
>> I can see which COM port number it has assigned. I need to find the
>> device by name (or see if it's not there). How do I do this?
>>
>> I am using Visual Studio 2005 and writing in ANSI C.
>>
>> Thanks,
>>
>> --
>> Al Jewer
>> Alcomp, Inc
>>



Re: Interfacing to Com port driver by Doron

Doron
Mon Jul 31 20:32:39 CDT 2006

this syntax will also work for com ports < COM10, e.g. \\.\COM1, so you
don't have to special case any names or ranges.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Maxim S. Shatskih" <maxim@storagecraft.com> wrote in message
news:%23tBtPCOtGHA.3912@TK2MSFTNGP03.phx.gbl...
>> 1) How do I open a COM port greater than COM9:? When I try to use the
>> recommended procedure (open as a file), it fails if the COM port number
>> is greater than 9.
>
> \\.\COM10
>
>> 2) How do I find which COM port number the device is connected to?
>> It manifests as a modem, and has a specific device name which I can
>> see in Hardware Manager. If I examine the advanced port properties,
>
> You can enumerate all modems via SetupDiGetClassDevs.
>
> --
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> maxim@storagecraft.com
> http://www.storagecraft.com
>



Re: Interfacing to Com port driver by alcompinc

alcompinc
Mon Jul 31 21:38:01 CDT 2006

OK, I checked out the source code, and found an instance of
SetupDiGetClassDevsEx(.....
Digesting over 100K of largly incomprehensible code seems like
a bit much for what I need to do - I only need to find the COM port
number of a named device. Is there an easier way?

--
Al Jewer
Alcomp, Inc



"Gary G. Little" wrote:

> Check the DevCon source in the DDK.
>
> The personal opinion of
> Gary G. Little
>
> "alcompinc" <alcompinc@discussions.microsoft.com> wrote in message
> news:236B9CBF-851B-41D2-B3FE-D26568BE09F9@microsoft.com...
> > Thanks! Do you know where I can find example
> > code using this technique? (SetupDiGetClassDevs).
> >
> > --
> > Al Jewer
> > Alcomp, Inc
> >
> >
> >
> > "alcompinc" wrote:
> >
> >> I am attempting to interface to a piece of equipment which
> >> provides serial port emulation via its driver for USB. When it
> >> is plugged into different USB ports, it appears at different
> >> com port addresses - i.e. COM8: or COM12: (on my machine).
> >>
> >> I have two specific quistions:
> >>
> >> 1) How do I open a COM port greater than COM9:? When I try to use the
> >> recommended procedure (open as a file), it fails if the COM port number
> >> is greater than 9.
> >>
> >> 2) How do I find which COM port number the device is connected to?
> >> It manifests as a modem, and has a specific device name which I can
> >> see in Hardware Manager. If I examine the advanced port properties,
> >> I can see which COM port number it has assigned. I need to find the
> >> device by name (or see if it's not there). How do I do this?
> >>
> >> I am using Visual Studio 2005 and writing in ANSI C.
> >>
> >> Thanks,
> >>
> >> --
> >> Al Jewer
> >> Alcomp, Inc
> >>
>
>
>

Re: Interfacing to Com port driver by alcompinc

alcompinc
Mon Jul 31 22:10:02 CDT 2006

OK, stupid me. I can open a named device by doing a
CreateFile("\\.\<DeviceName>"....
It would be so great if this were better documented......

Thanks to all who responded, I finally tumbled to the answer....

--
Al Jewer
Alcomp, Inc



"alcompinc" wrote:

> OK, I checked out the source code, and found an instance of
> SetupDiGetClassDevsEx(.....
> Digesting over 100K of largly incomprehensible code seems like
> a bit much for what I need to do - I only need to find the COM port
> number of a named device. Is there an easier way?
>
> --
> Al Jewer
> Alcomp, Inc
>
>
>
> "Gary G. Little" wrote:
>
> > Check the DevCon source in the DDK.
> >
> > The personal opinion of
> > Gary G. Little
> >
> > "alcompinc" <alcompinc@discussions.microsoft.com> wrote in message
> > news:236B9CBF-851B-41D2-B3FE-D26568BE09F9@microsoft.com...
> > > Thanks! Do you know where I can find example
> > > code using this technique? (SetupDiGetClassDevs).
> > >
> > > --
> > > Al Jewer
> > > Alcomp, Inc
> > >
> > >
> > >
> > > "alcompinc" wrote:
> > >
> > >> I am attempting to interface to a piece of equipment which
> > >> provides serial port emulation via its driver for USB. When it
> > >> is plugged into different USB ports, it appears at different
> > >> com port addresses - i.e. COM8: or COM12: (on my machine).
> > >>
> > >> I have two specific quistions:
> > >>
> > >> 1) How do I open a COM port greater than COM9:? When I try to use the
> > >> recommended procedure (open as a file), it fails if the COM port number
> > >> is greater than 9.
> > >>
> > >> 2) How do I find which COM port number the device is connected to?
> > >> It manifests as a modem, and has a specific device name which I can
> > >> see in Hardware Manager. If I examine the advanced port properties,
> > >> I can see which COM port number it has assigned. I need to find the
> > >> device by name (or see if it's not there). How do I do this?
> > >>
> > >> I am using Visual Studio 2005 and writing in ANSI C.
> > >>
> > >> Thanks,
> > >>
> > >> --
> > >> Al Jewer
> > >> Alcomp, Inc
> > >>
> >
> >
> >

Re: Interfacing to Com port driver by David

David
Mon Jul 31 23:31:34 CDT 2006

How are you going to handle a serial port with COM11 and no others? How
about one that doesn't even use COM as a prefix? If devcon is "largely
incomprehensible code" you should consider hiring a contractor.

"alcompinc" <alcompinc@discussions.microsoft.com> wrote in message
news:7BA7126B-5BD8-4B6E-8751-4B1689E0B7EB@microsoft.com...
> OK, stupid me. I can open a named device by doing a
> CreateFile("\\.\<DeviceName>"....
> It would be so great if this were better documented......
>
> Thanks to all who responded, I finally tumbled to the answer....
>
> --
> Al Jewer
> Alcomp, Inc
>
>
>
> "alcompinc" wrote:
>
>> OK, I checked out the source code, and found an instance of
>> SetupDiGetClassDevsEx(.....
>> Digesting over 100K of largly incomprehensible code seems like
>> a bit much for what I need to do - I only need to find the COM port
>> number of a named device. Is there an easier way?
>>
>> --
>> Al Jewer
>> Alcomp, Inc
>>
>>
>>
>> "Gary G. Little" wrote:
>>
>> > Check the DevCon source in the DDK.
>> >
>> > The personal opinion of
>> > Gary G. Little
>> >
>> > "alcompinc" <alcompinc@discussions.microsoft.com> wrote in message
>> > news:236B9CBF-851B-41D2-B3FE-D26568BE09F9@microsoft.com...
>> > > Thanks! Do you know where I can find example
>> > > code using this technique? (SetupDiGetClassDevs).
>> > >
>> > > --
>> > > Al Jewer
>> > > Alcomp, Inc
>> > >
>> > >
>> > >
>> > > "alcompinc" wrote:
>> > >
>> > >> I am attempting to interface to a piece of equipment which
>> > >> provides serial port emulation via its driver for USB. When it
>> > >> is plugged into different USB ports, it appears at different
>> > >> com port addresses - i.e. COM8: or COM12: (on my machine).
>> > >>
>> > >> I have two specific quistions:
>> > >>
>> > >> 1) How do I open a COM port greater than COM9:? When I try to use
>> > >> the
>> > >> recommended procedure (open as a file), it fails if the COM port
>> > >> number
>> > >> is greater than 9.
>> > >>
>> > >> 2) How do I find which COM port number the device is connected to?
>> > >> It manifests as a modem, and has a specific device name which I can
>> > >> see in Hardware Manager. If I examine the advanced port properties,
>> > >> I can see which COM port number it has assigned. I need to find the
>> > >> device by name (or see if it's not there). How do I do this?
>> > >>
>> > >> I am using Visual Studio 2005 and writing in ANSI C.
>> > >>
>> > >> Thanks,
>> > >>
>> > >> --
>> > >> Al Jewer
>> > >> Alcomp, Inc
>> > >>
>> >
>> >
>> >



Re: Interfacing to Com port driver by Maxim

Maxim
Mon Jul 31 23:38:02 CDT 2006

> OK, I checked out the source code, and found an instance of
> SetupDiGetClassDevsEx(.....
> Digesting over 100K of largly incomprehensible code seems like
> a bit much for what I need to do - I only need to find the COM port
> number of a named device. Is there an easier way?

100K? A screenful in my old project:

- SetupDiGetClassDevs
- SetupDiEnumDeviceInterfaces in a loop
- SetupDiGetDeviceInterfaceDetail
- CreateFile
- SetupDiDestroyDeviceInfoList

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


Re: Interfacing to Com port driver by alcompinc

alcompinc
Mon Jul 31 23:57:01 CDT 2006

Maxim:

Sorry - I was referring to trying to figure it out in context of the
rest of the code. It is a bit daunting when you don't do this kind
of thing on a regular basis. I am largely an embedded systems
programmer. Thanks for your help.

David:

Thanks for your kind commentary.

--
Al Jewer
Alcomp, Inc



"Maxim S. Shatskih" wrote:

> > OK, I checked out the source code, and found an instance of
> > SetupDiGetClassDevsEx(.....
> > Digesting over 100K of largly incomprehensible code seems like
> > a bit much for what I need to do - I only need to find the COM port
> > number of a named device. Is there an easier way?
>
> 100K? A screenful in my old project:
>
> - SetupDiGetClassDevs
> - SetupDiEnumDeviceInterfaces in a loop
> - SetupDiGetDeviceInterfaceDetail
> - CreateFile
> - SetupDiDestroyDeviceInfoList
>
> --
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> maxim@storagecraft.com
> http://www.storagecraft.com
>
>

Re: Interfacing to Com port driver by dzabel

dzabel
Thu Aug 03 06:53:02 CDT 2006



"Maxim S. Shatskih" wrote:

> > 1) How do I open a COM port greater than COM9:? When I try to use the
> > recommended procedure (open as a file), it fails if the COM port number
> > is greater than 9.
>
> \\.\COM10
>
Hi,
I had the same problem as the OP, so this helped me, too. Thanks!
Where in the SDK Docs should I have found this info? I hope I am not
supposed to work through the DDK when all I want do do is write an
application program which uses COM10?

-- Dirk




Re: Interfacing to Com port driver by Maxim

Maxim
Thu Aug 03 11:36:31 CDT 2006

> supposed to work through the DDK when all I want do do is write an
> application program which uses COM10?

Modern application programs are not suggested to use "COM%d" names. They should
use SetupDiGetClassDevs to find all COM ports in the system, and then open one
of them by SetupDiGetDeviceInterfaceDetail + CreateFile.

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


Re: Interfacing to Com port driver by dzabel

dzabel
Fri Aug 04 07:52:01 CDT 2006



"Maxim S. Shatskih" wrote:

> > supposed to work through the DDK when all I want do do is write an
> > application program which uses COM10?
>
> Modern application programs are not suggested to use "COM%d" names. They should
> use SetupDiGetClassDevs to find all COM ports in the system, and then open one
> of them by SetupDiGetDeviceInterfaceDetail + CreateFile.
>
> --
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> maxim@storagecraft.com
> http://www.storagecraft.com
>
>