patrick

patrick

  • NA
  • 397
  • 0

Make caller ID pick up faster

Apr 14 2010 4:04 PM

Hello, Im using the following code for my caller id lines on standard modems.
private void InitializeComPort()
{

    serialPort1.PortName = Settings.Default.callerID1PORT;

   serialPort1.BaudRate = 9600;

   serialPort1.StopBits = StopBits.One;

   serialPort1.DataBits = 8;

   serialPort1.Handshake = Handshake.None;

   serialPort1.DataReceived += OnSerialDataReceived;

   serialPort1.Open();

   serialPort1.WriteLine("AT#cid=1" + Environment.NewLine);

}
private void OnSerialDataReceived(object sender, SerialDataReceivedEventArgs args)
{
   string str = serialPort1.ReadExisting();
   string number = "";
   string name = "";
   if (str.Trim().ToLower().IndexOf("nmbr") >= 0)
   {
   number = str.Substring(str.Trim().ToLower().IndexOf("nmbr=") + 7);

   }
number = Functions.removeNonNumeric(number);
if (str.Trim().ToLower().IndexOf("name") >= 0)
{
name = str.substring(str.Trim().ToLower().IndexOf("name=") + 7);
name = name.Remove(name.Trim().ToLower().IndexOf("nmbr="));
}
 
The problem is that it takes 3 rings for the line to pick up.  Is there any way to make it go faster?