diff options
author | Gary E. Miller <gem@rellim.com> | 2010-12-28 15:40:59 -0800 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2010-12-28 15:40:59 -0800 |
commit | cd6db4e8a3161530f921ad96d82ca5c866928cce (patch) | |
tree | f1761bd20baaeef5144707bc6bb29aae7d8a98c5 | |
parent | 61689e31730f70536030953e43077de9aa3deb8f (diff) | |
download | gpsd-cd6db4e8a3161530f921ad96d82ca5c866928cce.tar.gz |
Change uint2int() macro so as not to offend ckuethe. More comments.
Move comments and data scaling on Subframe 3.
-rw-r--r-- | subframe.c | 49 |
1 files changed, 25 insertions, 24 deletions
@@ -8,14 +8,8 @@ #include "gpsd.h" #include "timebase.h" -#define BIT6 0x00020 -#define BIT8 0x00080 -#define BIT11 0x00400 -#define BIT16 0x08000 -#define BIT22 0x0200000 -#define BIT24 0x0800000 /* convert unsigned to signed */ -#define uint2int( u, m) ( u & m ? u - m : u) +#define uint2int( u, bit) ( u & (1<<bit) ? u - (1<<bit) : u) /*@ -usedef @*/ int gpsd_interpret_subframe_raw(struct gps_device_t *session, @@ -147,21 +141,21 @@ static void subframe_almanac(unsigned int svid, uint32_t words[], almp->sqrtA = ( words[5] & 0xFFFFFF); almp->d_sqrtA = pow(2.0,-11) * almp->sqrtA; almp->Omega0 = ( words[6] & 0xFFFFFF); - almp->Omega0 = uint2int(almp->Omega0, BIT24); + almp->Omega0 = uint2int(almp->Omega0, 24); almp->d_Omega0 = pow(2.0, -23) * almp->Omega0; almp->omega = ( words[7] & 0xFFFFFF); - almp->omega = uint2int(almp->omega, BIT24); + almp->omega = uint2int(almp->omega, 24); almp->d_omega = pow(2.0, -23) * almp->omega; almp->M0 = ( words[8] & 0xFFFFFF); - almp->M0 = uint2int(almp->M0, BIT24); + almp->M0 = uint2int(almp->M0, 24); almp->d_M0 = pow(2.0,-23) * almp->M0; almp->af1 = ((words[9] >> 5) & 0x0007FF); - almp->af1 = uint2int(almp->af1, BIT11); + almp->af1 = uint2int(almp->af1, 11); almp->d_af1 = pow(2.0,-38) * almp->af1; almp->af0 = ((words[9] >> 16) & 0x0000FF); almp->af0 <<= 3; almp->af0 |= ((words[9] >> 2) & 0x000007); - almp->af0 = uint2int(almp->af0, BIT11); + almp->af0 = uint2int(almp->af0, 11); almp->d_af0 = pow(2.0,-20) * almp->af0; gpsd_report(LOG_PROG, "50B: SF:%d SV:%2u TSV:%2u data_id %d e:%g toa:%lu " @@ -215,7 +209,7 @@ struct subframe { int8_t af2; double d_af2; /* Tgd, L1-L2 correction term, 8 bits signed, seconds */ - int32_t Tgd; + int8_t Tgd; double d_Tgd; } sub1; /* subframe 2, part of ephemeris, see IS-GPS-200E, Table 20-II @@ -347,7 +341,6 @@ void gpsd_interpret_subframe(struct gps_device_t *session, subp->sub1.IODC = (words[2] & 0x000003); /* IODC 2 MSB */ subp->sub1.l2p = ((words[3] >> 23) & 0x000001); /* L2 P flag */ subp->sub1.Tgd = ( words[6] & 0x0000FF); - subp->sub1.Tgd = uint2int(subp->sub1.Tgd, BIT8); subp->sub1.d_Tgd = pow(2.0, -31) * subp->sub1.Tgd; subp->sub1.toc = ( words[7] & 0x00FFFF); subp->sub1.l_toc = subp->sub1.toc << 4; @@ -356,7 +349,7 @@ void gpsd_interpret_subframe(struct gps_device_t *session, subp->sub1.af1 = ( words[8] & 0x00FFFF); subp->sub1.d_af1 = pow(2.0, -43) * subp->sub1.af1; subp->sub1.af0 = ((words[9] >> 1) & 0x03FFFFF); - subp->sub1.af0 = uint2int(subp->sub1.af0, BIT22); + subp->sub1.af0 = uint2int(subp->sub1.af0, 22); subp->sub1.d_af0 = pow(2.0, -31) * subp->sub1.af0; subp->sub1.IODC <<= 8; subp->sub1.IODC |= ((words[7] >> 16) & 0x00FF); @@ -387,7 +380,7 @@ void gpsd_interpret_subframe(struct gps_device_t *session, subp->sub2.M0 = ( words[3] & 0x0000FF); subp->sub2.M0 <<= 24; subp->sub2.M0 |= ( words[4] & 0x00FFFFFF); - subp->sub2.M0 = uint2int(subp->sub2.M0, BIT24); + subp->sub2.M0 = uint2int(subp->sub2.M0, 24); subp->sub2.d_M0 = pow(2.0,-31) * subp->sub2.M0; subp->sub2.Cuc = ((words[5] >> 8) & 0x00FFFF); subp->sub2.d_Cuc = pow(2.0,-29) * subp->sub2.Cuc; @@ -437,7 +430,15 @@ void gpsd_interpret_subframe(struct gps_device_t *session, * Angle of Inclination, 16 bits signed, radians*/ uint16_t Cic; double d_Cic; - int32_t Cis, Crc, i0; + /* Cis, Amplitude of the Sine Harmonic Correction Term to the + * Angle of Inclination, 16 bits, unsigned, scale 2**-29, radians */ + int16_t Cis; + double d_Cis; + /* Crc, Amplitude of the Cosine Harmonic Correction Term to the + * Orbit Radius, 16 bits signed, scale 2**-5, meters */ + int16_t Crc; + double d_Crc; + int32_t i0; /* Omega0, Longitude of Ascending Node of Orbit Plane at Weekly * Epoch, 32 bits signed, semi-circles */ int32_t Omega0; @@ -457,26 +458,26 @@ void gpsd_interpret_subframe(struct gps_device_t *session, Omega0 |= ( words[3] & 0x00FFFFFF); d_Omega0 = pow(2.0, -31) * Omega0; Cis = ((words[4] >> 8) & 0x00FFFF); - Cis = uint2int(Cis, BIT16); + d_Cis = pow(2.0, -29) * Cis; i0 = ( words[4] & 0x0000FF); i0 <<= 24; i0 |= ( words[5] & 0x00FFFFFF); Crc = ((words[6] >> 8) & 0x00FFFF); - Crc = uint2int(Crc, BIT16); + d_Crc = pow(2.0, -5) * Crc; omega = ( words[6] & 0x0000FF); omega <<= 24; omega |= ( words[7] & 0x00FFFFFF); d_omega = pow(2.0, -31) * omega; Omegad = ( words[8] & 0x00FFFFFF); - Omegad = uint2int(Omegad, BIT24); + Omegad = uint2int(Omegad, 24); d_Omegad = pow(2.0, -43) * Omegad; IODE = ((words[9] >> 16) & 0x0000FF); IDOT = ((words[9] >> 2) & 0x003FFF); d_IDOT = pow(2.0, -43) * IDOT; gpsd_report(LOG_PROG, "50B: SF:3 SV:%2u IODE:%3u I IDOT:%.6g Cic:%.6e Omega0:%.11e " - " Cis:%d i0:%d crc:%d omega:%.11e Omegad:%.6e\n", - svid, IODE, d_IDOT, d_Cic, d_Omega0, Cis, i0, Crc, + " Cis:%.7g i0:%d Crc:%.7g omega:%.11e Omegad:%.6e\n", + svid, IODE, d_IDOT, d_Cic, d_Omega0, d_Cis, i0, d_Crc, d_omega, d_Omegad ); } break; @@ -627,7 +628,7 @@ void gpsd_interpret_subframe(struct gps_device_t *session, ERD[30] = (char)((words[9] >> 2) & 0x00003F); for ( i = 1; i < 31; i++ ) { - ERD[i] = uint2int(ERD[i], BIT6); + ERD[i] = uint2int(ERD[i], 6); } gpsd_report(LOG_PROG, "50B: SF:4-13 data_id %d ai:%u " @@ -832,7 +833,7 @@ void gpsd_interpret_subframe(struct gps_device_t *session, beta2 = ((words[4] >> 8) & 0x0000FF); beta3 = ((words[4] >> 0) & 0x0000FF); A1 = ((words[5] >> 0) & 0xFFFFFF); - A1 = uint2int(A1, BIT24); + A1 = uint2int(A1, 24); A0 = ((words[6] >> 0) & 0xFFFFFF); A0 <<= 8; A0 |= ((words[7] >> 16) & 0x00FFFF); |