By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,755 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

A97 dialing numbers via writing directly to the COM port

P: n/a
MLH
I found some code Dev Ashish posted nearly a decade
ago in response to someone's inquiry describing their need
to dial a number, monitor call progress and determine whether
it was busy. This was back when A2.0 was more widely used,
so the code is Access Basic. Autodialer is not the answer, as
it requires users to take handsets off-hook manually.

I find myself in need of more direct control of a voice/data/fax
modem from an A97 program. There's a 3Com chipset on the
card. I want to seize a line, take it off-hook, dial a number and
hang it up (go back on hook) at a desired time. That's the basics.
If it is possible, some call progress feedback would be nice to
read and act upon. Yes, if after picking up on a line, if no dialtone
is present, I would like to hang it back up (IE, someone has picked
up on the line at another extension and is already using it). If I can
get feedback on ring detect, busy, fast busy - that would be great
and I can use it. But I'll be content to pickup, dial and hangup.

Am seeking some example procedures illustrating basic concepts.

Here's a snippet from Dev's 1997 post...

' ************************************************** *********
' FUNCTION: DialNumber()
'
' PURPOSE: To dial a telephone number using the computer's modem
'
' ARGUMENTS:
' PhoneNumber: The telephone number to dial
'
' CommPort: The communications port the modem is connected
' to. Typically, modems are found on COM2, however,
' they can be configured for any COM port.
'
' EXAMPLE:
' Type the following in the Immediate window using a modem
' connected to the COM2 port:
'
' ? DialNumber("555-1212", "COM2")
'
' ************************************************** *********
Function DialNumber (PhoneNumber, CommPort As String)
Dim Msg As String, MsgBoxType As Integer, MsgBoxTitle As
String
Dim ModemCommand As String
Dim OpenPort As Integer
Dim RetVal As Integer
Dim StartTime
Dim CR As String: CR = Chr$(13)
Dim LF As String: LF = Chr$(10)
' Ask the user to pick up the phone
Msg = "Please pickup the phone and choose OK to dial " _
& PhoneNumber
MsgBoxType = MB_ICONINFORMATION + MB_OKCANCEL
MsgBoxTitle = "Dial Number"
If MsgBox(Msg, MsgBoxType, MsgBoxTitle) = ID_CANCEL Then
Exit Function
End If
' Open the communications port
OpenPort = OpenComm(CommPort, 1024, 128)
If OpenPort < 0 Then
Msg = "Unable to open communication port " & CommPort
GoTo Err_DialNumber
End If
' Send the telephone number to the modem
ModemCommand = "ATDT" & PhoneNumber & CR & LF
If WriteComm(OpenPort, ModemCommand, Len(ModemCommand)) < 0
Then
Msg = "Unable to dial number " & PhoneNumber
GoTo Err_DialNumber
End If
' Wait WAITSECONDS seconds for the phone to dial
StartTime = Timer
While Timer < StartTime + WAITSECONDS
DoEvents
Wend
' Reset the modem and take it off line
ModemCommand = "ATH0" & CR & LF
RetVal = WriteComm(OpenPort, ModemCommand, Len(ModemCommand))
' Close the communications port
RetVal = CloseComm(OpenPort)
Exit Function
Err_DialNumber: 'This is not an On Error routine
Msg = Msg & CR & CR & "Make sure no other devices are using _
communication port " & CommPort
MsgBoxType = MB_ICONSTOP
MsgBoxTitle = "Dial Number Error"
MsgBox Msg, MsgBoxType, MsgBoxTitle
End Function
4. Open the Employees form in Design view.
5. Place a command button with the following properties on the form,
next
to the Home Phone field.
Microsoft Access 1.x:
ControlName: btnDialPhone
Caption: Dial
OnPush: =DialNumber([Home Phone], "COM2")
Microsoft Access 2.0:
Name: btnDialPhone
Caption: Dial
OnClick: =DialNumber([Home Phone], "COM2")
6. View the form in Form view. To dial an employee's home phone
number,
choose the Dial button.
--
__________________________________________________ ________________________
Dev Ashish
dash...@mailnet.ho.att.com
Applied Technologies Organization Holmdel, NJ
AT&T Laboratories

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
MLH
BTW, the link for that old thread is...
http://groups.google.com/group/comp....06af07165970c6
Nov 13 '05 #2

P: n/a

I did this a while back... Sadly, I don't have code that I can release
"into the wild", as it was a contract and they got the rights to the
code. Basically, the code I wrote picked up the phone, dialed a
number, listened for a tone, then dialed in a pager number, paused,
then dialed in a string of numbers to indicate the number to call back
and the "error condition".

If memory serves, it wasn't all that hard, but it needed to be
precise. The big "secret" was to use TAPI (Telephone application
programmer interface).

There's a Knowledgebase article or two on it all somewhere at
support.microsoft.com, but I didn't leave a note to myself as to the
article number(s). (D'oh!)

I do remember however, that I had to modify some VB5 code to make it
work....
On Tue, 18 Oct 2005 10:27:38 -0400, MLH <CR**@NorthState.net> wrote:
I found some code Dev Ashish posted nearly a decade
ago in response to someone's inquiry describing their need
to dial a number, monitor call progress and determine whether
it was busy. This was back when A2.0 was more widely used,
so the code is Access Basic. Autodialer is not the answer, as
it requires users to take handsets off-hook manually.
I find myself in need of more direct control of a voice/data/fax
modem from an A97 program. There's a 3Com chipset on the
card. I want to seize a line, take it off-hook, dial a number and
hang it up (go back on hook) at a desired time. That's the basics.
If it is possible, some call progress feedback would be nice to
read and act upon. Yes, if after picking up on a line, if no dialtone
is present, I would like to hang it back up (IE, someone has picked
up on the line at another extension and is already using it). If I can
get feedback on ring detect, busy, fast busy - that would be great
and I can use it. But I'll be content to pickup, dial and hangup.

--
Drive C: Error. (A)bort (R)etry (S)mack The Darned Thing

Nov 13 '05 #3

P: n/a
MLH
Thx, Chuck, for the reply. This topic is slightly O.T. for this NG.
Even though I'm doing it with VBA, its more of a serial port com
job than it is a database development chore. I don't expect many
will join the thread. I like this stuff, though. About 9 years ago, I
bought Dick Grier's 2nd edition paperback and had a ball with it.
I did this a while back... Sadly, I don't have code that I can release
"into the wild", as it was a contract and they got the rights to the
code. Basically, the code I wrote picked up the phone, dialed a
number, listened for a tone, then dialed in a pager number, paused,
then dialed in a string of numbers to indicate the number to call back
and the "error condition".


I'm trying not to use TAPI - apparently, its quite thorough because
its extremely slow. It must be polling the modem from one end to the
other before bringing up the outbound dialer interface. And, that
itself is quit sluggish. I'm confident that if I can get the following
running, it'll outperform the TAPI option. Right now, I have TAPI
working. But my customer won't have the patience to wait on it
to pop up 'n dial.

Article ID : 148857
Last Review : August 12, 2005
Revision : 3.1

Option Explicit
Declare Function WriteFile& Lib "kernel32" _
(ByVal hFile As Long, lpBuffer As Any, _
ByVal nNumberOfBytesToWrite&, _
lpNumberOfBytesWritten&, ByVal lpOverlapped&)
Declare Function CreateFile& Lib "kernel32" Alias "CreateFileA"
_
(ByVal lpFileName$, ByVal dwDesiredAccess&, _
ByVal dwShareMode&, ByVal lpSecurityAttributes&, _
ByVal dwCreationDisposition&, ByVal dwFlagsAndAttributes&, _
ByVal hTemplateFile&)
Declare Function CloseHandle& Lib "kernel32" (ByVal hObject&)
Declare Function FlushFileBuffers& Lib "kernel32" (ByVal hFile&)

' The number of seconds to wait for the modem to dial before
' .. resetting the modem. If the phone hangs up prematurely
' .. try increasing this value by small increments.
Public Const WAITSECONDS = 4

Public Const ID_CANCEL = 2
Public Const MB_OKCANCEL = 1
Public Const MB_ICONSTOP = 16, MB_ICONINFORMATION = 64
DialNumber(PhoneNumber, CommPort As String)
' PURPOSE: To dial a telephone number using the computer's modem
' ARGUMENTS:
' PhoneNumber: The telephone number to dial
' CommPort: The communications port the modem is connected
' to. Typically, modems are found on COM2, however,
' they can be configured for any COM port.
'
' EXAMPLE:
' Type the following in the Immediate window using a modem
' connected to the COM2 port:
'
' ? DialNumber("555-1212", "COM2")
'
' ************************************************** *********

Dim Msg As String, MsgBoxType As Integer, MsgBoxTitle As
String
Dim bModemCommand(256) As Byte, ModemCommand As String
Dim OpenPort As Long
Dim RetVal As Long, RetBytes as Long, i as integer
Dim StartTime

' Ask the user to pick up the phone.
Msg = "Please pickup the phone and choose OK to dial " _
& PhoneNumber
MsgBoxType = MB_ICONINFORMATION + MB_OKCANCEL
MsgBoxTitle = "Dial Number"
If MsgBox(Msg, MsgBoxType, MsgBoxTitle) = ID_CANCEL Then
Exit Function
End If

' Open the communications port for read/write (&HC0000000).
' Must specify existing file (3).
OpenPort = CreateFile(CommPort, &HC0000000, 0, 0, 3, 0, 0)
If OpenPort = -1 Then
Msg = "Unable to open communication port " & CommPort
GoTo Err_DialNumber
End If

' Send the telephone number to the modem.
ModemCommand = "ATDT" & PhoneNumber & vbCrLf
' Pack the string in a Byte array.
For i = 0 To Len(ModemCommand) - 1
bModemCommand(i) = Asc(Mid(ModemCommand, i + 1, 1))
Next

' Write the string to the Com port.
RetVal = WriteFile(OpenPort, bModemCommand(0), _
Len(ModemCommand), RetBytes, 0)
If RetVal = 0 Then
Msg = "Unable to dial number " & PhoneNumber
GoTo Err_DialNumber
End If

' Flush the buffer to make sure it actually wrote
RetVal = FlushFileBuffers(OpenPort)

' Wait WAITSECONDS seconds for the phone to dial.
StartTime = Timer
While Timer < StartTime + WAITSECONDS
DoEvents
Wend

' Reset the modem and take it off line.
ModemCommand = "ATH0" & vbCrLf
' Pack the byte array again.
For i = 0 To Len(ModemCommand) - 1
bModemCommand (i) = Asc(Mid(ModemCommand, i + 1, 1))
Next
RetVal = WriteFile(OpenPort, bModemCommand(0), _
Len(ModemCommand), RetBytes, 0)

'Flush the buffer again.
RetVal = FlushFileBuffers(OpenPort)

' Close the communications port.
RetVal = CloseHandle(OpenPort)

Exit Function

Err_DialNumber: 'This is not an On Error routine.
Msg = Msg & vbCr & vbCr & _
"Make sure no other devices are using Com port " &
CommPort
MsgBoxType = MB_ICONSTOP
MsgBoxTitle = "Dial Number Error"
MsgBox Msg, MsgBoxType, MsgBoxTitle

End Function
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.