//发送彩信
public int SendMMS(SerialPort comm)
{
int DataByte = 0;
byte[] RecvData;
string temp = "";
string str = "AT$MMSSEND" + HUICHE;//发送彩信的命令,发送彩信的前置条件已经在前面设置
comm.Write(str);//串口写入
Thread.Sleep(MAX_DELAY_TIME1);//延时
DataByte = comm.BytesToRead;//通信返回的字节数
if (DataByte > 0)
{
RecvData = new byte[DataByte];
comm.Read(RecvData, 0, DataByte);//读出串口缓冲区的数据
temp = System.Text.Encoding.ASCII.GetString(RecvData);//编码
if ((temp.IndexOf("ok") >= 0) || (temp.IndexOf("OK") >= 0))
{
//if (CheckMMSTRACE(comm, 1) == 1)
// return 1;
//else
// return 0;
//pt.Increment(30);
return CheckMMSTRACE(comm, 1, temp/*, pt*/);
}
else
return 0;
}
else
return 0;
}我现在的问题是如果temp 里面返回值里包含OK字符串的话,那么彩信就发送成功了,可是现在接收到得temp 里面没有ok字符串手机仍然能收到彩信,也就是说temp里面理论上应该有“OK”字符串,但跟踪程序发现里面没有“OK”字符串,请问大家程序哪里有问题呢???谢谢!!
public int SendMMS(SerialPort comm)
{
int DataByte = 0;
byte[] RecvData;
string temp = "";
string str = "AT$MMSSEND" + HUICHE;//发送彩信的命令,发送彩信的前置条件已经在前面设置
comm.Write(str);//串口写入
Thread.Sleep(MAX_DELAY_TIME1);//延时
DataByte = comm.BytesToRead;//通信返回的字节数
if (DataByte > 0)
{
RecvData = new byte[DataByte];
comm.Read(RecvData, 0, DataByte);//读出串口缓冲区的数据
temp = System.Text.Encoding.ASCII.GetString(RecvData);//编码
if ((temp.IndexOf("ok") >= 0) || (temp.IndexOf("OK") >= 0))
{
//if (CheckMMSTRACE(comm, 1) == 1)
// return 1;
//else
// return 0;
//pt.Increment(30);
return CheckMMSTRACE(comm, 1, temp/*, pt*/);
}
else
return 0;
}
else
return 0;
}我现在的问题是如果temp 里面返回值里包含OK字符串的话,那么彩信就发送成功了,可是现在接收到得temp 里面没有ok字符串手机仍然能收到彩信,也就是说temp里面理论上应该有“OK”字符串,但跟踪程序发现里面没有“OK”字符串,请问大家程序哪里有问题呢???谢谢!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货