这是一个创建于 3764 天前的主题,其中的信息可能已经有所发展或是发生改变。
public int send(string phonenum,string msg){
commPort.WriteLine("AT+CMGF=1\r\n");
commPort.WriteLine("AT+CSCS=\"UCS2\"\r\n");
commPort.WriteLine("AT+CMGS="+ToUnicode(phonenum)+"\r\n");
Thread.Sleep(1000);
string data = commPort.ReadExisting();
if(data.Length > 0 && data.EndsWith("> ")){
commPort.Write(ToUnicode(String.Format("{0}\x01a",msg)));
return 0;
}else{
return -1;
}
}
这个函数在发送完消息的时候,返回的数据是一堆乱码,应该是“>”,为什么吗?然后我在发送消息。另外有示例的话,最好。谢谢!
3 条回复 2015-06-29 20:14:58 +08:00  | | 1 mhycy 2015-06-29 19:30:57 +08:00 没资料的情况下让我们怎么回答这种嵌入式问题。。 |
 | | 2 dong3580 2015-06-29 19:52:37 +08:00 via Android 看看这货是什么ToUnicode,顺便改改说不定能解决 |
 | | 3 luent 2015-06-29 20:14:58 +08:00 这个是将字符串转为Unicode |