/*------------------------------------------------------------------------------ * str2str.c : console version of stream server * * Copyright (C) 2007-2020 by T.TAKASU, All rights reserved. * * version : $Revision: 1.1 $ $Date: 2008/07/17 21:54:53 $ * history : 2009/06/17 1.0 new * 2011/05/29 1.1 add -f, -l and -x option * 2011/11/29 1.2 fix bug on recognize ntrips:// (rtklib_2.4.1_p4) * 2012/12/25 1.3 add format conversion functions * add -msg, -opt and -sta options * modify -p option * 2013/01/25 1.4 fix bug on showing message * 2014/02/21 1.5 ignore SIG_HUP * 2014/08/10 1.5 fix bug on showing message * 2014/08/26 1.6 support input format gw10, binex and rt17 * 2014/10/14 1.7 use stdin or stdout if option -in or -out omitted * 2014/11/08 1.8 add option -a, -i and -o * 2015/03/23 1.9 fix bug on parsing of command line options * 2016/01/23 1.10 enable septentrio * 2016/01/26 1.11 fix bug on station position by -p option (#126) * add option -px * 2016/07/01 1.12 support CMR/CMR+ * 2016/07/23 1.13 add option -c1 -c2 -c3 -c4 * 2016/09/03 1.14 support ntrip caster * add option -ft,-fl * 2016/09/06 1.15 add reload soure table by USR2 signal * 2016/09/17 1.16 add option -b * 2017/05/26 1.17 add input format tersus * 2020/11/30 1.18 support api change strsvrstart(),strsvrstat() *-----------------------------------------------------------------------------*/ #include #include #include "rtklib.h" #define PRGNAME "str2str" /* program name */ #define MAXSTR 5 /* max number of streams */ #define TRFILE "str2str.trace" /* trace file */ /* global variables ----------------------------------------------------------*/ static strsvr_t strsvr; /* stream server */ static volatile int intrflg=0; /* interrupt flag */ /* help text -----------------------------------------------------------------*/ static const char *help[]={ "", " usage: str2str [-in stream] [-out stream [-out stream...]] [options]", "", " Input data from a stream and divide and output them to multiple streams", " The input stream can be serial, tcp client, tcp server, ntrip client, or", " file. The output stream can be serial, tcp client, tcp server, ntrip server,", " or file. str2str is a resident type application. To stop it, type ctr-c in", " console if run foreground or send signal SIGINT for background process.", " if run foreground or send signal SIGINT for background process.", " if both of the input stream and the output stream follow #format, the", " format of input messages are converted to output. To specify the output", " messages, use -msg option. If the option -in or -out omitted, stdin for", " input or stdout for output is used. If the stream in the option -in or -out", " is null, stdin or stdout is used as well.", " Command options are as follows.", "", " -in stream[#format] input stream path and format", " -out stream[#format] output stream path and format", "", " stream path", " serial : serial://port[:brate[:bsize[:parity[:stopb[:fctr]]]]]", " tcp server : tcpsvr://:port", " tcp client : tcpcli://addr[:port]", " ntrip client : ntrip://[user[:passwd]@]addr[:port][/mntpnt]", " ntrip server : ntrips://[:passwd@]addr[:port]/mntpnt[:str] (only out)", " ntrip caster : ntripc://[user:passwd@][:port]/mntpnt[:srctbl] (only out)", " file : [file://]path[::T][::+start][::xseppd][::S=swap]", "", " format", " rtcm2 : RTCM 2 (only in)", " rtcm3 : RTCM 3", " nov : NovAtel OEMV/4/6,OEMStar (only in)", " oem3 : NovAtel OEM3 (only in)", " ubx : ublox LEA-4T/5T/6T (only in)", " ss2 : NovAtel Superstar II (only in)", " hemis : Hemisphere Eclipse/Crescent (only in)", " stq : SkyTraq S1315F (only in)", " javad : Javad (only in)", " nvs : NVS BINR (only in)", " binex : BINEX (only in)", " rt17 : Trimble RT17 (only in)", " sbf : Septentrio SBF (only in)", "", " -msg \"type[(tint)][,type[(tint)]...]\"", " rtcm message types and output intervals (s)", " -sta sta station id", " -opt opt receiver dependent options", " -s msec timeout time (ms) [10000]", " -r msec reconnect interval (ms) [10000]", " -n msec nmea request cycle (m) [0]", " -f sec file swap margin (s) [30]", " -c file input commands file [no]", " -c1 file output 1 commands file [no]", " -c2 file output 2 commands file [no]", " -c3 file output 3 commands file [no]", " -c4 file output 4 commands file [no]", " -p lat lon hgt station position (latitude/longitude/height) (deg,m)", " -px x y z station position (x/y/z-ecef) (m)", " -a antinfo antenna info (separated by ,)", " -i rcvinfo receiver info (separated by ,)", " -o e n u antenna offset (e,n,u) (m)", " -l local_dir ftp/http local directory []", " -x proxy_addr http/ntrip proxy address [no]", " -b str_no relay back messages from output str to input str [no]", " -t level trace level [0]", " -fl file log file [str2str.trace]", " -h print help", }; /* print help ----------------------------------------------------------------*/ static void printhelp(void) { int i; for (i=0;iout.sta.antdes,ant[0]); strcpy(conv[i]->out.sta.antsno,ant[1]); conv[i]->out.sta.antsetup=atoi(ant[2]); strcpy(buff,rcvinfo); for (p=strtok(buff,","),j=0;p&&j<3;p=strtok(NULL,",")) rcv[j++]=p; strcpy(conv[i]->out.sta.rectype,rcv[0]); strcpy(conv[i]->out.sta.recver ,rcv[1]); strcpy(conv[i]->out.sta.recsno ,rcv[2]); matcpy(conv[i]->out.sta.pos,stapos,3,1); matcpy(conv[i]->out.sta.del,stadel,3,1); } signal(SIGTERM,sigfunc); signal(SIGINT ,sigfunc); signal(SIGHUP ,SIG_IGN); signal(SIGPIPE,SIG_IGN); strsvrinit(&strsvr,n+1); if (trlevel>0) { traceopen(*logfile?logfile:TRFILE); tracelevel(trlevel); } fprintf(stderr,"stream server start\n"); strsetdir(local); strsetproxy(proxy); for (i=0;i0) { traceclose(); } fprintf(stderr,"stream server stop\n"); return 0; }