C#串口编写 DTU sim900A 的问题

2015-06-29 19:28:22 +08:00
 luent
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;
}
}
这个函数在发送完消息的时候,返回的数据是一堆乱码,应该是“>”,为什么吗?然后我在发送消息。另外有示例的话,最好。谢谢!
2313 次点击
所在节点    问与答
3 条回复
mhycy
2015-06-29 19:30:57 +08:00
没资料的情况下让我们怎么回答这种嵌入式问题。。囧
dong3580
2015-06-29 19:52:37 +08:00
看看这货是什么ToUnicode,顺便改改说不定能解决
luent
2015-06-29 20:14:58 +08:00
这个是将字符串转为Unicode

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/201992

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX