⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ogr_inout.c

📁 The OpenGPSRec receiver software runs on the real time operating system RTAI-Linux. It compiles with
💻 C
📖 第 1 页 / 共 3 页
字号:
            "frq_step", &rt_par->frq_step, sep);#if 0        if ( !ret)          ret = read_key_value_pair_long( token,             "trk_div", &rt_par->trk_div, sep);#endif        if ( !ret)          ret = read_key_value_pair_int( token,             "confirm_above_thresh_max", &rt_par->confirm_above_thresh_max, sep);        if ( !ret)          ret = read_key_value_pair_int( token,             "confirm_count_max", &rt_par->confirm_count_max, sep);        if ( !ret)          ret = read_key_value_pair_int( token,             "pull_in_count_max", &rt_par->pull_in_count_max, sep);        if ( !ret)          ret = read_key_value_pair_int( token,             "align_count_max", &rt_par->align_count_max, sep);//  unkown keyword        if ( !ret)        {          token = strtok( NULL, sep);          if ( token)          {            printf( "ogr: unkown keyword >%s< in file %s\n", buf, infile);            exit( -1);          }          }      }       else// --- token is NULL ---              loop = 0;    } // --- while ( !feof( fp) && loop) ---  }  fclose( fp);  //  printf( "Finished reading parameter file %s\n", tmpstr);//  printf( "... press ENTER\n");    return;}/*******************************************************************************FUNCTION read_ion_utc()RETURNS  None.PARAMETERS None.PURPOSE  This function WRITTEN BY  Clifford Kelley*******************************************************************************/void  read_ion_utc( void){  char text[256];  char tmpstr[] = IONUTC_FILE;  FILE *fp;  if ((fp = fopen( tmpstr, "rt")) == NULL)  {    printf( "ogr: error opening %s.\n", tmpstr);  }  else  {    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Iono.al0);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Iono.al1);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Iono.al2);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Iono.al3);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Iono.b0);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Iono.b1);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Iono.b2);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Iono.b3);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Utc.a0);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Utc.a1);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Utc.dtls);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Utc.tot);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Utc.WNt);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Utc.WNlsf);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Utc.DN);    fscanf( fp, "%27c", text);    fscanf( fp, "%lf", &Utc.dtlsf);    fclose( fp);  }  return;}/*******************************************************************************FUNCTION read_almanac()RETURNS  None.PARAMETERS None.PURPOSE  Read almanac data from file ALM_FILEWRITTEN BY  Clifford Kelley*******************************************************************************/void read_almanac( void){  char text[256];  INT16 id, health, week;  float eccen, rinc, rras, sqra,        ratoa, aopg, rma, af0, af1, toa;  char  tmpstr[] = ALM_FILE;  FILE *fp = NULL;  if (( fp = fopen( tmpstr, "rt")) == NULL)  {    printf( "ogr: error opening almanach file %s.\n", tmpstr);    for ( id=1; id<=32; id++)    {      GPS_Alm[id].week = Ctrl.gps_week - 1;      GPS_Alm[id].inc  = 1.0;    }  }  else  {    Ctrl.status = mode_warmstart;    while ( !feof( fp))    {      fscanf( fp, "%45c", text);      fscanf( fp, "%27c", text);      fscanf( fp, "%hd", &id);  // read PRN, index into GPS_Alm[]      fscanf( fp, "%27c",text);      fscanf( fp, "%hi", &health);      fscanf( fp, "%27c", text);      fscanf( fp, "%f", &eccen);      fscanf( fp, "%27c", text);      fscanf( fp, "%f", &toa);      fscanf( fp, "%27c", text);      fscanf( fp, "%f", &rinc);      fscanf( fp, "%27c", text);      fscanf( fp, "%f", &rras);      fscanf( fp, "%27c", text);      fscanf( fp, "%f", &sqra);      fscanf( fp, "%27c", text);      fscanf( fp, "%f", &ratoa);      fscanf( fp, "%27c", text);      fscanf( fp, "%f", &aopg);      fscanf( fp, "%27c", text);      fscanf( fp, "%f", &rma);      fscanf( fp, "%27c", text);      fscanf( fp, "%f", &af0);      fscanf( fp, "%27c", text);      fscanf( fp, "%f", &af1);      fscanf( fp, "%27c", text);      fscanf( fp, "%hi", &week);      fscanf( fp, "%c", text);      GPS_Alm[id].health   = health;      GPS_Alm[id].week     = week;      GPS_Alm[id].toa      = toa;      GPS_Alm[id].ety      = eccen;      GPS_Alm[id].toa      = toa;      GPS_Alm[id].inc      = rinc;      GPS_Alm[id].rra      = rras;      GPS_Alm[id].sqra      = sqra;      GPS_Alm[id].lan      = ratoa;      GPS_Alm[id].aop      = aopg;      GPS_Alm[id].ma       = rma;      GPS_Alm[id].af0      = af0;      GPS_Alm[id].af1      = af1;      GPS_Alm[id].sat_file = 0;      if ( GPS_Alm[id].sqra > 0.0)         GPS_Alm[id].n0 = SQRTGM / pow( GPS_Alm[id].sqra, 3.0);    }    fclose( fp);//    alm_gps_week = week;//    alm_toa      = toa;  }  return;}/*******************************************************************************FUNCTION read_ephemeris()RETURNS  None.PARAMETERS None.PURPOSE  This function WRITTEN BY  Clifford Kelley*******************************************************************************/void read_ephemeris( void){  char   text[256];  INT16  id, health, week;  double toc, toe,         crc, crs, cic, cis, cuc, cus,         tgd, ety, inc0, Wdot,          w0, w, ma,         daf0, daf1, daf2,         esqra;  float  d_toe;  FILE   *fp;  char   tmpstr[] = EPH_FILE;  if ((fp = fopen( tmpstr, "rt")) == NULL)  {    printf( "ogr: error opening %s.\n", tmpstr);  }  else  {    while ( !feof( fp))    {      fscanf( fp, "%37c", text);      fscanf( fp, "%27c", text);      fscanf( fp, "%hi", &id);      if ( id < 1 || id > 32)      {        printf( "ogr: error in reading %s (id=%d)\n     line: %s\n",           tmpstr, id, text);        exit(-1);      }      fscanf( fp, "%27c", text);      fscanf( fp, "%hi", &health);      fscanf( fp, "%27c", text);      fscanf( fp, "%hi", &week);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &toe);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &toc);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &tgd);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &daf0);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &daf1);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &daf2);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &ety);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &inc0);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &Wdot);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &esqra);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &w0);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &w);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &ma);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &cuc);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &cus);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &crc);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &crs);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &cic);      fscanf( fp, "%27c", text);      fscanf( fp, "%le", &cis);      fscanf( fp, "%c", text);      d_toe = RT_Ctrl->tow_tic_count / 10.0 - toe;      if ( d_toe > 302400.0)         d_toe -= 604800.0;      else if ( d_toe < -302400.0)        d_toe += 604800.0;/* *    If week is current and time is less than 2 hours old use for hot start *    note: gps_week is computed from the PCs real time clock *          and does not roll over at 1024 */      if ( week == (Ctrl.gps_week % 1024) &&            fabs( d_toe) < 7200.0)         GPS_Eph[id].valid = 1;      GPS_Eph[id].health   = health;      GPS_Eph[id].week     = week;      GPS_Eph[id].toe      = toe;      GPS_Eph[id].toc      = toc;      GPS_Eph[id].tgd      = tgd;      GPS_Eph[id].af0      = daf0;      GPS_Eph[id].af1      = daf1;      GPS_Eph[id].af2      = daf2;      GPS_Eph[id].ety      = ety;      GPS_Eph[id].inc0     = inc0;      GPS_Eph[id].Wdot     = Wdot;      GPS_Eph[id].sqra     = esqra;      GPS_Eph[id].W0       = w0;      GPS_Eph[id].w        = w;      GPS_Eph[id].ma       = ma;      GPS_Eph[id].cuc      = cuc;      GPS_Eph[id].cus      = cus;      GPS_Eph[id].crc      = crc;      GPS_Eph[id].crs      = crs;      GPS_Eph[id].cic      = cic;      GPS_Eph[id].cis      = cis;      if ( GPS_Eph[id].sqra > 0.0)         GPS_Eph[id].n0 = SQRTGM / pow( GPS_Eph[id].sqra, 3.0);    }    fclose( fp);  }  return;}/*******************************************************************************FUNCTION write_almanac()RETURNS  None.PARAMETERS None.PURPOSE  This function writes the broadcast almanac data to a file for later      use.  In particular to support a warm or hot start.WRITTEN BY  Clifford Kelley*******************************************************************************/void write_almanac( void){  INT16 i;  char tmpstr[] = ALM_FILE;  FILE *fp;  fp = fopen( tmpstr, "w+");  if ( !fp)  {    printf( "ogr: error opening %s.\n", tmpstr);    exit( -1);  }    for (i=1; i<=32; i++)  {    if ( GPS_Alm[i].inc > 0.0)    {      fprintf( fp, "**** Week %4d almanac for PRN-%02d ***********\n",        GPS_Alm[i].week % 1024, i);      fprintf( fp, "ID:                         %3d\n",i);      fprintf( fp, "Health:                     %3d\n",GPS_Alm[i].health);      fprintf( fp, "Eccentricity:               %10.9e\n",GPS_Alm[i].ety);      fprintf( fp, "Time of Applicability(s):   %10.9e\n",GPS_Alm[i].toa);      fprintf( fp, "Orbital Inclination(rad):   %10.9e\n",GPS_Alm[i].inc);      fprintf( fp, "Rate of Right Ascen(R/s):   %10.9e\n",GPS_Alm[i].rra);      fprintf( fp, "SQRT(A) (m^1/2):            %10.9e\n",GPS_Alm[i].sqra);      fprintf( fp, "Right Ascen at TOA(rad):    %10.9e\n",GPS_Alm[i].lan);      fprintf( fp, "Argument of Perigee(rad):   %10.9e\n",GPS_Alm[i].aop);      fprintf( fp, "Mean Anom(rad):             %10.9e\n",GPS_Alm[i].ma);      fprintf( fp, "Af0(s):                     %10.9e\n",GPS_Alm[i].af0);      fprintf( fp, "Af1(s/s):                   %10.9e\n",GPS_Alm[i].af1);      fprintf( fp, "week:                       %4d   \n",GPS_Alm[i].week % 1024);      fprintf( fp, "\n");    }  }  fclose( fp);  return;}/*******************************************************************************FUNCTION write_ephemeris()RETURNS  None.PARAMETERS None.PURPOSE  This function writes the broadcast ephemeris data to a file for later  use.  In particular to support a hot start.WRITTEN BY  Clifford Kelley*******************************************************************************/void write_ephemeris( void){  INT16 i;  FILE *fp;  char tmpstr[] = EPH_FILE;  if ( (fp = fopen( tmpstr, "w+")) == NULL)  {    printf( "ogr: error opening %s.\n", tmpstr);    exit( -1);  }  for ( i=1; i<=32; i++)  {    if ( GPS_Eph[i].inc0 > 0.0)    {      fprintf( fp, "**** Ephemeris for PRN-%02d ***********\n", i);      fprintf( fp, "ID:                         %3d\n", i);      fprintf( fp, "Health:                     %3d\n", GPS_Eph[i].health);      fprintf( fp, "Week:                       %4d\n", GPS_Eph[i].week);      fprintf( fp, "E Time of Applic(s):        %10.9e\n", GPS_Eph[i].toe);      fprintf( fp, "C Time of Applic(s):        %10.9e\n", GPS_Eph[i].toc);      fprintf( fp, "Tgd(s):                     %10.9e\n", GPS_Eph[i].tgd);      fprintf( fp, "Af0(s):                     %10.9e\n", GPS_Eph[i].af0);      fprintf( fp, "Af1(s/s):                   %10.9e\n", GPS_Eph[i].af1);      fprintf( fp, "Af2(s/s/s):                 %10.9e\n", GPS_Eph[i].af2);      fprintf( fp, "Eccentricity:               %10.9e\n", GPS_Eph[i].ety);      fprintf( fp, "Orbital Inclination(rad):   %10.9e\n", GPS_Eph[i].inc0);      fprintf( fp, "Rate of Right Ascen(R/s):   %10.9e\n", GPS_Eph[i].Wdot);      fprintf( fp, "SQRT(A) (m^1/2):            %10.9e\n", GPS_Eph[i].sqra);      fprintf( fp, "Right Ascen at TOE(rad):    %10.9e\n", GPS_Eph[i].W0);      fprintf( fp, "Argument of Perigee(rad):   %10.9e\n", GPS_Eph[i].w);      fprintf( fp, "Mean Anom(rad):             %10.9e\n", GPS_Eph[i].ma);      fprintf( fp, "Cuc(rad):                   %10.9e\n", GPS_Eph[i].cuc);      fprintf( fp, "Cus(rad):                   %10.9e\n", GPS_Eph[i].cus);      fprintf( fp, "Crc(m):                     %10.9e\n", GPS_Eph[i].crc);      fprintf( fp, "Crs(m):                     %10.9e\n", GPS_Eph[i].crs);      fprintf( fp, "Cic(rad):                   %10.9e\n", GPS_Eph[i].cic);      fprintf( fp, "Cis(rad):                   %10.9e\n", GPS_Eph[i].cis);      fprintf( fp, "\n");    }  }  fclose( fp);  return;}/*******************************************************************************FUNCTION write_ion_utc()RETURNS  None.PARAMETERS None.PURPOSE  This function writes the broadcast ionospheric correction data and the      parameters to tie GPS time to UTC to a file for later use.WRITTEN BY  Clifford Kelley*******************************************************************************/void write_ion_utc(){  FILE *out;  char tmpstr[] = IONUTC_FILE;  out=fopen( tmpstr, "w+");  if ( !out)  {    printf( "ogr: error opening %s.\n", tmpstr);    exit(-1);  }  fprintf( out, "al0:                        %e\n", Iono.al0);  fprintf( out, "al1:                        %e\n", Iono.al1);  fprintf( out, "al2:                        %e\n", Iono.al2);  fprintf( out, "al3:                        %e\n", Iono.al3);  fprintf( out, "b0:                         %f\n", Iono.b0);  fprintf( out, "b1:                         %f\n", Iono.b1);  fprintf( out, "b2:                         %f\n", Iono.b2);  fprintf( out, "b3:                         %f\n", Iono.b3);  fprintf( out, "a0:                         %f\n", Utc.a0);  fprintf( out, "a1:                         %f\n", Utc.a1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -