gps正用解算卫星个数或GSA语句上传问题

 

转载时请注明出处和作者文章出处:http://blog.csdn.net/lbmygf/archive/2011/06/28/6573036.aspx

作者:曼云-->孤峰

 

 

 

最近发现很多人都不知道,gps正用解算卫星个数或GSA语句数据上传给谁 ?

 

在GPGSA的数据中有:

 

 

a.GPS DOP and Active Satellites(GSA)当前卫星信息

$GPGSA,<1>,<2>,<3>,<3>,<3>,<3>,<3>,<3>,<3>,<3>,<3>,<3>,<3>,<3>,<4>,<5>,<6>*hh<CR><LF>
<1> 模式,M=手动,A=自动
<2> 定位类型,1=没有定位,2=2D定位,3=3D定位

<3> PRN码(伪随机噪声码),正在用于解算位置的卫星号(01~32,前面的0也将被传输)。
<4> PDOP位置精度因子(0.5~99.9)
<5> HDOP水平精度因子(0.5~99.9)
<6> VDOP垂直精度因子(0.5~99.9)

 

 

注意 3 部分,那就是 正在用于解算位置的卫星号 刚好32个标号, 现在看下gps.h中

GpsSvStatus结构体

 

 

 

typedef struct {

    /** set to sizeof(GpsSvInfo) */

    size_t          size;

    /** Pseudo-random number for the SV. */

    int     prn;

    /** Signal to noise ratio. */

    float   snr;

    /** Elevation of SV in degrees. */

    float   elevation;

    /** Azimuth of SV in degrees. */

    float   azimuth;

} GpsSvInfo;

 

/** Represents SV status. */

typedef struct {

    /** set to sizeof(GpsSvStatus) */

    size_t          size;

 

    /** Number of SVs currently visible. */

    int         num_svs;

 

    /** Contains an array of SV information. */

    GpsSvInfo   sv_list[GPS_MAX_SVS];

 

    /** Represents a bit mask indicating which SVs

     * have ephemeris data.

     */

    uint32_t    ephemeris_mask;

 

    /** Represents a bit mask indicating which SVs

     * have almanac data.

     */

    uint32_t    almanac_mask;

 

    /**

     * Represents a bit mask indicating which SVs

     * were used for computing the most recent position fix.

     */

    uint32_t    used_in_fix_mask;

} GpsSvStatus;

 

注意最后一项 uint32_t    used_in_fix_mask ,32位的数据 ,刚好与卫星号(01-32)匹配,所以问题就解决了。

 

下面吧我代码贴出来给大家参考下:

 

 else if ( !memcmp(tok.p, "GSA", 3) ) {

 

 

Token tok_use_prn1   = nmea_tokenizer_get(tzer, 3);

Token tok_use_prn2   = nmea_tokenizer_get(tzer, 4);

Token tok_use_prn3   = nmea_tokenizer_get(tzer, 5);

Token tok_use_prn4   = nmea_tokenizer_get(tzer, 6);

Token tok_use_prn5   = nmea_tokenizer_get(tzer, 7);

Token tok_use_prn6   = nmea_tokenizer_get(tzer, 8);

Token tok_use_prn7   = nmea_tokenizer_get(tzer, 9);

Token tok_use_prn8   = nmea_tokenizer_get(tzer, 10);

Token tok_use_prn9   = nmea_tokenizer_get(tzer, 11);

Token tok_use_prn10 = nmea_tokenizer_get(tzer, 12);

Token tok_use_prn11 = nmea_tokenizer_get(tzer, 13);

Token tok_use_prn12 = nmea_tokenizer_get(tzer, 14);

 

nmea_reader_update_use_prn(r, tok_use_prn1,   tok_use_prn2,    tok_use_prn3,

    tok_use_prn4,   tok_use_prn5,    tok_use_prn6,

    tok_use_prn7,   tok_use_prn8,    tok_use_prn9,

    tok_use_prn10, tok_use_prn11,  tok_use_prn12);

}

 

 

 

 

static int

nmea_reader_update_use_prn(NmeaReader*  r, 

 Token tok_use_prn1,   Token tok_use_prn2,   Token  tok_use_prn3,

        Token tok_use_prn4,   Token tok_use_prn5,   Token  tok_use_prn6,

        Token tok_use_prn7,   Token tok_use_prn8,    Token tok_use_prn9,

        Token tok_use_prn10, Token tok_use_prn11,  Token tok_use_prn12)

{

if (tok_use_prn1.p   +2  == tok_use_prn1.end)    r->sv.used_in_fix_mask |= (1 <<( str2int(tok_use_prn1.p,   tok_use_prn1.p+2)   -1));

if (tok_use_prn2.p   +2  == tok_use_prn2.end)    r->sv.used_in_fix_mask |= (1 <<( str2int(tok_use_prn2.p,   tok_use_prn2.p+2)   -1));

if (tok_use_prn3.p   +2  == tok_use_prn3.end)    r->sv.used_in_fix_mask |= (1 <<( str2int(tok_use_prn3.p,   tok_use_prn3.p+2)   -1));

if (tok_use_prn4.p   +2  == tok_use_prn4.end)    r->sv.used_in_fix_mask |= (1 <<( str2int(tok_use_prn4.p,   tok_use_prn4.p+2)   -1));

if (tok_use_prn5.p   +2  == tok_use_prn5.end)    r->sv.used_in_fix_mask |= (1 <<( str2int(tok_use_prn5.p,   tok_use_prn5.p+2)   -1));

if (tok_use_prn6.p   +2  == tok_use_prn6.end)    r->sv.used_in_fix_mask |= (1 <<( str2int(tok_use_prn6.p,   tok_use_prn6.p+2)   -1));

if (tok_use_prn7.p   +2  == tok_use_prn7.end)    r->sv.used_in_fix_mask |= (1 <<( str2int(tok_use_prn7.p,   tok_use_prn7.p+2)   -1));

if (tok_use_prn8.p   +2  == tok_use_prn8.end)    r->sv.used_in_fix_mask |= (1 <<( str2int(tok_use_prn8.p,   tok_use_prn8.p+2)   -1));

if (tok_use_prn9.p   +2  == tok_use_prn9.end)    r->sv.used_in_fix_mask |= (1 <<( str2int(tok_use_prn9.p,   tok_use_prn9.p+2)   -1));

if (tok_use_prn10.p +2  == tok_use_prn10.end)  r->sv.used_in_fix_mask |= (1 <<( str2int(tok_use_prn10.p, tok_use_prn10.p+2) -1));

if (tok_use_prn11.p +2  == tok_use_prn11.end)  r->sv.used_in_fix_mask |= (1 <<( str2int(tok_use_prn11.p, tok_use_prn11.p+2) -1));

if (tok_use_prn12.p +2  == tok_use_prn12.end)  r->sv.used_in_fix_mask |= (1 <<( str2int(tok_use_prn12.p, tok_use_prn12.p+2) -1));

return 0;

}

 

 

so   完工了

 

 

你可能感兴趣的:(struct,list,token,float,Signal)