获取AT命令响应 [英] Get AT command response

查看:246
本文介绍了获取AT命令响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一个Arduino欧诺与SIM900 GPS / GPRS模块,我使用AT命令,我怎样才能在命令(即OK,ERROR),这样我可以做一些事情如果响应==OK或响应==ERROR

I am using an Arduino Uno with a sim900 gps/gprs module and I'm using at commands, how can I get the response of at command (i.e OK, ERROR) so that I can do something if response == "OK" or response == "ERROR"

推荐答案

您可以只发出AT命令后,使用以下code读取SIM900 GSM模块响应。

You can use following code to read response from SIM900 GSM Module just after issuing AT command.

char response[200];
for(int i = 0 ; Serial.available() > 0 && i<200 ; i++) {
   response[i++] = Serial.read();
}

阅读响应,您可以使用的strstr()函数来检查它是否是'的确定的'或'的错误',如下给出:

After reading response you can use strstr() function to check whether it is 'OK' or 'ERROR', as given below:

if(strstr(responce, "OK"){
   /*Do your code to handle OK response*/
}
else if(strstr(responce, "ERROR"){
   /*Do your code to handle ERROR response*/
}
else {
   /* You got some other response*/
}

这篇关于获取AT命令响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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