diff --git a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc index f63b6644d..c8ba20466 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc @@ -23,7 +23,7 @@ void saveoutbuf(rtksvr_t *svr, unsigned char *buff, int n, int index) { rtksvrlock(svr); - n = nbuffsize-svr->nsb[index]?n:svr->buffsize-svr->nsb[index]; + n = n < svr->buffsize-svr->nsb[index] ? n : svr->buffsize-svr->nsb[index]; memcpy(svr->sbuf[index]+svr->nsb[index], buff, n); svr->nsb[index] += n; @@ -40,7 +40,7 @@ void writesol(rtksvr_t *svr, int index) tracet(4, "writesol: index=%d\n", index); - for (i = 0; i<2; i++) + for (i = 0; i < 2; i++) { /* output solution */ n = outsols(buff, &svr->rtk.sol, svr->rtk.rb, svr->solopt+i); @@ -63,7 +63,7 @@ void writesol(rtksvr_t *svr, int index) strwrite(svr->moni, buff, n); } /* save solution buffer */ - if (svr->nsolnsol < MAXSOLBUF) { rtksvrlock(svr); svr->solbuf[svr->nsol++] = svr->rtk.sol; @@ -76,7 +76,7 @@ void writesol(rtksvr_t *svr, int index) void updatenav(nav_t *nav) { int i, j; - for (i = 0; ilam[i][j] = satwavelen(i+1, j, nav); } @@ -88,18 +88,18 @@ void updatefcn(rtksvr_t *svr) { int i, j, sat, frq; - for (i = 0; iraw[j].nav.geph[i].sat != sat) continue; frq = svr->raw[j].nav.geph[i].frq; } - if (frq<-7 || frq>6) continue; + if (frq < -7 || frq>6) continue; - for (j = 0; j<3; j++) + for (j = 0; j < 3; j++) { if (svr->raw[j].nav.geph[i].sat == sat) continue; svr->raw[j].nav.geph[i].sat = sat; @@ -123,9 +123,9 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, if (ret == 1) { /* observation data */ - if (iobsn; i++) + for (i = 0; i < obs->n; i++) { if (svr->rtk.opt.exsats[obs->data[i].sat-1] == 1 || !(satsys(obs->data[i].sat, NULL)&svr->rtk.opt.navsys)) continue; @@ -181,13 +181,13 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, { /* sbas message */ if (sbsmsg && (sbssat == sbsmsg->prn || sbssat == 0)) { - if (svr->nsbsnsbs < MAXSBSMSG) { svr->sbsmsg[svr->nsbs++] = *sbsmsg; } else { - for (i = 0; isbsmsg[i] = svr->sbsmsg[i+1]; + for (i = 0; i < MAXSBSMSG-1; i++) svr->sbsmsg[i] = svr->sbsmsg[i+1]; svr->sbsmsg[i] = *sbsmsg; } sbsupdatecorr(sbsmsg, &svr->nav); @@ -198,12 +198,12 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, { /* ion/utc parameters */ if (svr->navsel == index || svr->navsel >= 3) { - for (i = 0; i<8; i++) svr->nav.ion_gps[i] = nav->ion_gps[i]; - for (i = 0; i<4; i++) svr->nav.utc_gps[i] = nav->utc_gps[i]; - for (i = 0; i<4; i++) svr->nav.ion_gal[i] = nav->ion_gal[i]; - for (i = 0; i<4; i++) svr->nav.utc_gal[i] = nav->utc_gal[i]; - for (i = 0; i<8; i++) svr->nav.ion_qzs[i] = nav->ion_qzs[i]; - for (i = 0; i<4; i++) svr->nav.utc_qzs[i] = nav->utc_qzs[i]; + for (i = 0; i < 8; i++) svr->nav.ion_gps[i] = nav->ion_gps[i]; + for (i = 0; i < 4; i++) svr->nav.utc_gps[i] = nav->utc_gps[i]; + for (i = 0; i < 4; i++) svr->nav.ion_gal[i] = nav->ion_gal[i]; + for (i = 0; i < 4; i++) svr->nav.utc_gal[i] = nav->utc_gal[i]; + for (i = 0; i < 8; i++) svr->nav.ion_qzs[i] = nav->ion_qzs[i]; + for (i = 0; i < 4; i++) svr->nav.utc_qzs[i] = nav->utc_qzs[i]; svr->nav.leaps = nav->leaps; } svr->nmsg[index][2]++; @@ -212,7 +212,7 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, { /* antenna postion parameters */ if (svr->rtk.opt.refpos == 4 && index == 1) { - for (i = 0; i<3; i++) + for (i = 0; i < 3; i++) { svr->rtk.rb[i] = svr->rtcm[1].sta.pos[i]; } @@ -222,7 +222,7 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, { /* xyz */ del[2] = svr->rtcm[1].sta.hgt; enu2ecef(pos, del, dr); - for (i = 0; i<3; i++) + for (i = 0; i < 3; i++) { svr->rtk.rb[i] += svr->rtcm[1].sta.del[i]+dr[i]; } @@ -230,7 +230,7 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, else { /* enu */ enu2ecef(pos, svr->rtcm[1].sta.del, dr); - for (i = 0; i<3; i++) + for (i = 0; i < 3; i++) { svr->rtk.rb[i] += dr[i]; } @@ -244,7 +244,7 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, } else if (ret == 10) { /* ssr message */ - for (i = 0; irtcm[index].ssr[i].update) continue; svr->rtcm[index].ssr[i].update = 0; @@ -297,7 +297,7 @@ int decoderaw(rtksvr_t *svr, int index) rtksvrlock(svr); - for (i = 0; inb[index]; i++) + for (i = 0; i < svr->nb[index]; i++) { /* input rtcm/receiver raw data from stream */ if (svr->format[index] == STRFMT_RTCM2) @@ -336,7 +336,7 @@ int decoderaw(rtksvr_t *svr, int index) /* observation data received */ if (ret == 1) { - if (fobsprcout++; + if (fobs < MAXOBSBUF) fobs++; else svr->prcout++; } } svr->nb[index] = 0; @@ -450,7 +450,7 @@ void *rtksvrthread(void *arg) { tick = tickget(); - for (i = 0; i<3; i++) + for (i = 0; i < 3; i++) { p = svr->buff[i]+svr->nb[i]; q = svr->buff[i]+svr->buffsize; @@ -465,12 +465,12 @@ void *rtksvrthread(void *arg) /* save peek buffer */ rtksvrlock(svr); - n = nbuffsize-svr->npb[i]?n:svr->buffsize-svr->npb[i]; + n = n < svr->buffsize-svr->npb[i] ? n : svr->buffsize-svr->npb[i]; memcpy(svr->pbuf[i]+svr->npb[i], p, n); svr->npb[i] += n; rtksvrunlock(svr); } - for (i = 0; i<3; i++) + for (i = 0; i < 3; i++) { if (svr->format[i] == STRFMT_SP3 || svr->format[i] == STRFMT_RNXCLK) { @@ -483,14 +483,14 @@ void *rtksvrthread(void *arg) fobs[i] = decoderaw(svr, i); } } - for (i = 0; iobs[0][i].n && obs.nobs[0][i].n && obs.n < MAXOBS*2; j++) { obs.data[obs.n++] = svr->obs[0][i].data[j]; } - for (j = 0; jobs[1][0].n && obs.nobs[1][0].n && obs.n < MAXOBS*2; j++) { obs.data[obs.n++] = svr->obs[1][0].data[j]; } @@ -543,8 +543,8 @@ void *rtksvrthread(void *arg) /* sleep until next cycle */ sleepms(svr->cycle-cputime); } - for (i = 0; istream+i); - for (i = 0; i<3; i++) + for (i = 0; i < MAXSTRRTK; i++) strclose(svr->stream+i); + for (i = 0; i < 3; i++) { svr->nb[i] = svr->npb[i] = 0; free(svr->buff[i]); svr->buff[i] = NULL; @@ -552,7 +552,7 @@ void *rtksvrthread(void *arg) //free_raw (svr->raw +i); free_rtcm(svr->rtcm+i); } - for (i = 0; i<2; i++) + for (i = 0; i < 2; i++) { svr->nsb[i] = 0; free(svr->sbuf[i]); svr->sbuf[i] = NULL; @@ -569,51 +569,55 @@ void *rtksvrthread(void *arg) int rtksvrinit(rtksvr_t *svr) { gtime_t time0 = {0, 0.0}; - sol_t sol0 = {{0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0}, '0', '0', '0', 0, 0, 0 }; - eph_t eph0 = {0, -1, -1, 0, 0, 0, 0, 0, {0,0.0}, {0,0.0}, {0,0.0}, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {0.0}, 0.0, 0.0}; - geph_t geph0 = {0, -1, 0, 0, 0, 0, {0,0.0}, {0,0.0}, {0.0}, {0.0}, {0.0}, 0.0, 0.0, 0.0}; + sol_t sol0 = {{0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0}, + '0', '0', '0', 0, 0, 0 }; + eph_t eph0 = {0, -1, -1, 0, 0, 0, 0, 0, {0,0.0}, {0,0.0}, {0,0.0}, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {0.0}, 0.0, 0.0}; + geph_t geph0 = {0, -1, 0, 0, 0, 0, {0,0.0}, {0,0.0}, {0.0}, {0.0}, {0.0}, + 0.0, 0.0, 0.0}; seph_t seph0 = {0, {0,0.0}, {0,0.0}, 0, 0, {0.0}, {0.0}, {0.0}, 0.0, 0.0}; int i, j; tracet(3, "rtksvrinit:\n"); svr->state = svr->cycle = svr->nmeacycle = svr->nmeareq = 0; - for (i = 0; i<3; i++) svr->nmeapos[i] = 0.0; + for (i = 0; i < 3; i++) svr->nmeapos[i] = 0.0; svr->buffsize = 0; - for (i = 0; i<3; i++) svr->format[i] = 0; - for (i = 0; i<2; i++) svr->solopt[i] = solopt_default; + for (i = 0; i < 3; i++) svr->format[i] = 0; + for (i = 0; i < 2; i++) svr->solopt[i] = solopt_default; svr->navsel = svr->nsbs = svr->nsol = 0; rtkinit(&svr->rtk, &prcopt_default); - for (i = 0; i<3; i++) svr->nb[i] = 0; - for (i = 0; i<2; i++) svr->nsb[i] = 0; - for (i = 0; i<3; i++) svr->npb[i] = 0; - for (i = 0; i<3; i++) svr->buff[i] = NULL; - for (i = 0; i<2; i++) svr->sbuf[i] = NULL; - for (i = 0; i<3; i++) svr->pbuf[i] = NULL; - for (i = 0; isolbuf[i] = sol0; - for (i = 0; i<3; i++) for (j = 0; j<10; j++) svr->nmsg[i][j] = 0; - for (i = 0; i<3; i++) svr->ftime[i] = time0; - for (i = 0; i<3; i++) svr->files[i][0] = '\0'; + for (i = 0; i < 3; i++) svr->nb[i] = 0; + for (i = 0; i < 2; i++) svr->nsb[i] = 0; + for (i = 0; i < 3; i++) svr->npb[i] = 0; + for (i = 0; i < 3; i++) svr->buff[i] = NULL; + for (i = 0; i < 2; i++) svr->sbuf[i] = NULL; + for (i = 0; i < 3; i++) svr->pbuf[i] = NULL; + for (i = 0; i < MAXSOLBUF; i++) svr->solbuf[i] = sol0; + for (i = 0; i < 3; i++) for (j = 0; j < 10; j++) svr->nmsg[i][j] = 0; + for (i = 0; i < 3; i++) svr->ftime[i] = time0; + for (i = 0; i < 3; i++) svr->files[i][0] = '\0'; svr->moni = NULL; svr->tick = 0; svr->thread = 0; svr->cputime = svr->prcout = 0; - if (!(svr->nav.eph = (eph_t *)malloc(sizeof(eph_t )*MAXSAT *2)) || + if (!(svr->nav.eph = (eph_t *)malloc(sizeof(eph_t )*MAXSAT *2)) || !(svr->nav.geph = (geph_t *)malloc(sizeof(geph_t)*NSATGLO*2)) || !(svr->nav.seph = (seph_t *)malloc(sizeof(seph_t)*NSATSBS*2))) { tracet(1, "rtksvrinit: malloc error\n"); return 0; } - for (i = 0; inav.eph [i] = eph0; - for (i = 0; inav.geph[i] = geph0; - for (i = 0; inav.seph[i] = seph0; + for (i = 0; i < MAXSAT *2; i++) svr->nav.eph [i] = eph0; + for (i = 0; i < NSATGLO*2; i++) svr->nav.geph[i] = geph0; + for (i = 0; i < NSATSBS*2; i++) svr->nav.seph[i] = seph0; svr->nav.n = MAXSAT *2; svr->nav.ng = NSATGLO*2; svr->nav.ns = NSATSBS*2; - for (i = 0; i<3; i++) for (j = 0; jobs[i][j].data = (obsd_t *)malloc(sizeof(obsd_t)*MAXOBS))) { @@ -621,12 +625,12 @@ int rtksvrinit(rtksvr_t *svr) return 0; } } - for (i = 0; i<3; i++) + for (i = 0; i < 3; i++) { memset(svr->raw +i, 0, sizeof(raw_t )); memset(svr->rtcm+i, 0, sizeof(rtcm_t)); } - for (i = 0; istream+i); + for (i = 0; i < MAXSTRRTK; i++) strinit(svr->stream+i); initlock(&svr->lock); @@ -646,7 +650,7 @@ void rtksvrfree(rtksvr_t *svr) free(svr->nav.eph ); free(svr->nav.geph); free(svr->nav.seph); - for (i = 0; i<3; i++) for (j = 0; jobs[i][j].data); } @@ -718,12 +722,12 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, if (svr->state) return 0; strinitcom(); - svr->cycle = cycle>1?cycle:1; - svr->nmeacycle = nmeacycle>1000?nmeacycle:1000; + svr->cycle = cycle > 1 ? cycle : 1; + svr->nmeacycle = nmeacycle > 1000 ? nmeacycle : 1000; svr->nmeareq = nmeareq; - for (i = 0; i<3; i++) svr->nmeapos[i] = nmeapos[i]; - svr->buffsize = buffsize>4096?buffsize:4096; - for (i = 0; i<3; i++) svr->format[i] = formats[i]; + for (i = 0; i < 3; i++) svr->nmeapos[i] = nmeapos[i]; + svr->buffsize = buffsize > 4096 ? buffsize : 4096; + for (i = 0; i < 3; i++) svr->format[i] = formats[i]; svr->navsel = navsel; svr->nsbs = 0; svr->nsol = 0; @@ -731,7 +735,7 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, rtkfree(&svr->rtk); rtkinit(&svr->rtk, prcopt); - for (i = 0; i<3; i++) + for (i = 0; i < 3; i++) { /* input/log streams */ svr->nb[i] = svr->npb[i] = 0; if (!(svr->buff[i] = (unsigned char *)malloc(buffsize)) || @@ -740,8 +744,8 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, tracet(1, "rtksvrstart: malloc error\n"); return 0; } - for (j = 0; j<10; j++) svr->nmsg[i][j] = 0; - for (j = 0; jobs[i][j].n = 0; + for (j = 0; j < 10; j++) svr->nmsg[i][j] = 0; + for (j = 0; j < MAXOBSBUF; j++) svr->obs[i][j].n = 0; /* initialize receiver raw and rtcm control */ //init_raw (svr->raw +i); @@ -754,7 +758,7 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, /* connect dgps corrections */ svr->rtcm[i].dgps = svr->nav.dgps; } - for (i = 0; i<2; i++) + for (i = 0; i < 2; i++) { /* output peek buffer */ if (!(svr->sbuf[i] = (unsigned char *)malloc(buffsize))) { @@ -763,28 +767,28 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, } } /* set solution options */ - for (i = 0; i<2; i++) + for (i = 0; i < 2; i++) { svr->solopt[i] = solopt[i]; } /* set base station position */ - for (i = 0; i<6; i++) + for (i = 0; i < 6; i++) { - svr->rtk.rb[i] = i<3?prcopt->rb[i]:0.0; + svr->rtk.rb[i] = i < 3 ? prcopt->rb[i] : 0.0; } /* update navigation data */ - for (i = 0; inav.eph [i].ttr = time0; - for (i = 0; inav.geph[i].tof = time0; - for (i = 0; inav.seph[i].tof = time0; + for (i = 0; i < MAXSAT *2; i++) svr->nav.eph [i].ttr = time0; + for (i = 0; i < NSATGLO*2; i++) svr->nav.geph[i].tof = time0; + for (i = 0; i < NSATSBS*2; i++) svr->nav.seph[i].tof = time0; updatenav(&svr->nav); /* set monitor stream */ svr->moni = moni; /* open input streams */ - for (i = 0; i<8; i++) + for (i = 0; i < 8; i++) { - rw = i<3?STR_MODE_R:STR_MODE_W; + rw = i < 3 ? STR_MODE_R : STR_MODE_W; if (strs[i] != STR_FILE) rw |= STR_MODE_W; if (!stropen(svr->stream+i, strs[i], rw, paths[i])) { @@ -792,11 +796,11 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, return 0; } /* set initial time for rtcm and raw */ - if (i<3) + if (i < 3) { time = utc2gpst(timeget()); - svr->raw [i].time = strs[i] == STR_FILE?strgettime(svr->stream+i):time; - svr->rtcm[i].time = strs[i] == STR_FILE?strgettime(svr->stream+i):time; + svr->raw [i].time = strs[i] == STR_FILE ? strgettime(svr->stream+i) : time; + svr->rtcm[i].time = strs[i] == STR_FILE ? strgettime(svr->stream+i) : time; } } /* sync input streams */ @@ -804,19 +808,19 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, strsync(svr->stream, svr->stream+2); /* write start commands to input streams */ - for (i = 0; i<3; i++) + for (i = 0; i < 3; i++) { if (cmds[i]) strsendcmd(svr->stream+i, cmds[i]); } /* write solution header to solution streams */ - for (i = 3; i<5; i++) + for (i = 3; i < 5; i++) { writesolhead(svr->stream+i, svr->solopt+i-3); } /* create rtk server thread */ if (pthread_create(&svr->thread, NULL, rtksvrthread, svr)) { - for (i = 0; istream+i); + for (i = 0; i < MAXSTRRTK; i++) strclose(svr->stream+i); return 0; } return 1; @@ -840,7 +844,7 @@ void rtksvrstop(rtksvr_t *svr, char **cmds) /* write stop commands to input streams */ rtksvrlock(svr); - for (i = 0; i<3; i++) + for (i = 0; i < 3; i++) { if (cmds[i]) strsendcmd(svr->stream+i, cmds[i]); } @@ -870,7 +874,7 @@ int rtksvropenstr(rtksvr_t *svr, int index, int str, const char *path, { tracet(3, "rtksvropenstr: index=%d str=%d path=%s\n", index, str, path); - if (index<3 || index>7 || !svr->state) return 0; + if (index < 3 || index > 7 || !svr->state) return 0; rtksvrlock(svr); @@ -909,7 +913,7 @@ void rtksvrclosestr(rtksvr_t *svr, int index) { tracet(3, "rtksvrclosestr: index=%d\n", index); - if (index<3 || index>7 || !svr->state) return; + if (index < 3 || index>7 || !svr->state) return; rtksvrlock(svr); @@ -946,12 +950,12 @@ int rtksvrostat(rtksvr_t *svr, int rcv, gtime_t *time, int *sat, { *time = svr->obs[rcv][0].data[0].time; } - for (i = 0; iobs[rcv][0].data[i].sat; az [i] = svr->rtk.ssat[sat[i]-1].azel[0]; el [i] = svr->rtk.ssat[sat[i]-1].azel[1]; - for (j = 0; jobs[rcv][0].data[i].SNR[j]*0.25); } @@ -984,7 +988,7 @@ void rtksvrsstat(rtksvr_t *svr, int *sstat, char *msg) tracet(4, "rtksvrsstat:\n"); rtksvrlock(svr); - for (i = 0; istream+i, s); if (*s) p += sprintf(p, "(%d) %s ", i+1, s); diff --git a/src/algorithms/libs/rtklib/rtklib_solution.cc b/src/algorithms/libs/rtklib/rtklib_solution.cc index 2bf9b9752..82f804305 100644 --- a/src/algorithms/libs/rtklib/rtklib_solution.cc +++ b/src/algorithms/libs/rtklib/rtklib_solution.cc @@ -492,7 +492,7 @@ int decode_solenu(char *buff, const solopt_t *opt, sol_t *sol) /* decode gsi f solution -----------------------------------------------------*/ -int decode_solgsi(char *buff, const solopt_t *opt, sol_t *sol) +int decode_solgsi(char *buff, const solopt_t *opt __attribute((unused)), sol_t *sol) { double val[MAXFIELD]; int i = 0,j; diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 6436f6ebd..c7931ed59 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -158,7 +158,7 @@ void closeserial(serial_t *serial) /* read serial ---------------------------------------------------------------*/ -int readserial(serial_t *serial, unsigned char *buff, int n, char *msg) +int readserial(serial_t *serial, unsigned char *buff, int n, char *msg __attribute__((unused))) { int nr; tracet(4, "readserial: dev=%d n=%d\n", serial->dev, n); @@ -170,7 +170,7 @@ int readserial(serial_t *serial, unsigned char *buff, int n, char *msg) /* write serial --------------------------------------------------------------*/ -int writeserial(serial_t *serial, unsigned char *buff, int n, char *msg) +int writeserial(serial_t *serial, unsigned char *buff, int n, char *msg __attribute__((unused))) { int ns; tracet(3, "writeserial: dev=%d n=%d\n", serial->dev, n);