gpt4 book ai didi

c# - +CDS AT COMMAND 问题

转载 作者:太空宇宙 更新时间:2023-11-03 13:50:02 29 4
gpt4 key购买 nike

当我使用 SerialPort 通过 c# 在 AT COMMAND 中获取 +CDS 时出现问题,任何时候我都会截断此 +CDS,例如:

+光盘:250002970C91555868047414212181414094882121814140948830

为什么我有这个问题,为什么每次都能正常工作?

我正在启动 SerialPort:

    public PortCOM(string porta)
: base(porta, 115200, Parity.None, 8, StopBits.One)
{
this.StatusPort = StatusPorta.Ready;
this.DiscardNull = true;
this.ReadTimeout = 21000;
this.RtsEnable = true;
this.DtrEnable = true;
this.ReceivedBytesThreshold = 9;
this.NewLine = "\r\n";
this.ReadBufferSize = 1024;
}

public static void TestPort()
{
var p = new PortCom("COM12");

if (!p.IsOpen)
p.Open();

p.StatusPort = StatusPorta.Ready;
p.DataReceived += new SerialDataReceivedEventHandler(p_DataReceivedSample);
p.PinChanged += new SerialPinChangedEventHandler(p_PinChanged);
p.ErrorReceived += new SerialErrorReceivedEventHandler(p_ErrorReceived);

p.Disposed += new EventHandler((obj, porta) =>
{
Console.WriteLine(((PortaCOM)obj).ToString());
});

if (Console.ReadKey().Key == ConsoleKey.B)
{
p.Close();
p.Dispose();
}
}

static void p_DataReceivedSample(object sender, SerialDataReceivedEventArgs e)
{
var p = (PortaCOM)sender;
try
{
Console.WriteLine(p.ReadExisting());
var sb = new StringBuilder();

sb.Append(p.ReadExisting());
int y = sb.ToString().IndexOf("\r\n");


var stop = Stopwatch.StartNew();
stop.Start();
while (y == -1)
{
sb.Append(p.ReadExisting());
y = sb.ToString().IndexOf("\r\n");
if (stop.Elapsed.TotalSeconds > 10)
break;
}
stop.Stop();

var _retorno = sb.ToString();
var cmt = regCMT.Match(_retorno);
var succ = regSucess.Match(_retorno);
var report = regStatusReport.Match(_retorno);
var erro = regError.Match(_retorno);


#region Resposta
if (cmt.Success)
{
var smss = new SMS();
var source = cmt.Groups[3].Value;
SMS.Fetch(smss, ref source);
var resposta = new Resposta()
{
Mensagem = smss.Message,
Data = smss.ServiceCenterTimeStamp,
Sender = smss.PhoneNumber,
Operadora = p.OperadoraName.NomeOperadora.ToString()
};

GravaResposta().ToAsync(Scheduler.TaskPool).Invoke(p, cmt.Groups[3].Value);
p.IsError = false;
}
#endregion

#region StatusReport
if (report.Success)
{
RecebeReport(p, report.Groups[2].Value.Trim());
p.IsError = false;
}
#endregion
}
catch (Exception err)
{
Console.WriteLine(err.Message);
}
}

拜托,我真的需要帮助,我很高兴能得到任何帮助!

最佳答案

+cds对带有 SIM 内存中消息位置的传入消息发出警报。

所以这里似乎是 PDU 模式数据。看起来可能是 flash 消息内容。

将数据PDU模式转换为文本模式接收消息。

查看此 ATSMS library

关于c# - +CDS AT COMMAND 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13956694/

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