我是靠谱客的博主 想人陪夏天,这篇文章主要介绍rt-thread AT设备EC20获取GNSS信息,现在分享给大家,希望可以做个参考。

EC20的某些版本,如EC20CEFILG-128-SGNS是具有GPS定位功能的,参照手册有对应的AT指令集可以读取,通过at_exec_cmd可以很方便的执行。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <rtthread.h> #define DBG_TAG "main" #define DBG_LVL DBG_LOG #include <rtdbg.h> #include <at.h> static void show_information() { at_response_t resp = RT_NULL; resp = at_create_resp(512, 0, rt_tick_from_millisecond(5000)); at_exec_cmd(resp, "AT+QGPSGNMEA="RMC""); LOG_D("resp->line_counts:%d", resp->line_counts); for (int i = 0; i < (int) resp->line_counts; i++) { LOG_D("%s", at_resp_get_line(resp, i + 1)); } at_delete_resp(resp); } int main(void) { int count = 1; int i = 0; //用于保存是否已经开启GPS LOG_D("Hello RT-Thread!"); rt_thread_mdelay(5000); LOG_D("Hello RT-Thread!"); at_response_t resp = RT_NULL; resp = at_create_resp(512, 0, rt_tick_from_millisecond(5000)); at_exec_cmd(resp, "AT+QGPS?"); LOG_D("resp->line_counts:%d", resp->line_counts); LOG_D("at_resp_get_line_by_kw:%s", at_resp_get_line_by_kw(resp, "+QGPS:")); at_resp_parse_line_args_by_kw(resp, "+QGPS:", "+QGPS:%d", &i); if (i == 0) { at_exec_cmd(resp, "AT+QGPS=1"); } LOG_D("at_resp_parse_line_args_by_kw:%d", i); for (int i = 0; i < (int) resp->line_counts; i++) { LOG_D("%s", at_resp_get_line(resp, i + 1)); } at_exec_cmd(resp, "AT+QGPSCFG=?"); at_delete_resp(resp); while (count++) { show_information(); rt_thread_mdelay(1000); } return RT_EOK; }

最后

以上就是想人陪夏天最近收集整理的关于rt-thread AT设备EC20获取GNSS信息的全部内容,更多相关rt-thread内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(72)

评论列表共有 0 条评论

立即
投稿
返回
顶部