Commit 7dbec353 authored by Matteo Quintiliani's avatar Matteo Quintiliani

Added the option -r

  -r, --reclen            Specify the desired mini-SEED record length in bytes
                          which must be expressible as 2 raised to the power of X
                          where X is between (and including) 8 to 20.
                          (Default is 512).


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@1349 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent 9bccbd0b
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool.c,v 1.227 2010-08-27 07:53:47 mtheo Exp $
* $Id: nmxptool.c,v 1.228 2010-09-01 20:13:12 mtheo Exp $
*
*/
......@@ -403,10 +403,14 @@ int main (int argc, char **argv) {
strncpy(msr_list_chan[i_chan]->station, station_code, 11);
strncpy(msr_list_chan[i_chan]->channel, channel_code, 11);
msr_list_chan[i_chan]->reclen = 512; /* byte record length */
msr_list_chan[i_chan]->reclen = params.reclen; /* Byte record length */
msr_list_chan[i_chan]->encoding = params.encoding; /* Steim 1 compression by default */
/* Reset some values */
msr_list_chan[i_chan]->sequence_number = 0;
msr_list_chan[i_chan]->datasamples = NULL;
msr_list_chan[i_chan]->numsamples = 0;
} else {
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL,
"Channels %s error in format!\n", NMXP_LOG_STR(channelList_subset->channel[i_chan].name));
......@@ -755,6 +759,14 @@ int main (int argc, char **argv) {
#ifdef HAVE_LIBMSEED
if(params.type_writeseed) {
if(*msr_list_chan) {
for(i_chan = 0; i_chan < channelList_subset->number; i_chan++) {
if(msr_list_chan[i_chan]) {
/* Flush remaining samples */
nmxp_data_msr_pack(NULL, &data_seed, msr_list_chan[i_chan]);
}
}
}
nmxp_data_seed_fclose_all(&data_seed);
}
#endif
......@@ -1084,6 +1096,14 @@ int main (int argc, char **argv) {
#ifdef HAVE_LIBMSEED
if(params.type_writeseed) {
if(*msr_list_chan) {
for(i_chan = 0; i_chan < channelList_subset->number; i_chan++) {
if(msr_list_chan[i_chan]) {
/* Flush remaining samples */
nmxp_data_msr_pack(NULL, &data_seed, msr_list_chan[i_chan]);
}
}
}
nmxp_data_seed_fclose_all(&data_seed);
}
#endif
......@@ -1425,6 +1445,7 @@ static void nmxptool_AlarmHandler(int sig) {
#ifdef HAVE_LIBMSEED
int nmxptool_write_miniseed(NMXP_DATA_PROCESS *pd) {
int cur_chan;
int ret = 0;
if( (cur_chan = nmxp_chan_lookupKeyIndex(pd->key, channelList_subset)) != -1) {
......@@ -1458,7 +1479,6 @@ int nmxptool_msr_send_mseed(NMXP_DATA_PROCESS *pd) {
int psamples;
int precords;
flag verbose = 0;
flag flush = 1;
if( (cur_chan = nmxp_chan_lookupKeyIndex(pd->key, channelList_subset)) != -1) {
......@@ -1487,7 +1507,7 @@ int nmxptool_msr_send_mseed(NMXP_DATA_PROCESS *pd) {
/* msr_print(msr, 2); */
precords = msr_pack (msr, &nmxptool_msr_send_mseed_handler, pd, &psamples, flush, verbose);
precords = msr_pack (msr, &nmxptool_msr_send_mseed_handler, pd, &psamples, 1, verbose);
NMXP_MEM_FREE(msr->datasamples);
if ( precords == -1 ) {
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN,
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool_getoptlong.c,v 1.121 2010-08-27 10:10:30 mtheo Exp $
* $Id: nmxptool_getoptlong.c,v 1.122 2010-09-01 20:13:12 mtheo Exp $
*
*/
......@@ -56,6 +56,7 @@ const NMXPTOOL_PARAMS NMXPTOOL_PARAMS_DEFAULT =
DEFAULT_TIMING_QUALITY,
DEFAULT_QUALITY_INDICATOR,
DEFAULT_ENCODING,
DEFAULT_RECLEN_MINISEED,
0,
0,
0,
......@@ -340,6 +341,11 @@ Mini-SEED arguments:\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
-x, --encoding=ENC Set the mini-SEED encoding. Either 'steim1' or 'steim2'.\n\
(Default is 'steim1').\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
-r, --reclen Specify the desired mini-SEED record length in bytes\n\
which must be expressible as 2 raised to the power of X\n\
where X is between (and including) 8 to 20.\n\
(Default is %d).\n", DEFAULT_RECLEN_MINISEED);
#endif
......@@ -584,6 +590,9 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
char one_time_option[255];
int c;
int flag_reclen_pow = 0;
int reclen_pow = DEFAULT_RECLEN_MINIMUM;
/*
int len_int, j;
char unit = 'X';
......@@ -630,7 +639,8 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
{"writeseed", required_argument, NULL, 'm'},
{"outdirseed", required_argument, NULL, 'o'},
{"quality_indicator", required_argument, NULL, 'q'},
{"encoding", required_argument, NULL, 'x'},
{"encoding", required_argument, NULL, 'x'},
{"reclen", required_argument, NULL, 'r'},
#endif
{"writefile", no_argument, NULL, 'w'},
#ifdef HAVE___SRC_SEEDLINK_PLUGIN_C
......@@ -664,6 +674,7 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
strcat(optstr, "o:");
strcat(optstr, "q:");
strcat(optstr, "x:");
strcat(optstr, "r:");
#endif
......@@ -963,6 +974,7 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
"Syntax error in option -%c %s!\n", c, NMXP_LOG_STR(optarg));
}
break;
case 'o':
params->outdirseed = optarg;
if(params->outdirseed) {
......@@ -975,6 +987,7 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
}
}
break;
case 'q':
switch(optarg[0]) {
case 'D':
......@@ -989,18 +1002,41 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
"Quality indicator %s is invalid! Must be D, R, Q or M!\n", NMXP_LOG_STR(optarg));
break;
}
break;
case 'x':
if (strcmp(optarg,"steim1") == 0) {
params->encoding = DE_STEIM1;
} else if (strcmp(optarg,"steim2") == 0) {
params->encoding = DE_STEIM2;
} else {
ret_errors++;
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY,
"Encoding %s is invalid! Must either be steim1 or steim2!\n",NMXP_LOG_STR(optarg));
}
break;
break;
case 'x':
if (strcmp(optarg,"steim1") == 0) {
params->encoding = DE_STEIM1;
} else if (strcmp(optarg,"steim2") == 0) {
params->encoding = DE_STEIM2;
} else {
ret_errors++;
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY,
"Encoding %s is invalid! Must either be steim1 or steim2!\n",NMXP_LOG_STR(optarg));
}
break;
case 'r':
params->reclen = atoi(optarg);
if(params->reclen >= DEFAULT_RECLEN_MINIMUM && params->reclen <= DEFAULT_RECLEN_MAXIMUM) {
flag_reclen_pow = 0;
while(!flag_reclen_pow && reclen_pow <= DEFAULT_RECLEN_MAXIMUM) {
if(params->reclen == reclen_pow) {
flag_reclen_pow = 1;
}
reclen_pow *= 2;
}
if(!flag_reclen_pow) {
ret_errors++;
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY,
"reclen must expressible as 2 raised to the power of X where X is between (and including) 8 to 20.\n");
}
} else {
ret_errors++;
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY,
"reclen must expressible as 2 raised to the power of X where X is between (and including) 8 to 20.\n");
}
break;
#endif
case 'w':
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool_getoptlong.h,v 1.107 2010-08-25 20:37:48 racine Exp $
* $Id: nmxptool_getoptlong.h,v 1.108 2010-09-01 20:13:12 mtheo Exp $
*
*/
......@@ -79,6 +79,14 @@
#define DEFAULT_ENCODING 0
#endif
#define DEFAULT_RECLEN_POW8 (2 * 2 * 2 * 2 * 2 * 2 * 2 * 2)
#define DEFAULT_RECLEN_POW10 (DEFAULT_RECLEN_POW8 * 2 * 2)
#define DEFAULT_RECLEN_POW20 (DEFAULT_RECLEN_POW10 * DEFAULT_RECLEN_POW10)
#define DEFAULT_RECLEN_MINIMUM DEFAULT_RECLEN_POW8
#define DEFAULT_RECLEN_MAXIMUM DEFAULT_RECLEN_POW20
#define DEFAULT_RECLEN_MINISEED 512
/* Empiric constant values TODO */
#define DEFAULT_N_CHANNEL 9
#define DEFAULT_N_CHANNEL_MINIMUM 3
......@@ -128,6 +136,7 @@ typedef struct {
/* RR */
char quality_indicator;
int8_t encoding;
int reclen;
int flag_listchannels;
int flag_listchannelsnaqs;
int flag_request_channelinfo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment