SPX SPIDAR NIC-500s Operation Manual page 77

Table of Contents

Advertisement

5.4.4
Reading Data
In SDK mode, data is not saved on the NIC-500. Data is pushed over a network socket to the
client which must read the data from the buffer. If power to the NIC-500 is lost then all of the
data in the buffer is forgotten, and if the buffer is filled, the earliest traces will be overwritten. For
these reasons we strongly recommend running a script to read data from the system while the
system is collecting.
The first thing you must do is open the data socket:
ret=requests.get("http://192.168.20.221:8080/api/nic/gpr/data_socket")
This command will return information on the data socket including the port number. You must
then open a socket on this port, the following example uses Python socket library:
data_channel = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
data_channel.connect(("192.168.20.221", 8090))
Once the data channel is connected the data must be received. The data is sent from the buffer
in bytes so it must be converted to be readable. Each trace consists of a 20-byte header
followed by the trace data, which writes each sample point as a 4-byte floating point amplitude
in mV. The header contains information such as a time stamp, the trace number, number of
stacks etc. The total length of a single trace (in bytes) then is 4 × points per trace + 20. In our
example one trace is 820 bytes. The following code reads in a single trace and converts it to a
readable format:
data = data_channel.recv(820)
(tv_sec, tv_nsec, trace_num, status, stacks, header_size), s =
struct.unpack('<LLLLHH', data[0:20]),data[20:]
trace = numpy.frombuffer(s, dtype=numpy.float32)
The first line receives the bytes from the buffer over the data channel. The second and third
lines split the received data into the header (in brackets, from left to right: the time of collection
in seconds, time of collection in ns, the trace number, the status of the trace, the number of
stacks in the trace and the size of the header) and the trace amplitude data (held in the variable
s). The final line converts the trace amplitude data from bytes to an array of numbers.
5.5 Troubleshooting
Refer to the sample code provided when programming SDK, this may give you a starting point,
and something to build on.
If you believe the system is not operating properly, turn off SDK mode and see if normal
operation resumes. If it does, then there is possibly something in your SDK commands which is
affecting operation.
69
SPIDAR SDK

Advertisement

Table of Contents
loading

Table of Contents