代码拉取完成,页面将自动刷新
同步操作将从 Anna Catherine/GNSS 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "rtcm.h"
/* constants -----------------------------------------------------------------*/
#define RTCM3PREAMB 0xD3 /* rtcm ver.3 frame preamble */
/* initialize rtcm control -----------------------------------------------------
* initialize rtcm control struct and reallocate memory for observation and
* ephemeris buffer in rtcm control struct
* args : rtcm_t *raw IO rtcm control struct
* return : status (1:ok,0:memory allocation error)
*-----------------------------------------------------------------------------*/
extern int init_rtcm(rtcm_t *rtcm)
{
gtime_t time0={0};
obsd_t data0={{0}};
eph_t eph0 ={0,-1,-1};
geph_t geph0={0,-1};
ssr_t ssr0={{{0}}};
int i,j;
trace(3,"init_rtcm:\n");
rtcm->staid=rtcm->stah=rtcm->seqno=rtcm->outtype=0;
rtcm->time=rtcm->time_s=time0;
rtcm->sta.name[0]=rtcm->sta.marker[0]='\0';
rtcm->sta.antdes[0]=rtcm->sta.antsno[0]='\0';
rtcm->sta.rectype[0]=rtcm->sta.recver[0]=rtcm->sta.recsno[0]='\0';
rtcm->sta.antsetup=rtcm->sta.itrf=rtcm->sta.deltype=0;
for (i=0;i<3;i++) {
rtcm->sta.pos[i]=rtcm->sta.del[i]=0.0;
}
rtcm->sta.hgt=0.0;
rtcm->dgps=NULL;
for (i=0;i<MAXSAT;i++) {
rtcm->ssr[i]=ssr0;
}
rtcm->msg[0]=rtcm->msgtype[0]=rtcm->opt[0]='\0';
for (i=0;i<6;i++) rtcm->msmtype[i][0]='\0';
rtcm->obsflag=rtcm->ephsat=0;
for (i=0;i<MAXSAT;i++) for (j=0;j<NFREQ+NEXOBS;j++) {
rtcm->cp[i][j]=0.0;
rtcm->lock[i][j]=rtcm->loss[i][j]=0;
rtcm->lltime[i][j]=time0;
}
rtcm->nbyte=rtcm->nbit=rtcm->len=0;
rtcm->word=0;
for (i=0;i<100;i++) rtcm->nmsg2[i]=0;
for (i=0;i<400;i++) rtcm->nmsg3[i]=0;
rtcm->obs.data=NULL;
rtcm->nav.eph =NULL;
rtcm->nav.geph=NULL;
/* reallocate memory for observation and ephemris buffer */
if (!(rtcm->obs.data=(obsd_t *)malloc(sizeof(obsd_t)*MAXOBS))||
!(rtcm->nav.eph =(eph_t *)malloc(sizeof(eph_t )*MAXSAT))||
!(rtcm->nav.geph=(geph_t *)malloc(sizeof(geph_t)*MAXPRNGLO))) {
free_rtcm(rtcm);
return 0;
}
rtcm->obs.n=0;
rtcm->nav.n=MAXSAT;
rtcm->nav.ng=MAXPRNGLO;
for (i=0;i<MAXOBS ;i++) rtcm->obs.data[i]=data0;
for (i=0;i<MAXSAT ;i++) rtcm->nav.eph [i]=eph0;
for (i=0;i<MAXPRNGLO;i++) rtcm->nav.geph[i]=geph0;
return 1;
}
/* free rtcm control ----------------------------------------------------------
* free observation and ephemris buffer in rtcm control struct
* args : rtcm_t *raw IO rtcm control struct
* return : none
*-----------------------------------------------------------------------------*/
extern void free_rtcm(rtcm_t *rtcm)
{
trace(3,"free_rtcm:\n");
/* free memory for observation and ephemeris buffer */
free(rtcm->obs.data); rtcm->obs.data=NULL; rtcm->obs.n=0;
free(rtcm->nav.eph ); rtcm->nav.eph =NULL; rtcm->nav.n=0;
free(rtcm->nav.geph); rtcm->nav.geph=NULL; rtcm->nav.ng=0;
}
/* input rtcm 3 message from stream --------------------------------------------
* fetch next rtcm 3 message and input a message from byte stream
* args : rtcm_t *rtcm IO rtcm control struct
* unsigned char data I stream data (1 byte)
* return : status (-1: error message, 0: no message, 1: input observation data,
* 2: input ephemeris, 5: input station pos/ant parameters,
* 10: input ssr messages)
* notes : before firstly calling the function, time in rtcm control struct has
* to be set to the approximate time within 1/2 week in order to resolve
* ambiguity of time in rtcm messages.
*
* to specify input options, set rtcm->opt to the following option
* strings separated by spaces.
*
* -EPHALL : input all ephemerides
* -STA=nnn : input only message with STAID=nnn
* -GLss : select signal ss for GPS MSM (ss=1C,1P,...)
* -RLss : select signal ss for GLO MSM (ss=1C,1P,...)
* -ELss : select signal ss for GAL MSM (ss=1C,1B,...)
* -JLss : select signal ss for QZS MSM (ss=1C,2C,...)
* -CLss : select signal ss for BDS MSM (ss=2I,7I,...)
*
* supported RTCM 3 messages
* (ref [2][3][4][5][6][7][8][9][10][11][12][13][14][15])
*
* TYPE GPS GLOASS GALILEO QZSS BEIDOU SBAS
* ----------------------------------------------------------------------
* OBS C-L1 : 1001~ 1009~ - - - -
* F-L1 : 1002 1010 - - - -
* C-L12 : 1003~ 1011~ - - - -
* F-L12 : 1004 1012 - - - -
*
* NAV : 1019 1020 1045* 1044* 1047* -
* - - 1046* - - -
* MSM 7 : 1077 1087 1097 1117* 1127* 1107*
* ANT INFO : 1005 1006 1007 1008 1033
* ----------------------------------------------------------------------
* (* draft, ~ only encode)
*
* for MSM observation data with multiple signals for a frequency,
* a signal is selected according to internal priority. to select
* a specified signal, use the input options.
*
* rtcm3 message format:
* +----------+--------+-----------+--------------------+----------+
* | preamble | 000000 | length | data message | parity |
* +----------+--------+-----------+--------------------+----------+
* |<-- 8 --->|<- 6 -->|<-- 10 --->|<--- length x 8 --->|<-- 24 -->|
*
*----------------------------------------------------------------------------*/
extern int input_rtcm3(rtcm_t* rtcm, unsigned char data)
{
/* synchronize frame */
if (rtcm->nbyte == 0) {
if (data != RTCM3PREAMB) {//识别文件头D3
return 0;
}
rtcm->buff[rtcm->nbyte++] = data;
return 0;
}
rtcm->buff[rtcm->nbyte++] = data;
if (rtcm->nbyte == 3) {/* 无奇偶校验位长度 */
rtcm->len = getbitu(rtcm->buff, 14, 10) + 3;
}
//字节数目小于len + 3,则退出函数
if (rtcm->nbyte < 3 || rtcm->nbyte < rtcm->len + 3) { //读取一帧数据至buff
return 0;
}
rtcm->nbyte = 0; //一帧数据字节数清0,为下一帧数据做准备
if (rtk_crc24q(rtcm->buff, rtcm->len) != getbitu(rtcm->buff, rtcm->len * 8, 24)) { /* 检查CRC */
return 0;
}
/* decode rtcm3 message */
return decode_rtcm3(rtcm);
}
/* input rtcm 3 message from file ----------------------------------------------
* fetch next rtcm 3 message and input a messsage from file
* args : rtcm_t *rtcm IO rtcm control struct
* FILE *fp I file pointer
* return : status (-2: end of file, -1...10: same as above)
* notes : same as above
*-----------------------------------------------------------------------------*/
extern int input_rtcm3f(rtcm_t* rtcm, FILE* fp) {
int data = 0, ret;
rtcm->sys = 0;
rtcm->timeflag = 0;
//int posflag = rtcm->time.time = 0; //posflag不等于rtcm->time.time 就会跳出RTCM解析
for (int i = 0; i < 1024; i++) {/* return at every 4096 bytes */
if ((data = fgetc(fp)) == EOF) {
return -2;
}
if ((ret = input_rtcm3(rtcm, (unsigned char)data))) {
return ret;
}
}
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。