Commit c9d9827d authored by Ivan Tyagov's avatar Ivan Tyagov

Print micro seconds since epoch.

parent 49a9ad06
...@@ -2,8 +2,19 @@ ...@@ -2,8 +2,19 @@
* See http://creativecommons.org/publicdomain/zero/1.0/for more information. */ * See http://creativecommons.org/publicdomain/zero/1.0/for more information. */
#define countof(a) (sizeof(a)/sizeof(*(a))) #define countof(a) (sizeof(a)/sizeof(*(a)))
#include <sys/time.h>
#include <stdio.h>
#include <open62541/server.h> #include <open62541/server.h>
int getMicroSeconds() {
struct timeval current_time;
gettimeofday(&current_time, NULL);
long int ms = current_time.tv_sec * 1000 + current_time.tv_usec / 1000;
return ms;
}
/* loadFile parses the certificate file. /* loadFile parses the certificate file.
* *
* @param path specifies the file name given in argv[] * @param path specifies the file name given in argv[]
......
...@@ -28,12 +28,14 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore ...@@ -28,12 +28,14 @@ static void dataChangeNotificationCallback(UA_Server *server, UA_UInt32 monitore
void *monitoredItemContext, const UA_NodeId *nodeId, void *monitoredItemContext, const UA_NodeId *nodeId,
void *nodeContext, UA_UInt32 attributeId, void *nodeContext, UA_UInt32 attributeId,
const UA_DataValue *var) { const UA_DataValue *var) {
long int micro_seconds = getMicroSeconds();
// filter out ID from Data Set // filter out ID from Data Set
if(UA_Variant_hasScalarType(&var->value, &UA_TYPES[UA_TYPES_UINT32])) { if(UA_Variant_hasScalarType(&var->value, &UA_TYPES[UA_TYPES_UINT32])) {
unsigned int coupler_id = *(UA_UInt32*) var->value.data; unsigned int coupler_id = *(UA_UInt32*) var->value.data;
if (coupler_id!=COUPLER_ID) { if (coupler_id!=COUPLER_ID) {
// care for other coupler_id NOT ourselves // care for other coupler_id NOT ourselves
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "ID = %d", coupler_id); UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "ID = %d, microseconds=%ld", coupler_id, micro_seconds);
} }
} }
......
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