V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
luent
V2EX  ›  问与答

C#串口编写 DTU sim900A 的问题

  •  
  •   luent · 2015-06-29 19:28:22 +08:00 · 2279 次点击
    这是一个创建于 3234 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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
    mhycy
        1
    mhycy  
       2015-06-29 19:30:57 +08:00
    没资料的情况下让我们怎么回答这种嵌入式问题。。囧
    dong3580
        2
    dong3580  
       2015-06-29 19:52:37 +08:00 via Android
    看看这货是什么ToUnicode,顺便改改说不定能解决
    luent
        3
    luent  
    OP
       2015-06-29 20:14:58 +08:00
    这个是将字符串转为Unicode
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1280 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 23:29 · PVG 07:29 · LAX 16:29 · JFK 19:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.