誰かが私の電話番号に電話をかけたときにリングを取得して認識しようとしますが、モデム (電話番号) で電話を受けると、DataReceieved イベントが機能しません。何が問題ですか?これは私のコードです:
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
delegate void SetTextCallback(string text);
private void SetText(string text)
{
if (this.lblStatus.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
this.lblStatus.Text = text;
}
private void sp1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
string rs = sp1.ReadExisting();
MessageBox.Show(rs);
if (rs.Contains("NMBR"))
{
int sx = rs.IndexOf("NMBR");
SetText("Incomming Call From: " + rs.Substring(sx + 7, 11));
}
}
private void Form1_Load(object sender, EventArgs e)
{
if (sp1.IsOpen)
sp1.Close();
sp1.Open();
sp1.Write("AT+SCID=1;" + Environment.NewLine);
sp1.Write("AT+FCLASS=0;" + Environment.NewLine);
sp1.Write("AT+VCID=1;" + Environment.NewLine);
sp1.Write("AT+PCW=0;" + Environment.NewLine);
lblStatus.Text = "Ready...";
}
}
}