Microsoft TAPI (en)
 

obtaining a handle to a modem


 
obtaining a handle to a modem Post Reply
05.11.2008 05:46 knk53

I have a relatively simple user program that communicates to my equipment
over a modem.  The program is designed to talk to the modem using a serial
port.   I used the CreateFile, ReadFile, Writefile, SetCommState etc.  APIs.  
The program then controls the modem using AT commands.

  Recently, we have encountered some laptops that our users own where this
user program cannot open the COM port associated with the modem.  In
addition, Hyperterminal cannot open the COM port associated with the modem.  
By using Hyperterminal, I can choose the installed modem in the "Connect
Using" drop down box and then talk to the modem using AT commands.

  I did some research and cannot seem to find a way to obtain a Handle to
the actual modem device as opposed to the COM port the modem is attached to.  
The only way seemed to be to TAPI 2.2 and the lineGetID function.  I am using
Visual Basic .Net 2003.   Is there any way to talk to the modem directly
without opening the COM port?  Do I need to open the COM port Overlapped to
solve this problem?  

I was able to add add a reference to the TAPI 3 library to my application.  
I could then enumerate the addresses using the ITADDRESS interface and find
the Modem Device.  Once I have the ITADDRESS object, can I somehow use it to
communicate to the modem?

Any help would be greatly appreciated!
Re: obtaining a handle to a modem Post Reply
05.11.2008 10:12 Bob Day


"knk53" wrote in message
news:183B3F7B-146F-4521-AD93-0B77A617F45C@microsoft.com...
>I have a relatively simple user program that communicates to my equipment
> over a modem.  The program is designed to talk to the modem using a serial
> port.   I used the CreateFile, ReadFile, Writefile, SetCommState etc.
> APIs.
> The program then controls the modem using AT commands.
>
>  Recently, we have encountered some laptops that our users own where this
> user program cannot open the COM port associated with the modem.  In
> addition, Hyperterminal cannot open the COM port associated with the
> modem.
> By using Hyperterminal, I can choose the installed modem in the "Connect
> Using" drop down box and then talk to the modem using AT commands.
>
>  I did some research and cannot seem to find a way to obtain a Handle to
> the actual modem device as opposed to the COM port the modem is attached
> to.
> The only way seemed to be to TAPI 2.2 and the lineGetID function.  I am
> using
> Visual Basic .Net 2003.   Is there any way to talk to the modem directly
> without opening the COM port?  Do I need to open the COM port Overlapped
> to
> solve this problem?
>
> I was able to add add a reference to the TAPI 3 library to my application.
> I could then enumerate the addresses using the ITADDRESS interface and
> find
> the Modem Device.  Once I have the ITADDRESS object, can I somehow use it
> to
> communicate to the modem?
>
> Any help would be greatly appreciated!

I have some C language code on my website that sets up a
passthrough mode interface to a modem using TAPI2.  Perhaps you
could modify it a bit and interface to it in Visual Basic.  Or maybe, as
you suggested, you could use overlapped IO to the modem, as I do
in my example code.  Here's the link:

http://mysite.verizon.net/vze3psh8/SendATCmdToModem.zip

-- Bob Day
http://bobday.vze.com

Re: obtaining a handle to a modem Post Reply
05.11.2008 10:26 knk53

Bob,

   Thanks for the info.  I would try this as a last resort however
translating it into VB would be rather difficult.   I am trying to avoid
using TAPI 2, and try to either use TAPI 3 or some other method.

"Bob Day" wrote:

>
> "knk53" wrote in message
> news:183B3F7B-146F-4521-AD93-0B77A617F45C@microsoft.com...
> >I have a relatively simple user program that communicates to my equipment
> > over a modem.  The program is designed to talk to the modem using a serial
> > port.   I used the CreateFile, ReadFile, Writefile, SetCommState etc.
> > APIs.
> > The program then controls the modem using AT commands.
> >
> >  Recently, we have encountered some laptops that our users own where this
> > user program cannot open the COM port associated with the modem.  In
> > addition, Hyperterminal cannot open the COM port associated with the
> > modem.
> > By using Hyperterminal, I can choose the installed modem in the "Connect
> > Using" drop down box and then talk to the modem using AT commands.
> >
> >  I did some research and cannot seem to find a way to obtain a Handle to
> > the actual modem device as opposed to the COM port the modem is attached
> > to.
> > The only way seemed to be to TAPI 2.2 and the lineGetID function.  I am
> > using
> > Visual Basic .Net 2003.   Is there any way to talk to the modem directly
> > without opening the COM port?  Do I need to open the COM port Overlapped
> > to
> > solve this problem?
> >
> > I was able to add add a reference to the TAPI 3 library to my application.
> > I could then enumerate the addresses using the ITADDRESS interface and
> > find
> > the Modem Device.  Once I have the ITADDRESS object, can I somehow use it
> > to
> > communicate to the modem?
> >
> > Any help would be greatly appreciated!
>
> I have some C language code on my website that sets up a
> passthrough mode interface to a modem using TAPI2.  Perhaps you
> could modify it a bit and interface to it in Visual Basic.  Or maybe, as
> you suggested, you could use overlapped IO to the modem, as I do
> in my example code.  Here's the link:
>
> http://mysite.verizon.net/vze3psh8/SendATCmdToModem.zip
>
> -- Bob Day
> http://bobday.vze.com
>
>
>
Re: obtaining a handle to a modem Post Reply
06.11.2008 11:00 Andreas Marschall [MVP TAPI]

"knk53" schrieb im Newsbeitrag
news:183B3F7B-146F-4521-AD93-0B77A617F45C@microsoft.com...
>   I did some research and cannot seem to find a way to obtain a Handle to
> the actual modem device as opposed to the COM port the modem is attached to.
> The only way seemed to be to TAPI 2.2 and the lineGetID function.  I am
using
> Visual Basic .Net 2003.   Is there any way to talk to the modem directly
> without opening the COM port?  Do I need to open the COM port Overlapped to
> solve this problem?

knk53, in addition to Bob's reply,
in TAPI you definitely need to use the COM port handle aquired via lineGetID()
in overlapped mode.

Do you know the TapiComm sample from P-SDK?
You may want to take a look and try it:
http://www.tapi.info/default.aspx/TAPI/PSDKSamples.html


> I was able to add add a reference to the TAPI 3 library to my application.
> I could then enumerate the addresses using the ITADDRESS interface and find
> the Modem Device.  Once I have the ITADDRESS object, can I somehow use it to
> communicate to the modem?

Regarding TAPI and .NET see KB article "841712 - Telephony Application
Programming Interface (TAPI) functionality is not supported from managed
code".
http://support.microsoft.com/kb/841712

Please have a look at JulMar's
ITAPI3 - TAPI 3.0 wrapper for .NET 2.0
existing TAPI3.0 code based on TAPI3 interop can easily be ported
http://www.julmar.com/blog/mark/CategoryView,category,Tapi.aspx

--
Best Regards
Andreas Marschall
Microsoft MVP for TAPI / Windows SDK / Visual C++
TAPI / TSP Developer and Tester
My TAPI and TSPI FAQ:
http://www.I-B-A-M.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm
My Toto® Tools (a collection of free, mostly TAPI related tools):
http://www.i-b-a-m.de/Andreas_Marschall's_Toto_Tools.htm
TAPI development around the world (Frappr! map):
http://www.frappr.com/TAPIaroundTheWorld
* Please post all messages and replies to the newsgroup so all may
* benefit from the discussion.  Private mail is usually not replied to.
* This posting is provided "AS IS" with no warranties, and confers no rights.


Re: obtaining a handle to a modem Post Reply
06.11.2008 16:17 Matthias Moetje [MVP]

Hi,

in addition to the other replies I'd like to point out the following:

You cannot open the COM port directly if the modem is already
in use by other TAPI applications (e.g. the Fax service).
It is a good idea to use TAPI to communicate to the modem,
because this will allow you to share the modem with other
TAPI applications.

With TAPI you have two possible ways for data communication:

- Use passthrough mode, and then use the modem using writefile
and readfile like before (though, you need to switch to ovelapped
mode)

- Use TAPI functions to establish a data connection with a remote
modem (including dialing and handshake). Then call
lineGetID("comm/datamodem") and do only the actual data communication
using file IO.
Best regards,

Matthias Moetje
-------------------------------------
TAPI WIKI: http://www.tapi.info
-------------------------------------
TERASENS GmbH
Augustenstraße 24
80333 Munich, GERMANY
-------------------------------------
e-mail: moetje at terasens dot com
www:   www.terasens.com
-------------------------------------


"knk53" wrote in message
news:183B3F7B-146F-4521-AD93-0B77A617F45C@microsoft.com...
>I have a relatively simple user program that communicates to my equipment
> over a modem.  The program is designed to talk to the modem using a serial
> port.   I used the CreateFile, ReadFile, Writefile, SetCommState etc.
> APIs.
> The program then controls the modem using AT commands.
>
>  Recently, we have encountered some laptops that our users own where this
> user program cannot open the COM port associated with the modem.  In
> addition, Hyperterminal cannot open the COM port associated with the
> modem.
> By using Hyperterminal, I can choose the installed modem in the "Connect
> Using" drop down box and then talk to the modem using AT commands.
>
>  I did some research and cannot seem to find a way to obtain a Handle to
> the actual modem device as opposed to the COM port the modem is attached
> to.
> The only way seemed to be to TAPI 2.2 and the lineGetID function.  I am
> using
> Visual Basic .Net 2003.   Is there any way to talk to the modem directly
> without opening the COM port?  Do I need to open the COM port Overlapped
> to
> solve this problem?
>
> I was able to add add a reference to the TAPI 3 library to my application.
> I could then enumerate the addresses using the ITADDRESS interface and
> find
> the Modem Device.  Once I have the ITADDRESS object, can I somehow use it
> to
> communicate to the modem?
>
> Any help would be greatly appreciated!

 
 
 Write Us|  Add to favorites
 
 
 ©2007 TERASENS GmbH. All rights reserved. Copyright Notice