gpt4 book ai didi

c# - 来电显示 - 无法获取来电号码

转载 作者:行者123 更新时间:2023-11-30 22:28:13 26 4
gpt4 key购买 nike

<分区>

UI 上的标签一直显示为“RING RING”,然后返回为空“”。但是它不显示来电号码,这正是我想要的。我试图添加一个 if 函数来检查数据中是否有“0”,但由于某种原因仍然不起作用。

以下是我的代码:

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;
}
}
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com