Commit 1782c365 authored by Matteo Quintiliani's avatar Matteo Quintiliani
Browse files

Minor changes


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@57 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent 38e731a4
......@@ -6,7 +6,7 @@
*
* \section dependencies_sec Dependencies
*
* qlib2
* qlib2 ftp://quake.geo.berkeley.edu/pub/quanterra/ucb/
*
* \section install_sec Installation
*
......@@ -24,7 +24,7 @@
*
* \section about_sec About
*
* Author:
* Author: \n
* Matteo Quintiliani
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
......@@ -126,11 +126,11 @@ int nmxp_receiveChannelList(int isock, NMXP_CHAN_LIST **pchannelList);
int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST *channelList, uint32_t shortTermCompletion, uint32_t out_format, NMXP_BUFFER_FLAG buffer_flag);
/*! \brief Receive Compressed or Decompressed Data message from a socket
/*! \brief Receive Compressed or Decompressed Data message from a socket and launch func_processData() on the extracted data
*
* \param isock A descriptor referencing the socket.
* \param channelList Channel list.
* \param func_processData
* \param func_processData Pointer to the function manages data extracted. It could be NULL.
*
* \retval SOCKET_OK on success
* \retval SOCKET_ERROR on error
......
......@@ -248,7 +248,12 @@ int nmxp_unpack_bundle (int *outdata, unsigned char *indata, int *prev);
int nmxp_log_process_data(NMXP_PROCESS_DATA *pd);
/*! \brief Process Compressed Data message
/*! \brief Process Compressed Data message by function func_processData().
*
* \param buffer_data Pointer to the data buffer containing Compressed Nanometrics packets.
* \param length_data Buffer length in bytes.
* \param channelList Pointer to the Channel List.
* \param func_processData Pointer to the function manages data extracted. It could be NULL.
*
*/
void nmxp_processCompressedDataFunc(char* buffer_data, int length_data, NMXP_CHAN_LIST *channelList,
......@@ -256,15 +261,15 @@ void nmxp_processCompressedDataFunc(char* buffer_data, int length_data, NMXP_CHA
);
/*! \brief Process decompressed Data message
/*! \brief Process decompressed Data message by function func_processData().
*
* \param buffer
* \param length
* \param channelList
* \param func_processData
* \param buffer_data Pointer to the data buffer containing Decompressed Nanometrics packets.
* \param length_data Buffer length in bytes.
* \param channelList Pointer to the Channel List.
* \param func_processData Pointer to the function manages data extracted. It could be NULL.
*
*/
void nmxp_processDecompressedDataFunc(char* buffer, int length, NMXP_CHAN_LIST *channelList,
void nmxp_processDecompressedDataFunc(char* buffer_data, int length_data, NMXP_CHAN_LIST *channelList,
int (*func_processData)(NMXP_PROCESS_DATA *pd)
);
......
......@@ -331,7 +331,7 @@ int nmxp_log_process_data(NMXP_PROCESS_DATA *pd) {
}
void nmxp_processDecompressedDataFunc(char* buffer, int length, NMXP_CHAN_LIST *channelList,
void nmxp_processDecompressedDataFunc(char* buffer_data, int length_data, NMXP_CHAN_LIST *channelList,
int (*func_processData)(NMXP_PROCESS_DATA *pd)
)
{
......@@ -348,20 +348,20 @@ void nmxp_processDecompressedDataFunc(char* buffer, int length, NMXP_CHAN_LIST *
char *chan = 0; /* The channel code */
/* copy the header contents into local fields and swap */
memcpy(&netInt, &buffer[0], 4);
memcpy(&netInt, &buffer_data[0], 4);
pKey = ntohl(netInt);
if ( pKey != netInt ) { swap = 1; }
memcpy(&pTime, &buffer[4], 8);
memcpy(&pTime, &buffer_data[4], 8);
if ( swap ) { swab8(&pTime); }
memcpy(&netInt, &buffer[12], 4);
memcpy(&netInt, &buffer_data[12], 4);
pNSamp = ntohl(netInt);
memcpy(&netInt, &buffer[16], 4);
memcpy(&netInt, &buffer_data[16], 4);
pSampRate = ntohl(netInt);
/* There should be (length - 20) bytes of data as 32-bit ints here */
pDataPtr = (int32_t *) &buffer[20];
/* There should be (length_data - 20) bytes of data as 32-bit ints here */
pDataPtr = (int32_t *) &buffer_data[20];
/* Swap the data samples to host order */
for ( idx=0; idx < pNSamp; idx++ ) {
......@@ -396,13 +396,15 @@ void nmxp_processDecompressedDataFunc(char* buffer, int length, NMXP_CHAN_LIST *
// pd.x0 = ;
// pd.seq_no = ;
pd.time = pTime;
pd.buffer = buffer;
pd.length = length;
pd.buffer = buffer_data;
pd.length = length_data;
pd.nSamp = pNSamp;
pd.pDataPtr = pDataPtr;
pd.sampRate = pSampRate;
func_processData(&pd);
if(func_processData) {
func_processData(&pd);
}
free(sta);
}
......@@ -575,7 +577,9 @@ void nmxp_processCompressedDataFunc(char* buffer_data, int length_data, NMXP_CHA
pd.pDataPtr = pDataPtr;
pd.sampRate = pSampRate;
func_processData(&pd);
if(func_processData) {
func_processData(&pd);
}
free(sta);
}
......
......@@ -10,6 +10,7 @@
*/
#include "nmxp_chan.h"
#include "nmxp_base.h"
#include <string.h>
#include <stdlib.h>
......
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