Commit 256b08d7 authored by Matteo Quintiliani's avatar Matteo Quintiliani
Browse files

Fixed bugs from branch nmxptool_1_2_4_beta8_fixing_MTSAFE2


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@1284 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent aef3f0e8
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -11,7 +11,7 @@ m4_define([major_version], [1])
m4_define([minor_version], [2])
m4_define([minor_version], [2])
m4_define([micro_version], [4])
m4_define([micro_version], [4])
# Comment build_version for stable release
# Comment build_version for stable release
m4_define([build_version], [beta8])
m4_define([build_version], [beta9])


m4_ifdef([build_version], [
m4_ifdef([build_version], [
	  m4_define([version],
	  m4_define([version],
@@ -119,6 +119,8 @@ AM_CONDITIONAL(ENABLE_DLL_PTHREAD, test x$DLL_PTHREAD != x)
AC_ARG_VAR(DIR_PTHREAD, [Directory containing PThread DDL library])
AC_ARG_VAR(DIR_PTHREAD, [Directory containing PThread DDL library])
AC_ARG_VAR(DLL_PTHREAD, [Name of PThread DLL library - i.e. pthreadVC2.dll])
AC_ARG_VAR(DLL_PTHREAD, [Name of PThread DLL library - i.e. pthreadVC2.dll])


CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS"

# Checks for header files.
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/stat.h sys/time.h unistd.h pthread.h])
AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/stat.h sys/time.h unistd.h pthread.h])
@@ -257,7 +259,7 @@ AC_STRUCT_TM
# AC_CHECK_SIZEOF([long int])
# AC_CHECK_SIZEOF([long int])


# Checks for library functions.
# Checks for library functions.
AC_FUNC_MALLOC
# AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_FUNC_MKTIME
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_STRERROR_R
AC_FUNC_STRERROR_R
+2 −2
Original line number Original line Diff line number Diff line
@@ -7,7 +7,7 @@
 * 	Istituto Nazionale di Geofisica e Vulcanologia - Italy
 * 	Istituto Nazionale di Geofisica e Vulcanologia - Italy
 *	quintiliani@ingv.it
 *	quintiliani@ingv.it
 *
 *
 * $Id: nmxp_base.h,v 1.34 2009-08-17 08:47:13 mtheo Exp $
 * $Id: nmxp_base.h,v 1.35 2009-08-31 12:16:41 mtheo Exp $
 *
 *
 */
 */


@@ -78,7 +78,7 @@ int nmxp_setsockopt_RCVTIMEO(int isock, int timeoutsec);


/*! \brief Wrapper to strerror, strerror_r or WSAGetLastErrorMessage
/*! \brief Wrapper to strerror, strerror_r or WSAGetLastErrorMessage
 *
 *
 * \return String message of errno_value. It is static, not need to be freed.
 * \return String message of errno_value. It is not static, need to be freed.
 *
 *
 */
 */
char *nmxp_strerror(int errno_value);
char *nmxp_strerror(int errno_value);
+3 −1
Original line number Original line Diff line number Diff line
@@ -7,7 +7,7 @@
 * 	Istituto Nazionale di Geofisica e Vulcanologia - Italy
 * 	Istituto Nazionale di Geofisica e Vulcanologia - Italy
 *	quintiliani@ingv.it
 *	quintiliani@ingv.it
 *
 *
 * $Id: nmxp_chan.h,v 1.25 2009-03-10 16:36:25 mtheo Exp $
 * $Id: nmxp_chan.h,v 1.26 2009-08-31 12:16:41 mtheo Exp $
 *
 *
 */
 */


@@ -179,6 +179,8 @@ int nmxp_chan_lookupKeyIndex(int32_t key, NMXP_CHAN_LIST_NET *channelList);
 *
 *
 * \return Name of channel with key. NULL on error.
 * \return Name of channel with key. NULL on error.
 *
 *
 * \warning Returned value will need to be freed!
 *
 */
 */
char *nmxp_chan_lookupName(int32_t key, NMXP_CHAN_LIST_NET *channelList);
char *nmxp_chan_lookupName(int32_t key, NMXP_CHAN_LIST_NET *channelList);


+43 −31
Original line number Original line Diff line number Diff line
@@ -7,7 +7,7 @@
 * 	Istituto Nazionale di Geofisica e Vulcanologia - Italy
 * 	Istituto Nazionale di Geofisica e Vulcanologia - Italy
 *	quintiliani@ingv.it
 *	quintiliani@ingv.it
 *
 *
 * $Id: nmxp.c,v 1.94 2009-08-17 08:57:10 mtheo Exp $
 * $Id: nmxp.c,v 1.95 2009-08-31 12:16:41 mtheo Exp $
 *
 *
 */
 */


@@ -46,13 +46,15 @@ int nmxp_receiveChannelList(int isock, NMXP_CHAN_LIST **pchannelList) {
    int recv_errno;
    int recv_errno;


    NMXP_MSG_SERVER type;
    NMXP_MSG_SERVER type;
    char buffer[NMXP_MAX_LENGTH_DATA_BUFFER];
    char buffer[NMXP_MAX_LENGTH_DATA_BUFFER]={0};
    int32_t length;
    int32_t length;


    *pchannelList = NULL;
    *pchannelList = NULL;


    ret = nmxp_receiveMessage(isock, &type, buffer, &length, 0, &recv_errno, NMXP_MAX_LENGTH_DATA_BUFFER);
    ret = nmxp_receiveMessage(isock, &type, buffer, &length, 0, &recv_errno, NMXP_MAX_LENGTH_DATA_BUFFER);
    
    
    /*TODO controllare ret*/
    if (ret == NMXP_SOCKET_OK) {
        if(type != NMXP_MSG_CHANNELLIST) {
        if(type != NMXP_MSG_CHANNELLIST) {
            nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Type %d is not NMXP_MSG_CHANNELLIST!\n", type);
            nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Type %d is not NMXP_MSG_CHANNELLIST!\n", type);
        } else {
        } else {
@@ -78,7 +80,7 @@ int nmxp_receiveChannelList(int isock, NMXP_CHAN_LIST **pchannelList) {
                nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "nmxp_receiveChannelList() Error allocating pchannelList!\n");
                nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "nmxp_receiveChannelList() Error allocating pchannelList!\n");
                ret = NMXP_SOCKET_ERROR;
                ret = NMXP_SOCKET_ERROR;
            }
            }

        }
    }
    }


    return ret;
    return ret;
@@ -136,6 +138,7 @@ int nmxp_sendAddTimeSeriesChannel_raw(int isock, NMXP_CHAN_LIST_NET *channelList
int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, int32_t shortTermCompletion, int32_t out_format, NMXP_BUFFER_FLAG buffer_flag, int n_channel, int n_usec, int flag_restart) {
int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, int32_t shortTermCompletion, int32_t out_format, NMXP_BUFFER_FLAG buffer_flag, int n_channel, int n_usec, int flag_restart) {
    static int i = 0;
    static int i = 0;
    static int first_time = 1;
    static int first_time = 1;
    /*TODO avoid static Stefano*/
    static struct timeval last_tp_now;
    static struct timeval last_tp_now;


    char s_channels[MAX_LEN_S_CHANNELS];
    char s_channels[MAX_LEN_S_CHANNELS];
@@ -221,7 +224,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, in


NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST_NET *channelList, const char *network_code, int timeoutsec, int *recv_errno ) {
NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST_NET *channelList, const char *network_code, int timeoutsec, int *recv_errno ) {
    NMXP_MSG_SERVER type;
    NMXP_MSG_SERVER type;
    char buffer[NMXP_MAX_LENGTH_DATA_BUFFER];
    char buffer[NMXP_MAX_LENGTH_DATA_BUFFER]={0};
    int32_t length;
    int32_t length;
    NMXP_DATA_PROCESS *pd = NULL;
    NMXP_DATA_PROCESS *pd = NULL;


@@ -744,6 +747,8 @@ void nmxp_raw_stream_init(NMXP_RAW_STREAM_DATA *raw_stream_buffer, int32_t max_t
    raw_stream_buffer->max_pdlist_items = max_tolerable_latency * 4;
    raw_stream_buffer->max_pdlist_items = max_tolerable_latency * 4;
    raw_stream_buffer->timeoutrecv = timeoutrecv;
    raw_stream_buffer->timeoutrecv = timeoutrecv;
    raw_stream_buffer->n_pdlist = 0;
    raw_stream_buffer->n_pdlist = 0;

    raw_stream_buffer->pdlist=NULL;
    raw_stream_buffer->pdlist = (NMXP_DATA_PROCESS **) NMXP_MEM_MALLOC(raw_stream_buffer->max_pdlist_items * sizeof(NMXP_DATA_PROCESS *));
    raw_stream_buffer->pdlist = (NMXP_DATA_PROCESS **) NMXP_MEM_MALLOC(raw_stream_buffer->max_pdlist_items * sizeof(NMXP_DATA_PROCESS *));
    for(j=0; j<raw_stream_buffer->max_pdlist_items; j++) {
    for(j=0; j<raw_stream_buffer->max_pdlist_items; j++) {
	raw_stream_buffer->pdlist[j] = NULL;
	raw_stream_buffer->pdlist[j] = NULL;
@@ -797,6 +802,10 @@ int nmxp_raw_stream_manage(NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int


	/* Allocate memory for pd and copy a_pd */
	/* Allocate memory for pd and copy a_pd */
	pd = (NMXP_DATA_PROCESS *) NMXP_MEM_MALLOC(sizeof(NMXP_DATA_PROCESS));
	pd = (NMXP_DATA_PROCESS *) NMXP_MEM_MALLOC(sizeof(NMXP_DATA_PROCESS));
	if (pd == NULL) {
	    nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_RAWSTREAM,"nmxp_raw_stream_manage(): Error allocating memory\n");
	    exit(-1);
	}
	memcpy(pd, a_pd, sizeof(NMXP_DATA_PROCESS));
	memcpy(pd, a_pd, sizeof(NMXP_DATA_PROCESS));
	if(a_pd->nSamp *  sizeof(int) > 0) {
	if(a_pd->nSamp *  sizeof(int) > 0) {
	    pd->pDataPtr = (int *) NMXP_MEM_MALLOC(a_pd->nSamp * sizeof(int));
	    pd->pDataPtr = (int *) NMXP_MEM_MALLOC(a_pd->nSamp * sizeof(int));
@@ -889,7 +898,8 @@ int nmxp_raw_stream_manage(NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int
	}
	}
    } else {
    } else {
	if(pd) {
	if(pd) {
	    p->pdlist[p->n_pdlist++] = pd;
	    p->pdlist[p->n_pdlist] = pd;
            p->n_pdlist++;
	}
	}
    }
    }


@@ -1021,10 +1031,12 @@ int nmxp_raw_stream_manage(NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int
		if(p->pdlist[k]) {
		if(p->pdlist[k]) {
		    NMXP_MEM_FREE(p->pdlist[k]);
		    NMXP_MEM_FREE(p->pdlist[k]);
		    p->pdlist[k] = NULL;
		    p->pdlist[k] = NULL;
                    /*nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_RAWSTREAM, "Freeing p->pdlist[%d]\n", k);*/
		}
		}
	    }
	    }
	    if(k + j < p->n_pdlist) {
	    if(k + j < p->n_pdlist) {
		p->pdlist[k] = p->pdlist[k+j];
		p->pdlist[k] = p->pdlist[k+j];
                p->pdlist[k+j]=NULL;
	    } else {
	    } else {
		p->pdlist[k] = NULL;
		p->pdlist[k] = NULL;
	    }
	    }
+63 −50
Original line number Original line Diff line number Diff line
@@ -7,7 +7,7 @@
 * 	Istituto Nazionale di Geofisica e Vulcanologia - Italy
 * 	Istituto Nazionale di Geofisica e Vulcanologia - Italy
 *	quintiliani@ingv.it
 *	quintiliani@ingv.it
 *
 *
 * $Id: nmxp_base.c,v 1.80 2009-08-17 08:47:13 mtheo Exp $
 * $Id: nmxp_base.c,v 1.81 2009-08-31 12:16:41 mtheo Exp $
 *
 *
 */
 */


@@ -41,6 +41,7 @@


int nmxp_openSocket(char *hostname, int portNum, int (*func_cond)(void))
int nmxp_openSocket(char *hostname, int portNum, int (*func_cond)(void))
{
{
  /*TODO stefano avoid static*/
  static int sleepTime = 1;
  static int sleepTime = 1;
  int isock = -1;
  int isock = -1;
  struct hostent *hostinfo = NULL;
  struct hostent *hostinfo = NULL;
@@ -227,19 +228,19 @@ int nmxp_setsockopt_RCVTIMEO(int isock, int timeoutsec) {
#define MAXLEN_RECV_ERRNO_STR 200
#define MAXLEN_RECV_ERRNO_STR 200


char *nmxp_strerror(int errno_value) {
char *nmxp_strerror(int errno_value) {
    static char ret_recv_errno_str[MAXLEN_RECV_ERRNO_STR];
    char * ret_recv_errno_str;
#ifdef HAVE_WINDOWS_H
#ifdef HAVE_WINDOWS_H
    char *recv_errno_str;
    char *recv_errno_str;
#else
#else


#ifdef HAVE_STRERROR_R
#ifdef HAVE_STRERROR_R
    char recv_errno_str[MAXLEN_RECV_ERRNO_STR];
    char recv_errno_str[MAXLEN_RECV_ERRNO_STR]="";
#else
#else
    char *recv_errno_str;
    char *recv_errno_str=NULL; 
#endif
#endif


#endif
#endif

    ret_recv_errno_str= (char *) NMXP_MEM_MALLOC (MAXLEN_RECV_ERRNO_STR * sizeof(char));
    ret_recv_errno_str[0] = 0;
    ret_recv_errno_str[0] = 0;


#ifdef HAVE_WINDOWS_H
#ifdef HAVE_WINDOWS_H
@@ -319,7 +320,7 @@ int nmxp_recv_ctrl(int isock, void *buffer, int length, int timeoutsec, int *rec
	  nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "nmxp_recv_ctrl(): %s (errno=%d recvCount=%d length=%d cc=%d)\n",
	  nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "nmxp_recv_ctrl(): %s (errno=%d recvCount=%d length=%d cc=%d)\n",
		  NMXP_LOG_STR(recv_errno_str), *recv_errno, recvCount, length, cc);
		  NMXP_LOG_STR(recv_errno_str), *recv_errno, recvCount, length, cc);
      }
      }

       NMXP_MEM_FREE(recv_errno_str);
      /* TO IMPROVE 
      /* TO IMPROVE 
       * Fixed bug receiving zero byte from recv() 'TCP FIN or EOF received'
       * Fixed bug receiving zero byte from recv() 'TCP FIN or EOF received'
       * */
       * */
@@ -356,14 +357,14 @@ int nmxp_sendHeader(int isock, NMXP_MSG_CLIENT type, int32_t length)
int nmxp_receiveHeader(int isock, NMXP_MSG_SERVER *type, int32_t *length, int timeoutsec, int *recv_errno )
int nmxp_receiveHeader(int isock, NMXP_MSG_SERVER *type, int32_t *length, int timeoutsec, int *recv_errno )
{  
{  
    int ret ;
    int ret ;
    NMXP_MESSAGE_HEADER msg;
    NMXP_MESSAGE_HEADER msg={0};


    ret = nmxp_recv_ctrl(isock, &msg, sizeof(NMXP_MESSAGE_HEADER), timeoutsec, recv_errno);
    ret = nmxp_recv_ctrl(isock, &msg, sizeof(NMXP_MESSAGE_HEADER), timeoutsec, recv_errno);


    *type = 0;
    *type = 0;
    *length = 0;
    *length = 0;


    if(ret == NMXP_SOCKET_OK) {
    if((ret == NMXP_SOCKET_OK) && (msg.type != 0)) {
	msg.signature = ntohl(msg.signature);
	msg.signature = ntohl(msg.signature);
	msg.type      = ntohl(msg.type);
	msg.type      = ntohl(msg.type);
	msg.length    = ntohl(msg.length);
	msg.length    = ntohl(msg.length);
@@ -464,25 +465,26 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
  int32_t  *pDataPtr  = NULL;
  int32_t  *pDataPtr  = NULL;
  int       swap      = 0;
  int       swap      = 0;
  int       idx;
  int       idx;
  static int32_t outdata[MAX_OUTDATA];
  int32_t  *outdata   = NULL;



  char station_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
  char station_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
  char channel_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
  char channel_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
  char network_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
  char network_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];


  char *nmxp_channel_name = NULL;
  char *nmxp_channel_name = NULL;
  static NMXP_DATA_PROCESS pd;
  NMXP_DATA_PROCESS *pd   = NULL;


  /* copy the header contents into local fields and swap */
  /* copy the header contents into local fields and swap */
  memcpy(&netInt, &buffer_data[0], 4);
  memcpy(&netInt, &buffer_data[0], 4);
  pKey = ntohl(netInt);
  pKey = ntohl(netInt);
  if ( pKey != netInt ) { swap = 1; }
  if ( pKey != netInt ) { swap = 1; }


  nmxp_data_init(&pd);
  nmxp_data_init(pd);

  outdata = (int32_t *) NMXP_MEM_MALLOC(MAX_OUTDATA*sizeof(int32_t));
  nmxp_channel_name = nmxp_chan_lookupName(pKey, channelList);
  nmxp_channel_name = nmxp_chan_lookupName(pKey, channelList);


  if(nmxp_channel_name) {
  if(nmxp_channel_name != NULL) {


  memcpy(&pTime, &buffer_data[4], 8);
  memcpy(&pTime, &buffer_data[4], 8);
  if ( swap ) { nmxp_data_swap_8b(&pTime); }
  if ( swap ) { nmxp_data_swap_8b(&pTime); }
@@ -507,35 +509,39 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
	    NMXP_LOG_STR(nmxp_channel_name));
	    NMXP_LOG_STR(nmxp_channel_name));
  }
  }


  pd.key = pKey;
  pd->key = pKey;
  if(network_code[0] != 0) {
  if(network_code[0] != 0) {
      strncpy(pd.network, network_code, NMXP_DATA_NETWORK_LENGTH);
      strncpy(pd->network, network_code, NMXP_DATA_NETWORK_LENGTH);
  } else {
  } else {
      strncpy(pd.network, network_code_default, NMXP_DATA_NETWORK_LENGTH);
      strncpy(pd->network, network_code_default, NMXP_DATA_NETWORK_LENGTH);
  }
  }
  if(station_code[0] != 0) {
  if(station_code[0] != 0) {
      strncpy(pd.station, station_code, NMXP_DATA_STATION_LENGTH);
      strncpy(pd->station, station_code, NMXP_DATA_STATION_LENGTH);
  }
  }
  if(channel_code[0] != 0) {
  if(channel_code[0] != 0) {
      strncpy(pd.channel, channel_code, NMXP_DATA_CHANNEL_LENGTH);
      strncpy(pd->channel, channel_code, NMXP_DATA_CHANNEL_LENGTH);
  }
  }
  pd.packet_type = NMXP_MSG_DECOMPRESSED;
  pd->packet_type = NMXP_MSG_DECOMPRESSED;
  pd.x0 = -1;
  pd->x0 = -1;
  pd.xn = -1;
  pd->xn = -1;
  pd.x0n_significant = 0;
  pd->x0n_significant = 0;
  pd->time = pTime;
  pd->nSamp = pNSamp;
  pd->pDataPtr = pDataPtr;
  pd->sampRate = pSampRate;



  /* TODO*/
  /* TODO*/
  /* pd.oldest_seq_no = ;*/
  /* pd.oldest_seq_no = ;*/
  /* pd.seq_no = ;*/
  /* pd.seq_no = ;*/
  pd.time = pTime;
  pd.nSamp = pNSamp;
  pd.pDataPtr = pDataPtr;
  pd.sampRate = pSampRate;


  NMXP_MEM_FREE(nmxp_channel_name);
  } else {
  } else {
      nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Channel name not found for key %d\n", pKey);
      nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Channel name not found for key %d\n", pKey);
  }
  }


  return &pd;
  return pd;
}
}




@@ -551,7 +557,9 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
    char channel_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
    char channel_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
    char network_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
    char network_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];


    static NMXP_DATA_PROCESS pd;
    NMXP_DATA_PROCESS *pd = NULL;




    int32_t nmx_rate_code_to_sample_rate[32] = {
    int32_t nmx_rate_code_to_sample_rate[32] = {
	0,1,2,5,10,20,40,50,
	0,1,2,5,10,20,40,50,
@@ -572,7 +580,8 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data


	int32_t comp_bytecount;
	int32_t comp_bytecount;
	unsigned char *indata;
	unsigned char *indata;
	static int32_t outdata[MAX_OUTDATA];
        int32_t * outdata = NULL;

	int32_t nout, i, k;
	int32_t nout, i, k;
	int32_t prev_xn;
	int32_t prev_xn;
	const uint32_t high_scale = 4096 * 2048;
	const uint32_t high_scale = 4096 * 2048;
@@ -580,6 +589,9 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data


	char *nmxp_channel_name = NULL;
	char *nmxp_channel_name = NULL;


        pd= (NMXP_DATA_PROCESS *) NMXP_MEM_MALLOC(sizeof(NMXP_DATA_PROCESS));
        memset(pd,0,sizeof(NMXP_DATA_PROCESS));

	/* TOREMOVE int my_order = get_my_wordorder();*/
	/* TOREMOVE int my_order = get_my_wordorder();*/
	int my_host_is_bigendian = nmxp_data_bigendianhost();
	int my_host_is_bigendian = nmxp_data_bigendianhost();
	nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "my_host_is_bigendian %d\n", my_host_is_bigendian);
	nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "my_host_is_bigendian %d\n", my_host_is_bigendian);
@@ -645,8 +657,8 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data


	pSampRate = this_sample_rate;
	pSampRate = this_sample_rate;


	nmxp_data_init(&pd);
	nmxp_data_init(pd);

        outdata = (int32_t *) NMXP_MEM_MALLOC(MAX_OUTDATA*sizeof(int32_t));
	nmxp_channel_name = nmxp_chan_lookupName(pKey, channelList);
	nmxp_channel_name = nmxp_chan_lookupName(pKey, channelList);


	if(nmxp_channel_name) {
	if(nmxp_channel_name) {
@@ -693,37 +705,38 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
	nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "Unpacked %d samples.\n", nout);
	nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "Unpacked %d samples.\n", nout);


	pDataPtr = outdata;
	pDataPtr = outdata;

	pNSamp = nout;
	pNSamp = nout;


	pd.key = pKey;
        pd->key = pKey;
	if(network_code[0] != 0) {
	if(network_code[0] != 0) {
	    strncpy(pd.network, network_code, NMXP_DATA_NETWORK_LENGTH);
	    strncpy(pd->network, network_code, NMXP_DATA_NETWORK_LENGTH);
	} else {
	} else {
	    strncpy(pd.network, network_code_default, NMXP_DATA_NETWORK_LENGTH);
	    strncpy(pd->network, network_code_default, NMXP_DATA_NETWORK_LENGTH);
	}
	}
	if(station_code[0] != 0) {
	if(station_code[0] != 0) {
	    strncpy(pd.station, station_code, NMXP_DATA_STATION_LENGTH);
	    strncpy(pd->station, station_code, NMXP_DATA_STATION_LENGTH);
	}
	}
	if(channel_code[0] != 0) {
	if(channel_code[0] != 0) {
	    strncpy(pd.channel, channel_code, NMXP_DATA_CHANNEL_LENGTH);
	    strncpy(pd->channel, channel_code, NMXP_DATA_CHANNEL_LENGTH);
	}
	}
	pd.packet_type = nmx_ptype;
	pd->packet_type = nmx_ptype;
	pd.x0 = nmx_x0;
	pd->x0 = nmx_x0;
	pd.xn = pDataPtr[nout];
	pd->xn = pDataPtr[nout];
	pd.x0n_significant = 1;
	pd->x0n_significant = 1;
	pd.oldest_seq_no = nmx_oldest_sequence_number;
	pd->oldest_seq_no = nmx_oldest_sequence_number;
	pd.seq_no = nmx_seqno;
	pd->seq_no = nmx_seqno;
	pd.time = pTime;
	pd->time = pTime;
	pd.nSamp = pNSamp;
	pd->nSamp = pNSamp;
	pd.pDataPtr = pDataPtr;
	pd->pDataPtr = pDataPtr;
	pd.sampRate = pSampRate;
	pd->sampRate = pSampRate;


	NMXP_MEM_FREE(nmxp_channel_name);
	} else {
	} else {
	    nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Channel name not found for key %d\n", pKey);
	    nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Channel name not found for key %d\n", pKey);
	}
	}


	return &pd;
	return pd;

}
}




Loading