Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-11-29 10:06:42 -0500
committerHenrik Rentz-Reichert2013-11-29 11:18:16 -0500
commit054dbda337b01fca7d894ec98f1a50780865b9f3 (patch)
tree0089d208a2e6449ad0be394047ad82707d20d331 /runtime/org.eclipse.etrice.runtime.c
parentc273955b8645fc1d4ff249ead1c538f413ec2930 (diff)
downloadorg.eclipse.etrice-054dbda337b01fca7d894ec98f1a50780865b9f3.tar.gz
org.eclipse.etrice-054dbda337b01fca7d894ec98f1a50780865b9f3.tar.xz
org.eclipse.etrice-054dbda337b01fca7d894ec98f1a50780865b9f3.zip
Bug 422859: [generator.c] implement a means to log data driven ports during execution
https://bugs.eclipse.org/422859 Change-Id: Ie635ece6909663873b227ce2a20a07deb85aa6ad
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etDataLogger.c63
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etDataLogger.h52
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/config/etRuntimeConfig.h3
4 files changed, 119 insertions, 1 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etDataLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etDataLogger.c
new file mode 100644
index 000000000..652c3677d
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etDataLogger.c
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "debugging/etDataLogger.h"
+#include "debugging/etLogger.h"
+
+static etFileHandle etDataLogger_fileHandle = NULL;
+static int etDataLogger_row = 0;
+
+/*TODO: move or replace ET_MAX_FILENAME_LEN */
+#define ET_MAX_FILENAME_LEN 256
+
+void etDataLogger_open(const char* logPath, const char* logName) {
+ char path[ET_MAX_FILENAME_LEN];
+ etDataLogger_row = 0;
+ sprintf(path, "%s/%s.data.csv", logPath, logName);
+ etDataLogger_fileHandle = etLogger_fopen(path, "w+");
+}
+
+void etDataLogger_close(void) {
+ if (etDataLogger_fileHandle != NULL) {
+ etLogger_fclose(etDataLogger_fileHandle);
+ }
+}
+
+void etDataLogger_logString(const char* entry) {
+ if (etDataLogger_fileHandle != NULL) {
+ etLogger_fprintf(etDataLogger_fileHandle, ",%s", entry);
+ }
+}
+
+void etDataLogger_logBool(int val) {
+ if (etDataLogger_fileHandle != NULL) {
+ etLogger_fprintf(etDataLogger_fileHandle, ",%d", val);
+ }
+}
+
+void etDataLogger_logInt(int val) {
+ if (etDataLogger_fileHandle != NULL) {
+ etLogger_fprintf(etDataLogger_fileHandle, ",%d", val);
+ }
+}
+
+void etDataLogger_logDouble(double val) {
+ if (etDataLogger_fileHandle != NULL) {
+ etLogger_fprintf(etDataLogger_fileHandle, ",%lf", val);
+ }
+}
+
+void etDataLogger_newRow() {
+ if (etDataLogger_fileHandle != NULL) {
+ etLogger_fprintf(etDataLogger_fileHandle, "\n%d", etDataLogger_row++);
+ }
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etDataLogger.h b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etDataLogger.h
new file mode 100644
index 000000000..f78594bc1
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etDataLogger.h
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef ETDATALOGGER_H_
+#define ETDATALOGGER_H_
+
+#include "etRuntimeConfig.h"
+
+void etDataLogger_open(const char* logPath, const char* logName);
+void etDataLogger_close(void);
+
+void etDataLogger_logString(const char* text);
+void etDataLogger_logBool(int val);
+void etDataLogger_logInt(int val);
+void etDataLogger_logDouble(double val);
+void etDataLogger_newRow();
+
+#ifdef ET_DATA_LOGGER_ACTIVATE
+ #define ET_DATA_LOGGER_OPEN(name) \
+ etDataLogger_open("tmp/log", name);
+ #define ET_DATA_LOGGER_CLOSE \
+ etDataLogger_close();
+ #define ET_DATA_LOGGER_LOG_STRING(text) \
+ etDataLogger_logString(text);
+ #define ET_DATA_LOGGER_LOG_BOOL(val) \
+ etDataLogger_logBool(val);
+ #define ET_DATA_LOGGER_LOG_INT(val) \
+ etDataLogger_logInt(val);
+ #define ET_DATA_LOGGER_LOG_DOUBLE(val) \
+ etDataLogger_logDouble(val);
+ #define ET_DATA_LOGGER_NEW_ROW \
+ etDataLogger_newRow();
+#else
+ #define ET_DATA_LOGGER_OPEN(name)
+ #define ET_DATA_LOGGER_CLOSE
+ #define ET_DATA_LOGGER_LOG_STRING(text)
+ #define ET_DATA_LOGGER_LOG_BOOL(val)
+ #define ET_DATA_LOGGER_LOG_INT(val)
+ #define ET_DATA_LOGGER_LOG_DOUBLE(val)
+ #define ET_DATA_LOGGER_NEW_ROW
+#endif
+
+#endif /* ETDATALOGGER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
index 7b6d4c344..6108170a7 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
@@ -195,7 +195,7 @@ static void etMessageService_timerCallback(void* data) {
{
etMessageService* self = (etMessageService*) data;
- /* create a temporary port struct and send the terminate message */
+ /* create a temporary port struct and send the poll message */
etSystemProtocolConjPort port;
port.localId = 0;
port.msgService = self;
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/config/etRuntimeConfig.h b/runtime/org.eclipse.etrice.runtime.c/src/config/etRuntimeConfig.h
index 9562638e6..a58cf0282 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/config/etRuntimeConfig.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/config/etRuntimeConfig.h
@@ -15,11 +15,14 @@
/* flags for debugging */
+/* MSC logger */
#define ET_MSC_LOGGER_ACTIVATE /* needs ET_LOGGER_ACTIVATE */
//#define ET_SYNC_MSC_LOGGER_ACTIVATE /* needs ET_MSC_LOGGER_ACTIVATE */
#define ET_ASYNC_MSC_LOGGER_ACTIVATE /* needs ET_MSC_LOGGER_ACTIVATE */
#define ET_LOGGER_ACTIVATE
+/* data logger */
+#define ET_DATA_LOGGER_ACTIVATE
#define STRUCT_ALIGN 8

Back to the top