mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 12:10:34 +00:00
Add work on rtklib functions
This commit is contained in:
parent
9da436ec87
commit
c804fb8d6f
@ -60,11 +60,51 @@
|
||||
#include <cmath>
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
#include <pthread.h>
|
||||
#include <netinet/in.h>
|
||||
#include "MATH_CONSTANTS.h"
|
||||
#include "gnss_frequencies.h"
|
||||
#include "gnss_obs_codes.h"
|
||||
|
||||
|
||||
/* macros --------------------------------------------------------------------*/
|
||||
|
||||
#define dev_t int
|
||||
#define socket_t int
|
||||
#define closesocket close
|
||||
#define lock_t pthread_mutex_t
|
||||
#define thread_t pthread_t
|
||||
#define initlock(f) pthread_mutex_init(f,NULL)
|
||||
#define rtk_lock(f) pthread_mutex_lock(f)
|
||||
#define rtk_unlock(f) pthread_mutex_unlock(f)
|
||||
|
||||
#define TINTACT 200 /* period for stream active (ms) */
|
||||
#define SERIBUFFSIZE 4096 /* serial buffer size (bytes) */
|
||||
#define TIMETAGH_LEN 64 /* time tag file header length */
|
||||
#define MAXCLI 32 /* max client connection for tcp svr */
|
||||
#define MAXSTATMSG 32 /* max length of status message */
|
||||
|
||||
#define VER_RTKLIB "2.4.2"
|
||||
#define NTRIP_AGENT "RTKLIB/" VER_RTKLIB
|
||||
#define NTRIP_CLI_PORT 2101 /* default ntrip-client connection port */
|
||||
#define NTRIP_SVR_PORT 80 /* default ntrip-server connection port */
|
||||
#define NTRIP_MAXRSP 32768 /* max size of ntrip response */
|
||||
#define NTRIP_MAXSTR 256 /* max length of mountpoint string */
|
||||
#define NTRIP_RSP_OK_CLI "ICY 200 OK\r\n" /* ntrip response: client */
|
||||
#define NTRIP_RSP_OK_SVR "OK\r\n" /* ntrip response: server */
|
||||
#define NTRIP_RSP_SRCTBL "SOURCETABLE 200 OK\r\n" /* ntrip response: source table */
|
||||
#define NTRIP_RSP_TBLEND "ENDSOURCETABLE"
|
||||
#define NTRIP_RSP_HTTP "HTTP/" /* ntrip response: http */
|
||||
#define NTRIP_RSP_ERROR "ERROR" /* ntrip response: error */
|
||||
|
||||
#define FTP_CMD "wget" /* ftp/http command */
|
||||
#define FTP_TIMEOUT 30 /* ftp/http timeout (s) */
|
||||
|
||||
#define MAXRAWLEN 4096 /* max length of receiver raw message */
|
||||
#define MAXSOLBUF 256 /* max number of solution buffer */
|
||||
#define MAXSBSMSG 32 /* max number of SBAS msg in RTK server */
|
||||
#define MAXOBSBUF 128 /* max number of observation data buffer */
|
||||
|
||||
const int FILEPATHSEP = '/';
|
||||
const double RE_WGS84 = 6378137.0; //!< earth semimajor axis (WGS84) (m)
|
||||
const double FE_WGS84 = (1.0 / 298.257223563); //!< earth flattening (WGS84)
|
||||
@ -1010,6 +1050,179 @@ typedef struct half_cyc_tag { /* half-cycle correction list type */
|
||||
} half_cyc_t;
|
||||
|
||||
|
||||
typedef struct { /* stream type */
|
||||
int type; /* type (STR_???) */
|
||||
int mode; /* mode (STR_MODE_?) */
|
||||
int state; /* state (-1:error,0:close,1:open) */
|
||||
unsigned int inb,inr; /* input bytes/rate */
|
||||
unsigned int outb,outr; /* output bytes/rate */
|
||||
unsigned int tick,tact; /* tick/active tick */
|
||||
unsigned int inbt,outbt; /* input/output bytes at tick */
|
||||
lock_t lock; /* lock flag */
|
||||
void *port; /* type dependent port control struct */
|
||||
char path[MAXSTRPATH]; /* stream path */
|
||||
char msg [MAXSTRMSG]; /* stream message */
|
||||
} stream_t;
|
||||
|
||||
|
||||
typedef struct { /* serial control type */
|
||||
dev_t dev; /* serial device */
|
||||
int error; /* error state */
|
||||
} serial_t;
|
||||
|
||||
|
||||
typedef struct { /* file control type */
|
||||
FILE *fp; /* file pointer */
|
||||
FILE *fp_tag; /* file pointer of tag file */
|
||||
FILE *fp_tmp; /* temporary file pointer for swap */
|
||||
FILE *fp_tag_tmp; /* temporary file pointer of tag file for swap */
|
||||
char path[MAXSTRPATH]; /* file path */
|
||||
char openpath[MAXSTRPATH]; /* open file path */
|
||||
int mode; /* file mode */
|
||||
int timetag; /* time tag flag (0:off,1:on) */
|
||||
int repmode; /* replay mode (0:master,1:slave) */
|
||||
int offset; /* time offset (ms) for slave */
|
||||
gtime_t time; /* start time */
|
||||
gtime_t wtime; /* write time */
|
||||
unsigned int tick; /* start tick */
|
||||
unsigned int tick_f; /* start tick in file */
|
||||
unsigned int fpos; /* current file position */
|
||||
double start; /* start offset (s) */
|
||||
double speed; /* replay speed (time factor) */
|
||||
double swapintv; /* swap interval (hr) (0: no swap) */
|
||||
lock_t lock; /* lock flag */
|
||||
} file_t;
|
||||
|
||||
|
||||
typedef struct { /* tcp control type */
|
||||
int state; /* state (0:close,1:wait,2:connect) */
|
||||
char saddr[256]; /* address string */
|
||||
int port; /* port */
|
||||
struct sockaddr_in addr; /* address resolved */
|
||||
socket_t sock; /* socket descriptor */
|
||||
int tcon; /* reconnect time (ms) (-1:never,0:now) */
|
||||
unsigned int tact; /* data active tick */
|
||||
unsigned int tdis; /* disconnect tick */
|
||||
} tcp_t;
|
||||
|
||||
|
||||
typedef struct { /* tcp server type */
|
||||
tcp_t svr; /* tcp server control */
|
||||
tcp_t cli[MAXCLI]; /* tcp client controls */
|
||||
} tcpsvr_t;
|
||||
|
||||
|
||||
typedef struct { /* tcp cilent type */
|
||||
tcp_t svr; /* tcp server control */
|
||||
int toinact; /* inactive timeout (ms) (0:no timeout) */
|
||||
int tirecon; /* reconnect interval (ms) (0:no reconnect) */
|
||||
} tcpcli_t;
|
||||
|
||||
|
||||
typedef struct { /* ntrip control type */
|
||||
int state; /* state (0:close,1:wait,2:connect) */
|
||||
int type; /* type (0:server,1:client) */
|
||||
int nb; /* response buffer size */
|
||||
char url[256]; /* url for proxy */
|
||||
char mntpnt[256]; /* mountpoint */
|
||||
char user[256]; /* user */
|
||||
char passwd[256]; /* password */
|
||||
char str[NTRIP_MAXSTR]; /* mountpoint string for server */
|
||||
unsigned char buff[NTRIP_MAXRSP]; /* response buffer */
|
||||
tcpcli_t *tcp; /* tcp client */
|
||||
} ntrip_t;
|
||||
|
||||
|
||||
typedef struct { /* ftp download control type */
|
||||
int state; /* state (0:close,1:download,2:complete,3:error) */
|
||||
int proto; /* protocol (0:ftp,1:http) */
|
||||
int error; /* error code (0:no error,1-10:wget error, */
|
||||
/* 11:no temp dir,12:uncompact error) */
|
||||
char addr[1024]; /* download address */
|
||||
char file[1024]; /* download file path */
|
||||
char user[256]; /* user for ftp */
|
||||
char passwd[256]; /* password for ftp */
|
||||
char local[1024]; /* local file path */
|
||||
int topts[4]; /* time options {poff,tint,toff,tretry} (s) */
|
||||
gtime_t tnext; /* next retry time (gpst) */
|
||||
thread_t thread; /* download thread */
|
||||
} ftp_t;
|
||||
|
||||
|
||||
typedef struct { /* receiver raw data control type */
|
||||
gtime_t time; /* message time */
|
||||
gtime_t tobs; /* observation data time */
|
||||
obs_t obs; /* observation data */
|
||||
obs_t obuf; /* observation data buffer */
|
||||
nav_t nav; /* satellite ephemerides */
|
||||
sta_t sta; /* station parameters */
|
||||
int ephsat; /* sat number of update ephemeris (0:no satellite) */
|
||||
sbsmsg_t sbsmsg; /* SBAS message */
|
||||
char msgtype[256]; /* last message type */
|
||||
unsigned char subfrm[MAXSAT][380]; /* subframe buffer */
|
||||
lexmsg_t lexmsg; /* LEX message */
|
||||
double lockt[MAXSAT][NFREQ+NEXOBS]; /* lock time (s) */
|
||||
double icpp[MAXSAT],off[MAXSAT],icpc; /* carrier params for ss2 */
|
||||
double prCA[MAXSAT],dpCA[MAXSAT]; /* L1/CA pseudrange/doppler for javad */
|
||||
unsigned char halfc[MAXSAT][NFREQ+NEXOBS]; /* half-cycle add flag */
|
||||
char freqn[MAXOBS]; /* frequency number for javad */
|
||||
int nbyte; /* number of bytes in message buffer */
|
||||
int len; /* message length (bytes) */
|
||||
int iod; /* issue of data */
|
||||
int tod; /* time of day (ms) */
|
||||
int tbase; /* time base (0:gpst,1:utc(usno),2:glonass,3:utc(su) */
|
||||
int flag; /* general purpose flag */
|
||||
int outtype; /* output message type */
|
||||
unsigned char buff[MAXRAWLEN]; /* message buffer */
|
||||
char opt[256]; /* receiver dependent options */
|
||||
double receive_time;/* RT17: Reiceve time of week for week rollover detection */
|
||||
unsigned int plen; /* RT17: Total size of packet to be read */
|
||||
unsigned int pbyte; /* RT17: How many packet bytes have been read so far */
|
||||
unsigned int page; /* RT17: Last page number */
|
||||
unsigned int reply; /* RT17: Current reply number */
|
||||
int week; /* RT17: week number */
|
||||
unsigned char pbuff[255+4+2]; /* RT17: Packet buffer */
|
||||
} raw_t;
|
||||
|
||||
|
||||
typedef struct { /* RTK server type */
|
||||
int state; /* server state (0:stop,1:running) */
|
||||
int cycle; /* processing cycle (ms) */
|
||||
int nmeacycle; /* NMEA request cycle (ms) (0:no req) */
|
||||
int nmeareq; /* NMEA request (0:no,1:nmeapos,2:single sol) */
|
||||
double nmeapos[3]; /* NMEA request position (ecef) (m) */
|
||||
int buffsize; /* input buffer size (bytes) */
|
||||
int format[3]; /* input format {rov,base,corr} */
|
||||
solopt_t solopt[2]; /* output solution options {sol1,sol2} */
|
||||
int navsel; /* ephemeris select (0:all,1:rover,2:base,3:corr) */
|
||||
int nsbs; /* number of sbas message */
|
||||
int nsol; /* number of solution buffer */
|
||||
rtk_t rtk; /* RTK control/result struct */
|
||||
int nb [3]; /* bytes in input buffers {rov,base} */
|
||||
int nsb[2]; /* bytes in soulution buffers */
|
||||
int npb[3]; /* bytes in input peek buffers */
|
||||
unsigned char *buff[3]; /* input buffers {rov,base,corr} */
|
||||
unsigned char *sbuf[2]; /* output buffers {sol1,sol2} */
|
||||
unsigned char *pbuf[3]; /* peek buffers {rov,base,corr} */
|
||||
sol_t solbuf[MAXSOLBUF]; /* solution buffer */
|
||||
unsigned int nmsg[3][10]; /* input message counts */
|
||||
raw_t raw [3]; /* receiver raw control {rov,base,corr} */
|
||||
rtcm_t rtcm[3]; /* RTCM control {rov,base,corr} */
|
||||
gtime_t ftime[3]; /* download time {rov,base,corr} */
|
||||
char files[3][MAXSTRPATH]; /* download paths {rov,base,corr} */
|
||||
obs_t obs[3][MAXOBSBUF]; /* observation data {rov,base,corr} */
|
||||
nav_t nav; /* navigation data */
|
||||
sbsmsg_t sbsmsg[MAXSBSMSG]; /* SBAS message buffer */
|
||||
stream_t stream[8]; /* streams {rov,base,corr,sol1,sol2,logr,logb,logc} */
|
||||
stream_t *moni; /* monitor stream */
|
||||
unsigned int tick; /* start tick */
|
||||
thread_t thread; /* server thread */
|
||||
int cputime; /* CPU time (ms) for a processing cycle */
|
||||
int prcout; /* missing observation data count */
|
||||
lock_t lock; /* lock flag */
|
||||
} rtksvr_t;
|
||||
|
||||
|
||||
const double chisqr[100] = { /* chi-sqr(n) (alpha=0.001) */
|
||||
10.8, 13.8, 16.3, 18.5, 20.5, 22.5, 24.3, 26.1, 27.9, 29.6,
|
||||
31.3, 32.9, 34.5, 36.1, 37.7, 39.3, 40.8, 42.3, 43.8, 45.3,
|
||||
|
@ -639,8 +639,11 @@ void *rtksvrthread(void *arg)
|
||||
* return : status (1:ok 0:error)
|
||||
*-----------------------------------------------------------------------------*/
|
||||
void rtksvrlock (rtksvr_t *svr) {rtk_lock (&svr->lock);}
|
||||
|
||||
|
||||
void rtksvrunlock(rtksvr_t *svr) {rtk_unlock(&svr->lock);}
|
||||
|
||||
|
||||
/* start rtk server ------------------------------------------------------------
|
||||
* start rtk server thread
|
||||
* args : rtksvr_t *svr IO rtk server
|
||||
@ -791,13 +794,8 @@ void *rtksvrthread(void *arg)
|
||||
writesolhead(svr->stream+i, svr->solopt+i-3);
|
||||
}
|
||||
/* create rtk server thread */
|
||||
#ifdef WIN32
|
||||
if (!(svr->thread = CreateThread(NULL,0,rtksvrthread,svr,0,NULL)))
|
||||
{
|
||||
#else
|
||||
if (pthread_create(&svr->thread, NULL, rtksvrthread, svr))
|
||||
{
|
||||
#endif
|
||||
for (i = 0;i<MAXSTRRTK;i++) strclose(svr->stream+i);
|
||||
return 0;
|
||||
}
|
||||
@ -832,12 +830,7 @@ void *rtksvrthread(void *arg)
|
||||
svr->state = 0;
|
||||
|
||||
/* free rtk server thread */
|
||||
#ifdef WIN32
|
||||
WaitForSingleObject(svr->thread,10000);
|
||||
CloseHandle(svr->thread);
|
||||
#else
|
||||
pthread_join(svr->thread, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,12 +55,7 @@
|
||||
#define GNSS_SDR_RTKLIB_RKTSVR_H_
|
||||
|
||||
#include "rtklib.h"
|
||||
#include "rtklib_stream.h"
|
||||
|
||||
#define MAXRAWLEN 4096 /* max length of receiver raw message */
|
||||
#define MAXSOLBUF 256 /* max number of solution buffer */
|
||||
#define MAXSBSMSG 32 /* max number of SBAS msg in RTK server */
|
||||
#define MAXOBSBUF 128 /* max number of observation data buffer */
|
||||
|
||||
const solopt_t solopt_default = { /* defaults solution output options */
|
||||
SOLF_LLH, TIMES_GPST, 1, 3, /* posf, times, timef, timeu */
|
||||
@ -92,105 +87,50 @@ const prcopt_t prcopt_default = { /* defaults processing options */
|
||||
0, 0, 0, {"",""}, {}, 0, {{},{}}, { {}, {{},{}}, {{},{}}, {}, {} }, 0, {}
|
||||
};
|
||||
|
||||
typedef struct { /* receiver raw data control type */
|
||||
gtime_t time; /* message time */
|
||||
gtime_t tobs; /* observation data time */
|
||||
obs_t obs; /* observation data */
|
||||
obs_t obuf; /* observation data buffer */
|
||||
nav_t nav; /* satellite ephemerides */
|
||||
sta_t sta; /* station parameters */
|
||||
int ephsat; /* sat number of update ephemeris (0:no satellite) */
|
||||
sbsmsg_t sbsmsg; /* SBAS message */
|
||||
char msgtype[256]; /* last message type */
|
||||
unsigned char subfrm[MAXSAT][380]; /* subframe buffer */
|
||||
lexmsg_t lexmsg; /* LEX message */
|
||||
double lockt[MAXSAT][NFREQ+NEXOBS]; /* lock time (s) */
|
||||
double icpp[MAXSAT],off[MAXSAT],icpc; /* carrier params for ss2 */
|
||||
double prCA[MAXSAT],dpCA[MAXSAT]; /* L1/CA pseudrange/doppler for javad */
|
||||
unsigned char halfc[MAXSAT][NFREQ+NEXOBS]; /* half-cycle add flag */
|
||||
char freqn[MAXOBS]; /* frequency number for javad */
|
||||
int nbyte; /* number of bytes in message buffer */
|
||||
int len; /* message length (bytes) */
|
||||
int iod; /* issue of data */
|
||||
int tod; /* time of day (ms) */
|
||||
int tbase; /* time base (0:gpst,1:utc(usno),2:glonass,3:utc(su) */
|
||||
int flag; /* general purpose flag */
|
||||
int outtype; /* output message type */
|
||||
unsigned char buff[MAXRAWLEN]; /* message buffer */
|
||||
char opt[256]; /* receiver dependent options */
|
||||
double receive_time;/* RT17: Reiceve time of week for week rollover detection */
|
||||
unsigned int plen; /* RT17: Total size of packet to be read */
|
||||
unsigned int pbyte; /* RT17: How many packet bytes have been read so far */
|
||||
unsigned int page; /* RT17: Last page number */
|
||||
unsigned int reply; /* RT17: Current reply number */
|
||||
int week; /* RT17: week number */
|
||||
unsigned char pbuff[255+4+2]; /* RT17: Packet buffer */
|
||||
} raw_t;
|
||||
|
||||
typedef struct { /* RTK server type */
|
||||
int state; /* server state (0:stop,1:running) */
|
||||
int cycle; /* processing cycle (ms) */
|
||||
int nmeacycle; /* NMEA request cycle (ms) (0:no req) */
|
||||
int nmeareq; /* NMEA request (0:no,1:nmeapos,2:single sol) */
|
||||
double nmeapos[3]; /* NMEA request position (ecef) (m) */
|
||||
int buffsize; /* input buffer size (bytes) */
|
||||
int format[3]; /* input format {rov,base,corr} */
|
||||
solopt_t solopt[2]; /* output solution options {sol1,sol2} */
|
||||
int navsel; /* ephemeris select (0:all,1:rover,2:base,3:corr) */
|
||||
int nsbs; /* number of sbas message */
|
||||
int nsol; /* number of solution buffer */
|
||||
rtk_t rtk; /* RTK control/result struct */
|
||||
int nb [3]; /* bytes in input buffers {rov,base} */
|
||||
int nsb[2]; /* bytes in soulution buffers */
|
||||
int npb[3]; /* bytes in input peek buffers */
|
||||
unsigned char *buff[3]; /* input buffers {rov,base,corr} */
|
||||
unsigned char *sbuf[2]; /* output buffers {sol1,sol2} */
|
||||
unsigned char *pbuf[3]; /* peek buffers {rov,base,corr} */
|
||||
sol_t solbuf[MAXSOLBUF]; /* solution buffer */
|
||||
unsigned int nmsg[3][10]; /* input message counts */
|
||||
raw_t raw [3]; /* receiver raw control {rov,base,corr} */
|
||||
rtcm_t rtcm[3]; /* RTCM control {rov,base,corr} */
|
||||
gtime_t ftime[3]; /* download time {rov,base,corr} */
|
||||
char files[3][MAXSTRPATH]; /* download paths {rov,base,corr} */
|
||||
obs_t obs[3][MAXOBSBUF]; /* observation data {rov,base,corr} */
|
||||
nav_t nav; /* navigation data */
|
||||
sbsmsg_t sbsmsg[MAXSBSMSG]; /* SBAS message buffer */
|
||||
stream_t stream[8]; /* streams {rov,base,corr,sol1,sol2,logr,logb,logc} */
|
||||
stream_t *moni; /* monitor stream */
|
||||
unsigned int tick; /* start tick */
|
||||
thread_t thread; /* server thread */
|
||||
int cputime; /* CPU time (ms) for a processing cycle */
|
||||
int prcout; /* missing observation data count */
|
||||
lock_t lock; /* lock flag */
|
||||
} rtksvr_t;
|
||||
|
||||
|
||||
|
||||
void writesolhead(stream_t *stream, const solopt_t *solopt);
|
||||
|
||||
void saveoutbuf(rtksvr_t *svr, unsigned char *buff, int n, int index);
|
||||
|
||||
void writesol(rtksvr_t *svr, int index);
|
||||
|
||||
void updatenav(nav_t *nav);
|
||||
|
||||
void updatefcn(rtksvr_t *svr);
|
||||
|
||||
void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat,
|
||||
sbsmsg_t *sbsmsg, int index, int iobs);
|
||||
|
||||
int decoderaw(rtksvr_t *svr, int index);
|
||||
|
||||
void decodefile(rtksvr_t *svr, int index);
|
||||
|
||||
void *rtksvrthread(void *arg);
|
||||
|
||||
int rtksvrinit(rtksvr_t *svr);
|
||||
|
||||
void rtksvrfree(rtksvr_t *svr);
|
||||
|
||||
void rtksvrlock (rtksvr_t *svr);
|
||||
|
||||
void rtksvrunlock(rtksvr_t *svr);
|
||||
|
||||
int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs,
|
||||
char **paths, int *formats, int navsel, char **cmds,
|
||||
char **rcvopts, int nmeacycle, int nmeareq,
|
||||
const double *nmeapos, prcopt_t *prcopt,
|
||||
solopt_t *solopt, stream_t *moni);
|
||||
|
||||
void rtksvrstop(rtksvr_t *svr, char **cmds);
|
||||
|
||||
int rtksvropenstr(rtksvr_t *svr, int index, int str, const char *path,
|
||||
const solopt_t *solopt);
|
||||
|
||||
void rtksvrclosestr(rtksvr_t *svr, int index);
|
||||
|
||||
int rtksvrostat(rtksvr_t *svr, int rcv, gtime_t *time, int *sat,
|
||||
double *az, double *el, int **snr, int *vsat);
|
||||
|
||||
void rtksvrsstat(rtksvr_t *svr, int *sstat, char *msg);
|
||||
|
||||
|
||||
|
@ -1191,7 +1191,7 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol)
|
||||
static double dirp = 0.0;
|
||||
gtime_t time;
|
||||
double ep[6],pos[3],enuv[3],dms1[3],dms2[3],vel,dir,amag = 0.0;
|
||||
char *p = (char *)buff,*q,sum,*emag = "E";
|
||||
char *p = (char *)buff,*q,sum,*emag = (char*)"E";
|
||||
|
||||
trace(3,"outnmea_rmc:\n");
|
||||
|
||||
|
@ -59,69 +59,121 @@
|
||||
#define MSG_DISCONN "$_DISCONNECT\r\n" /* disconnect message */
|
||||
|
||||
const char *opt2sep(const solopt_t *opt);
|
||||
|
||||
int tonum(char *buff, const char *sep, double *v);
|
||||
|
||||
double sqvar(double covar);
|
||||
|
||||
double dmm2deg(double dmm);
|
||||
|
||||
void septime(double t, double *t1, double *t2, double *t3);
|
||||
|
||||
void soltocov(const sol_t *sol, double *P);
|
||||
|
||||
void covtosol(const double *P, sol_t *sol);
|
||||
|
||||
int decode_nmearmc(char **val, int n, sol_t *sol);
|
||||
|
||||
int decode_nmeagga(char **val, int n, sol_t *sol);
|
||||
|
||||
int decode_nmea(char *buff, sol_t *sol);
|
||||
|
||||
char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time);
|
||||
|
||||
int decode_solxyz(char *buff, const solopt_t *opt, sol_t *sol);
|
||||
|
||||
int decode_solllh(char *buff, const solopt_t *opt, sol_t *sol);
|
||||
|
||||
int decode_solenu(char *buff, const solopt_t *opt, sol_t *sol);
|
||||
|
||||
int decode_solgsi(char *buff, const solopt_t *opt, sol_t *sol);
|
||||
|
||||
int decode_solpos(char *buff, const solopt_t *opt, sol_t *sol);
|
||||
|
||||
void decode_refpos(char *buff, const solopt_t *opt, double *rb);
|
||||
|
||||
int decode_sol(char *buff, const solopt_t *opt, sol_t *sol, double *rb);
|
||||
|
||||
void decode_solopt(char *buff, solopt_t *opt);
|
||||
|
||||
void readsolopt(FILE *fp, solopt_t *opt);
|
||||
|
||||
int inputsol(unsigned char data, gtime_t ts, gtime_t te, double tint,
|
||||
int qflag, const solopt_t *opt, solbuf_t *solbuf);
|
||||
|
||||
int readsoldata(FILE *fp, gtime_t ts, gtime_t te, double tint, int qflag,
|
||||
const solopt_t *opt, solbuf_t *solbuf);
|
||||
|
||||
int cmpsol(const void *p1, const void *p2);
|
||||
|
||||
int sort_solbuf(solbuf_t *solbuf);
|
||||
|
||||
int readsolt(char *files[], int nfile, gtime_t ts, gtime_t te,
|
||||
double tint, int qflag, solbuf_t *solbuf);
|
||||
|
||||
int readsol(char *files[], int nfile, solbuf_t *sol);
|
||||
|
||||
int addsol(solbuf_t *solbuf, const sol_t *sol);
|
||||
|
||||
sol_t *getsol(solbuf_t *solbuf, int index);
|
||||
|
||||
void initsolbuf(solbuf_t *solbuf, int cyclic, int nmax);
|
||||
|
||||
void freesolbuf(solbuf_t *solbuf);
|
||||
|
||||
void freesolstatbuf(solstatbuf_t *solstatbuf);
|
||||
|
||||
int cmpsolstat(const void *p1, const void *p2);
|
||||
|
||||
int sort_solstat(solstatbuf_t *statbuf);
|
||||
|
||||
int decode_solstat(char *buff, solstat_t *stat);
|
||||
|
||||
void addsolstat(solstatbuf_t *statbuf, const solstat_t *stat);
|
||||
|
||||
int readsolstatdata(FILE *fp, gtime_t ts, gtime_t te, double tint,
|
||||
solstatbuf_t *statbuf);
|
||||
|
||||
int readsolstatt(char *files[], int nfile, gtime_t ts, gtime_t te,
|
||||
double tint, solstatbuf_t *statbuf);
|
||||
|
||||
int readsolstat(char *files[], int nfile, solstatbuf_t *statbuf);
|
||||
|
||||
int outecef(unsigned char *buff, const char *s, const sol_t *sol,
|
||||
const solopt_t *opt);
|
||||
|
||||
int outpos(unsigned char *buff, const char *s, const sol_t *sol, const solopt_t *opt);
|
||||
|
||||
int outenu(unsigned char *buff, const char *s, const sol_t *sol,
|
||||
const double *rb, const solopt_t *opt);
|
||||
|
||||
int outnmea_rmc(unsigned char *buff, const sol_t *sol);
|
||||
|
||||
int outnmea_gga(unsigned char *buff, const sol_t *sol);
|
||||
|
||||
int outnmea_gsa(unsigned char *buff, const sol_t *sol,
|
||||
const ssat_t *ssat);
|
||||
|
||||
int outnmea_gsv(unsigned char *buff, const sol_t *sol,
|
||||
const ssat_t *ssat);
|
||||
|
||||
int outprcopts(unsigned char *buff, const prcopt_t *opt);
|
||||
|
||||
int outsolheads(unsigned char *buff, const solopt_t *opt);
|
||||
|
||||
int outsols(unsigned char *buff, const sol_t *sol, const double *rb,
|
||||
const solopt_t *opt);
|
||||
|
||||
int outsolexs(unsigned char *buff, const sol_t *sol, const ssat_t *ssat,
|
||||
const solopt_t *opt);
|
||||
|
||||
void outprcopt(FILE *fp, const prcopt_t *opt);
|
||||
|
||||
void outsolhead(FILE *fp, const solopt_t *opt);
|
||||
|
||||
void outsol(FILE *fp, const sol_t *sol, const double *rb,
|
||||
const solopt_t *opt);
|
||||
|
||||
void outsolex(FILE *fp, const sol_t *sol, const ssat_t *ssat,
|
||||
const solopt_t *opt);
|
||||
|
||||
|
@ -217,7 +217,7 @@
|
||||
{
|
||||
createdir(file->openpath);
|
||||
}
|
||||
if (file->mode&STR_MODE_R) rw="rb"; else rw="wb";
|
||||
if (file->mode&STR_MODE_R) rw = (char*)"rb"; else rw = (char*)"wb";
|
||||
|
||||
if (!(file->fp = fopen(file->openpath, rw)))
|
||||
{
|
||||
@ -402,7 +402,8 @@
|
||||
{
|
||||
struct timeval tv = {0};
|
||||
fd_set rs;
|
||||
unsigned int nr=0,t,tick;
|
||||
unsigned int t, tick;
|
||||
int nr = 0;
|
||||
size_t fpos;
|
||||
|
||||
tracet(4, "readfile: fp=%d nmax=%d\n", file->fp, nmax);
|
||||
@ -893,7 +894,8 @@
|
||||
|
||||
if (!waittcpsvr(tcpsvr, msg) || tcpsvr->cli[0].state != 2) return 0;
|
||||
|
||||
if ((nr=recv_nb(tcpsvr->cli[0].sock,buff,n)) == -1) {
|
||||
if ((nr = recv_nb(tcpsvr->cli[0].sock, buff, n)) == -1)
|
||||
{
|
||||
err = errsock();
|
||||
tracet(1, "readtcpsvr: recv error sock=%d err=%d\n", tcpsvr->cli[0].sock, err);
|
||||
sprintf(msg, "recv error (%d)", err);
|
||||
@ -1490,7 +1492,7 @@
|
||||
FILE *fp;
|
||||
gtime_t time;
|
||||
char remote[1024], local[1024], tmpfile[1024], errfile[1024], *p;
|
||||
char cmd[2048],env[1024]="",opt[1024],*proxyopt="",*proto;
|
||||
char cmd[2048], env[1024] = "", opt[1024], *proxyopt = (char*)"", *proto;
|
||||
int ret;
|
||||
|
||||
tracet(3, "ftpthread:\n");
|
||||
@ -1531,7 +1533,7 @@
|
||||
{
|
||||
proto = ftp->proto ? (char*)"http" : (char*)"ftp";
|
||||
sprintf(env, "set %s_proxy=http://%s & ", proto, proxyaddr);
|
||||
proxyopt="--proxy=on ";
|
||||
proxyopt = (char*)"--proxy=on ";
|
||||
}
|
||||
/* download command (ref [2]) */
|
||||
if (ftp->proto == 0)
|
||||
@ -1813,6 +1815,7 @@
|
||||
stream->port = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* sync streams ----------------------------------------------------------------
|
||||
* sync time for streams
|
||||
* args : stream_t *stream1 IO stream 1
|
||||
@ -1829,6 +1832,7 @@
|
||||
if (file1 && file2) syncfile(file1, file2);
|
||||
}
|
||||
|
||||
|
||||
/* lock/unlock stream ----------------------------------------------------------
|
||||
* lock/unlock stream
|
||||
* args : stream_t *stream I stream
|
||||
@ -1838,6 +1842,7 @@
|
||||
|
||||
void strunlock(stream_t *stream) {rtk_unlock(&stream->lock);}
|
||||
|
||||
|
||||
/* read stream -----------------------------------------------------------------
|
||||
* read data from stream (unblocked)
|
||||
* args : stream_t *stream I stream
|
||||
|
@ -54,8 +54,6 @@
|
||||
#define GNSS_SDR_RTKLIB_STREAM_H_
|
||||
|
||||
#include "rtklib.h"
|
||||
#include <pthread.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
/* constants -----------------------------------------------------------------*/
|
||||
|
||||
@ -81,189 +79,159 @@
|
||||
#define FTP_CMD "wget" /* ftp/http command */
|
||||
#define FTP_TIMEOUT 30 /* ftp/http timeout (s) */
|
||||
|
||||
/* macros --------------------------------------------------------------------*/
|
||||
|
||||
#define dev_t int
|
||||
#define socket_t int
|
||||
#define closesocket close
|
||||
#define lock_t pthread_mutex_t
|
||||
#define thread_t pthread_t
|
||||
#define initlock(f) pthread_mutex_init(f,NULL)
|
||||
#define rtk_lock(f) pthread_mutex_lock(f)
|
||||
#define rtk_unlock(f) pthread_mutex_unlock(f)
|
||||
|
||||
|
||||
typedef struct { /* stream type */
|
||||
int type; /* type (STR_???) */
|
||||
int mode; /* mode (STR_MODE_?) */
|
||||
int state; /* state (-1:error,0:close,1:open) */
|
||||
unsigned int inb,inr; /* input bytes/rate */
|
||||
unsigned int outb,outr; /* output bytes/rate */
|
||||
unsigned int tick,tact; /* tick/active tick */
|
||||
unsigned int inbt,outbt; /* input/output bytes at tick */
|
||||
lock_t lock; /* lock flag */
|
||||
void *port; /* type dependent port control struct */
|
||||
char path[MAXSTRPATH]; /* stream path */
|
||||
char msg [MAXSTRMSG]; /* stream message */
|
||||
} stream_t;
|
||||
|
||||
|
||||
/* type definition -----------------------------------------------------------*/
|
||||
|
||||
typedef struct { /* serial control type */
|
||||
dev_t dev; /* serial device */
|
||||
int error; /* error state */
|
||||
} serial_t;
|
||||
|
||||
typedef struct { /* file control type */
|
||||
FILE *fp; /* file pointer */
|
||||
FILE *fp_tag; /* file pointer of tag file */
|
||||
FILE *fp_tmp; /* temporary file pointer for swap */
|
||||
FILE *fp_tag_tmp; /* temporary file pointer of tag file for swap */
|
||||
char path[MAXSTRPATH]; /* file path */
|
||||
char openpath[MAXSTRPATH]; /* open file path */
|
||||
int mode; /* file mode */
|
||||
int timetag; /* time tag flag (0:off,1:on) */
|
||||
int repmode; /* replay mode (0:master,1:slave) */
|
||||
int offset; /* time offset (ms) for slave */
|
||||
gtime_t time; /* start time */
|
||||
gtime_t wtime; /* write time */
|
||||
unsigned int tick; /* start tick */
|
||||
unsigned int tick_f; /* start tick in file */
|
||||
unsigned int fpos; /* current file position */
|
||||
double start; /* start offset (s) */
|
||||
double speed; /* replay speed (time factor) */
|
||||
double swapintv; /* swap interval (hr) (0: no swap) */
|
||||
lock_t lock; /* lock flag */
|
||||
} file_t;
|
||||
|
||||
typedef struct { /* tcp control type */
|
||||
int state; /* state (0:close,1:wait,2:connect) */
|
||||
char saddr[256]; /* address string */
|
||||
int port; /* port */
|
||||
struct sockaddr_in addr; /* address resolved */
|
||||
socket_t sock; /* socket descriptor */
|
||||
int tcon; /* reconnect time (ms) (-1:never,0:now) */
|
||||
unsigned int tact; /* data active tick */
|
||||
unsigned int tdis; /* disconnect tick */
|
||||
} tcp_t;
|
||||
|
||||
typedef struct { /* tcp server type */
|
||||
tcp_t svr; /* tcp server control */
|
||||
tcp_t cli[MAXCLI]; /* tcp client controls */
|
||||
} tcpsvr_t;
|
||||
|
||||
typedef struct { /* tcp cilent type */
|
||||
tcp_t svr; /* tcp server control */
|
||||
int toinact; /* inactive timeout (ms) (0:no timeout) */
|
||||
int tirecon; /* reconnect interval (ms) (0:no reconnect) */
|
||||
} tcpcli_t;
|
||||
|
||||
typedef struct { /* ntrip control type */
|
||||
int state; /* state (0:close,1:wait,2:connect) */
|
||||
int type; /* type (0:server,1:client) */
|
||||
int nb; /* response buffer size */
|
||||
char url[256]; /* url for proxy */
|
||||
char mntpnt[256]; /* mountpoint */
|
||||
char user[256]; /* user */
|
||||
char passwd[256]; /* password */
|
||||
char str[NTRIP_MAXSTR]; /* mountpoint string for server */
|
||||
unsigned char buff[NTRIP_MAXRSP]; /* response buffer */
|
||||
tcpcli_t *tcp; /* tcp client */
|
||||
} ntrip_t;
|
||||
|
||||
typedef struct { /* ftp download control type */
|
||||
int state; /* state (0:close,1:download,2:complete,3:error) */
|
||||
int proto; /* protocol (0:ftp,1:http) */
|
||||
int error; /* error code (0:no error,1-10:wget error, */
|
||||
/* 11:no temp dir,12:uncompact error) */
|
||||
char addr[1024]; /* download address */
|
||||
char file[1024]; /* download file path */
|
||||
char user[256]; /* user for ftp */
|
||||
char passwd[256]; /* password for ftp */
|
||||
char local[1024]; /* local file path */
|
||||
int topts[4]; /* time options {poff,tint,toff,tretry} (s) */
|
||||
gtime_t tnext; /* next retry time (gpst) */
|
||||
thread_t thread; /* download thread */
|
||||
} ftp_t;
|
||||
|
||||
serial_t *openserial(const char *path, int mode, char *msg);
|
||||
|
||||
void closeserial(serial_t *serial);
|
||||
|
||||
int readserial(serial_t *serial, unsigned char *buff, int n, char *msg);
|
||||
|
||||
int writeserial(serial_t *serial, unsigned char *buff, int n, char *msg);
|
||||
|
||||
int stateserial(serial_t *serial);
|
||||
|
||||
int openfile_(file_t *file, gtime_t time, char *msg);
|
||||
|
||||
void closefile_(file_t *file);
|
||||
|
||||
file_t *openfile(const char *path, int mode, char *msg);
|
||||
|
||||
void closefile(file_t *file);
|
||||
|
||||
void swapfile(file_t *file, gtime_t time, char *msg);
|
||||
|
||||
void swapclose(file_t *file);
|
||||
|
||||
int statefile(file_t *file);
|
||||
|
||||
int readfile(file_t *file, unsigned char *buff, int nmax, char *msg);
|
||||
|
||||
int writefile(file_t *file, unsigned char *buff, int n, char *msg);
|
||||
|
||||
void syncfile(file_t *file1, file_t *file2);
|
||||
|
||||
void decodetcppath(const char *path, char *addr, char *port, char *user,
|
||||
char *passwd, char *mntpnt, char *str);
|
||||
|
||||
int errsock(void);
|
||||
|
||||
int setsock(socket_t sock, char *msg);
|
||||
|
||||
socket_t accept_nb(socket_t sock, struct sockaddr *addr, socklen_t *len);
|
||||
|
||||
int connect_nb(socket_t sock, struct sockaddr *addr, socklen_t len);
|
||||
|
||||
int recv_nb(socket_t sock, unsigned char *buff, int n);
|
||||
|
||||
int send_nb(socket_t sock, unsigned char *buff, int n);
|
||||
|
||||
int gentcp(tcp_t *tcp, int type, char *msg);
|
||||
|
||||
void discontcp(tcp_t *tcp, int tcon);
|
||||
|
||||
tcpsvr_t *opentcpsvr(const char *path, char *msg);
|
||||
|
||||
void closetcpsvr(tcpsvr_t *tcpsvr);
|
||||
|
||||
void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg);
|
||||
|
||||
int accsock(tcpsvr_t *tcpsvr, char *msg);
|
||||
|
||||
int waittcpsvr(tcpsvr_t *tcpsvr, char *msg);
|
||||
|
||||
int readtcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg);
|
||||
|
||||
int writetcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg);
|
||||
|
||||
int statetcpsvr(tcpsvr_t *tcpsvr);
|
||||
|
||||
int consock(tcpcli_t *tcpcli, char *msg);
|
||||
|
||||
tcpcli_t *opentcpcli(const char *path, char *msg);
|
||||
|
||||
void closetcpcli(tcpcli_t *tcpcli);
|
||||
|
||||
int waittcpcli(tcpcli_t *tcpcli, char *msg);
|
||||
|
||||
int readtcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg);
|
||||
|
||||
int writetcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg);
|
||||
|
||||
int statetcpcli(tcpcli_t *tcpcli);
|
||||
|
||||
int encbase64(char *str, const unsigned char *byte, int n);
|
||||
|
||||
int reqntrip_s(ntrip_t *ntrip, char *msg);
|
||||
|
||||
int reqntrip_c(ntrip_t *ntrip, char *msg);
|
||||
|
||||
int rspntrip_s(ntrip_t *ntrip, char *msg);
|
||||
|
||||
int rspntrip_c(ntrip_t *ntrip, char *msg);
|
||||
|
||||
int waitntrip(ntrip_t *ntrip, char *msg);
|
||||
|
||||
ntrip_t *openntrip(const char *path, int type, char *msg);
|
||||
|
||||
void closentrip(ntrip_t *ntrip);
|
||||
|
||||
int readntrip(ntrip_t *ntrip, unsigned char *buff, int n, char *msg);
|
||||
|
||||
int writentrip(ntrip_t *ntrip, unsigned char *buff, int n, char *msg);
|
||||
|
||||
int statentrip(ntrip_t *ntrip);
|
||||
|
||||
void decodeftppath(const char *path, char *addr, char *file, char *user,
|
||||
char *passwd, int *topts);
|
||||
|
||||
gtime_t nextdltime(const int *topts, int stat);
|
||||
|
||||
void *ftpthread(void *arg);
|
||||
|
||||
ftp_t *openftp(const char *path, int type, char *msg);
|
||||
|
||||
void closeftp(ftp_t *ftp);
|
||||
|
||||
int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg);
|
||||
|
||||
int stateftp(ftp_t *ftp);
|
||||
|
||||
void strinitcom(void);
|
||||
|
||||
void strinit(stream_t *stream);
|
||||
|
||||
int stropen(stream_t *stream, int type, int mode, const char *path);
|
||||
|
||||
void strclose(stream_t *stream);
|
||||
|
||||
void strsync(stream_t *stream1, stream_t *stream2);
|
||||
|
||||
void strlock(stream_t *stream);
|
||||
|
||||
void strunlock(stream_t *stream);
|
||||
|
||||
int strread(stream_t *stream, unsigned char *buff, int n);
|
||||
|
||||
int strwrite(stream_t *stream, unsigned char *buff, int n);
|
||||
|
||||
int strstat(stream_t *stream, char *msg);
|
||||
|
||||
void strsum(stream_t *stream, int *inb, int *inr, int *outb, int *outr);
|
||||
|
||||
void strsetopt(const int *opt);
|
||||
|
||||
void strsettimeout(stream_t *stream, int toinact, int tirecon);
|
||||
|
||||
void strsetdir(const char *dir);
|
||||
|
||||
void strsetproxy(const char *addr);
|
||||
|
||||
gtime_t strgettime(stream_t *stream);
|
||||
|
||||
void strsendnmea(stream_t *stream, const double *pos);
|
||||
|
||||
int gen_hex(const char *msg, unsigned char *buff);
|
||||
|
||||
void strsendcmd(stream_t *str, const char *cmd);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user