473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

A97 dialing numbers via writing directly to the COM port

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
3 2624
MLH
BTW, the link for that old thread is...
http://groups.google.com/group/comp....06af07165970c6
Nov 13 '05 #2

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ^CeFoS^ | last post by:
Hello to everybody, I've done an application that draws in a frame the trajectory of a robot. The robot position is readed through the serial port, and several commands are wrote through the...
11
by: Todd Gardner | last post by:
--------------------------------------------------------------- I would appreciate any ideas how to write to the parallel port (Mem 0x378) when runnning WinXP or Mandrake 9.2. In C and LabVIEW I...
0
by: Damon | last post by:
I am using the following code (primarily wizard created) to dial a phone number on an access form via the on double click event. Application.Run "utility.wlib_AutoDial", stDialStr I want to...
1
by: DaleMan | last post by:
I'm looking for some help on how to dial a phone number in my application and send a text message to the portable machine that answers the call (cell phone, Palm, etc..). Anyone know of any sites...
3
by: JRB | last post by:
I need to read from and write to USB and RS-232 ports in a new project I'm working on. I was thinking about using C#, but I'm not sure if there's a way to do this in that language. If not, any...
13
by: jay.dow | last post by:
I want to write to the pins of an RS232 without using the serial protocol. The use would be every pin could act to complete a circuit in customized hardware. I could use python to communicate...
3
by: Radi Radichev | last post by:
Hi! I'm using .net 2.0 C# and i was wondering if there is any way of dialing a number, that i take from a database, inside an application? Thanks
2
by: Simon T. | last post by:
Hello All, I am new to C# and the .NET framework, so please forgive and pity me if the question and understand reveals massive ignorance. I am trying to get SerialPort talking to a "Standard...
5
by: Brent | last post by:
Hi, I want to recreate my own version of http://snakesonaplane.varitalk.com/ .. So basically I want to start with a basic, make the modem dial a number and play a soundclip to the person that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.