本帖最后由 lustao 于 2022-3-11 15:59 编辑
在开箱+环境搭建 基础上,获得合宙Air551G双频定位开发板数据
信息类型:
- ??GSV:可见卫星信息
- ??GLL:地理定位信息
- ??RMC:推荐最小定位信息(含时间,日期)
- ??VTG:地面速度信息
- ??GGA:GPS定位信息(含时间)
- ??GSA:当前卫星信息
准备采集??RMC:推荐最小定位信息 (含时间,日期)信息
GNRMC 最小定位信息:
数据详解:$GNRMC,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>,<9>,<10>,<11>,<12>*hh
<1> UTC 时间,hhmmss(时分秒)格式
<2> 定位状态,A=有效定位,V=无效定位
<3>纬度ddmm.mmmm(度分)格式(前面的0也将被传输)
<4> 纬度半球N(北半球)或S(南半球)
<5>经度dddmm.mmmm(度分)格式(前面的0也将被传输)
<6> 经度半球E(东经)或W(西经)
<7>地面速率(000.0~999.9节,前面的0也将被传输)
<8>地面航向(000.0~359.9度,以真北为参考基准,前面的0也将被传输)
<9> UTC 日期,ddmmyy(日月年)格式
<10>磁偏角(000.0~180.0度,前面的0也将被传输)
<11> 磁偏角方向,E(东)或W(西)
<12>模式指示(仅NMEA01833.00版本输出,A=自主定位,D=差分,E=估算,N=数据无效)
环境合宙Air551G双频定位开发板、RTT Studio2.1、Cortex-M4F内核32位评估板
在RTT Studio中打开软硬件资源。
com1:控制台
com2: 合宙Air551G双频定位开发板
部分程序:
- #define SAMPLE_UART_NAME "uart2"
- /* 串口设备名称 PA3 USART2_RX
- PA2 USART2_TX
- 25
- 26*/
- /* 串口接收消息结构*/
- struct rx_msg
- {
- rt_device_t dev;
- rt_size_t size;
- };
- /* 串口设备句柄 */
- static rt_device_t serial;
- char rx_buffsize[2248];
- rt_int32_t rx_bufftime[100];
- static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
- {
- static char *buff= RT_NULL;
- rt_uint32_t rx_length;
- rx_bufftime[10] =rt_tick_get();
- switch (rx_bufftime[0]) {
- case 0:
- rx_bufftime[0] ++;
- rx_bufftime[9] =rx_bufftime[10] ;
- break;
- case 1:
- if(rx_bufftime[10] -rx_bufftime[9] > 500)
- {
- rx_length = rt_device_read(dev, 0, rx_buffsize, size);
- rx_bufftime[0] ++;
- rx_bufftime[9] =rx_bufftime[10] ;
- rx_bufftime[11] =rx_bufftime[10] ;
- buff = rx_buffsize + rx_length ;
- rx_bufftime[1] = rx_length ;
- }
- else {
- }
- case 11 ... 14:
- break;
- case 2:
- if(rx_bufftime[10] -rx_bufftime[9] > 500)
- {
- rx_length = rt_device_read(dev, 0, buff, size);
- rx_bufftime[0] ++;
- rx_bufftime[9] =rx_bufftime[10] ;
- buff = buff + rx_length ;
- *buff = '\0';
- rx_bufftime[1] += rx_length ;}
- else {
- rx_length = rt_device_read(dev, 0, buff, size);
- rx_bufftime[9] =rx_bufftime[10] ;
- buff = buff + rx_length ;
- rx_bufftime[1] += rx_length ;
- }
- break;
- default:
- break;
- }
- }
复制代码
- static void serial_thread_entry(void *parameter)
- {
- char *buffp= RT_NULL;
- char *buffp1= RT_NULL;
- static char rx_buffer[100];
- rt_err_t ret = RT_EOK;
- time_t now;
- while (1)
- {
- if(rx_bufftime[0] == 3)
- {
- buffp= strstr(rx_buffsize, "$GNR"); //ret3 = arecsdn!
- if (buffp!= RT_NULL) {
- buffp1=strchr(buffp,'*');
- strncpy(rx_buffer, buffp, buffp1-buffp);
- rx_buffer[buffp1-buffp] = '\0';
- rt_kprintf("%sn",rx_buffer);
- strncpy(rx_buffsize,rx_buffer+7 , 2);//<1> UTC 时间,hhmmss(时分秒)格式
- rx_buffsize[2] = '\0';
- rt_uint32_t t_time_hh = atoi(rx_buffsize);
- rt_kprintf("t_time_hh:%d +8Hn",t_time_hh);
- strncpy(rx_buffsize,rx_buffer+9 , 2);//<1> UTC 时间,hhmmss(时分秒)格式
- rt_uint32_t t_time_mm = atoi(rx_buffsize);
- rt_kprintf("t_time_mm:%dn",t_time_mm);
- strncpy(rx_buffsize,rx_buffer+11 , 2);//<1> UTC 时间,hhmmss(时分秒)格式
- rt_uint32_t t_time_ss = atoi(rx_buffsize);
- rt_kprintf("t_time_ss:%dn",t_time_ss);
- buffp1=strchr(rx_buffer,'E');
- if (buffp1== NULL) {
- rt_kprintf("set ,E,RTC date failedn");
- return ret;
- }
- strncpy(rx_buffsize, buffp1, 9);
- rx_buffsize[9] = '\0';
- buffp1=strchr(buffp1+2,',');
- if (buffp1== NULL) {
- rt_kprintf("set ,E,, RTC date failedn");
- return ret;
- }
- strncpy(rx_buffsize, buffp1, 9);
- rx_buffsize[9] = '\0';
- buffp1=strchr(buffp1+1,',');
- if (buffp== NULL) {
- rt_kprintf("set ,E,, ,RTC date failedn");
- return ret;
- }
- strncpy(rx_buffsize, buffp1, 7);
- rx_buffsize[7] = '\0';
- strncpy(rx_buffsize,buffp1+1 , 2);//<1> UTC 时间,day_month_year)格式
- rx_buffsize[2] = '\0';
- rt_uint32_t t_time_day = atoi(rx_buffsize);
- rt_kprintf(",t_time_day:%dn",t_time_day);
- strncpy(rx_buffsize,buffp1+3 , 2);//<1> UTC 时间,hhmmss(时分秒)格式
- rt_uint32_t t_time_month = atoi(rx_buffsize);
- rt_kprintf("t_time_month:%dn",t_time_month);
- strncpy(rx_buffsize,buffp1+5 , 2);//<1> UTC 时间,hhmmss(时分秒)格式
- rt_uint32_t t_time_year = atoi(rx_buffsize);
- rt_kprintf("t_time_year:%dn",t_time_year );
- t_time_year += 2000;
- /* 设置日期 */
- ret = set_date(t_time_year, t_time_month, t_time_day );
- if (ret != RT_EOK)
- {
- rt_kprintf("set RTC date failedn");
- return ret;
- }
- /* 设置时间 */
- ret = set_time(t_time_hh, t_time_mm, t_time_ss);// ( rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second )
- if (ret != RT_EOK)
- {
- rt_kprintf("set RTC time failedn");
- return ret;
- }
- /* 延时3秒 */
- rt_thread_mdelay(3000);
- /* 获取时间 */
- now = time(RT_NULL);
- rt_kprintf("%sn", ctime(&now));
- // struct timeval now1;
- now+=3600*8;
- stime(&now);
- now = time(RT_NULL);
- rt_kprintf("now+=3600*8:%sn", ctime(&now));
- }
- rt_kprintf("24 t_time_hh " );
- rt_thread_mdelay(3600*1000*24);
- rx_bufftime[0]=0;
- rx_bufftime[1]=0;
- }
- rt_thread_mdelay(10);
- }
- }
复制代码
- static int uart_dma_sample(int argc, char *argv[])
- {
- rt_err_t ret = RT_EOK;
- char uart_name[RT_NAME_MAX];
- static char msg_pool[256];
- rx_buffsize[0]=0;
- rx_buffsize[1]=0;
- // char str[] = "hello RT-Thread!rn";
- if (argc == 2)
- {
- rt_strncpy(uart_name, argv[1], RT_NAME_MAX);
- }
- else
- {
- rt_strncpy(uart_name, SAMPLE_UART_NAME, RT_NAME_MAX);
- }
- /* 查找串口设备 */
- serial = rt_device_find(uart_name);
- if (!serial)
- {
- rt_kprintf("find %s failed!n", uart_name);
- return RT_ERROR;
- }
- rt_kprintf("find %s 2636line!n", uart_name);
- /* 以 DMA 接收及轮询发送方式打开串口设备 */
- rt_device_open(serial, RT_DEVICE_FLAG_DMA_RX);
- rt_device_set_rx_indicate(serial, uart_input);
- rt_thread_t thread = rt_thread_create("serial", serial_thread_entry, RT_NULL, 1024, 25, 10);
-
- if (thread != RT_NULL)
- {
- rt_thread_startup(thread);
- }
- else
- {
- ret = RT_ERROR;
- }
- return ret;
- }
复制代码
com1:
- [15:03:37.377]发→◇uart_dma_sample
- □
- [15:03:37.392]收←◆uart_dma_sample
- find uart2 2636line!
- msh >
- msh >
- [15:03:40.345]收←◆start rx-char size512
- $GNRMC,070339.089,V,?.5?1,N,1?.7?9,E,0.000,0.00,100322,,,N,V
- t_time_hh:7 +8H
- t_time_mm:3
- t_time_ss:39
- ,t_time_day:10
- t_time_month:3
- t_time_year:22
- [15:03:43.470]收←◆Thu Mar 10 07:03:43 2022
- now+=3600*8:Thu Mar 10 15:03:43 2022
- 24 t_time_hh
复制代码
com2:
- $GNGGA,070339.089,??.52717,N,??.70287,E,0,4,,90.17,M,8.08,M,,*5F
- $GNGSA,A,1,26,16,193,,,,,,,,,,,,,1*25
- $GNGSA,A,1,20,,,,,,,,,,,,,,,4*1A
- $GNGSA,A,1,,,,,,,,,,,,,,,,2*1E
- $GNGSA,A,1,,,,,,,,,,,,,,,,3*1F
- $GPGSV,3,1,09,22,68,154,,26,60,230,31,193,38,167,36,25,26,050,,1*53
- $GPGSV,3,2,09,16,23,223,38,40,13,248,,32,,,42,29,,,27,1*63
- $GPGSV,3,3,09,194,,,30,1*52
- $GPGSV,1,1,01,26,,,30,8*6B
- $GLGSV,1,1,00,1*78
- $GAGSV,1,1,00,1*75
- $GAGSV,1,1,00,2*76
- $BDGSV,2,1,05,19,50,248,,40,46,194,,20,26,188,36,27,17,123,,1*7B
- $BDGSV,2,2,05,22,26,312,,1*44
- $BDGSV,1,1,00,4*70
- $GNRMC,070339.089,V,??.52717,N,??.70287,E,0.193,210.76, 100322,,,N,V*
复制代码
RTC_工作正常,符合程序
|