Skip to content

Commit 02c9d0c

Browse files
author
Chad Trabant
committed
Mark as version 4.3 and use a few modern defines
1 parent eaefa7c commit 02c9d0c

File tree

3 files changed

+276
-7
lines changed

3 files changed

+276
-7
lines changed

ChangeLog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
2016.292:
1+
2016.293: version 4.3
22
- Update libslink to 2.6.
33
- Reformat source code using included clang-format profile.
44
- Fix some compiler warnings.

doc/slinktool.md

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
# <p >slinktool
2+
### SeedLink client for data stream inspection, data collection and server testing</p>
3+
4+
1. [Name](#)
5+
1. [Synopsis](#synopsis)
6+
1. [Description](#description)
7+
1. [Options](#options)
8+
1. [Examples](#examples)
9+
1. [Seedlink Selectors](#seedlink-selectors)
10+
1. [Archiving Data](#archiving-data)
11+
1. [Stream List File](#stream-list-file)
12+
1. [Notes](#notes)
13+
1. [Author](#author)
14+
15+
## <a id='synopsis'>Synopsis</a>
16+
17+
<pre >
18+
slinktool [options] [host][:][port]
19+
</pre>
20+
21+
## <a id='description'>Description</a>
22+
23+
<p ><b>slinktool</b> connects to a <u>SeedLink</u> server and queries the server for informaion or requests data using uni-station or multi-station mode and prints information about the packets received. All received packets can optionally be dumped to a single file or saved in custom directory and file layouts.</p>
24+
25+
## <a id='options'>Options</a>
26+
27+
<b>-V</b>
28+
29+
<p style="padding-left: 30px;">Report program version and exit.</p>
30+
31+
<b>-h</b>
32+
33+
<p style="padding-left: 30px;">Print program usage and exit.</p>
34+
35+
<b>-v</b>
36+
37+
<p style="padding-left: 30px;">Be more verbose. This flag can be used multiple times ("-v -v" or "-vv") for more verbosity. One flag: report basic handshaking (link configuration) details and briefly report each packet received. Two flags: report the details of the handshaking, each packet received and detailed connection diagnostics.</p>
38+
39+
<b>-P</b>
40+
41+
<p style="padding-left: 30px;">Ping the server: connect, print out the server ID and exit. If the server was successfully contacted the return code will be 0, if errors were encountered the return code will be 1.</p>
42+
43+
<b>-p</b>
44+
45+
<p style="padding-left: 30px;">Print details of received Mini-SEED data records. This flag can be used multiple times ("-p -p" or "-pp") for more detail. One flag: a single summary line for each data packet received. Two flags: details of the Mini-SEED data records received, including information from fixed header and 100/1000/1001 blockettes.</p>
46+
47+
<b>-u</b>
48+
49+
<p style="padding-left: 30px;">Print data samples in data packets, implies at least one -p flag.</p>
50+
51+
<b>-nd </b><u>delay</u>
52+
53+
<p style="padding-left: 30px;">The network reconnect delay (in seconds) for the connection to the SeedLink server. If the connection breaks for any reason this will govern how soon a reconnection should be attempted. The default value is 30 seconds.</p>
54+
55+
<b>-nt </b><u>timeout</u>
56+
57+
<p style="padding-left: 30px;">The network timeout (in seconds) for the connection to the SeedLink server. If no data [or keep alive packets?] are received in this time the connection is closed and re-established (after the reconnect delay has expired). The default value is 600 seconds. A value of 0 disables the timeout.</p>
58+
59+
<b>-k </b><u>keepalive</u> (requires SeedLink >= 3)
60+
61+
<p style="padding-left: 30px;">Keepalive packet interval (in seconds) at which keepalive (heartbeat) packets are sent to the server. Keepalive packets are only sent if nothing is received within the interval.</p>
62+
63+
<b>-x </b><u>statefile</u>[:<u>interval</u>]
64+
65+
<p style="padding-left: 30px;">During client shutdown the last received sequence numbers and time stamps (start times) for each data stream will be saved in this file. If this file exists upon startup the information will be used to resume the data streams from the point at which they were stopped. In this way the client can be stopped and started without data loss, assuming the data are still available on the server. If <u>interval</u> is specified the state will be saved every <u>interval</u> packets that are received. Otherwise the state will be saved only on normal program termination.</p>
66+
67+
<b>-d</b>
68+
69+
<p style="padding-left: 30px;">Configure the connection in "dial-up" mode. The remote server will close the connection when it has sent all of the data in it's buffers for the selected data streams. This is opposed to the normal behavior of waiting indefinately for data.</p>
70+
71+
<b>-b</b>
72+
73+
<p style="padding-left: 30px;">Configure the connection in "batch" mode. Negotiation with the remote server is made faster by minimizing acknowledgement checks.</p>
74+
75+
<b>-o </b><u>dumpfile</u>
76+
77+
<p style="padding-left: 30px;">If specified, all packets (Mini-SEED records) received will be appended to this file. The file is created if it does not exist. A special mode for this option is to send all received packets to standard output when the dumpfile is specified as '-'. In this case all output besides these records will be redirected to standard error.</p>
78+
79+
<b>-A </b><u>format</u>
80+
81+
<p style="padding-left: 30px;">If specified, all packets (Mini-SEED records) received will be appended to a directory/file structure defined by <b>format</b>. All directories implied in the <b>format</b> string will be created if necessary. See the section <u>Archiving data</u>.</p>
82+
83+
<b>-SDS </b><u>SDSdir</u>
84+
85+
<p style="padding-left: 30px;">If specified, all packets (Mini-SEED records) received will be saved into a Simple Data Structure (SDS) dir/file structure starting at the specified directory. This directory and all subdirectories will be created if necessary. This option is esentially a preset version of '-A' option. The SDS dir/file structure is:</p>
86+
<pre style="padding-left: 30px;">
87+
SDSdir/YEAR/NET/STA/CHAN.TYPE/NET.STA.LOC.CHAN.TYPE.YEAR.DAY
88+
</pre>
89+
90+
<b>-BUD </b><u>BUDdir</u>
91+
92+
<p style="padding-left: 30px;">If specified, all waveform data packets (Mini-SEED data records) received will be saved into a Buffer of Uniform Data (BUD) dir/file structure starting at the specified directory. This directory and all subdirectories will be created if necessary. This option is esentially a preset version of '-A' option. The BUD dir/file structure is:</p>
93+
<pre style="padding-left: 30px;">
94+
BUDdir/NET/STA/STA.NET.LOC.CHAN.YEAR.DAY
95+
</pre>
96+
97+
<b>-s </b><u>selectors</u>
98+
99+
<p style="padding-left: 30px;">This defines default selectors. If no multi-station data streams are configured these selectors will be used for uni-station mode. Otherwise these selectors will be used when no selectors are specified for a given stream using the '-S' or '-l' options.</p>
100+
101+
<b>-l </b><u>streamfile</u>
102+
103+
<p style="padding-left: 30px;">A list of streams will be read from the given file. This option implies multi-station mode. The format of the stream list file is given below in the section <u>Stream list file</u>.</p>
104+
105+
<b>-S </b><u>stream[:selectors],...</u> (requires SeedLink >= 2.5)
106+
107+
<p style="padding-left: 30px;">A list of streams is given as an argument. This option implies multi-station mode. The stream list is composed of multiple streams (stations) and optional selectors. <u>stream</u> should be provided in NET\_STA format and <u>selectors</u> are normal SeedLink selectors, see examples and notes below. If no selectors are provided for a given stream, the default selectors, if defined, will be used.</p>
108+
109+
<b>-tw </b><u>start:[end]</u> (requires SeedLink >= 3)
110+
111+
<p style="padding-left: 30px;">Specifies a time window applied, by the server, to data streams. The format for both times is year,month,day,hour,min,sec; for example: "2002,08,05,14,00:2002,08,05,14,15,00". The end time is optional but the colon must be present. If no end time is specified the server will send data indefinately. This option will override any saved state information.</p>
112+
113+
<p style="padding-left: 30px;">Warning: time windowing might be disabled on the remote server.</p>
114+
115+
<b>-i </b><u>level</u> (requires SeedLink >= 3)
116+
117+
<p style="padding-left: 30px;">Send an information request (INFO); the returned raw XML response is displayed. Possible levels are: ID, CAPABILITIES, STATIONS, STREAMS, GAPS, CONNECTIONS, ALL.</p>
118+
119+
<p style="padding-left: 30px;">Formatted INFO shortcuts (formats the XML for readability):</p>
120+
121+
<pre style="padding-left: 30px;">
122+
-I print server id/version and exit
123+
-L print station list and exit
124+
-Q print stream list and exit
125+
-G print gap list and exit
126+
-C print connection list and exit
127+
</pre>
128+
129+
<p >Warning: informational (INFO) messages might be disabled on the server.</p>
130+
131+
<b>[host][:][port]</b>
132+
133+
<p style="padding-left: 30px;">A required argument, specifies the address of the SeedLink server in host:port format. Either the host, port or both can be omitted. If host is omitted then localhost is assumed, i.e. ':18000' implies 'localhost:18000'. If the port is omitted then 18000 is assumed, i.e. 'localhost' implies 'localhost:18000'. If only ':' is specified 'localhost:18000' is assumed.</p>
134+
135+
## <a id='examples'>Examples</a>
136+
137+
<b>All-station/Uni-station mode example:</b>
138+
139+
<p style="padding-left: 30px;">The following would connect to a SeedLink server at slink.host.com port 18000 and configure the link in all-station/uni-station mode, exactly which data are received depends on the data being served by the SeedLink server on that particular port. Additionally, all of the received packets are appended to the file 'data.mseed' and each packet received is reported on the standard output.</p>
140+
141+
<p style="padding-left: 30px;"><b>> slinktool -v -o data.mseed slink.host.com:18000</b></p>
142+
143+
<p style="padding-left: 30px;">The '-s' argument could be used to indicate selectors to limit the type of packets sent by the SeedLink server (without selectors all packet types are sent). The following would limit this connection to BHZ channel waveform data with a location code of 10 (see an explanation of SeedLink selectors below). Additionally another verbose flag is given, causing slinktool to report detailed header information from data records.</p>
144+
145+
<p style="padding-left: 30px;"><b>> slinktool -vv -s 10BHZ.D -o data.mseed slink.host.com:18000</b></p>
146+
147+
<b>Multi-station mode example:</b>
148+
149+
<p style="padding-left: 30px;">The following example would connect to a SeedLink server on localhost port 18010 and configure the link in multi-station mode. Each station specified with the '-S' argument will be requested, optionally specifying selectors for each station.</p>
150+
151+
<p style="padding-left: 30px;"><b>> slinktool -v -S GE\_WLF,MN\_AQU:00???,IU\_KONO:BHZ.D :18010</b></p>
152+
153+
<p style="padding-left: 30px;">This would request GEOFON station WLF (all data as no selectors were indicated), MedNet station AQU with location code 00 (all channels) and IU network station KONO (only waveform data) from channel BHZ.</p>
154+
155+
<p style="padding-left: 30px;">Of course, a variety of different data selections can be made:</p>
156+
157+
<p style="padding-left: 30px;"><b>-s 'BHE.D BHN.D' -S 'GE\_STU,GE\_MALT,GE\_WLF'</b> (horizontal BH channels, data only)</p>
158+
159+
<p style="padding-left: 30px;"><b>-s BHZ -S GE\_STU,GE\_WLF,GE\_RUE,GE\_EIL</b> (vertical channels only)</p>
160+
161+
<b>Wildcarding network and station codes</b>
162+
163+
<p style="padding-left: 30px;">Some SeedLink implementation support wildcarding of the network and station codes, when this is the case the only two wildcard characters recognized are '\*' for one or more characters and '?' for any single character.</p>
164+
165+
<p style="padding-left: 30px;">As an example, all US network data can be requested using the following syntax:</p>
166+
167+
<p style="padding-left: 30px;"><b>-S 'US\_\*'</b></p>
168+
169+
## <a id='seedlink-selectors'>Seedlink Selectors</a>
170+
171+
<p >SeedLink selectors are used to request specific types of data within a given data stream, in effect limiting the default action of sending all data types. A data packet is sent to the client if it matches any positive selector (without leading "!") and doesn't match any negative selectors (with a leading "!"). The general format of selectors is LLSSS.T, where LL is location, SSS is channel and T is type (one of [DECOTL] for Data, Event, Calibration, Blockette, Timing, and Log records). "LL", ".T", and "LLSSS." can be omitted, implying anything in that field. It is also possible to use "?" in place of L and S as a single character wildcard. Multiple selectors are separated by space(s).</p>
172+
173+
<pre >
174+
Some examples:
175+
BH? - BHZ, BHN, BHE (all record types)
176+
00BH?.D - BHZ, BHN, BHE with location code '00' (data records)
177+
BH? !E - BHZ, BHN, BHE (excluding detection records)
178+
BH? E - BHZ, BHN, BHE & detection records of all channels
179+
!LCQ !LEP - exclude LCQ and LEP channels
180+
!L !T - exclude log and timing records
181+
</pre>
182+
183+
## <a id='archiving-data'>Archiving Data</a>
184+
185+
<p >Using the '-A <b>format</b>' option received data can be saved in a custom directory and file structure. The archive <b>format</b> argument is expanded for each packet processed using the following flags:</p>
186+
187+
<pre >
188+
<b>n</b> : network code, white space removed
189+
<b>s</b> : station code, white space removed
190+
<b>l</b> : location code, white space removed
191+
<b>c</b> : channel code, white space removed
192+
<b>Y</b> : year, 4 digits
193+
<b>y</b> : year, 2 digits zero padded
194+
<b>j</b> : day of year, 3 digits zero padded
195+
<b>H</b> : hour, 2 digits zero padded
196+
<b>M</b> : minute, 2 digits zero padded
197+
<b>S</b> : second, 2 digits zero padded
198+
<b>F</b> : fractional seconds, 4 digits zero padded
199+
<b>%</b> : the percent (%) character
200+
<b>#</b> : the number (#) character
201+
<b>t</b> : single character type code:
202+
D - waveform data packet
203+
E - detection packet
204+
C - calibration packet
205+
T - timing packet
206+
L - log packet
207+
O - opaque data packet
208+
U - unknown/general packet
209+
I - INFO packet
210+
? - unidentifiable packet
211+
</pre>
212+
213+
<p >The flags are prefaced with either the <b>%</b> or <b>#</b> modifier. The <b>%</b> modifier indicates a defining flag while the <b>#</b> indicates a non-defining flag. All received packets with the same set of defining flags will be saved to the same file. Non-defining flags will be expanded using the values in the first packet received for the resulting file name.</p>
214+
215+
<p >Time flags are based on the start time of the given packet.</p>
216+
217+
<p >For example, the format string:</p>
218+
219+
<p ><b>/archive/%n/%s/%n.%s.%l.%c.%Y.%j</b></p>
220+
221+
<p >would be expanded to day length files named something like:</p>
222+
223+
<p ><b>/archive/NL/HGN/NL.HGN..BHE.2003.055</b></p>
224+
225+
<p >Using non-defining flags the format string:</p>
226+
227+
<p ><b>/data/%n.%s.%Y.%j.%H:#M:#S.miniseed</b></p>
228+
229+
<p >would be expanded to:</p>
230+
231+
<p ><b>/data/NL.HGN.2003.044.14:17:54.miniseed</b></p>
232+
233+
<p >resulting in hour length files because the minute and second are specified with the non-defining modifier. The minute and second fields are from the first packet in the file.</p>
234+
235+
## <a id='stream-list-file'>Stream List File</a>
236+
237+
<p >The stream list file used with the '-l' option is expected to define a data stream on each line. The format of each line is:</p>
238+
239+
<pre >
240+
Network Station [selectors]
241+
</pre>
242+
243+
<p >The selectors are optional. If default selectors are also specified (with the '-s' option), they they will be used when no selectors are specified for a given stream. An example file follows:</p>
244+
245+
<pre >
246+
---- Begin example file -----
247+
# Comment lines begin with a '#' or '\*'
248+
# Example stream list file for use with the -l argument of slclient or
249+
# with the sl\_read\_streamlist() libslink function.
250+
GE ISP BH?.D
251+
NL HGN
252+
MN AQU BH? HH?
253+
---- End example file -----
254+
</pre>
255+
256+
## <a id='notes'>Notes</a>
257+
258+
<p >All diagnostic output from slinktool is printed to standard error (stderr), exceptions are when printing Mini-SEED packet details (the -p flag), when printing unpacked samples (the -u flag) and when printing the raw or formatted responses to INFO requests.</p>
259+
260+
## <a id='author'>Author</a>
261+
262+
<pre >
263+
Chad Trabant
264+
ORFEUS Data Center/EC-Project MEREDIAN
265+
IRIS Data Management Center
266+
</pre>
267+
268+
269+
(man page 2016/10/19)

src/slinktool.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
*
99
* Written by Chad Trabant, ORFEUS/EC-Project MEREDIAN
1010
*
11-
* modified 2016.292
11+
* modified 2016.293
1212
***************************************************************************/
1313

1414
#include <stdio.h>
1515
#include <stdlib.h>
1616
#include <string.h>
1717
#include <time.h>
1818

19-
#ifndef WIN32
19+
#ifndef SLP_WIN
2020
#include <signal.h>
2121
#endif
2222

@@ -26,7 +26,7 @@
2626
#include "slinkxml.h"
2727

2828
#define PACKAGE "slinktool"
29-
#define VERSION "4.3dev"
29+
#define VERSION "4.3"
3030

3131
/* Idle archive stream timeout */
3232
#define IDLE_ARCH_STREAM_TIMEOUT 120
@@ -70,7 +70,7 @@ static void print_stderr (const char *message);
7070
static void report_environ ();
7171
static void usage (void);
7272

73-
#ifndef WIN32
73+
#ifndef SLP_WIN
7474
static void term_handler (int sig);
7575
#endif
7676

@@ -82,7 +82,7 @@ main (int argc, char **argv)
8282
int ptype;
8383
int packetcnt = 0;
8484

85-
#ifndef WIN32
85+
#ifndef SLP_WIN
8686
/* Signal handling, use POSIX calls with standardized semantics */
8787
struct sigaction sa;
8888

@@ -894,7 +894,7 @@ report_environ ()
894894
}
895895
} /* End of report_environ() */
896896

897-
#ifndef WIN32
897+
#ifndef SLP_WIN
898898
/***************************************************************************
899899
* term_handler:
900900
* Signal handler routine to set the termination flag.

0 commit comments

Comments
 (0)