上传者: raul0709
|
上传时间: 2022-03-07 12:26:11
|
文件大小: 49KB
|
文件类型: -
///
/// 执行AT指令并返回 成功失败
///
/// AT指令
/// AT指令标准结束标识
///
private void ATCommand3(string ATCmd, string StCmd)
{
string response = "";
response = ATCommand(ATCmd, StCmd);
}
///
/// 执行AT指令并返回结果字符
///
/// AT指令
/// AT指令标准结束标识
///
private string ATCommand(string ATCmd, string StCmd)
{
string response = "";
int i;
if (!ATCmd.EndsWith("\x01a"))
{
if (!(ATCmd.EndsWith("\r") || ATCmd.EndsWith("\r\n")))
{
ATCmd = ATCmd + "\r";
}
}
Sp.WriteLine(ATCmd);
//第一次读响应数据
if (Sp.BytesToRead > 0)
{
response = Sp.ReadExisting();
//去除前端多可能多读取的字符
if (response.IndexOf(ATCmd) > 0)
{
response = response.Substring(response.IndexOf(ATCmd));
}
else
{
}
if (response == "" || response.IndexOf(StCmd) = 0)
{
string[] cols = new string[100];
cols = response.Split(';');
if (cols.Length > 1)
{
string errorCode = cols[1];
}
}
}
}
}
//读第一次没有读完的响应数据,直到读到特征数据或超时
for (i = 0; i = 0)
{
break;
}
}
return response;
}