linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Error calling timer_create
@ 2004-05-19  5:09 MERRITT Nigel
  2004-05-19  6:52 ` Gerhard Jaeger
  0 siblings, 1 reply; 2+ messages in thread
From: MERRITT Nigel @ 2004-05-19  5:09 UTC (permalink / raw)
  To: linuxppc-embedded


I am trying to get timers working on a Embedded Planet 405GP running Timesys Linux.
The code is compiled using the correct tool chain and is based on the example in Timesys documentation, however, when calling the timer_create function, I get an error, and errno is set to 38, which is listed as:

   #define ENOSYS  38 /* Function not implemented */

in errno.h

The code for calling timer_create is:


#include <time.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>

// Define a timer signal value.
#define TEMP_MON_TIMER_SIGNAL (SIGRTMIN + 1)

// Prototype for the timer handling function.
void TimerHandler(int signo, siginfo_t *info, void *context);

int main(int argc, char** argv) {

   struct sigevent   stEvent;
   struct sigaction  stSignalAction;
   struct itimerspec stITimerSpec;

   struct timespec stClockRes;
   timer_t nTimerId;if (sigemptyset(&stSignalAction.sa_mask))
{
   printf("Signal mask could not be emptied (err=%d).\n", errno);
   return -1;
}

stSignalAction.sa_flags = SA_SIGINFO;
stSignalAction.sa_sigaction = TimerHandler;

// Register the handler.
if (sigaction(TEMP_MON_TIMER_SIGNAL, &stSignalAction, NULL))
{
   printf("Signal mask could not be emptied (err=%d).\n", errno);
   return -1;
}

// The signal has been created, now set up the event that will
// trigger the signal.
stEvent.sigev_signo = TEMP_MON_TIMER_SIGNAL;
stEvent.sigev_notify = SIGEV_SIGNAL;
stEvent.sigev_value.sival_ptr = &nTimerId;

// Use the event that was just set up to set up the timer.
if ((clock_getres(CLOCK_REALTIME, &stClockRes)) < 0)
{
   printf("Clock resolution could not be obtained (err=%d).\n", errno);
   return -1;
}

stITimerSpec.it_interval.tv_sec = 1;
stITimerSpec.it_interval.tv_nsec = 0 * stClockRes.tv_nsec;
stITimerSpec.it_value = stITimerSpec.it_interval;

// Initialise the timer.
if (timer_create(CLOCK_REALTIME, &stEvent, &nTimerId))
{
   printf("Timer could not be created (err=%d).\n", errno);
   return -1;
}
.
.
.

... with the result:

   Timer could not be created (err=38).

The code obviously compiles so I can't work out why it would claim the function does not exist.  The code is compiled with static linking so all libraries should be included in the executable.

Any help would be appreciated...

   NJM

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Error calling timer_create
  2004-05-19  5:09 Error calling timer_create MERRITT Nigel
@ 2004-05-19  6:52 ` Gerhard Jaeger
  0 siblings, 0 replies; 2+ messages in thread
From: Gerhard Jaeger @ 2004-05-19  6:52 UTC (permalink / raw)
  To: linuxppc-embedded


Hi,

ENOSYS means, that the function is not implemented on your system, probaly
your glibc is somwhat outdatet. I remember the same thing here some time
ago before using glibc-2.2.5. Updating your CDK should help.

Ciao,
  Gerhard

On Wednesday 19 May 2004 07:09, MERRITT Nigel wrote:
[SNIPSNAP]
> // Initialise the timer.
> if (timer_create(CLOCK_REALTIME, &stEvent, &nTimerId))
> {
>    printf("Timer could not be created (err=%d).\n", errno);
>    return -1;
> }
> .
> .
> .
>
> ... with the result:
>
>    Timer could not be created (err=38).
>
> The code obviously compiles so I can't work out why it would claim the
> function does not exist.  The code is compiled with static linking so all
> libraries should be included in the executable.
>
> Any help would be appreciated...
>
>    NJM


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-05-19  6:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-19  5:09 Error calling timer_create MERRITT Nigel
2004-05-19  6:52 ` Gerhard Jaeger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).