Skip to content

Commit 5ad3a28

Browse files
Merge pull request #757 from ourairquality/nglo-misc
Misc issues with GLONASS not enabled in a build
2 parents fcac25d + 30482bf commit 5ad3a28

File tree

6 files changed

+74
-40
lines changed

6 files changed

+74
-40
lines changed

src/rcvraw.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,6 @@ extern int init_raw(raw_t *raw, int format)
13031303
obsd_t data0={{0}};
13041304
eph_t eph0 ={0,-1,-1};
13051305
alm_t alm0 ={0,-1};
1306-
geph_t geph0={0,-1};
13071306
seph_t seph0={0};
13081307
sbsmsg_t sbsmsg0={0};
13091308
int i,j,ret=1;
@@ -1346,7 +1345,6 @@ extern int init_raw(raw_t *raw, int format)
13461345
!(raw->obuf.data=(obsd_t *)malloc(sizeof(obsd_t)*MAXOBS))||
13471346
!(raw->nav.eph =(eph_t *)malloc(sizeof(eph_t )*MAXSAT*2))||
13481347
!(raw->nav.alm =(alm_t *)malloc(sizeof(alm_t )*MAXSAT))||
1349-
!(raw->nav.geph =(geph_t *)malloc(sizeof(geph_t)*NSATGLO))||
13501348
!(raw->nav.seph =(seph_t *)malloc(sizeof(seph_t)*NSATSBS*2))) {
13511349
free_raw(raw);
13521350
return 0;
@@ -1355,13 +1353,11 @@ extern int init_raw(raw_t *raw, int format)
13551353
raw->obuf.n=0;
13561354
raw->nav.n =raw->nav.nmax =MAXSAT*2;
13571355
raw->nav.na=raw->nav.namax=MAXSAT;
1358-
raw->nav.ng=raw->nav.ngmax=NSATGLO;
13591356
raw->nav.ns=raw->nav.nsmax=NSATSBS*2;
13601357
for (i=0;i<MAXOBS ;i++) raw->obs.data [i]=data0;
13611358
for (i=0;i<MAXOBS ;i++) raw->obuf.data[i]=data0;
13621359
for (i=0;i<MAXSAT*2 ;i++) raw->nav.eph [i]=eph0;
13631360
for (i=0;i<MAXSAT ;i++) raw->nav.alm [i]=alm0;
1364-
for (i=0;i<NSATGLO ;i++) raw->nav.geph [i]=geph0;
13651361
for (i=0;i<NSATSBS*2;i++) raw->nav.seph [i]=seph0;
13661362
raw->sta.name[0]=raw->sta.markerno[0]=raw->sta.markertype[0]='\0';
13671363
raw->sta.observer[0]=raw->sta.agency[0]='\0';
@@ -1372,7 +1368,18 @@ extern int init_raw(raw_t *raw, int format)
13721368
raw->sta.pos[i]=raw->sta.del[i]=0.0;
13731369
}
13741370
raw->sta.hgt=0.0;
1375-
1371+
1372+
if (MAXPRNGLO > 0) {
1373+
raw->nav.geph = (geph_t *)malloc(sizeof(geph_t) * MAXPRNGLO);
1374+
if (raw->nav.geph == NULL) {
1375+
free_raw(raw);
1376+
return 0;
1377+
}
1378+
geph_t geph0 = {0, -1};
1379+
for (int i = 0; i < MAXPRNGLO; i++) raw->nav.geph[i] = geph0;
1380+
}
1381+
raw->nav.ng = raw->nav.ngmax = MAXPRNGLO;
1382+
13761383
/* initialize receiver dependent data */
13771384
raw->format=format;
13781385
switch (format) {

src/rinex.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,6 @@ extern int init_rnxctr(rnxctr_t *rnx)
18641864
gtime_t time0={0};
18651865
obsd_t data0={{0}};
18661866
eph_t eph0={0,-1,-1};
1867-
geph_t geph0={0,-1};
18681867
seph_t seph0={0};
18691868
int i,j;
18701869

@@ -1877,7 +1876,6 @@ extern int init_rnxctr(rnxctr_t *rnx)
18771876

18781877
if (!(rnx->obs.data=(obsd_t *)malloc(sizeof(obsd_t)*MAXOBS ))||
18791878
!(rnx->nav.eph =(eph_t *)malloc(sizeof(eph_t )*MAXSAT*2 ))||
1880-
!(rnx->nav.geph=(geph_t *)malloc(sizeof(geph_t)*NSATGLO ))||
18811879
!(rnx->nav.seph=(seph_t *)malloc(sizeof(seph_t)*NSATSBS*2))) {
18821880
free_rnxctr(rnx);
18831881
return 0;
@@ -1889,15 +1887,24 @@ extern int init_rnxctr(rnxctr_t *rnx)
18891887
rnx->obs.n=0;
18901888
rnx->obs.nmax=MAXOBS;
18911889
rnx->nav.n=rnx->nav.nmax=MAXSAT*2;
1892-
rnx->nav.ng=rnx->nav.ngmax=NSATGLO;
18931890
rnx->nav.ns=rnx->nav.nsmax=NSATSBS*2;
18941891
for (i=0;i<MAXOBS ;i++) rnx->obs.data[i]=data0;
18951892
for (i=0;i<MAXSAT*2 ;i++) rnx->nav.eph [i]=eph0;
1896-
for (i=0;i<NSATGLO ;i++) rnx->nav.geph[i]=geph0;
18971893
for (i=0;i<NSATSBS*2;i++) rnx->nav.seph[i]=seph0;
18981894
rnx->ephsat=rnx->ephset=0;
18991895
rnx->opt[0]='\0';
19001896

1897+
if (MAXPRNGLO > 0) {
1898+
rnx->nav.geph = (geph_t *)malloc(sizeof(geph_t) * MAXPRNGLO);
1899+
if (rnx->nav.geph == NULL) {
1900+
free_rnxctr(rnx);
1901+
return 0;
1902+
}
1903+
geph_t geph0 = {0, -1};
1904+
for (int i = 0; i < MAXPRNGLO ; i++) rnx->nav.geph[i] = geph0;
1905+
}
1906+
rnx->nav.ng = rnx->nav.ngmax = MAXPRNGLO;
1907+
19011908
return 1;
19021909
}
19031910
/* free RINEX control ----------------------------------------------------------

src/rtcm.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ extern int init_rtcm(rtcm_t *rtcm)
6868
gtime_t time0={0};
6969
obsd_t data0={{0}};
7070
eph_t eph0 ={0,-1,-1};
71-
geph_t geph0={0,-1};
7271
ssr_t ssr0={{{0}}};
7372
int i,j;
7473

@@ -107,20 +106,29 @@ extern int init_rtcm(rtcm_t *rtcm)
107106
rtcm->nav.geph=NULL;
108107
rtcm->nav.seph=NULL;
109108

110-
/* reallocate memory for observation and ephemeris buffer */
109+
// Allocate memory for observation and ephemeris buffer.
111110
if (!(rtcm->obs.data=(obsd_t *)malloc(sizeof(obsd_t)*MAXOBS))||
112-
!(rtcm->nav.eph =(eph_t *)malloc(sizeof(eph_t )*MAXSAT*2))||
113-
!(rtcm->nav.geph=(geph_t *)malloc(sizeof(geph_t)*MAXPRNGLO))) {
111+
!(rtcm->nav.eph =(eph_t *)malloc(sizeof(eph_t )*MAXSAT*2))) {
114112
free_rtcm(rtcm);
115113
return 0;
116114
}
117115
rtcm->obs.n=0;
118116
rtcm->nav.n=rtcm->nav.nmax=MAXSAT*2;
119-
rtcm->nav.ng=rtcm->nav.ngmax=MAXPRNGLO;
120117
rtcm->nav.ns=rtcm->nav.nsmax=0;
121118
for (i=0;i<MAXOBS ;i++) rtcm->obs.data[i]=data0;
122119
for (i=0;i<MAXSAT*2 ;i++) rtcm->nav.eph [i]=eph0;
123-
for (i=0;i<MAXPRNGLO;i++) rtcm->nav.geph[i]=geph0;
120+
121+
if (MAXPRNGLO > 0) {
122+
rtcm->nav.geph = (geph_t *)malloc(sizeof(geph_t) * MAXPRNGLO);
123+
if (rtcm->nav.geph == NULL) {
124+
free_rtcm(rtcm);
125+
return 0;
126+
}
127+
geph_t geph0 = {0, -1};
128+
for (int i = 0; i < MAXPRNGLO; i++) rtcm->nav.geph[i] = geph0;
129+
}
130+
rtcm->nav.ng = rtcm->nav.ngmax = MAXPRNGLO;
131+
124132
return 1;
125133
}
126134
/* free rtcm control ----------------------------------------------------------

src/rtcm3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2085,7 +2085,7 @@ static void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r,
20852085
rtcm->nav.glo_fcn[prn-1]=fcn+8; /* fcn+8 */
20862086
}
20872087
}
2088-
else if (rtcm->nav.geph[prn-1].sat==sat) {
2088+
else if (sat && rtcm->nav.geph[prn-1].sat == sat) {
20892089
fcn=rtcm->nav.geph[prn-1].frq;
20902090
}
20912091
else if (rtcm->nav.glo_fcn[prn-1]>0) {

src/rtksvr.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ static void update_eph(rtksvr_t *svr, nav_t *nav, int ephsat, int ephset,
181181
int index)
182182
{
183183
eph_t *eph1,*eph2,*eph3;
184-
geph_t *geph1,*geph2,*geph3;
185184
int prn;
186185

187186
if (satsys(ephsat,&prn)!=SYS_GLO) {
@@ -202,8 +201,9 @@ static void update_eph(rtksvr_t *svr, nav_t *nav, int ephsat, int ephset,
202201
}
203202
svr->nmsg[index][1]++;
204203
}
205-
else {
204+
else {
206205
if (!svr->navsel||svr->navsel==index+1) {
206+
geph_t *geph1,*geph2,*geph3;
207207
geph1=nav->geph+prn-1;
208208
geph2=svr->nav.geph+prn-1;
209209
geph3=svr->nav.geph+prn-1+MAXPRNGLO;
@@ -215,8 +215,8 @@ static void update_eph(rtksvr_t *svr, nav_t *nav, int ephsat, int ephset,
215215
}
216216
}
217217
svr->nmsg[index][6]++;
218-
}
219218
}
219+
}
220220
/* update sbas message -------------------------------------------------------*/
221221
static void update_sbs(rtksvr_t *svr, sbsmsg_t *sbsmsg, int index)
222222
{
@@ -767,7 +767,6 @@ extern int rtksvrinit(rtksvr_t *svr)
767767
gtime_t time0={0};
768768
sol_t sol0 ={{0}};
769769
eph_t eph0 ={0,-1,-1};
770-
geph_t geph0={0,-1};
771770
seph_t seph0={0};
772771
int i,j;
773772

@@ -799,19 +798,28 @@ extern int rtksvrinit(rtksvr_t *svr)
799798
memset(&svr->nav,0,sizeof(nav_t));
800799
memset(&svr->obs,0,sizeof(svr->obs));
801800
if (!(svr->nav.eph =(eph_t *)malloc(sizeof(eph_t )*MAXSAT*4 ))||
802-
!(svr->nav.geph=(geph_t *)malloc(sizeof(geph_t)*NSATGLO*2))||
803801
!(svr->nav.seph=(seph_t *)malloc(sizeof(seph_t)*NSATSBS*2))) {
804802
tracet(1,"rtksvrinit: malloc error\n");
805803
rtksvrfree(svr);
806804
return 0;
807805
}
808806
for (i=0;i<MAXSAT*4 ;i++) svr->nav.eph [i]=eph0;
809-
for (i=0;i<NSATGLO*2;i++) svr->nav.geph[i]=geph0;
810807
for (i=0;i<NSATSBS*2;i++) svr->nav.seph[i]=seph0;
811808
svr->nav.n =svr->nav.nmax =MAXSAT *4;
812-
svr->nav.ng=svr->nav.ngmax=NSATGLO*2;
813809
svr->nav.ns=svr->nav.nsmax=NSATSBS*2;
814-
810+
811+
if (MAXPRNGLO > 0) {
812+
svr->nav.geph = (geph_t *)malloc(sizeof(geph_t) * MAXPRNGLO * 2);
813+
if (svr->nav.geph == NULL) {
814+
tracet(1,"rtksvrinit: malloc error\n");
815+
rtksvrfree(svr);
816+
return 0;
817+
}
818+
geph_t geph0 = {0,-1};
819+
for (i = 0; i < MAXPRNGLO * 2; i++) svr->nav.geph[i] = geph0;
820+
}
821+
svr->nav.ng = svr->nav.ngmax = MAXPRNGLO * 2;
822+
815823
for (i=0;i<3;i++) for (j=0;j<MAXOBSBUF;j++) {
816824
if (!(svr->obs[i][j].data=(obsd_t *)malloc(sizeof(obsd_t)*MAXOBS))) {
817825
tracet(1,"rtksvrinit: malloc error\n");
@@ -978,7 +986,7 @@ extern int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs,
978986
}
979987
/* update navigation data */
980988
for (i=0;i<MAXSAT*4 ;i++) svr->nav.eph [i].ttr=time0;
981-
for (i=0;i<NSATGLO*2;i++) svr->nav.geph[i].tof=time0;
989+
for (i=0;i<MAXPRNGLO*2;i++) svr->nav.geph[i].tof=time0;
982990
for (i=0;i<NSATSBS*2;i++) svr->nav.seph[i].tof=time0;
983991

984992
/* set monitor stream */

util/rnx2rtcm/rnx2rtcm.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -186,25 +186,29 @@ static int conv_rtcm(const int *type, int n, const char *opt, const char *outfil
186186
rtcm.nav.n = rtcm.nav.nmax = 2;
187187
for (int i = 0; i < MAXSAT * 2; i++) rtcm.nav.eph[i] = eph0;
188188

189-
geph_t geph0 = {0};
190-
rtcm.nav.geph = (geph_t *)malloc(sizeof(geph_t) * MAXPRNGLO);
191-
if (!rtcm.nav.geph) return 0;
192-
rtcm.nav.ng = rtcm.nav.ngmax = 1;
193-
for (int i = 0; i < MAXPRNGLO; i++) rtcm.nav.geph[i] = geph0;
189+
rtcm.nav.geph = NULL;
190+
rtcm.nav.ng = rtcm.nav.ngmax = 0;
191+
if (MAXPRNGLO > 0) {
192+
geph_t geph0 = {0};
193+
rtcm.nav.geph = (geph_t *)malloc(sizeof(geph_t) * MAXPRNGLO);
194+
if (!rtcm.nav.geph) return 0;
195+
rtcm.nav.ng = rtcm.nav.ngmax = 1;
196+
for (int i = 0; i < MAPRNGLO; i++) rtcm.nav.geph[i] = geph0;
197+
198+
// Update GLONASS freq channel number
199+
for (int i = 0; i < nav->ng; i++) {
200+
int prn;
201+
if (satsys(nav->geph[i].sat, &prn) != SYS_GLO) continue;
202+
rtcm.nav.geph[prn - 1] = nav->geph[i];
203+
}
204+
for (int i = 0; i < MAXPRNGLO; i++) {
205+
rtcm.nav.glo_fcn[i] = nav->glo_fcn[i];
206+
}
207+
}
194208

195209
rtcm.staid = staid;
196210
rtcm.sta = *sta;
197211

198-
// Update GLONASS freq channel number
199-
for (int i = 0; i < nav->ng; i++) {
200-
int prn;
201-
if (satsys(nav->geph[i].sat, &prn) != SYS_GLO) continue;
202-
rtcm.nav.geph[prn - 1] = nav->geph[i];
203-
}
204-
for (int i = 0; i < NSATGLO; i++) {
205-
rtcm.nav.glo_fcn[i] = nav->glo_fcn[i];
206-
}
207-
208212
FILE *fp = stdout;
209213
if (*outfile && !(fp = fopen(outfile, "wb"))) {
210214
fprintf(stderr, "file open error: %s\n", outfile);

0 commit comments

Comments
 (0)