UI의 레이블이 "링링"을 계속 읽은 다음 다시 빈 ""으로 표시합니다. 그러나 들어오는 번호는 표시하지 않습니다. 원하는 번호입니다. 데이터에 '0'이 있는지 확인하는 if 함수를 추가하려고했지만 어떤 이유로 든 여전히 작동하지 않습니다.발신자 번호 - 수신 번호를 얻을 수 없음
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
namespace CallerID
{
public partial class CallerID : Form
{
public CallerID()
{
InitializeComponent();
port.Open();
WatchModem();
SetModem();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
WatchModem();
}
private SerialPort port = new SerialPort("COM3");
string CallName;
string CallNumber;
string ReadData;
private void SetModem()
{
port.WriteLine("AT+VCID=1\n");
port.RtsEnable = true;
}
private void WatchModem()
{
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
}
public delegate void SetCallerIdText();
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
ReadData = port.ReadExisting();
//Add code to split up/decode the incoming data
if (lblCallerIDTitle.InvokeRequired)
{
if (ReadData.Contains('0'))
lblCallerIDTitle.Invoke(new SetCallerIdText(() => lblCallerIDTitle.Text = ReadData));
}
else
lblCallerIDTitle.Text = ReadData;
}
}
}
우리가 도와 드릴 수없는'ReadData'에 담긴 내용의 예를 들어주세요. 또한 ... 예제 코드가 불완전합니다. "Ring ... Ring"코드는 어디에 있습니까? –
내 UI 레이블에 집 전화 번호가 울릴 때마다 "\ r \ nRING \ r \ n \"이 포함됩니다. 코드 : lblCallerIDTitle.Invoke (새 SetCallerIdText (() => lblCallerIDTitle.Text = ReadData)); 그 일이 일어나는 이유입니다. 발신자 번호를 테스트 한 적이 있습니다. 내 질문은 '링링'이 아닌 수신 전화 번호를 얻는 방법입니다. – Subby
추가 코드를 제공하면 질문을 업데이트하십시오. 우리는 여전히'ReadData'의 내용을 알 필요가 있습니다. 우리에게 충분한 정보를주지 않았습니다. –