如何在内存有限的嵌入式系统上使用AT阅读短信? [英] How to read SMS using AT on an embedded system with limited memory?

查看:272
本文介绍了如何在内存有限的嵌入式系统上使用AT阅读短信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一块嵌入式软件,它也通过AT协议与调制解调器进行通信。现在我想阅读消息,但是我遇到了一个内存容量的问题。可能是有多个消息给我,并使用AT命令集,我让他们一次返回。我没有记忆能力来存储它们(我只有1KB左右)。



看到这里的例子:
http://www.smssolutions.net/tutorials/gsm/receivesmsat/



我发送 AT + CMGL =ALL。然后我会收到以下内容:

  + CMGL:1,REC UNREAD,+ 31625012354,,07 / 07 / 05,09:55:16 + 08
测试信息1
+ CMGL:2,REC UNREAD,+ 31625012354,,07/07 / 05,09:56: 03 + 08
测试消息2

OK

这里的问题是消息可以包含某些指令,这些指令会触发某些操作,这可能需要一段时间才能执行。在此期间,用于从调制解调器接收数据的缓冲区可以(将)溢出。另一方面,我没有内存容量首先将所有消息读入内存,以防止缓冲区溢出,然后从内存中处理它们。



正在阅读单个消息, AT + CMGR = 2 ,只返回一条消息:

  + CMGL:2,REC UNREAD,+ 31625012354,,07/07 / 05,09:56:03 + 08
测试信息2

OK

然而,为了这个工作,我需要知道存储位置(上面的2个例如)



我的直觉感觉告诉我要先运行 AT + CMGL ,解析数据,只保留存储位置,然后使用 AT + CMGR 逐个请求并解析(并删除)它们。



但是,我想收到第二个意见。我不是有经验的AT和嵌入式软件,所以也许我忽略了一些。

解决方案

发送 AT + CMGL =ALL并将第一条消息保存回归。忽略所有其他数据,直到您收到 OK ,表示调制解调器已完成。在处理第一条消息之后,通过发送 AT + CMGD =< NUM> (第一个消息的号码)删除它。



是的,这很丑,但效果很好。


I'm developing a piece of embedded software, which also communicates with a modem through the AT protocol. Now I want to read messages, but I have come across a problem with my memory capacity. It could be that there are multiple messages for me, and using the AT command set, I get them returned all at once. I do not have the memory capacity to store them all to process them (I only have 1KB or so).

See the examples here: http://www.smssolutions.net/tutorials/gsm/receivesmsat/

I send AT+CMGL="ALL". I then get back something like:

+CMGL: 1,"REC UNREAD","+31625012354",,"07/07/05,09:55:16+08"
Test message 1
+CMGL: 2,"REC UNREAD","+31625012354",,"07/07/05,09:56:03+08"
Test message 2

OK

The problem here is that the message can contain certain directives, which trigger certain actions, which might take a while to execute. During that time, the buffer for receiving data from the modem can (will) overflow. On the other hand, I do not have the memory capacity to first read ALL the messages into memory to prevent the buffer overflow, and then process them from memory.

An alternative is reading a single message, with AT+CMGR=2, getting back just one message:

+CMGL: 2,"REC UNREAD","+31625012354",,"07/07/05,09:56:03+08"
Test message 2

OK

However, for this to work, I need know the storage location (2 in the above example).

My gut feeling tells me to first run AT+CMGL, parsing the data and only keeping the storage locations, then requesting and parsing (and deleting) them one by one with AT+CMGR.

However, I would like to receive a second opinion. I'm not that experienced with AT nor with embedded software yet, so perhaps I'm overlooking something.

解决方案

Send AT+CMGL="ALL" and save the first message up to the return. Ignore all other data until you receive OK, indicating that the modem is done. After processing the first message, delete it by sending AT+CMGD=<NUM> (where is the number of the first message). Repeat.

Yes, it's kind of ugly, but it works fine.

这篇关于如何在内存有限的嵌入式系统上使用AT阅读短信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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