📄 tsip_ifc.c
字号:
float *t_oa,
float *i_0,
float *OMEGA_dot,
float *sqrt_A,
float *OMEGA_0,
float *omega,
float *M_0)
/* almanac data for specified satellite */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 39) return TRUE;
*sv_prn = buf[0];
*t_zc = bGetSingle (&buf[1]);
*week_num = bGetShort (&buf[5]);
*eccentricity = bGetSingle (&buf[7]);
*t_oa = bGetSingle (&buf[11]);
*i_0 = bGetSingle (&buf[15]);
*OMEGA_dot = bGetSingle (&buf[19]);
*sqrt_A = bGetSingle (&buf[23]);
*OMEGA_0 = bGetSingle (&buf[27]);
*omega = bGetSingle (&buf[31]);
*M_0 = bGetSingle (&buf[35]);
return FALSE;
}
short rpt_0x41 (TSIPPKT *rpt,
float *time_of_week,
float *UTC_offset,
short *week_num)
/* GPS time */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 10) return TRUE;
*time_of_week = bGetSingle (buf);
*week_num = bGetShort (&buf[4]);
*UTC_offset = bGetSingle (&buf[6]);
return FALSE;
}
short rpt_0x42 (TSIPPKT *rpt,
float pos_ECEF[3],
float *time_of_fix)
/* position in ECEF, single precision */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 16) return TRUE;
pos_ECEF[0] = bGetSingle (buf);
pos_ECEF[1]= bGetSingle (&buf[4]);
pos_ECEF[2]= bGetSingle (&buf[8]);
*time_of_fix = bGetSingle (&buf[12]);
return FALSE;
}
short rpt_0x43 (TSIPPKT *rpt,
float ECEF_vel[3],
float *freq_offset,
float *time_of_fix)
/* velocity in ECEF, single precision */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 20) return TRUE;
ECEF_vel[0] = bGetSingle (buf);
ECEF_vel[1] = bGetSingle (&buf[4]);
ECEF_vel[2] = bGetSingle (&buf[8]);
*freq_offset = bGetSingle (&buf[12]);
*time_of_fix = bGetSingle (&buf[16]);
return FALSE;
}
short rpt_0x45 (TSIPPKT *rpt,
unsigned char *major_nav_version,
unsigned char *minor_nav_version,
unsigned char *nav_day,
unsigned char *nav_month,
unsigned char *nav_year,
unsigned char *major_dsp_version,
unsigned char *minor_dsp_version,
unsigned char *dsp_day,
unsigned char *dsp_month,
unsigned char *dsp_year)
/* software versions */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 10) return TRUE;
*major_nav_version = buf[0];
*minor_nav_version = buf[1];
*nav_day = buf[2];
*nav_month = buf[3];
*nav_year = buf[4];
*major_dsp_version = buf[5];
*minor_dsp_version = buf[6];
*dsp_day = buf[7];
*dsp_month = buf[8];
*dsp_year = buf[9];
return FALSE;
}
short rpt_0x46 (TSIPPKT *rpt,
unsigned char *status_code,
unsigned char *error_code)
/* receiver health and status */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 2) return TRUE;
*status_code = buf[0];
*error_code = buf[1];
return FALSE;
}
short rpt_0x47 (TSIPPKT *rpt,
unsigned char *nsvs, unsigned char *sv_prn,
float *snr)
/* signal levels for all satellites tracked */
{
short isv;
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 1 + 5*buf[0]) return TRUE;
*nsvs = buf[0];
for (isv = 0; isv < (*nsvs); isv++) {
sv_prn[isv] = buf[5*isv + 1];
snr[isv] = bGetSingle (&buf[5*isv + 2]);
}
return FALSE;
}
short rpt_0x48 (TSIPPKT *rpt,
unsigned char *message)
/* GPS system message */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 22) return TRUE;
memcpy (message, buf, 22);
message[22] = 0;
return FALSE;
}
short rpt_0x49 (TSIPPKT *rpt,
unsigned char *sv_health)
/* health for all satellites from almanac health page */
{
short i;
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 32) return TRUE;
for (i = 0; i < 32; i++) sv_health [i]= buf[i];
return FALSE;
}
short rpt_0x4A (TSIPPKT *rpt,
float *lat,
float *lon,
float *alt,
float *clock_bias,
float *time_of_fix)
/* position in lat-lon-alt, single precision */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 20) return TRUE;
*lat = bGetSingle (buf);
*lon = bGetSingle (&buf[4]);
*alt = bGetSingle (&buf[8]);
*clock_bias = bGetSingle (&buf[12]);
*time_of_fix = bGetSingle (&buf[16]);
return FALSE;
}
short rpt_0x4A_2 (TSIPPKT *rpt,
float *alt, float *dummy , unsigned char *alt_flag)
/* reference altitude parameters */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 9) return TRUE;
*alt = bGetSingle (buf);
*dummy = bGetSingle (&buf[4]);
*alt_flag = buf[8];
return FALSE;
}
short rpt_0x4B (TSIPPKT *rpt,
unsigned char *machine_id,
unsigned char *status_1,
unsigned char *status_2)
/* machine ID code, status */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 3) return TRUE;
*machine_id = buf[0];
*status_1 = buf[1];
*status_2 = buf[2];
return FALSE;
}
short rpt_0x4C (TSIPPKT *rpt,
unsigned char *dyn_code,
float *el_mask,
float *snr_mask,
float *dop_mask,
float *dop_switch)
/* operating parameters and masks */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 17) return TRUE;
*dyn_code = buf[0];
*el_mask = bGetSingle (&buf[1]);
*snr_mask = bGetSingle (&buf[5]);
*dop_mask = bGetSingle (&buf[9]);
*dop_switch = bGetSingle (&buf[13]);
return FALSE;
}
short rpt_0x4D (TSIPPKT *rpt,
float *osc_offset)
/* oscillator offset */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 4) return TRUE;
*osc_offset = bGetSingle (buf);
return FALSE;
}
short rpt_0x4E (TSIPPKT *rpt,
unsigned char *response)
/* yes/no response to command to set GPS time */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 1) return TRUE;
*response = buf[0];
return FALSE;
}
short rpt_0x4F (TSIPPKT *rpt,
double *a0,
float *a1,
float *time_of_data,
short *dt_ls,
short *wn_t,
short *wn_lsf,
short *dn,
short *dt_lsf)
/* UTC data */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 26) return TRUE;
*a0 = bGetDouble (buf);
*a1 = bGetSingle (&buf[8]);
*dt_ls = bGetShort (&buf[12]);
*time_of_data = bGetSingle (&buf[14]);
*wn_t = bGetShort (&buf[18]);
*wn_lsf = bGetShort (&buf[20]);
*dn = bGetShort (&buf[22]);
*dt_lsf = bGetShort (&buf[24]);
return FALSE;
}
/**/
short rpt_0x54 (TSIPPKT *rpt,
float *clock_bias,
float *freq_offset,
float *time_of_fix)
/* clock offset and frequency offset in 1-SV (0-D) mode */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 12) return TRUE;
*clock_bias = bGetSingle (buf);
*freq_offset = bGetSingle (&buf[4]);
*time_of_fix = bGetSingle (&buf[8]);
return FALSE;
}
short rpt_0x55 (TSIPPKT *rpt,
unsigned char *pos_code,
unsigned char *vel_code,
unsigned char *time_code,
unsigned char *aux_code)
/* I/O serial options */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 4) return TRUE;
*pos_code = buf[0];
*vel_code = buf[1];
*time_code = buf[2];
*aux_code = buf[3];
return FALSE;
}
short rpt_0x56 (TSIPPKT *rpt,
float vel_ENU[3], float *freq_offset, float *time_of_fix)
/* velocity in east-north-up coordinates */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 20) return TRUE;
/* east */
vel_ENU[0] = bGetSingle (buf);
/* north */
vel_ENU[1] = bGetSingle (&buf[4]);
/* up */
vel_ENU[2] = bGetSingle (&buf[8]);
*freq_offset = bGetSingle (&buf[12]);
*time_of_fix = bGetSingle (&buf[16]);
return FALSE;
}
short rpt_0x57 (TSIPPKT *rpt,
unsigned char *source_code, unsigned char *diag_code,
short *week_num,
float *time_of_fix)
/* info about last computed fix */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 8) return TRUE;
*source_code = buf[0];
*diag_code = buf[1];
*time_of_fix = bGetSingle (&buf[2]);
*week_num = bGetShort (&buf[6]);
return FALSE;
}
short rpt_0x58 (TSIPPKT *rpt,
unsigned char *op_code, unsigned char *data_type, unsigned char *sv_prn,
unsigned char *data_length, unsigned char *data_packet)
/* GPS system data or acknowledgment of GPS system data load */
{
unsigned char *buf, *buf4;
short dl;
ALM_INFO* alminfo;
ION_INFO* ioninfo;
UTC_INFO* utcinfo;
NAV_INFO* navinfo;
buf = rpt->buf;
if (buf[0] == 2) {
if (rpt->len < 4) return TRUE;
if (rpt->len != 4+buf[3]) return TRUE;
}
else if (rpt->len != 3) {
return TRUE;
}
*op_code = buf[0];
*data_type = buf[1];
*sv_prn = buf[2];
if (*op_code == 2) {
dl = buf[3];
*data_length = (unsigned char)dl;
buf4 = &buf[4];
switch (*data_type) {
case 2:
/* Almanac */
if (*data_length != sizeof (ALM_INFO)) return TRUE;
alminfo = (ALM_INFO*)data_packet;
alminfo->t_oa_raw = buf4[0];
alminfo->SV_health = buf4[1];
alminfo->e = bGetSingle(&buf4[2]);
alminfo->t_oa = bGetSingle(&buf4[6]);
alminfo->i_0 = bGetSingle(&buf4[10]);
alminfo->OMEGADOT = bGetSingle(&buf4[14]);
alminfo->sqrt_A = bGetSingle(&buf4[18]);
alminfo->OMEGA_0 = bGetSingle(&buf4[22]);
alminfo->omega = bGetSingle(&buf4[26]);
alminfo->M_0 = bGetSingle(&buf4[30]);
alminfo->a_f0 = bGetSingle(&buf4[34]);
alminfo->a_f1 = bGetSingle(&buf4[38]);
alminfo->Axis = bGetSingle(&buf4[42]);
alminfo->n = bGetSingle(&buf4[46]);
alminfo->OMEGA_n = bGetSingle(&buf4[50]);
alminfo->ODOT_n = bGetSingle(&buf4[54]);
alminfo->t_zc = bGetSingle(&buf4[58]);
alminfo->weeknum = bGetShort(&buf4[62]);
alminfo->wn_oa = bGetShort(&buf4[64]);
break;
case 3:
/* Almanac health page */
if (*data_length != sizeof (ALH_PARMS) + 3) return TRUE;
/* this record is returned raw */
memcpy (data_packet, buf4, dl);
break;
case 4:
/* Ionosphere */
if (*data_length != sizeof (ION_INFO) + 8) return TRUE;
ioninfo = (ION_INFO*)data_packet;
ioninfo->alpha_0 = bGetSingle (&buf4[8]);
ioninfo->alpha_1 = bGetSingle (&buf4[12]);
ioninfo->alpha_2 = bGetSingle (&buf4[16]);
ioninfo->alpha_3 = bGetSingle (&buf4[20]);
ioninfo->beta_0 = bGetSingle (&buf4[24]);
ioninfo->beta_1 = bGetSingle (&buf4[28]);
ioninfo->beta_2 = bGetSingle (&buf4[32]);
ioninfo->beta_3 = bGetSingle (&buf4[36]);
break;
case 5:
/* UTC */
if (*data_length != sizeof (UTC_INFO) + 13) return TRUE;
utcinfo = (UTC_INFO*)data_packet;
utcinfo->A_0 = bGetDouble (&buf4[13]);
utcinfo->A_1 = bGetSingle (&buf4[21]);
utcinfo->delta_t_LS = bGetShort (&buf4[25]);
utcinfo->t_ot = bGetSingle(&buf4[27]);
utcinfo->WN_t = bGetShort (&buf4[31]);
utcinfo->WN_LSF = bGetShort (&buf4[33]);
utcinfo->DN = bGetShort (&buf4[35]);
utcinfo->delta_t_LSF = bGetShort (&buf4[37]);
break;
case 6:
/* Ephemeris */
if (*data_length != sizeof (NAV_INFO) - 1) return TRUE;
navinfo = (NAV_INFO*)data_packet;
navinfo->sv_number = buf4[0];
navinfo->t_ephem = bGetSingle (&buf4[1]);
navinfo->ephclk.weeknum = bGetShort (&buf4[5]);
navinfo->ephclk.codeL2 = buf4[7];
navinfo->ephclk.L2Pdata = buf4[8];
navinfo->ephclk.SVacc_raw = buf4[9];
navinfo->ephclk.SV_health = buf4[10];
navinfo->ephclk.IODC = bGetShort (&buf4[11]);
navinfo->ephclk.T_GD = bGetSingle (&buf4[13]);
navinfo->ephclk.t_oc = bGetSingle (&buf4[17]);
navinfo->ephclk.a_f2 = bGetSingle (&buf4[21]);
navinfo->ephclk.a_f1 = bGetSingle (&buf4[25]);
navinfo->ephclk.a_f0 = bGetSingle (&buf4[29]);
navinfo->ephclk.SVacc = bGetSingle (&buf4[33]);
navinfo->ephorb.IODE = buf4[37];
navinfo->ephorb.fit_interval = buf4[38];
navinfo->ephorb.C_rs = bGetSingle (&buf4[39]);
navinfo->ephorb.delta_n = bGetSingle (&buf4[43]);
navinfo->ephorb.M_0 = bGetDouble (&buf4[47]);
navinfo->ephorb.C_uc = bGetSingle (&buf4[55]);
navinfo->ephorb.e = bGetDouble (&buf4[59]);
navinfo->ephorb.C_us = bGetSingle (&buf4[67]);
navinfo->ephorb.sqrt_A = bGetDouble (&buf4[71]);
navinfo->ephorb.t_oe = bGetSingle (&buf4[79]);
navinfo->ephorb.C_ic = bGetSingle (&buf4[83]);
navinfo->ephorb.OMEGA_0 = bGetDouble (&buf4[87]);
navinfo->ephorb.C_is = bGetSingle (&buf4[95]);
navinfo->ephorb.i_0 = bGetDouble (&buf4[99]);
navinfo->ephorb.C_rc = bGetSingle (&buf4[107]);
navinfo->ephorb.omega = bGetDouble (&buf4[111]);
navinfo->ephorb.OMEGADOT=bGetSingle (&buf4[119]);
navinfo->ephorb.IDOT = bGetSingle (&buf4[123]);
navinfo->ephorb.Axis = bGetDouble (&buf4[127]);
navinfo->ephorb.n = bGetDouble (&buf4[135]);
navinfo->ephorb.r1me2 = bGetDouble (&buf4[143]);
navinfo->ephorb.OMEGA_n=bGetDouble (&buf4[151]);
navinfo->ephorb.ODOT_n = bGetDouble (&buf4[159]);
break;
}
}
return FALSE;
}
short rpt_0x59 (TSIPPKT *rpt,
unsigned char *code_type,
unsigned char status_code[32])
/* satellite enable/disable or health heed/ignore list */
{
short iprn;
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 33) return TRUE;
*code_type = buf[0];
for (iprn = 0; iprn < 32; iprn++)
status_code[iprn] = buf[iprn + 1];
return FALSE;
}
short rpt_0x5A (TSIPPKT *rpt,
unsigned char *sv_prn,
float *sample_length,
float *signal_level,
float *code_phase,
float *Doppler,
double *time_of_fix)
/* raw measurement data - code phase/Doppler */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 25) return TRUE;
*sv_prn = buf[0];
*sample_length = bGetSingle (&buf[1]);
*signal_level = bGetSingle (&buf[5]);
*code_phase = bGetSingle (&buf[9]);
*Doppler = bGetSingle (&buf[13]);
*time_of_fix = bGetDouble (&buf[17]);
return FALSE;
}
short rpt_0x5B (TSIPPKT *rpt,
unsigned char *sv_prn,
unsigned char *sv_health,
unsigned char *sv_iode,
unsigned char *fit_interval_flag,
float *time_of_collection,
float *time_of_eph,
float *sv_accy)
/* satellite ephorb status */
{
unsigned char *buf;
buf = rpt->buf;
if (rpt->len != 16) return TRUE;
*sv_prn = buf[0];
*time_of_collection = bGetSingle (&buf[1]);
*sv_health = buf[5];
*sv_iode = buf[6];
*time_of_eph = bGetSingle (&buf[7]);
*fit_interval_flag = buf[11];
*sv_accy = bGetSingle (&buf[12]);
return FALSE;
}
short rpt_0x5C (TSIPPKT *rpt,
unsigned char *sv_prn,
unsigned char *slot,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -