GSM SM5100B C M E R R O R : 4 错误 [英] GSM SM5100B C M E E R R O R : 4 error

查看:25
本文介绍了GSM SM5100B C M E R R O R : 4 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Arduino 控制 SM5100B GSM 设备,一切正常,除非我想在收到另一个短信后发送短信.我明白了,

I am using Arduino to control an SM5100B GSM device, everything works except when I want to send an SMS after receiving another. I get this,

错误代码:

O K > + C M G S : 2 5 O K + C M E R R O R : 4

O K > + C M G S : 2 5 O K + C M E E R R O R : 4

我处理上述收到的短信的代码:

My code for handling the aforementioned received SMS:

     #include <SoftwareSerial.h>  //Include the NewSoftSerial library to send serial commands to the cellular module. 
        char inchar;                //Will hold the incoming character from the Serial Port. 
        SoftwareSerial cell(2,3); 
        char mobilenumber[] = "0597010129";
        void setup() { 
        //GSM
        Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
        Serial.println("Initialize GSM module serial port for communication.");                       
        cell.begin(9600); 
        delay(35000); // give time for GSM module to register on network etc. 
        Serial.println("delay off");
        cell.println("AT+CMGF=1"); // set SMS mode to text 
        delay(200); 
        cell.println("AT+CNMI=3,3,0,0"); // set module to send SMS data to serial out upon receipt 
        delay(200); 
        } 



        void loop() {   

         if(cell.available() >0)//If a character comes in, from the cellular module
         { 
         inchar=cell.read(); 
         Serial.println(inchar); 
         if (inchar=='#'){ // OK - the start of our command 

           delay(10); 
           inchar=cell.read();
           Serial.println(inchar);  

             if (inchar=='a'){ 

               delay(10); 
               Serial.println("The folowing SMS : \n");
               inchar=cell.read();
               Serial.println(inchar); 

               if (inchar=='0'){ //sequance = #a0

                 Serial.println("#a0 was received"); 

             }
             else if (inchar=='1'){//sequance = #a1

                Serial.println("#a1 was received ");
                sendSms();

             }
         }
         cell.println("AT+CMGD=1,4");// AT command to delete all msgs
         Serial.println(" delete all SMS"); 
          } 
        }//end of  if(cell.available() >0) {...}
        }

        void sendSms(){
        //cell.println("AT+CMGF=1"); // set SMS mode to text 
        cell.print("AT+CMGS=");  // now send message... 
        cell.print((char)34); // ASCII equivalent of " 
        cell.print(mobilenumber); 
        cell.println((char)34);  // ASCII equivalent of " 
        delay(500); // give the module some thinking time 
        cell.print(":D hello m3alleg :D");   // our message to send 
        cell.println((char)26);  // ASCII equivalent of Ctrl-Z 
        delay(20000);
}

推荐答案

关于处理 AT 命令的一般说明.

不,不,不!这种做法永远不会可靠地工作.您必须等待 > 字符被接收,然后发送文本"发送".或者实际上它不仅仅是>字符,它是四个人物.引用自 3GPP 规范 27.005:

General note about your handling of AT commands.

No, no, no! This way of doing it will never work reliably. You MUST wait for the > character to be received before sending "text to send". Or actually it is not just the > character, it is four characters. Quote from 3GPP specification 27.005:

  • TA 应发送一个四字符序列 (IRA 13, 10, 62, 32) 在命令行之后以 结束;之后可以从 TE 输入文本到我/TA.
  • the TA shall send a four character sequence <CR><LF><greater_than><space> (IRA 13, 10, 62, 32) after command line is terminated with <CR>; after that text can be entered from TE to ME/TA.

(这里的TA(终端适配器)是调制解调器,TE(终端设备)是AT命令的发送者)

(TA (terminal adapter) here means modem and TE (terminal equipment) the sender of AT commands)

对于任何可中止的 AT 命令(并且 27.005 清楚地说明了 AT+CMGS这个命令应该是可中止的.) 任何字符的发送都会中止命令的操作.引用ITU V.250:

For any abortable AT command (and 27.005 clearly states for AT+CMGS This command should be abortable.) the sending of any character will abort the operation of the command. To quote ITU V.250:

5.6.1 中止命令

...

中止命令的完成由从 DTE 到 DCE 的传输任何字符.

Aborting of commands is accomplished by the transmission from the DTE to the DCE of any character.

(这里的DCE(数据通信设备)是调制解调器,DTE(数据终端设备)是AT命令的发送者)

(DCE (data communication equipment) here means modem and DTE (data terminal equipment) the sender of AT commands)

这意味着当您发送要发送的文本"时在\r\n"之前"已发送通过调制解调器命令将被中止.没有办法等久"够了"期待响应被发送.您必须阅读和解析您从调制解调器返回的响应文本.

This means that when you send "text to send" before "\r\n> " is sent by the modem the command will be aborted. There is no way to wait "long enough" for expecting the response be send. You MUST read and parse the response text you get back from the modem.

这同样适用于每个命令之后的最终结果代码(例如 OKERRORCME ERROR 等等).例如发送AT+CMGF=1"然后发送下一个命令而不先等待 OK 是乞求对于问题.所以总是在发送 AT 命令时,你必须等待发送下一个命令之前的最终结果代码.

The same applies for the final result code after each command (e.g. OK, ERROR, CME ERROR and a few more). For instance sending "AT+CMGF=1" and then sending the next command without first waiting for OK is begging for problems. So always when sending AT commands, you MUST wait for the final result code before sending the next command.

请永远不要使用delay来等待任何AT命令响应.它是就像踢挡你路的狗一样有用移动.是的,它可能有时确实有效,但在某些时候你会后悔采取这种方法...

Please never, never use delay to wait for any AT command response. It's as useful as kicking dogs that stand in your way in order to get them to move. Yes it might actually work some times, but at some point you will be sorry for taking that approach...

根据您得到的回复,我可以看出您的问题不是命令流产(虽然你的解析有如上所述的严重问题您应该修复),而 CME ERROR 是您最好的线索.从部分9.2.1 一般错误"在 27.007 它给出 operation not supported 作为值 4 的说明.

Based on the response you get, I can see that your problem is not command abortion (although your parsing have serious problems as described above that you should fix), and the CME ERROR is your best clue. From section "9.2.1 General errors" in 27.007 it gives operation not supported as description for value 4.

27.005 声明:

如果网络发送失败或ME错误,返回最终结果码+CMS ERROR:

If sending fails in a network or an ME error, final result code +CMS ERROR: is returned.

注意这是+CMS ERROR而不是+CME ERROR,但它是适用的,见下文.

Notice that this is +CMS ERROR and not +CME ERROR, but it is applicable, see below.

我猜动作顺序如下:

SM100B GSM调制解调器的AT指令处理部分接受短信数据并将其格式化为适当的格式并将其发送到与 GSM 网络通信的调制解调器.它成功发送向网络发送短信数据并将其报告回 AT 命令处理然后打印 +CMGS: 25 和最终结果代码 OK 的部分.然而一段时间后,网络发回一条拒绝短信的消息,然后作为 +CME ERROR 响应给出.

The AT command handling part of the SM100B GSM modem accepts the sms data and formats it in an appropriate format and sends it of to the part of the modem that communicates with the GSM network. It successfully send the sms data to the network and reports this back to the AT command handling part which then prints +CMGS: 25 and final result code OK. However after a short time the network sends back a rejection message for the sms, which is then given as the +CME ERROR response.

如果我上面的猜测是正确的,应该已经发送了响应改为 +CMS 错误?不,因为最后的回应已经给出了 AT+CMGS 命令(OK),并且永远不应该为一个命令返回多个最终结果代码(错误除外(注 1)).虽然 +CME ERROR 可以替换 ERROR 最终结果代码,它不仅是最终结果代码.来自 AT+CMEE 命令说明:

If my guess above is correct, should the response have been delivered as +CMS ERROR instead? No, because the final response has for the AT+CMGS command has already been given (OK), and returning multiple final result codes for a command should never be done (except by mistake (note 1)). And while +CME ERROR can replace the ERROR final result code, it is not only a final result code. From the AT+CMEE command description:

Set 命令禁用或启用结果代码 +CME ERROR:作为与相关错误的指示MT 的功能.启用后,与 MT 相关的错误会导致 +CME ERROR: final result code 代替常规 ERROR 最终结果代码.当错误与语法、无效参数、或 TA 功能.

Set command disables or enables the use of result code +CME ERROR: as an indication of an error relating to the functionality of the MT. When enabled, MT related errors cause +CME ERROR: final result code instead of the regular ERROR final result code. ERROR is returned normally when error is related to syntax, invalid parameters, or TA functionality.

因此 +CME ERROR 既可以是最终结果代码,也可以是主动提供的结果代码(也可能是中间结果代码).

Thus +CME ERROR can both be an final result code as well as an unsolicited result code (possibly also an intermediate result code).

但是不能AT+CMGS命令已经等待接收网络拒绝并返回 +CMS 错误?可能不是.也不知不觉关于短信发送的网络详细信息,可能是这种情况今天的拒绝可能发生在比以前晚得多的时间.这样的更改有时是与 GSM 相关的 AT 命令的问题,这些命令具有最初与 GSM 行为紧密相关的古老遗产随着技术转向GPRS,有时变得越来越不真实,UMTS、LTE等

But could not the AT+CMGS command have waited to receive the network rejection and returned +CMS ERROR? Probably not. Without knowing too much about the network details of sms sending, it might be the case that rejection today might occur at a much later time than before. Such changes are sometimes a problem with GSM related AT commands which have an old heritage that was originally tightly tied to GSM behaviour which some times becomes less and less true as the technology moves to GPRS, UMTS, LTE, etc.

注 1:

我以前的一位同事曾经抱怨标准的方式有指定的语音呼叫处理,因为在 ATD1234 之后;命令你首先得到最终结果代码 OK,然后当调用是最后你会得到一个新的最终结果代码 NO CARRIER.这太可怕了糟糕的设计,呼叫结束指示应该是特定的主动提供的回应而不是最终回应.

One of my former colleagues used to complain about the way the standard have specified voice call handling, because after a ATD1234; command you first get the final result code OK, and then later when the call is ended you get a new final result code NO CARRIER. This just horribly bad design, the call end indication should have been a specific unsolicited response and not a final response.

您的短信似乎被网络拒绝了.试着找出原因.你的 AT 命令处理也有一些严重的问题你应该解决的问题;没有办法处理 AT 命令读取和解析来自调制解调器的响应文本.

Your sms seems to be rejected by the network. Try to find out why. You also have some serious problems with your AT command handling that you should fix; there is no way to handle AT commands without reading and parsing the response text from the modem.

这篇关于GSM SM5100B C M E R R O R : 4 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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