GSM调制解调器AT命令UCS2错误500 [英] GSM modem AT commands UCS2 error 500

查看:245
本文介绍了GSM调制解调器AT命令UCS2错误500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

三天前,我开始制作一个简单的应用程序来发送短信.我已经对其进行了测试,并且可以在GSM CSCS模式下工作,但是当我将其切换到UCS2时,它不会显示西里尔字母

Three days ago I started making a simple app to send SMS. I already tested it and it works in GSM CSCS mode, but when I switch it to UCS2 it doesn't show the Cyrillic letters

<?php
error_reporting(E_ALL);

$fp = fopen("/dev/ttyUSB0", 'w+');

$msg = strtoupper(bin2hex(mb_convert_encoding("Тест", "UCS-2", "UTF-8")));
$number_raw = "+359000000000";
$number = bin2hex(mb_convert_encoding($number_raw, "UCS-2", "UTF-8"));
echo $number."<br>";
echo $msg;
$debug = false;
if(!$fp || $debug){
  //echo "Can not open!";
}else{
  fwrite($fp, "AT+CMGF=1".chr(13)); // OK
  sleep(5);
  fwrite($fp, 'AT+CSCS="UCS2"'.chr(13)); // OK
  sleep(5);
  fwrite($fp, 'AT+CMGS="'.$number.'"'.chr(13)); // OK
  sleep(5);
  fwrite($fp, $msg.chr(26)); // ERROR 500
  echo "<br>Sent";
}
?>

数字和消息已根据以下来源正确编码: http://www.columbia. edu/kermit/ucs2.html

Number and message are encoded properly according to this source: http://www.columbia.edu/kermit/ucs2.html

发送消息后,我收到了消息(因此,数字的编码是正确的),但是内容显示不正确.

When the message is sent, I receive it (so the encoding of the number is correct) but the content isn't shown properly.

https://imgur.com/a/cCaTU

此行为的可能原因是什么,这可能是我的PHP文件编码吗?另外,为什么Linux会找到3个GSM tty设备?

What are possible causes for this behaviour and could it be my PHP file encoding? Also why is linux finding 3 GSM tty devices?

推荐答案

在删除了所有可怕的sleep调用并实施了正确的最终响应解析之后,您需要修复 响应.

After you have removed all the horrible sleep calls and implemented proper final response parsing, then you need fix the parsing for waiting for the "\r\n> " response of AT+CMGS.

没有任何固定的字符集编码问题是一个很小的问题.当您运行AT+CSCS="UCS2" 每个单个字符串时,调制解调器都会采用这种方式进行编码,并且您必须采用这种方式进行编码,直到永恒(或选择了另一个字符集)为止,例如,从UCS2进行切换到UTF-8的是AT+CSCS="005500540046002D0038"而不是AT+CSCS="UTF-8".

Without any of that fixed, character set encoding trouble is a very minor problem. When you run AT+CSCS="UCS2" every single string will be encoded by the modem that way and must be encoded that way by you until eternity (or another character set is selected), so for instance to switch from UCS2 to UTF-8 would be AT+CSCS="005500540046002D0038" and not AT+CSCS="UTF-8".

这篇关于GSM调制解调器AT命令UCS2错误500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆