Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/.cproject18
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FreeList.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/base/etQueue.c1
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.c3
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h1
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c10
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h31
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.c31
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h34
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etWakeupService.c33
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etWakeupService.h42
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etRTSystemServicesProtocol.h18
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/platform/etPlatform.h43
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.c17
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h18
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etThreadList.c14
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etThreadList.h32
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h8
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c8
19 files changed, 322 insertions, 43 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/.cproject b/runtime/org.eclipse.etrice.runtime.c/.cproject
index 6daae3393..8700d49e2 100644
--- a/runtime/org.eclipse.etrice.runtime.c/.cproject
+++ b/runtime/org.eclipse.etrice.runtime.c/.cproject
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+<?fileVersion 4.0.0?>
+
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.lib.debug.505530637">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.lib.debug.505530637" moduleId="org.eclipse.cdt.core.settings" name="Debug">
@@ -49,19 +51,9 @@
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.278235928" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base"/>
</toolChain>
</folderInfo>
- <folderInfo id="cdt.managedbuild.config.gnu.mingw.lib.debug.505530637.91518658" name="/" resourcePath="src/platforms/ST_CoretexM3_Euros_GCCELF_SK_FM3_176PMC_Ethernet">
- <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.lib.debug.2014762902" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.lib.debug" unusedChildren="">
- <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.lib.debug.554229249" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.lib.debug.806687472"/>
- <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.lib.debug.2115657260" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.lib.debug.1896612237"/>
- <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.debug.263513205" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.lib.debug.1813889263"/>
- <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug.1485555154" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug.1185604346"/>
- <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.333821521" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base.597146923"/>
- <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.102741495" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.278235928"/>
- </toolChain>
- </folderInfo>
<sourceEntries>
<entry excluding="test|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
- <entry excluding="platforms/ST_CoretexM3_Euros_GCCELF_SK_FM3_176PMC_Ethernet|platforms/ST_MSP430_G2553_CCS5_LaunchPad|platforms/ST_MSP430_F5438_CCS5_HWElevator|platforms/ST_MSP430_F5438_CCS5_EXP430F5438|platforms/MSP430" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+ <entry excluding="platforms/ST_MSP430_F5438_CCS5_EXP430F5438|platforms/MSP430|platforms/ST_MSP430_F5438_CCS5_HWElevator|platforms/ST_MSP430_G2553_CCS5_LaunchPad|platforms/ST_CoretexM3_Euros_GCCELF_SK_FM3_176PMC_Ethernet" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
@@ -107,7 +99,7 @@
</folderInfo>
<sourceEntries>
<entry excluding="test|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
- <entry excluding="platforms/ST_MSP430_G2553_CCS5_LaunchPad|platforms/ST_MSP430_F5438_CCS5_HWElevator|platforms/ST_MSP430_F5438_CCS5_EXP430F5438|platforms/MSP430" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
+ <entry excluding="platforms/ST_MSP430_F5438_CCS5_EXP430F5438|platforms/MSP430|platforms/ST_MSP430_F5438_CCS5_HWElevator|platforms/ST_MSP430_G2553_CCS5_LaunchPad" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FreeList.h b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FreeList.h
index fcf19d37e..3f46272cf 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FreeList.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FreeList.h
@@ -20,10 +20,11 @@
*
* \param heap pointer to the heap to be managed
* \param size the size in bytes of the heap
- * \nslots the number of slots to be used (should be greater or equal the number of different object sizes)
+ * \param nslots the number of slots to be used (should be greater or equal the number of different object sizes)
*
* \return the pointer to the initialized etMemory struct
*/
+
etMemory* etMemory_FreeList_init(void* heap, etUInt32 size, etUInt16 nslots);
etUInt32 etMemory_FreeList_freeHeapMem(void* heap);
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etQueue.c b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etQueue.c
index 8496cdba0..418bf5867 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etQueue.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etQueue.c
@@ -26,7 +26,6 @@ void etQueue_init(etQueue* self){
void etQueue_push(etQueue* self, etQueueObj* obj){
- // TODO: optimize queue for concurrent push / pop
ET_MSC_LOGGER_SYNC_ENTRY("etQueue", "push")
if (self->first == NULL) {
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.c
index d9dd15e66..547eec00b 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.c
@@ -13,6 +13,7 @@
#include "debugging/etMSCLogger.h"
#include "debugging/etLogger.h"
+#include "platform/etPlatform.h"
static etFileHandle etMSCLogger_fileHandle = NULL;
static char* etMSCLogger_objectName = "";
@@ -42,7 +43,7 @@ char* etMSCLogger_getObjectName(void){
void etMSCLogger_syncCall(char* sourceName, char* messageName, char* targetName){
if (etMSCLogger_fileHandle != NULL) {
- etLogger_fprintf(etMSCLogger_fileHandle, "%s ==> %s %s\n", sourceName, targetName, messageName);
+ etLogger_fprintf(etMSCLogger_fileHandle, "%s ==> %s %s(thread=%ld)\n", sourceName, targetName, messageName, etThread_self_id());
}
}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h
index a1bd92ce2..a569a0887 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h
@@ -19,5 +19,6 @@
typedef void (*etActorReceiveMessage)(void* self, void* ifitem, const etMessage* msg);
typedef void (*etDispatcherReceiveMessage)(const etMessage* msg);
+typedef void (*etDispatcherExecute)(void);
#endif /* _ETMESSAGERECEIVER_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 de713f568..3d119ea80 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
@@ -23,7 +23,7 @@
* initialize message service with all needed data and initialize message queue and message pool
*
*/
-void etMessageService_init(etMessageService* self, etUInt8* buffer, etUInt16 maxBlocks, etUInt16 blockSize, etDispatcherReceiveMessage msgDispatcher){
+void etMessageService_init(etMessageService* self, etUInt8* buffer, etUInt16 maxBlocks, etUInt16 blockSize, etDispatcherReceiveMessage msgDispatcher, etDispatcherExecute executeFct, enum etMessageService_execmode execmode){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "init")
/* copy init data to self */
@@ -31,6 +31,8 @@ void etMessageService_init(etMessageService* self, etUInt8* buffer, etUInt16 max
self->messageBuffer.maxBlocks = maxBlocks;
self->messageBuffer.blockSize = blockSize;
self->msgDispatcher = msgDispatcher;
+ self->executeFct = executeFct;
+ self->execmode = execmode;
/* copy init queue and pool */
etMessageQueue_init( &(self->messagePool) ); /* the pool is also a queue*/
@@ -110,6 +112,12 @@ etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 si
ET_MSC_LOGGER_SYNC_EXIT
return msg;
}
+ else {
+ etLogger_logErrorF("etMessageService_getMessageBuffer: message pool empty: %d", etMessageService_getMessagePoolLowWaterMark(self));
+ }
+ }
+ else {
+ etLogger_logErrorF("etMessageService_getMessageBuffer: message too big: %d, blockSize: %d", size, self->messageBuffer.blockSize);
}
etMutex_leave(&self->poolMutex);
ET_MSC_LOGGER_SYNC_EXIT
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
index f91cb3f82..7bfeaa2a0 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
@@ -20,26 +20,31 @@
#include "platform/etPlatform.h"
+enum etMessageService_execmode {
+ EXECMODE_POLLED, EXECMODE_BLOCKED, EXECMODE_MIXED
+};
+
typedef struct etBuffer{
- etUInt8 *buffer;
- etUInt16 maxBlocks;
- etUInt16 blockSize;
+ etUInt8 *buffer; /** buffer points to the actual memory position for the message pool */
+ etUInt16 maxBlocks; /** number of blocks for the message pool */
+ etUInt16 blockSize; /** size of blocks for the message pool */
} etBuffer;
typedef struct etMessageService {
- etMessageQueue messageQueue;
- etMessageQueue messagePool;
- etBuffer messageBuffer;
- etDispatcherReceiveMessage msgDispatcher;
- etThread thread;
- etMutex poolMutex;
- etMutex queueMutex;
- etSema executionSemaphore; /* sempahore for waiting and waking up the execution */
+ etMessageQueue messageQueue; /** message queue that holds all used messages */
+ etMessageQueue messagePool; /** message pool that holds all free messages */
+ etBuffer messageBuffer; /** information about the message buffer that holds information about the actual memory position and size for the message pool */
+ etDispatcherReceiveMessage msgDispatcher; /** function pointer to the generated message dispatcher function */
+ etDispatcherExecute executeFct; /** function pointer to the generated message execute function */
+ etThread thread; /** thread for the execution of the message service */
+ etMutex poolMutex; /** mutex for synchronizing the access to the message pool */
+ etMutex queueMutex; /** mutex for synchronizing the access to the message queue */
+ etSema executionSemaphore; /** sempahore for waiting and waking up the execution */
+ enum etMessageService_execmode execmode; /** execution mode*/
} etMessageService;
-
/* lifecycle functions to startup, execute and shutdown the message service */
-void etMessageService_init(etMessageService* self, etUInt8* buffer, etUInt16 maxBlocks, etUInt16 blockSize, etDispatcherReceiveMessage msgDispatcher);
+void etMessageService_init(etMessageService* self, etUInt8* buffer, etUInt16 maxBlocks, etUInt16 blockSize, etDispatcherReceiveMessage msgDispatcher, etDispatcherExecute executeFct, enum etMessageService_execmode execmode);
void etMessageService_start(etMessageService* self);
void etMessageService_execute(etMessageService* self);
void etMessageService_stop(etMessageService* self);
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.c
new file mode 100644
index 000000000..8fb1516cc
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.c
@@ -0,0 +1,31 @@
+/**
+ * @author generated by eTrice
+ *
+ * Source File of ProtocolClass etSystemProtocol
+ *
+ */
+
+#include "etSystemProtocol.h"
+#include "debugging/etMSCLogger.h"
+
+
+void etSystemProtocolConjPort_poll(const etSystemProtocolConjPort* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etSystemProtocolConjPort", "poll")
+ etPort_sendMessage(self, etSystemProtocol_IN_poll, 0, NULL);
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+/*--------------------- debug helpers */
+
+/* message names as strings for debugging (generate MSC) */
+static const char* const etSystemProtocol_messageStrings[] = {"MIN", "poll", "MAX"};
+
+const char* etSystemProtocol_getMessageString(int msg_id) {
+ if (msg_id<etSystemProtocol_MSG_MIN || msg_id>etSystemProtocol_MSG_MAX+1){
+ /* id out of range */
+ return "Message ID out of range";
+ }
+ else{
+ return etSystemProtocol_messageStrings[msg_id];
+ }
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h
new file mode 100644
index 000000000..f3f803fe9
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h
@@ -0,0 +1,34 @@
+/**
+ * @author generated by eTrice
+ *
+ * Header File of ProtocolClass etSystemProtocol
+ *
+ */
+
+#ifndef _ETSYSTEMPROTOCOL_H_
+#define _ETSYSTEMPROTOCOL_H_
+
+#include "etDatatypes.h"
+#include "modelbase/etPort.h"
+
+/* message IDs */
+enum etSystemProtocol_msg_ids {
+ etSystemProtocol_MSG_MIN = 0,
+ etSystemProtocol_IN_poll = 1,
+ etSystemProtocol_MSG_MAX = 2
+};
+
+/*--------------------- port structs and methods */
+typedef etPort etSystemProtocolConjPort;
+
+
+void etSystemProtocolConjPort_poll(const etSystemProtocolConjPort* self);
+
+/*--------------------- debug helpers */
+
+/* get message string for message id */
+const char* etSystemProtocol_getMessageString(int msg_id);
+
+
+#endif /* _ETSYSTEMPROTOCOL_H_ */
+
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etWakeupService.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etWakeupService.c
new file mode 100644
index 000000000..ad288e9b5
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etWakeupService.c
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "etWakeupService.h"
+#include "etMessage.h"
+#include "etMessageService.h"
+
+
+/**
+ * static instance of the execute Message
+ */
+
+/**
+ * calls cyclically all receiveMessage functions (at the right time) to deliver the poll message
+ * */
+void etWakeupService_execute(etWakeupService* self) {
+ int i;
+ for (i=0; i<self->targetListLength; i++){
+ /** send message call the receiveMessage function to deliver the execute message */
+ etSystemProtocolConjPort_poll( &(self->targetList[i].messageServicePort) );
+ }
+}
+
+
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etWakeupService.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etWakeupService.h
new file mode 100644
index 000000000..c8a54213a
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etWakeupService.h
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef _ETWAKEUPSERVICE_H_
+#define _ETWAKEUPSERVICE_H_
+
+#include "etDatatypes.h"
+#include "etSystemProtocol.h"
+
+/**
+ * time definition composed by the number of seconds and the number of nano seconds
+ */
+typedef struct etTime {
+ etInt32 seconds;
+ etInt32 nseconds;
+} etTime;
+
+
+typedef struct etWakeupTarget {
+ etSystemProtocolConjPort messageServicePort; /** port to send the poll message to the message service */
+ etTime wakeupTime; /** time for the cyclic wake up call */
+} etWakeupTarget;
+
+
+typedef struct etWakeupService {
+ etWakeupTarget* targetList; /** array with targets to be called */
+ etInt16 targetListLength; /** number of targets to be called */
+} etWakeupService;
+
+void etWakeupService_execute(etWakeupService* self);
+
+
+#endif /* _ETWAKEUPSERVICE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etRTSystemServicesProtocol.h b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etRTSystemServicesProtocol.h
new file mode 100644
index 000000000..c192f452d
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etRTSystemServicesProtocol.h
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef ETRTSYSTEMSERVICESPROTOCOL_H_
+#define ETRTSYSTEMSERVICESPROTOCOL_H_
+
+
+
+#endif /* ETRTSYSTEMSERVICESPROTOCOL_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etPlatform.h b/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etPlatform.h
index 66d56c894..b332e2140 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etPlatform.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etPlatform.h
@@ -15,35 +15,54 @@
#include "etDatatypes.h"
-/*
+/**
* etPlatform.h defines a generic interface for platform specific implementations
*
* */
-/* platform specific functions */
-
-/******************thread********************/
+/*
+ * typedefs
+ */
typedef int32 etStacksize;
typedef int32 etPriority;
typedef charPtr etThreadname;
typedef void (*etThreadFunction)(void *);
+/**
+ * etThread holds all data needed to handle a thread instance
+ * the struct has to be filled before calling etThread_construct except for osData and osId
+ **/
typedef struct etThread{
- etOSThreadData osData; /* OS specific thread data (e.g. handle or id) */
- etStacksize stacksize;
- etPriority priority;
- etThreadname threadName;
- etThreadFunction threadFunction;
- void* threadFunctionData;
+ etOSThreadData osData; /**< OS specific thread data (e.g. handle or id) -> is filled in by etThread_construct **/
+ etOSThreadId osId; /**< integer thread id (used e.g. for debugging) -> is filled in by etThread_construct **/
+ etStacksize stacksize; /**< configuration of stacksize -> has to be filled in by caller of etThread_construct **/
+ etPriority priority; /**< configuration of priority -> has to be filled in by caller of etThread_construct **/
+ etThreadname threadName; /**< configuration of threadName -> has to be filled in by caller of etThread_construct **/
+ etThreadFunction threadFunction; /**< call back function to be called by thread -> has to be filled in by caller of etThread_construct **/
+ void* threadFunctionData; /**< data for call back function to be called by thread -> has to be filled in by caller of etThread_construct **/
} etThread;
-
+/**
+ * create and start a new thread
+ * \param self pointer to thread instance
+ */
+// TODO: add return values for error handling
void etThread_construct(etThread* self);
+
+/**
+ * stop and destroy a new thread
+ * \param self pointer to thread instance
+ */
void etThread_destruct(etThread* self);
-/******************thread helpers********************/
+/**
+ * pausing the execution of the thread for <b>millis</b> milliseconds
+ * \param millis sleeping time in milliseconds
+ */
void etThread_sleep(etInt32 millis);
+etOSThreadData etThread_self(void);
+etOSThreadId etThread_self_id(void);
/*****************mutex**********************/
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.c b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.c
new file mode 100644
index 000000000..a92a36c49
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.c
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
+#include "runtime/etRuntime.h"
+
+
+
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h
new file mode 100644
index 000000000..229e2e5e6
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef _ETRUNTIME_H_
+#define _ETRUNTIME_H_
+
+
+
+#endif /* _ETRUNTIME_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etThreadList.c b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etThreadList.c
new file mode 100644
index 000000000..8e488b05a
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etThreadList.c
@@ -0,0 +1,14 @@
+/*******************************************************************************
+ * 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
+#include "runtime/etThreadList.h"
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etThreadList.h b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etThreadList.h
new file mode 100644
index 000000000..7b20103df
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etThreadList.h
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef _etThreadController_H_
+#define _etThreadController_H_
+
+#include "platform/etPlatform.h"
+
+/**
+ * etThreadController holds a complete list of all threads
+ *
+ **/
+typedef struct etThreadController{
+ etThread* threadList; /**< list of all thread data (as array) **/
+ int32 size; /**< size of the list **/
+}etThreadController;
+
+int32 etThreadController_getNumberOfThreads(etThreadController* self);
+void etThreadController_startAll(etThreadController* self);
+void etThreadController_stopAll(etThreadController* self);
+void etThreadController_getCurrentThreadId(void);
+
+#endif /* _etThreadController_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h
index 7586d5dff..d6a33fd4d 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h
@@ -50,6 +50,11 @@ typedef double float64;
/* string datatypes */
typedef char* charPtr;
+
+#ifndef NULL
+ #define NULL 0
+#endif
+
/* boolean datatypes and values */
typedef char bool; /* TODO: bool, Bool, Boolean, and boolean are already defined in some platforms*/
#ifndef __MINGW32__
@@ -88,7 +93,7 @@ typedef bool etBool;
typedef FILE* etFileHandle;
-typedef int8 etAddressId;
+typedef int16 etAddressId;
/*
* typedefs for threading
@@ -98,6 +103,7 @@ typedef int8 etAddressId;
typedef CRITICAL_SECTION etOSMutexData;
typedef HANDLE etOSThreadData;
+ typedef DWORD etOSThreadId;
typedef HANDLE etOSSemaData;
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c
index efe9f2775..1e1a97bc4 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c
@@ -63,6 +63,14 @@ void etThread_sleep(etInt32 millis){
ET_MSC_LOGGER_SYNC_EXIT
}
+etOSThreadData etThread_self(void){
+ return GetCurrentThread();
+}
+
+etOSThreadId etThread_self_id(void){
+ return GetCurrentThreadId();
+}
+
/*****************mutex**********************/
void etMutex_construct(etMutex* self){
ET_MSC_LOGGER_SYNC_ENTRY("etMutex", "construct")

Back to the top