WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Serial
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Capture Caller ID Information from a Modem

Keywords: 	 capture caller ID information from a modem

Question:

Does anyone know how to capture caller ID information from a modem using the serial extender?

Answer:

Here is some code I was playing with a while back. The registry entries are set by another piece of code, but are pretty simple to figure out.
;********************************************************************************
; CALLERID - Connect to a caller id modem and log calls
;            Bill Meek - - 063101
;********************************************************************************
; Format of the caller ID info :
;
; RING
;
; DATE = 0709
; TIME = 1526
; NAME = MEEK BILL
; NMBR = 9998887777
;
; RING
;
;********************************************************************************
;    Test modem for caller id capabilities
;********************************************************************************

; Load extenders
AddExtender("wwser34i.dll")  ; Load the serial extender

;load settings from registry
key=RegOpenKey(@REGMACHINE, "SOFTWARE\TFIC.COM\CallerID")
logcreate=RegQueryValue(key,"Settings\Path[Log]")
installpath=RegQueryValue(key,"Settings\Path[InstallPath]")
comport=RegQueryValue(key,"Settings\Modem\Com[Port]")
useagent=RegQueryValue(key,"Settings[Agent]")
RegCloseKey(key)

;currdir=DirGet() ;not useable as service

IntControl(38,1,StrCat(installpath, "errorlog.txt"),0,0)

If useagent == 1
   MyAgent = ObjectOpen("Agent.Control.2")
   MyAgent.Connected = @TRUE
   Characters = MyAgent.Characters
   ; Load the character
   Characters.Load("Merlin", "Merlin.acs")
   Merlin = Characters.Character("Merlin")
EndIf
   

; TODO modify the next line to use reg entries other than com port?
ComHandle=pComOpen(StrCat("COM", comport),0,"9600","8N1","RTSRTS")
pPutLine(comhandle,"AT#CID=1")         ; Set caller ID ON
;*********** put in code to validate modem accepted set to callerid
pComControl(comhandle,6,0,0,0)         ;flush rec buffer


While @TRUE

   datastring=""
   While @TRUE
      x=pGetChar(ComHandle)
      If Char2Num(x) == 10 Then Continue      ; do not write out LF
      If Char2Num(x) == 13 Then Break         ; end of data is CR
      datastring=StrCat(datastring, x)
     GoSub portdata
   EndWhile

   If StrSub(datastring,1,4) == "DATE" 
      ciddate=StrSub(datastring,8,4)
   EndIf
   If StrSub(datastring,1,4) == "TIME"
      cidtime=StrSub(datastring,8,4)
   EndIf
   If StrSub(datastring,1,4) == "NAME"
      cidcaller=StrSub(datastring,8,-1)
   EndIf
   If StrSub(datastring,1,4) == "NMBR"
      cidnumber=StrSub(datastring,8,-1)
      displine=StrCat(@CRLF,"Call Date/Time : ", ciddate, " - ", cidtime, @CRLF, @CRLF, "Caller name : ", cidcaller, @CRLF, @CRLF, "Caller number : ", cidnumber, @CRLF) 
      ;Display (8, "Incoming call :", displine)

      If useagent != 1

         BoxesUp("0,0,500,500", @NORMAL) 
         ;main box
         BoxCaption(1, "Incoming call")
         BoxColor(1,"255,255,0",0)
         BoxDrawRect( 1, "0,0,1000,1000", 2) 
         ;bounding box
         BoxNew(2, "50,50,950,950", 0)
         BoxDrawRect( 2, "0,0,1000,1000", 2) 
         ;BoxDrawText(2, "150,500,850,550", "Message test ", @FALSE, 1)
         ;date box
         BoxNew(3, "50,50,500,100", 0)
         BoxDrawText(3, "50,0,500,100", StrCat("Date : ",ciddate), @FALSE, 0) ; 0 is left just
         ;time box
         BoxNew(4, "501,50,950,100", 0)
         BoxDrawText(4, "0,0,950,100", StrCat("Time : ",cidtime), @FALSE, 2) ; 2 is right just
         ;BoxCaption(4, "Style 2 BoxNew")
         ;call box
         BoxNew(5, "50,100,950,950", 0)
         BoxTextFont(5, "", 128, 99, 0)
         BoxTextColor(5,"0,0,255")
         BoxDrawText(5, "0,250,1000,500", cidcaller, @FALSE, 1)
         BoxDrawText(5, "0,501,1000,1000", cidnumber, @FALSE, 1)
         TimeDelay(7)
         BoxDestroy(1)
      Else
         Merlin.Show
         Merlin.Speak("Incoming call from ")
         callersaid=Merlin.Speak(cidcaller)
         While @TRUE
            If callersaid.status == 0 Then Break
         EndWhile
         Merlin.Hide
      EndIf      
      
      If logcreate == 1
         LogFile=FileOpen(StrCat(installpath,"callerid.log"), "APPEND")
         FileWrite(LogFile,"================================================================================")
         FileWrite(LogFile,StrCat("Date of call : ", ciddate))
         FileWrite(LogFile,StrCat("Time of call : ", cidtime))
         FileWrite(LogFile,StrCat("Name of caller : ", cidcaller))
         FileWrite(LogFile,StrCat("Number of caller : ", cidnumber))
         FileWrite(LogFile,"")
         FileClose(LogFile)
      EndIf

   EndIf

EndWhile
Exit

:portdata
;wait for data in serial port buffer
tport=pComInfo(ComHandle, 17)                  ;check for data in the port
While tport == 0                          ;while port is empty, loop
   TimeDelay(.25)
   tport=pComInfo(ComHandle, 17)
EndWhile
Return

Article ID:   W15424
File Created: 2011:01:12:09:34:30
Last Updated: 2011:01:12:09:34:30