Skip to content

Commit d3cee84

Browse files
authored
Fix compilation of rnx2rtcm (#87)
Compilation of rnx2rtcm broke when we upgraded to v2.4.3-b34. This breakage originates from upstream: rnx2rtcm compiles when using the upstream version of v2.4.3-b33, but not with the upstream version of v2.4.3-b34. Also add support for converting GAL F/NAV and BDS ephemerides.
1 parent 409b8cf commit d3cee84

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

src/rinex.c

+1
Original file line numberDiff line numberDiff line change
@@ -1854,6 +1854,7 @@ extern int input_rnxctr(rnxctr_t *rnx, FILE *fp)
18541854
case 'H': sys=SYS_SBS ; break;
18551855
case 'L': sys=SYS_GAL ; break; /* extension */
18561856
case 'J': sys=SYS_QZS ; break; /* extension */
1857+
case 'C': sys=SYS_CMP ; break; /* extension */
18571858
default: return 0;
18581859
}
18591860
if ((stat=readrnxnavb(fp,rnx->opt,rnx->ver,sys,&type,&eph,&geph,&seph))<=0) {

util/rnx2rtcm/makefile

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
BINDIR = /usr/local/bin
44
SRC = ../../src
5-
CFLAGS = -Wall -O3 -ansi -pedantic -I$(SRC) -DTRACE -DENAGLO -DENAGAL -DENAQZS -DNFREQ=3 -DNEXOBS=3
5+
CFLAGS = -Wall -O3 -pedantic -I$(SRC) -DTRACE -DENAGLO -DENAGAL -DENAQZS -DENACMP -DNFREQ=3 -DNEXOBS=3
66
LDLIBS = -lm
77

8-
rnx2rtcm : rnx2rtcm.o rtkcmn.o rinex.o rtcm.o rtcm2.o rtcm3.o rtcm3e.o
8+
rnx2rtcm : rnx2rtcm.o rtkcmn.o rinex.o rtcm.o rtcm2.o rtcm3.o rtcm3e.o ephemeris.o preceph.o sbas.o
99

1010
rnx2rtcm.o : rnx2rtcm.c
1111
$(CC) -c $(CFLAGS) rnx2rtcm.c
@@ -21,6 +21,12 @@ rtcm3.o : $(SRC)/rtcm3.c
2121
$(CC) -c $(CFLAGS) $(SRC)/rtcm3.c
2222
rtcm3e.o : $(SRC)/rtcm3e.c
2323
$(CC) -c $(CFLAGS) $(SRC)/rtcm3e.c
24+
ephemeris.o : $(SRC)/ephemeris.c
25+
$(CC) -c $(CFLAGS) $(SRC)/ephemeris.c
26+
preceph.o : $(SRC)/preceph.c
27+
$(CC) -c $(CFLAGS) $(SRC)/preceph.c
28+
sbas.o : $(SRC)/sbas.c
29+
$(CC) -c $(CFLAGS) $(SRC)/sbas.c
2430

2531
install:
2632
cp rnx2rtcm $(BINDIR)

util/rnx2rtcm/rnx2rtcm.c

+14-9
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static void print_help(void)
3737
/* test rtcm nav data --------------------------------------------------------*/
3838
static int is_nav(int type)
3939
{
40-
return type==1019||type==1044||type==1045||type==1046;
40+
return type==1019||type==1042||type==1044||type==1045||type==1046;
4141
}
4242
/* test rtcm gnav data -------------------------------------------------------*/
4343
static int is_gnav(int type)
@@ -61,28 +61,33 @@ static void gen_rtcm_obs(rtcm_t *rtcm, const int *type, int n, FILE *fp)
6161
for (i=0;i<n;i++) {
6262
if (is_nav(type[i])||is_gnav(type[i])||is_ant(type[i])) continue;
6363

64-
if (!gen_rtcm3(rtcm,type[i],i!=j)) continue;
64+
if (!gen_rtcm3(rtcm,type[i],0,i!=j)) continue;
6565
if (fwrite(rtcm->buff,rtcm->nbyte,1,fp)<1) break;
6666
}
6767
}
6868
/* generate rtcm nav data messages -------------------------------------------*/
6969
static void gen_rtcm_nav(gtime_t time, rtcm_t *rtcm, const nav_t *nav,
7070
int *index, const int *type, int n, FILE *fp)
7171
{
72-
int i,j,sat,prn;
72+
int i,j,sat,prn,code;
7373

7474
for (i=index[0];i<nav->n;i++) {
7575

7676
if (time.time&&timediff(nav->eph[i].ttr,time)>-0.1) continue;
7777
sat=nav->eph[i].sat;
78+
code=nav->eph[i].code;
7879
rtcm->time=nav->eph[i].ttr;
79-
rtcm->nav.eph[sat-1]=nav->eph[i];
80+
if (satsys(sat,&prn)!=SYS_GAL||((code&1)==1)) { // non-GAL or GAL I/NAV
81+
rtcm->nav.eph[sat-1]=nav->eph[i];
82+
} else { // GAL F/NAV
83+
rtcm->nav.eph[sat-1+MAXSAT]=nav->eph[i];
84+
}
8085
rtcm->ephsat=sat;
8186

8287
for (j=0;j<n;j++) {
8388
if (!is_nav(type[j])) continue;
8489

85-
if (!gen_rtcm3(rtcm,type[j],0)) continue;
90+
if (!gen_rtcm3(rtcm,type[j],0,0)) continue;
8691
if (fwrite(rtcm->buff,rtcm->nbyte,1,fp)<1) break;
8792
}
8893
index[0]=i+1;
@@ -99,7 +104,7 @@ static void gen_rtcm_nav(gtime_t time, rtcm_t *rtcm, const nav_t *nav,
99104
for (j=0;j<n;j++) {
100105
if (!is_gnav(type[j])) continue;
101106

102-
if (!gen_rtcm3(rtcm,type[j],0)) continue;
107+
if (!gen_rtcm3(rtcm,type[j],0,0)) continue;
103108
if (fwrite(rtcm->buff,rtcm->nbyte,1,fp)<1) break;
104109
}
105110
index[1]=i+1;
@@ -113,7 +118,7 @@ static void gen_rtcm_ant(rtcm_t *rtcm, const int *type, int n, FILE *fp)
113118
for (i=0;i<n;i++) {
114119
if (!is_ant(type[i])) continue;
115120

116-
if (!gen_rtcm3(rtcm,type[i],0)) continue;
121+
if (!gen_rtcm3(rtcm,type[i],0,0)) continue;
117122
if (fwrite(rtcm->buff,rtcm->nbyte,1,fp)<1) break;
118123
}
119124
}
@@ -129,13 +134,13 @@ static int conv_rtcm(const int *type, int n, const char *outfile,
129134
geph_t geph0={0};
130135
int i,j,prn,index[2]={0};
131136

132-
if (!(rtcm.nav.eph =(eph_t *)malloc(sizeof(eph_t )*MAXSAT ))||
137+
if (!(rtcm.nav.eph =(eph_t *)malloc(sizeof(eph_t )*MAXSAT*2 ))||
133138
!(rtcm.nav.geph=(geph_t *)malloc(sizeof(geph_t)*MAXPRNGLO))) return 0;
134139

135140
rtcm.staid=staid;
136141
rtcm.sta=*sta;
137142

138-
for (i=0;i<MAXSAT ;i++) rtcm.nav.eph [i]=eph0;
143+
for (i=0;i<MAXSAT*2 ;i++) rtcm.nav.eph [i]=eph0;
139144
for (i=0;i<MAXPRNGLO;i++) rtcm.nav.geph[i]=geph0;
140145

141146
/* update glonass freq channel number */

0 commit comments

Comments
 (0)