Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-06-05 17:12:42 +0000
committerHenrik Rentz-Reichert2013-06-05 17:12:42 +0000
commit8a47e135051a8f760da99b49a4ade103d046120b (patch)
treeb51ee56cb40ef8bda44f15f7c735bb44a09f1ce3 /runtime/org.eclipse.etrice.runtime.c/src
parent8d0a9b2a8ab422608c57346e5c3f547c32c0324c (diff)
downloadorg.eclipse.etrice-8a47e135051a8f760da99b49a4ade103d046120b.tar.gz
org.eclipse.etrice-8a47e135051a8f760da99b49a4ade103d046120b.tar.xz
org.eclipse.etrice-8a47e135051a8f760da99b49a4ade103d046120b.zip
[runtime.c] still debugging...
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etLogger.c12
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etMutex.c4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTime.c4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTimer.c51
7 files changed, 47 insertions, 35 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
index fab2d8e15..87465dd6f 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
@@ -7,6 +7,7 @@
*
* CONTRIBUTORS:
* Thomas Schuetz (initial contribution)
+ * Henrik Rentz-Reichert
*
*******************************************************************************/
@@ -22,6 +23,7 @@
#include <stdio.h>
#include <pthread.h>
#include <semaphore.h>
+#include <signal.h>
#include <sys/types.h>
/* unsigned integer datatypes */
@@ -98,6 +100,7 @@ typedef sem_t etOSSemaData;
typedef struct {
void* next;
timer_t timerid;
+ sigevent_t te;
etBool signaled;
}
etOSTimerData;
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etLogger.c
index 469987fa4..f3dbf37c4 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etLogger.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etLogger.c
@@ -16,8 +16,8 @@
void etLogger_logError(const char* message){
- printf("ERROR: %s\n", message);
- fflush(stdout);
+ fprintf(stderr, "ERROR: %s\n", message);
+ fflush(stderr);
}
void etLogger_logWarning(const char* message){
@@ -31,13 +31,13 @@ void etLogger_logInfo(const char* message){
}
void etLogger_logErrorF(const char* format, ... ){
- printf("ERROR: ");
+ fprintf(stderr, "ERROR: ");
va_list arglist;
va_start( arglist, format );
- vprintf( format, arglist );
+ vfprintf(stderr, format, arglist );
va_end( arglist );
- printf("\n");
- fflush(stdout);
+ fprintf(stderr, "\n");
+ fflush(stderr);
}
void etLogger_logWarningF(const char* format, ... ){
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etMutex.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etMutex.c
index 538a6f3d7..ce5cff169 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etMutex.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etMutex.c
@@ -6,13 +6,13 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* CONTRIBUTORS:
- * Thomas Schuetz, Thomas Jung (initial contribution)
+ * Henrik Rentz-Reichert (initial contribution)
*
*******************************************************************************/
/**
*
- * etMutex.c MinGW implementation of etMutex
+ * etMutex.c POSIX implementation of etMutex
*
*/
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c
index 81f040b2a..06ac30436 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etSema.c
@@ -6,13 +6,13 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* CONTRIBUTORS:
- * Thomas Schuetz, Thomas Jung (initial contribution)
+ * Henrik Rentz-Reichert (initial contribution)
*
*******************************************************************************/
/**
*
- * etSema.c MinGW implementation of etSema
+ * etSema.c POSIX implementation of etSema
*
*/
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c
index f40bc385e..2d7c145f5 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etThread.c
@@ -6,13 +6,13 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* CONTRIBUTORS:
- * Thomas Schuetz, Thomas Jung (initial contribution)
+ * Henrik Rentz-Reichert (initial contribution)
*
*******************************************************************************/
/**
*
- * etThread.c MinGW implementation of etThread
+ * etThread.c POSIX implementation of etThread
*
*/
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTime.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTime.c
index d367f9ebc..4b9955925 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTime.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTime.c
@@ -6,13 +6,13 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* CONTRIBUTORS:
- * Thomas Schuetz, Thomas Jung (initial contribution)
+ * Henrik Rentz-Reichert (initial contribution)
*
*******************************************************************************/
/**
*
- * etTime.c MinGW implementation of etTime
+ * etTime.c POSIX implementation of etTime
*
*/
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTimer.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTimer.c
index 9e857a336..97dda9ade 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTimer.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etTimer.c
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* CONTRIBUTORS:
- * Thomas Schuetz (initial contribution)
+ * Henrik Rentz-Reichert (initial contribution)
*
*******************************************************************************/
@@ -64,6 +64,7 @@ static void timerThreadFunction(void* data) {
while (TRUE) {
etTimer* it;
int idx;
+ int signaled = FALSE;
printf("timerThreadFunction: waiting\n"); fflush(stdout); // remove debug output
etSema_waitForWakeup(&timer_sema);
@@ -76,36 +77,46 @@ static void timerThreadFunction(void* data) {
printf("timerThreadFunction: signaled %d, calling user fct %p\n", idx, (void*)it->timerFunction); fflush(stdout); // remove debug output
it->osTimerData.signaled = FALSE;
it->timerFunction(it->timerFunctionData);
+ signaled = TRUE;
}
}
etMutex_leave(&timer_mutex);
+
+ if (!signaled) {
+ etLogger_logError("timerThreadFunction: signaled timer NOT found\n");
+ }
}
}
static void timerHandler(int sig, siginfo_t *si, void *uc) {
timer_t* tid = si->si_value.sival_ptr;
etTimer* it;
-
- printf("timerHandler\n"); fflush(stdout); // TODO: remove debug output
+ int signaled = FALSE;
etMutex_enter(&timer_mutex);
for (it=timers; it!=NULL; it=(etTimer*) it->osTimerData.next) {
- if (&it->osTimerData.timerid==tid) {
+ if (it->osTimerData.timerid==*tid) {
int sval = 0;
sem_getvalue(&(timer_sema.osData), &sval);
it->osTimerData.signaled = TRUE;
if (sval==0)
etSema_wakeup(&timer_sema);
- printf("timerHandler signaled\n"); fflush(stdout); // TODO: remove debug output
- break;
+ signaled = TRUE;
}
}
+
etMutex_leave(&timer_mutex);
+
+ if (!signaled) {
+ etLogger_logError("timerHandler: signaled timer NOT found\n");
+ }
}
void etTimer_construct(etTimer* self, etTime* timerInterval, etTimerFunction timerFunction, void* timerFunctionData){
ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "construct")
{
+ memset(self, 0, sizeof(etTimer));
+
self->timerInterval.sec = timerInterval->sec;
self->timerInterval.nSec = timerInterval->nSec;
self->timerFunction = timerFunction;
@@ -148,27 +159,25 @@ void etTimer_construct(etTimer* self, etTime* timerInterval, etTimerFunction tim
printf("etTimer_construct: installed signal handler and started thread\n"); fflush(stdout); // TODO: remove debug output
}
- /* place at list head */
- etMutex_enter(&timer_mutex);
- self->osTimerData.next = timers;
- timers = self;
- etMutex_leave(&timer_mutex);
-
/* create the timer (in disarmed state) */
{
- struct sigevent te;
-
/* create timer */
- te.sigev_notify = SIGEV_SIGNAL;
- te.sigev_signo = TIMER_SIGNAL;
- te.sigev_value.sival_ptr = &self->osTimerData.timerid;
- if (timer_create(CLOCK_REALTIME, &te, &self->osTimerData.timerid) != 0) {
+ self->osTimerData.te.sigev_notify = SIGEV_SIGNAL;
+ self->osTimerData.te.sigev_signo = TIMER_SIGNAL;
+ self->osTimerData.te.sigev_value.sival_ptr = &self->osTimerData.timerid;
+ if (timer_create(CLOCK_REALTIME, &self->osTimerData.te, &self->osTimerData.timerid) != 0) {
fprintf(stderr, "etTimer_construct: failed creating a timer\n");
fflush(stderr);
return;
}
printf("etTimer_construct: user callback is %p\n", (void*)self->timerFunction); fflush(stdout); // TODO: remove debug output
}
+
+ /* place at list head */
+ etMutex_enter(&timer_mutex);
+ self->osTimerData.next = timers;
+ timers = self;
+ etMutex_leave(&timer_mutex);
}
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -189,13 +198,13 @@ void etTimer_start(etTimer* self){
if (timer_settime(self->osTimerData.timerid, 0, &its, NULL) != 0) {
switch (errno) {
case EFAULT:
- fprintf(stderr, "etTimer_start: failed starting a timer with errno EFAULT\n");
+ etLogger_logError("etTimer_start: failed starting a timer with errno EFAULT");
break;
case EINVAL:
- fprintf(stderr, "etTimer_start: failed starting a timer with errno EINVAL\n");
+ etLogger_logError("etTimer_start: failed starting a timer with errno EINVAL");
break;
default:
- fprintf(stderr, "etTimer_start: failed starting a timer with errno %d\n", errno);
+ etLogger_logErrorF("etTimer_start: failed starting a timer with errno %d", errno);
break;
}
fflush(stderr);

Back to the top