Posts Tagged ‘us robotics’

One thing I was always interested was being able to notify me when a certain person calls.  And in this case flash a inteson light or two.

My code is in VB 2005, for a VB6 Sample you can go here and basically requires only some little coding.  In the case of VB6 I think you only need to add the Serial object and adjust the port via the objects property settings.

What I used,

  • Analog phone with Caller ID (Vonage actually)
  • Internal / External Modem – Mine is a 56k External modem and have caller Id capability.
  • Hook them up, from the wall to the modem, to the modem to the handset.  🙂

The best way to see if it does is to open Hyper terminal and type the following command AT #CID=1 if it respond’s ok your set. This of course if for the modem i’m using, depending on your device it may be different.  This page includes how you can check for Caller ID capability on your modem

Here is a example of what the modem will pickup and we will parse.


DATE = 0621

TIME = 1113
NMBR = 1407xxxxxxxxx
NAME = Carlos Cobol

If you modem is external like mine you need to make sure AutoAwnser is disabled this is done by the DIP switches, For the US robotics its Dip switch #5 as down. In the case its internal you will need to add the command to disable auto answer. This is done with the command ATS0=0.

My Dip settings are as follows,









Since the code below allows to send some strings up startup, just add the in there if you need to.

Note: I do make reference to textbox called txtDataReceived in my form which will include the output.

First we make our imports include the serial devices (My program writes to a SQL database so some lines may not be needed)

Imports System.IO
Imports System.IO.Ports
Imports System.Net
Imports System.Data
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.ComponentModel
Imports System.Threading

In our Class definitions we include the reference to the serial port and we’ll call it ‘Modem’

Public Class Form1
    Dim WithEvents Modem As New IO.Ports.SerialPort

In our Load event we will attach to the serial port and give it the basic settings, Here is where you would also add any initialization commands

 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Modem.PortName = "COM1"
        Modem.BaudRate = 9600
        Modem.DataBits = 8
        Modem.Parity = Parity.None
        Modem.StopBits = StopBits.One
        If Modem.IsOpen = False Then Modem.Open()

    End Sub

Next using the “Data Received” event we want to capture the Data which was received, Since there is a thread already running it wont allow us to update the textbox so simple we need to call use using the definition below,

 Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles Modem.DataReceived

            txtDataReceived.Invoke(New myDelegate(AddressOf updateTextBox), New Object() {})
        Catch EX As Exception
        End Try
    End Sub

Second function to update the textbox and check for the number, and check for one of the text information above, Ive stripped my code for simplicity but you can search for specific strings here, match it with fields in a database, even FTP the data somewhere else, but that i’ll show you on another post.
Here we will check for the number ‘123456789’

 Public Sub updateTextBox()
        Dim temp As String
        With txtDataReceived
            .Font = New Font("Garamond", 12.0!, FontStyle.Bold)
            .SelectionColor = Color.Red

            temp = Modem.ReadExisting.ToString
            Buffer = Buffer + temp
        End With

        If Buffer.Contains("NMBR") = True Then
            Dim FILENAME As String = "c:\cALLINFO.TXT"  ' - Set a filename
            File.WriteAllText(FILENAME, Buffer)    '---- Write all the buffer for testing if we want to see it
            If Buffer.contains("123456789") then   '----- check for specific #
                End If
        End if                  
End sub