NMEA

static void _gps_task(void *arg) {
    u8_t size;
    u8_t marker;
    u8_t type[5];
    u8_t body[128];
	
		nmeaINFO info;          //GPS解码后得到的信息
    nmeaPARSER parser;      //解码时使用的数据结构  

		
    nmea_zero_INFO(&info);	//初始化NMEA数据结构体
    nmea_parser_init(&parser);//初始化NMEA数据结构体
	
    _gps_init();
    os_driver_ioctl(_gps_dev, SET_EMPTY_FIFO, 0); // 清空接收缓冲队列

    OS_RTT_printf(0, "GPS Task implementation \n");

    while (1) {

        memset((void *) &marker, 0, sizeof(marker));
        size = _gps_read(&marker, 1);
        if (size == 0) {
            msleep(200);
            continue;
        }

        if (marker != '$') continue;

        memset((void *) &type, 0, sizeof(type));
        _gps_read((u8_t *) type, 5);
        OS_RTT_printf(0, "Type:%s \n", type);
        if (type[0] != 'G' || type[1] != 'N' || type[2] != 'Z' || type[3] != 'D' || type[4] != 'A') {
            continue;
        } else {
            _gps_read((u8_t *) body, 27);
            OS_RTT_printf(0, "Rec:%s \n", body);
        }
    }
}

  

 

几个重要的结构体:

1.返回时用来保存返回数据的。

_nmeaINFO
typedef struct _nmeaINFO
{
    int     smask;      /**< Mask specifying types of packages from which data have been obtained 掩码,指定从其中获取数据的包的类型 */

    nmeaTIME utc;       /**< UTC of position 位置的UTC */

    int     sig;        /**< GPS quality indicator (0 = Invalid; 1 = Fix; 2 = Differential, 3 = Sensitive) GPS质量指示器(0 =无效;1 =修复;2 =微分,3 =灵敏)*/
    int     fix;        /**< Operating mode, used for navigation (1 = Fix not available; 2 = 2D; 3 = 3D) 操作模式,用于导航(1 =修复不可用;2 = 2 d;3 = 3 d) */

    double  PDOP;       /**< Position Dilution Of Precision 位置精度系数*/
    double  HDOP;       /**< Horizontal Dilution Of Precision 水平精度系数*/
    double  VDOP;       /**< Vertical Dilution Of Precision 垂直精度系数*/
   
    double  lat;        /**< Latitude in NDEG - +/-[degree][min].[sec/60 ]纬度为NDEG - +/-[度][分钟]。(秒/ 60) */
    double  lon;        /**< Longitude in NDEG - +/-[degree][min].[sec/60] 经度在NDEG - +/-[度][分钟].[秒/60]*/
    double  elv;        /**< Antenna altitude above/below mean sea level (geoid) in meters 天线在平均海平面(大地水准面)上/下的高度,单位为米*/
    double  sog;        /**< 数值 对地速度,单位为节 */
    double  speed;      /**< Speed over the ground in kilometers/hour 在地面上的速度,单位为公里/小时*/
    double  direction;  /**< Track angle in degrees True 跟踪角度,度为真*/
    double  declination; /**< Magnetic variation degrees (Easterly var. subtracts from true course) 磁场变化度(东方方差减去真实航向)*/
    char    mode;       /**< 字符 定位模式标志 (A = 自主模式, D = 差分模式, E = 估算模式, N = 数据无效) */
    nmeaSATINFO satinfo; /**< Satellites information 卫星信息*/
    nmeaSATINFO BDsatinfo; /**北斗卫星信息*/
		
		int txt_level;
		char *txt;
		
} nmeaINFO;

  

posted @ 2022-09-04 17:08  glpa  阅读(183)  评论(0编辑  收藏  举报