[Asterisk-Dev] Using an additional modem to get CallerID information

Jonathan McHarg JMcHarg at McHarg.com
Sat Jan 31 07:46:49 MST 2004


There are two stages in the process of getting callerID information from a
standard modem, to be used in Asterisk. The first stage is actually
capturing the information from the modem, the second stage is importing the
captured data into Asterisk.

Capturing the caller ID details from the modem

I will presume at this stage, that you have a modem that supports caller ID
and it is installed and configured to work with your Linux box.

Here is my first script that reads the details in...

#!/usr/bin/perl
$PortName = "/dev/ttyn00";
$PortObj =  open(MODEM,$PortName) || die "Can't open $PortName: $!\n";
while (1==1) {
  local $/ = "\n";
  while ($line=<MODEM>) {
    chomp;
    if ($line =~ s/NMBR = //) {
      open(OUTFILE, ">/usr/src/myperl/callerid.txt") or die "Can't open
callerid.txt: $!";
      print OUTFILE "$line";
      close OUTFILE;
    };
  }
}

depending on your setup, you'll need to amend the $portName variable to
point to the port that you've installed the modem on. You also may want to
change the path that the callerid.txt file is written to.

Once the script is written, used the chmod A+X callerid.pl to change the
mode so that the program can be executed.

Finally run the program with & parameter, to spawn the program as a new
process.


Using the callerid.txt file in Asterisk

Once the callerid.pl file has captured the callerid data, the number needs
to be loaded into asterisk. This is done using AGI functions within
asterisk.

Firstly create a perl script as follows.

#!/usr/bin/perl
open(INFILE, "/usr/src/myperl/callerid.txt") or die "cannot open file";
if ($callerID=<INFILE>) {
  print "SET CALLERID $callerID"};
close INFILE;

once created, this script should be placed in the AGI directory.

Finally add a line to your extensions.conf file to call this script, an
example line would be.

Exten=>_.,1,agi,getcallerid.pl

Hopefully, this should now leave you with CID working !!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 4576 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20040131/8a019364/winmail.bin


More information about the asterisk-dev mailing list