INFO: The new Git default branch name is "main". Details here: https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/

Commit 599989ac authored by Matteo Quintiliani's avatar Matteo Quintiliani
Browse files

Adapted call for nmxp_log()


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@471 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent cbc6f34b
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxp.c,v 1.52 2007-10-07 20:28:44 mtheo Exp $
* $Id: nmxp.c,v 1.53 2007-11-22 11:12:08 mtheo Exp $
*
*/
......@@ -41,19 +41,19 @@ int nmxp_receiveChannelList(int isock, NMXP_CHAN_LIST **pchannelList) {
ret = nmxp_receiveMessage(isock, &type, &buffer, &length, 0, &recv_errno);
if(type != NMXP_MSG_CHANNELLIST) {
nmxp_log(1, 0, "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 {
*pchannelList = buffer;
(*pchannelList)->number = ntohl((*pchannelList)->number);
nmxp_log(0, 1, "number of channels %d\n", (*pchannelList)->number);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CHANNEL, "number of channels %d\n", (*pchannelList)->number);
// TODO check
for(i=0; i < (*pchannelList)->number; i++) {
(*pchannelList)->channel[i].key = ntohl((*pchannelList)->channel[i].key);
nmxp_log(0, 1, "%12d %s\n", (*pchannelList)->channel[i].key, (*pchannelList)->channel[i].name);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CHANNEL, "%12d %s\n", (*pchannelList)->channel[i].key, (*pchannelList)->channel[i].name);
}
}
......@@ -109,13 +109,13 @@ NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST_NET *channelList,
if(nmxp_receiveMessage(isock, &type, &buffer, &length, timeoutsec, recv_errno) == NMXP_SOCKET_OK) {
if(type == NMXP_MSG_COMPRESSED) {
nmxp_log(0, 1, "Type %d is NMXP_MSG_COMPRESSED!\n", type);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "Type %d is NMXP_MSG_COMPRESSED!\n", type);
pd = nmxp_processCompressedData(buffer, length, channelList, network_code);
} else if(type == NMXP_MSG_DECOMPRESSED) {
nmxp_log(0, 1, "Type %d is NMXP_MSG_DECOMPRESSED!\n", type);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "Type %d is NMXP_MSG_DECOMPRESSED!\n", type);
pd = nmxp_processDecompressedData(buffer, length, channelList, network_code);
} else {
nmxp_log(1, 0, "Type %d is not NMXP_MSG_COMPRESSED or NMXP_MSG_DECOMPRESSED!\n", type);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Type %d is not NMXP_MSG_COMPRESSED or NMXP_MSG_DECOMPRESSED!\n", type);
}
}
......@@ -155,9 +155,9 @@ int nmxp_sendConnectRequest(int isock, char *naqs_username, char *naqs_password,
ret = nmxp_sendMessage(isock, NMXP_MSG_CONNECTREQUEST, &connectRequest, sizeof(NMXP_CONNECT_REQUEST));
if(ret == NMXP_SOCKET_OK) {
nmxp_log(0, 1, "Send a ConnectRequest crc32buf = (%s), crc32 = %d\n", crc32buf, connectRequest.crc32);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CRC, "Send a ConnectRequest crc32buf = (%s), crc32 = %d\n", crc32buf, connectRequest.crc32);
} else {
nmxp_log(1, 0, "Send a ConnectRequest.\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CRC, "Send a ConnectRequest.\n");
}
return ret;
......@@ -169,9 +169,9 @@ int nmxp_readConnectionTime(int isock, int32_t *connection_time) {
int recv_errno;
ret = nmxp_recv_ctrl(isock, connection_time, sizeof(int32_t), 0, &recv_errno);
*connection_time = ntohl(*connection_time);
nmxp_log(0, 1, "Read connection time from socket %d.\n", *connection_time);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CONNFLOW, "Read connection time from socket %d.\n", *connection_time);
if(ret != NMXP_SOCKET_OK) {
nmxp_log(1, 0, "Read connection time from socket.\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Read connection time from socket.\n");
}
return ret;
}
......@@ -190,12 +190,12 @@ int nmxp_waitReady(int isock) {
if(rc != NMXP_SOCKET_OK) return rc;
signature = ntohl(signature);
if(signature == 0) {
nmxp_log(0, 1, "signature is equal to zero. receive again.\n");
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CONNFLOW, "signature is equal to zero. receive again.\n");
rc = nmxp_recv_ctrl(isock, &signature, sizeof(signature), 0, &recv_errno);
signature = ntohl(signature);
}
if(signature != NMX_SIGNATURE) {
nmxp_log(1, 0, "signature is not valid. signature = %d\n", signature);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "signature is not valid. signature = %d\n", signature);
if(signature == 200) {
int32_t err_length;
int32_t err_reason;
......@@ -208,7 +208,7 @@ int nmxp_waitReady(int isock) {
rc = nmxp_recv_ctrl(isock, err_buff, err_length-4, 0, &recv_errno);
err_buff[err_length] = 0;
}
nmxp_log(1, 0, "TerminateMessage from Server: %s (%d).\n", err_buff, err_reason);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "TerminateMessage from Server: %s (%d).\n", err_buff, err_reason);
}
return NMXP_SOCKET_ERROR;
}
......@@ -217,7 +217,7 @@ int nmxp_waitReady(int isock) {
if(rc != NMXP_SOCKET_OK) return rc;
type = ntohl(type);
if(type != NMXP_MSG_READY) {
nmxp_log(0, 1, "type is not READY. type = %d\n", type);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CONNFLOW, "type is not READY. type = %d\n", type);
rc = nmxp_recv_ctrl(isock, &length, sizeof(length), 0, &recv_errno);
if(rc != NMXP_SOCKET_OK) return rc;
length = ntohl(length);
......@@ -227,7 +227,7 @@ int nmxp_waitReady(int isock) {
rc = nmxp_recv_ctrl(isock, &app, length, 0, &recv_errno);
if(rc != NMXP_SOCKET_OK) return rc;
app = ntohl(app);
nmxp_log(0, 1, "value = %d\n", app);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CONNFLOW, "value = %d\n", app);
} else {
char *buf_app = (char *) malloc(sizeof(char) * length);
rc = nmxp_recv_ctrl(isock, buf_app, length, 0, &recv_errno);
......@@ -241,14 +241,14 @@ int nmxp_waitReady(int isock) {
if(rc != NMXP_SOCKET_OK) return rc;
length = ntohl(length);
if(length != 0) {
nmxp_log(1, 0, "length is not equal to zero. length = %d\n", length);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "length is not equal to zero. length = %d\n", length);
return NMXP_SOCKET_ERROR;
}
}
times++;
if(times > 10) {
nmxp_log(1, 0, "waiting_ready_message. times > 10\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "waiting_ready_message. times > 10\n");
rc = NMXP_SOCKET_ERROR;
}
......@@ -269,7 +269,7 @@ int nmxp_sendDataRequest(int isock, int32_t key, int32_t start_time, int32_t end
ret = nmxp_sendMessage(isock, NMXP_MSG_DATAREQUEST, &dataRequest, sizeof(dataRequest));
if(ret != NMXP_SOCKET_OK) {
nmxp_log(1,0, "Send a Request message\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Send a Request message\n");
}
return ret;
......@@ -293,13 +293,13 @@ NMXP_CHAN_LIST *nmxp_getAvailableChannelList(char * hostname, int portnum, NMXP_
if(nmxp_receiveChannelList(naqssock, &channelList) == NMXP_SOCKET_OK) {
channelList_subset = nmxp_chan_getType(channelList, datatype);
nmxp_log(0, 1, "%d / %d\n", channelList_subset->number, channelList->number);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CHANNEL, "%d / %d\n", channelList_subset->number, channelList->number);
// nmxp_chan_sortByKey(channelList_subset);
nmxp_chan_sortByName(channelList_subset);
for(i=0; i < channelList_subset->number; i++) {
nmxp_log(0, 1, "%12d %s\n", channelList_subset->channel[i].key, channelList_subset->channel[i].name);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CHANNEL, "%12d %s\n", channelList_subset->channel[i].key, channelList_subset->channel[i].name);
}
// 4. Send a Request Pending (optional)
......@@ -312,10 +312,10 @@ NMXP_CHAN_LIST *nmxp_getAvailableChannelList(char * hostname, int portnum, NMXP_
nmxp_sendTerminateSubscription(naqssock, NMXP_SHUTDOWN_NORMAL, "Good Bye!");
} else {
nmxp_log(1, 0, "Error on receiveChannelList()\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Error on receiveChannelList()\n");
}
} else {
nmxp_log(1, 0, "Error on sendConnect()\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Error on sendConnect()\n");
}
// 8. Close the socket
......@@ -357,25 +357,25 @@ NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_
/* DAP Step 1: Open a socket */
if( (naqssock = nmxp_openSocket(hostname, portnum)) == NMXP_SOCKET_ERROR) {
nmxp_log(1, 0, "Error opening socket!\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Error opening socket!\n");
return NULL;
}
/* DAP Step 2: Read connection time */
if(nmxp_readConnectionTime(naqssock, &connection_time) != NMXP_SOCKET_OK) {
nmxp_log(1, 0, "Error reading connection time from server!\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Error reading connection time from server!\n");
return NULL;
}
/* DAP Step 3: Send a ConnectRequest */
if(nmxp_sendConnectRequest(naqssock, datas_username, datas_password, connection_time) != NMXP_SOCKET_OK) {
nmxp_log(1, 0, "Error sending connect request!\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Error sending connect request!\n");
return NULL;
}
/* DAP Step 4: Wait for a Ready message */
if(nmxp_waitReady(naqssock) != NMXP_SOCKET_OK) {
nmxp_log(1, 0, "Error waiting Ready message!\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Error waiting Ready message!\n");
return NULL;
}
......@@ -386,7 +386,7 @@ NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_
nmxp_sendHeader(naqssock, NMXP_MSG_CHANNELLISTREQUEST, 0);
/* DAP Step 6: Receive Data until receiving a Ready message */
ret_sock = nmxp_receiveMessage(naqssock, &type, &buffer, &length, 0, &recv_errno);
nmxp_log(0, 1, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_EXTRA, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
while(ret_sock == NMXP_SOCKET_OK && type != NMXP_MSG_READY) {
channelList = buffer;
......@@ -402,7 +402,7 @@ NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_
/* Receive Message */
ret_sock = nmxp_receiveMessage(naqssock, &type, &buffer, &length, 0, &recv_errno);
nmxp_log(0, 1, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_EXTRA, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
}
......@@ -415,7 +415,7 @@ NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_
/* DAP Step 6: Receive Data until receiving a Ready message */
ret_sock = nmxp_receiveMessage(naqssock, &type, &buffer, &length, 0, &recv_errno);
nmxp_log(0, 1, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_EXTRA, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
while(ret_sock == NMXP_SOCKET_OK && type != NMXP_MSG_READY) {
precisChannelList = buffer;
......@@ -430,11 +430,11 @@ NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_
nmxp_data_to_str(str_end, precisChannelList->channel[i].end_time);
if(!nmxp_meta_chan_set_times(chan_list, precisChannelList->channel[i].key, precisChannelList->channel[i].start_time, precisChannelList->channel[i].end_time)) {
nmxp_log(1, 0, "Key %d not found for %s!\n", precisChannelList->channel[i].key, precisChannelList->channel[i].name);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Key %d not found for %s!\n", precisChannelList->channel[i].key, precisChannelList->channel[i].name);
}
/*
nmxp_log(0, 0, "%12d %12s %10d %10d %20s %20s\n",
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "%12d %12s %10d %10d %20s %20s\n",
precisChannelList->channel[i].key, precisChannelList->channel[i].name,
precisChannelList->channel[i].start_time, precisChannelList->channel[i].end_time,
str_start, str_end);
......@@ -443,7 +443,7 @@ NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_
/* Receive Message */
ret_sock = nmxp_receiveMessage(naqssock, &type, &buffer, &length, 0, &recv_errno);
nmxp_log(0, 1, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_EXTRA, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
}
......@@ -458,18 +458,18 @@ NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_
/* DAP Step 6: Receive Data until receiving a Ready message */
ret_sock = nmxp_receiveMessage(naqssock, &type, &buffer, &length, 0, &recv_errno);
nmxp_log(0, 1, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_EXTRA, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
while(ret_sock == NMXP_SOCKET_OK && type != NMXP_MSG_READY) {
channelInfo = buffer;
channelInfo->key = ntohl(channelInfo->key);
if(!nmxp_meta_chan_set_network(chan_list, channelInfo->key, channelInfo->network)) {
nmxp_log(1, 0, "Key %d (%d) not found for %s!\n", iter->key, channelInfo->key, iter->name);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Key %d (%d) not found for %s!\n", iter->key, channelInfo->key, iter->name);
}
/* Receive Message */
ret_sock = nmxp_receiveMessage(naqssock, &type, &buffer, &length, 0, &recv_errno);
nmxp_log(0, 1, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_EXTRA, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
}
}
}
......@@ -588,7 +588,7 @@ int nmxp_raw_stream_manage(NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int
p->last_seq_no_sent = 0;
p->last_sample_time = 0;
}
nmxp_log(0, 1, "First time nmxp_raw_stream_manage().\n");
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_RAWSTREAM, "First time nmxp_raw_stream_manage() for %s.%s.%s .\n", pd->network, pd->station, pd->channel);
}
if(p->n_pdlist > 0) {
......@@ -608,7 +608,7 @@ int nmxp_raw_stream_manage(NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int
latency = nmxp_data_latency(p->pdlist[0]);
nmxp_data_to_str(str_time, p->pdlist[0]->time);
if( seq_no_diff > 0) {
nmxp_log(NMXP_LOG_WARN, 0, "Force handling packet %s.%s.%d.%d (%s - %.2f sec.) time_diff %.2fs n_pdlist %d lat. %.1fs!\n",
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_RAWSTREAM, "Force handling packet %s.%s.%d.%d (%s - %.2f sec.) time_diff %.2fs n_pdlist %d lat. %.1fs!\n",
p->pdlist[0]->station, p->pdlist[0]->channel, p->pdlist[0]->seq_no, p->pdlist[0]->packet_type, str_time,
(double) p->pdlist[0]->nSamp / (double) p->pdlist[0]->sampRate, time_diff, p->n_pdlist, latency);
for(i_func_pd=0; i_func_pd<n_func_pd; i_func_pd++) {
......@@ -618,7 +618,7 @@ int nmxp_raw_stream_manage(NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int
p->last_sample_time = (p->pdlist[0]->time + ((double) p->pdlist[0]->nSamp / (double) p->pdlist[0]->sampRate ));
} else {
/* It should not occur */
nmxp_log(NMXP_LOG_WARN, 0, "NOT OCCUR! Packets %s.%s.%d.%d (%s - %.2f sec.) discarded, seq_no_diff=%d time_diff %.2fs lat. %.1fs\n",
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_RAWSTREAM, "NOT OCCUR! Packets %s.%s.%d.%d (%s - %.2f sec.) discarded, seq_no_diff=%d time_diff %.2fs lat. %.1fs\n",
p->pdlist[0]->station, p->pdlist[0]->channel, p->pdlist[0]->seq_no, p->pdlist[0]->packet_type, str_time,
(double) p->pdlist[0]->nSamp / (double) p->pdlist[0]->sampRate, seq_no_diff, time_diff, latency);
}
......@@ -659,7 +659,7 @@ int nmxp_raw_stream_manage(NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int
if(p->n_pdlist > 1) {
int y = 0;
for(y=0; y < p->n_pdlist; y++) {
nmxp_log(0, 1, "%02d pkt %d\n", y, p->pdlist[y]->seq_no);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_RAWSTREAM, "%02d pkt %d\n", y, p->pdlist[y]->seq_no);
}
}
......@@ -680,7 +680,7 @@ int nmxp_raw_stream_manage(NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int
nmxp_data_to_str(str_time, p->pdlist[j]->time);
if(seq_no_diff <= 0) {
// Duplicated packets: Discarded
nmxp_log(NMXP_LOG_WARN, 0, "Packets %s.%s.%d.%d (%s - %f sec.) discarded, seq_no_diff=%d time_diff=%.2fs lat %.1fs\n",
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_RAWSTREAM, "Packets %s.%s.%d.%d (%s - %f sec.) discarded, seq_no_diff=%d time_diff=%.2fs lat %.1fs\n",
p->pdlist[j]->station, p->pdlist[j]->channel, p->pdlist[j]->seq_no, p->pdlist[j]->packet_type, str_time,
(double) p->pdlist[j]->nSamp / (double) p->pdlist[j]->sampRate, seq_no_diff, time_diff, latency);
send_again = 1;
......@@ -690,7 +690,7 @@ int nmxp_raw_stream_manage(NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int
(*p_func_pd[i_func_pd])(p->pdlist[j]);
}
if(time_diff > TIME_TOLLERANCE || time_diff < -TIME_TOLLERANCE) {
nmxp_log(NMXP_LOG_WARN, 0, "%s.%s time is not correct seq_no_diff=%d time_diff=%.2fs ([%d] %d-%d) (%s - %.2f sec.) lat. %.1fs\n",
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_RAWSTREAM, "%s.%s time is not correct seq_no_diff=%d time_diff=%.2fs ([%d] %d-%d) (%s - %.2f sec.) lat. %.1fs\n",
p->pdlist[j]->station, p->pdlist[j]->channel,
seq_no_diff, time_diff, p->pdlist[j]->packet_type, p->pdlist[j]->seq_no, p->last_seq_no_sent,
str_time, (double) p->pdlist[j]->nSamp / (double) p->pdlist[j]->sampRate, latency);
......@@ -700,7 +700,7 @@ int nmxp_raw_stream_manage(NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int
send_again = 1;
j++;
} else {
nmxp_log(NMXP_LOG_WARN, 0, "%s.%s seq_no_diff=%d ([%d] %d-%d) j=%2d p->n_pdlist=%2d (%s - %.2f sec.) time_diff=%.2fs lat. %.1fs\n",
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_RAWSTREAM, "%s.%s seq_no_diff=%d ([%d] %d-%d) j=%2d p->n_pdlist=%2d (%s - %.2f sec.) time_diff=%.2fs lat. %.1fs\n",
p->pdlist[j]->station, p->pdlist[j]->channel,
seq_no_diff, p->pdlist[j]->packet_type, p->pdlist[j]->seq_no, p->last_seq_no_sent, j, p->n_pdlist,
str_time, (double) p->pdlist[j]->nSamp / (double) p->pdlist[j]->sampRate, time_diff, latency);
......@@ -733,7 +733,9 @@ int nmxp_raw_stream_manage(NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int
p->n_pdlist = p->n_pdlist - j;
}
nmxp_log(0, 1, "j=%d p->n_pdlist=%d FINAL\n", j, p->n_pdlist);
/* TOREMOVE
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_RAWSTREAM, "j=%d p->n_pdlist=%d FINAL\n", j, p->n_pdlist);
*/
return ret;
}
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxp_base.c,v 1.39 2007-11-21 13:22:20 mtheo Exp $
* $Id: nmxp_base.c,v 1.40 2007-11-22 11:12:08 mtheo Exp $
*
*/
......@@ -42,12 +42,12 @@ int nmxp_openSocket(char *hostname, int portNum)
if (!hostname)
{
nmxp_log(1,0, "Empty host name?\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Empty host name?\n");
return -1;
}
if ( (hostinfo = gethostbyname(hostname)) == NULL) {
nmxp_log(1,0, "Cannot lookup host: %s\n", hostname);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Cannot lookup host: %s\n", hostname);
return -1;
}
......@@ -56,7 +56,7 @@ int nmxp_openSocket(char *hostname, int portNum)
isock = socket (AF_INET, SOCK_STREAM, 0);
if (isock < 0)
{
nmxp_log (1,0, "Can't open stream socket\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Can't open stream socket\n");
exit(1);
}
......@@ -70,19 +70,19 @@ int nmxp_openSocket(char *hostname, int portNum)
/* Report action and resolved address */
memcpy(&hostaddr.s_addr, *hostinfo->h_addr_list,
sizeof (hostaddr.s_addr));
nmxp_log(0,1, "Attempting to connect to %s port %d\n",
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CONNFLOW, "Attempting to connect to %s port %d\n",
inet_ntoa(hostaddr), portNum);
if (connect(isock, (struct sockaddr *)&psServAddr, sizeof(psServAddr)) >= 0)
{
sleepTime = 1;
nmxp_log(0, 1, "Connection established: socket=%i,IP=%s,port=%d\n",
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CONNFLOW, "Connection established: socket=%i,IP=%s,port=%d\n",
isock, inet_ntoa(hostaddr), portNum);
return isock;
}
else
{
nmxp_log(1, 0, "Connecting to %s port %d. Trying again after %d seconds...\n",
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Connecting to %s port %d. Trying again after %d seconds...\n",
inet_ntoa(hostaddr), portNum, sleepTime);
close (isock);
sleep (sleepTime);
......@@ -96,7 +96,7 @@ int nmxp_openSocket(char *hostname, int portNum)
int nmxp_closeSocket(int isock)
{
nmxp_log(0, 1, "Closed connection.\n");
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CONNFLOW, "Closed connection.\n");
return close(isock);
}
......@@ -143,7 +143,7 @@ int nmxp_recv_ctrl(int isock, void *buffer, int length, int timeoutsec, int *rec
cc = recv(isock, buffer_char + recvCount, length - recvCount, 0);
*recv_errno = errno;
if(cc <= 0) {
nmxp_log(NMXP_LOG_ERR, 0, "nmxp_recv_ctrl(): (cc=%d <= 0) errno=%d recvCount=%d length=%d\n", cc, *recv_errno, recvCount, length);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "nmxp_recv_ctrl(): (cc=%d <= 0) errno=%d recvCount=%d length=%d\n", cc, *recv_errno, recvCount, length);
} else {
recvCount += cc;
}
......@@ -175,7 +175,7 @@ int nmxp_recv_ctrl(int isock, void *buffer, int length, int timeoutsec, int *rec
break;
}
*/
nmxp_log(NMXP_LOG_ERR, 0, "nmxp_recv_ctrl(): recvCount=%d length=%d (cc=%d) errno=%d (%s)\n", recvCount, length, cc, *recv_errno, recv_errno_str);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "nmxp_recv_ctrl(): recvCount=%d length=%d (cc=%d) errno=%d (%s)\n", recvCount, length, cc, *recv_errno, recv_errno_str);
if(recvCount != length || *recv_errno != EAGAIN) {
return NMXP_SOCKET_ERROR;
......@@ -213,13 +213,13 @@ int nmxp_receiveHeader(int isock, NMXP_MSG_SERVER *type, int32_t *length, int ti
msg.type = ntohl(msg.type);
msg.length = ntohl(msg.length);
nmxp_log(0,1, "nmxp_receiveHeader(): signature = %d, type = %d, length = %d\n",
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CONNFLOW, "nmxp_receiveHeader(): signature = %d, type = %d, length = %d\n",
msg.signature, msg.type, msg.length);
if (msg.signature != NMX_SIGNATURE)
{
ret = NMXP_SOCKET_ERROR;
nmxp_log(1,0, "nmxp_receiveHeader(): signature mismatches. signature = %d, type = %d, length = %d\n",
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "nmxp_receiveHeader(): signature mismatches. signature = %d, type = %d, length = %d\n",
msg.signature, msg.type, msg.length);
} else {
*type = msg.type;
......@@ -256,9 +256,9 @@ int nmxp_receiveMessage(int isock, NMXP_MSG_SERVER *type, void **buffer, int32_t
ret = nmxp_recv_ctrl(isock, *buffer, *length, 0, recv_errno);
if(*type == NMXP_MSG_ERROR) {
nmxp_log(NMXP_LOG_ERR, 0, "Received ErrorMessage: %s\n", *buffer);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Received ErrorMessage: %s\n", *buffer);
} else {
nmxp_log(NMXP_LOG_WARN, 1, "Received message type: %d length=%d\n", *type, *length);
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_PACKETMAN, "Received message type: %d length=%d\n", *type, *length);
}
}
......@@ -266,9 +266,9 @@ int nmxp_receiveMessage(int isock, NMXP_MSG_SERVER *type, void **buffer, int32_t
if(*recv_errno != 0) {
if(*recv_errno == EAGAIN) {
nmxp_log(NMXP_LOG_WARN, 0, "Timeout receveing in nmxp_receiveMessage()\n");
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_CONNFLOW, "Timeout receveing in nmxp_receiveMessage()\n");
} else {
nmxp_log(NMXP_LOG_ERR, 0, "Error in nmxp_receiveMessage()\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Error in nmxp_receiveMessage()\n");
}
}
......@@ -318,7 +318,7 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
}
if(!nmxp_chan_cpy_sta_chan(nmxp_chan_lookupName(pKey, channelList), station_code, channel_code, network_code)) {
nmxp_log(1,0, "Channel name not in STN.CHAN format: %s\n", nmxp_chan_lookupName(pKey, channelList));
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Channel name not in STA.CHAN format: %s\n", nmxp_chan_lookupName(pKey, channelList));
}
nmxp_data_init(&pd);
......@@ -392,17 +392,17 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
// TOREMOVE int my_order = get_my_wordorder();
int my_host_is_bigendian = nmxp_data_bigendianhost();
nmxp_log(0, 1, "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);
memcpy(&nmx_oldest_sequence_number, buffer_data, 4);
nmxp_log(0, 1, "Oldest sequence number = %d\n", nmx_oldest_sequence_number);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "Oldest sequence number = %d\n", nmx_oldest_sequence_number);
memcpy(nmx_hdr, buffer_data+4, 17);
/* Decode the Nanometrics packet header bundle. */
memcpy (&nmx_ptype, nmx_hdr+0, 1);
if ( (nmx_ptype & 0xf) == 9) {
/* Filler packet. Discard entire packet. */
nmxp_log (NMXP_LOG_ERR,0, "Filler packet - discarding\n");
nmxp_log (NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Filler packet - discarding\n");
//m continue;
exit(0);
}
......@@ -419,7 +419,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
const uint32_t high_scale_p = 4096 * 4096;
/* check if nmx_x0 is negative like as signed 3-byte int */
if( (nmx_x0 & high_scale) == high_scale) {
// nmxp_log(0, 1, "WARNING: changed nmx_x0, old value = %d\n", nmx_x0);
// nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "WARNING: changed nmx_x0, old value = %d\n", nmx_x0);
nmx_x0 -= high_scale_p;
}
/* TOREMOVE if (my_order != SEED_LITTLE_ENDIAN) { */
......@@ -439,17 +439,17 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
chan_code = nmx_sample_rate&7;
this_sample_rate = nmx_rate_code_to_sample_rate[rate_code];
nmxp_log(0, 1, "nmx_ptype = %d\n", nmx_ptype);
nmxp_log(0, 1, "nmx_seconds = %d\n", nmx_seconds);
nmxp_log(0, 1, "nmx_ticks = %d\n", nmx_ticks);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "nmx_ptype = %d\n", nmx_ptype);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "nmx_seconds = %d\n", nmx_seconds);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "nmx_ticks = %d\n", nmx_ticks);
nmxp_log(0, 1, "nmx_seconds_double = %f\n", nmx_seconds_double);
nmxp_log(0, 1, "nmx_x0 = %d\n", nmx_x0);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "nmx_seconds_double = %f\n", nmx_seconds_double);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "nmx_x0 = %d\n", nmx_x0);
nmxp_log(0, 1, "nmx_instr_id = %d\n", nmx_instr_id);
nmxp_log(0, 1, "nmx_seqno = %d\n", nmx_seqno);
nmxp_log(0, 1, "nmx_sample_rate = %d\n", nmx_sample_rate);
nmxp_log(0, 1, "this_sample_rate = %d\n", this_sample_rate);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "nmx_instr_id = %d\n", nmx_instr_id);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "nmx_seqno = %d\n", nmx_seqno);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "nmx_sample_rate = %d\n", nmx_sample_rate);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "this_sample_rate = %d\n", this_sample_rate);
pKey = (nmx_instr_id << 16) | ( 1 << 8) | ( chan_code);
......@@ -458,10 +458,10 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
pSampRate = this_sample_rate;
if(!nmxp_chan_cpy_sta_chan(nmxp_chan_lookupName(pKey, channelList), station_code, channel_code, network_code)) {
nmxp_log(NMXP_LOG_ERR,0, "Channel name not in STN.CHAN format: %s\n", nmxp_chan_lookupName(pKey, channelList));
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Channel name not in STA.CHAN format: %s\n", nmxp_chan_lookupName(pKey, channelList));
}
nmxp_log(0, 1, "Channel key %d for %s.%s\n", pKey, station_code, channel_code);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "Channel key %d for %s.%s\n", pKey, station_code, channel_code);
comp_bytecount = length_data-21;
indata = (unsigned char *) buffer_data + 21;
......@@ -472,23 +472,23 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
nout = 1;
for (i=0; i<comp_bytecount; i+=17) {
if (i+17>comp_bytecount) {
nmxp_log (NMXP_LOG_ERR,0, "comp_bytecount = %d, i+17 = %d\n",
nmxp_log (NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "comp_bytecount = %d, i+17 = %d\n",
comp_bytecount, i+17);
exit(1);
}
if (nout+16 > MAX_OUTDATA) {
nmxp_log (NMXP_LOG_ERR, 0, "Output buffer size too small\n");
nmxp_log (NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Output buffer size too small\n");
exit(1);
}
k = nmxp_data_unpack_bundle (outdata+nout,indata+i,&prev_xn);
if (k < 0) nmxp_log (NMXP_LOG_WARN, 1, "Null bundle: %s.%s.%s (k=%d) %s %d\n", network_code, station_code, channel_code, k, __FILE__, __LINE__);
if (k < 0) nmxp_log (NMXP_LOG_WARN, NMXP_LOG_D_PACKETMAN, "Null bundle: %s.%s.%s (k=%d) %s %d\n", network_code, station_code, channel_code, k, __FILE__, __LINE__);
if (k < 0) break;
nout += k;
/* prev_xn = outdata[nout-1]; */
}
nout--;
nmxp_log(0, 1, "Unpacked %d samples.\n", nout);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "Unpacked %d samples.\n", nout);
pDataPtr = outdata;
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxp_chan.c,v 1.23 2007-10-18 14:33:03 mtheo Exp $
* $Id: nmxp_chan.c,v 1.24 2007-11-22 11:12:08 mtheo Exp $
*
*/
......@@ -61,7 +61,7 @@ int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *statio
strcpy(channel_code, period1);
}
} else {
nmxp_log(1, 0, "Name %s is not in NET.STA.CHAN format! (NET. is optional)\n", net_dot_station_dot_channel);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Name %s is not in NET.STA.CHAN format! (NET. is optional)\n", net_dot_station_dot_channel);
}
if(tmp_name) {
......@@ -69,7 +69,7 @@ int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *statio
}
} else {
nmxp_log(1, 0, "Some parameter is NULL in nmxp_chan_cpy_sta_chan().\n", net_dot_station_dot_channel);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Some parameter is NULL in nmxp_chan_cpy_sta_chan().\n", net_dot_station_dot_channel);
}
return ret;
......@@ -95,7 +95,7 @@ int nmxp_chan_match(const char *net_dot_station_dot_channel, char *pattern)
/* validate pattern channel */
if(!nmxp_chan_cpy_sta_chan(pattern, sta_pattern, cha_pattern, net_pattern)) {
nmxp_log(1, 0, "Channel pattern %s is not in STA.CHAN format!\n", pattern);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Channel pattern %s is not in STA.CHAN format!\n", pattern);
return -1;
}
......@@ -108,7 +108,7 @@ int nmxp_chan_match(const char *net_dot_station_dot_channel, char *pattern)
|| (net_pattern[i] >= '0' && net_pattern[i] <= '9')
)
) {
nmxp_log(1, 0, "Channel pattern %s has not valid NET format!\n", pattern);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Channel pattern %s has not valid NET format!\n", pattern);
return -1;
}
i++;
......@@ -124,7 +124,7 @@ int nmxp_chan_match(const char *net_dot_station_dot_channel, char *pattern)
|| (sta_pattern[i] == '_' )
)
) {