Example #1
0
/******************************************************************************
**  Function:  CFE_PSP_DeleteOSResources()
**
**  Purpose:
**    Clean up any OS resources when exiting from the cFE
**
**  Arguments:
**    (none)
**
**  Return:
**    (none)
*/
void CFE_PSP_DeleteOSResources (void)
{
   uint32          i;
   int32           ReturnCode;

   for ( i = 0; i < OS_MAX_TASKS; i++)
      ReturnCode = OS_TaskDelete(i);
   printf("CFE_PSP: Deleted all Tasks in system\n");
   
   for ( i = 0; i < OS_MAX_BIN_SEMAPHORES; i++ )
      ReturnCode = OS_BinSemDelete(i);
   printf("CFE_PSP: Deleted all Binary Semaphores in system\n");
      
   for ( i = 0; i < OS_MAX_COUNT_SEMAPHORES; i++ )
      ReturnCode = OS_CountSemDelete(i);
   printf("CFE_PSP: Deleted all Counting Semaphores in system\n");
   
   for ( i = 0; i < OS_MAX_MUTEXES; i++ )
      ReturnCode = OS_MutSemDelete(i);
   printf("CFE_PSP: Deleted all Mutexes in system\n");

   for ( i = 0; i < OS_MAX_QUEUES; i++ )
      ReturnCode = OS_QueueDelete(i);
   printf("CFE_PSP: Deleted all Queues in system\n");
  
   for ( i = 0; i < OS_MAX_TIMERS; i++ )
      ReturnCode = OS_TimerDelete(i);
   printf("CFE_PSP: Deleted all Timers in system\n");
 
   printf("CFE_PSP: NOTE: After quitting the cFE with a Control-C signal, it MUST be started next time\n");
   printf("     with a Poweron Reset ( --reset PO ). \n");
   
}
Example #2
0
void OS_Application_Startup(void)
{
   
   int              i = 0;
   int32            TimerStatus;
   uint32           TimerID[NUMBER_OF_TIMERS];
   char             TimerName[NUMBER_OF_TIMERS][20] = {"TIMER1","TIMER2","TIMER3","TIMER4"};
   uint32           TimerStart[NUMBER_OF_TIMERS] = {1000, 2000000, 3000000, 4000000 };
   uint32           TimerInterval[NUMBER_OF_TIMERS] = {500000, 4000000, 4000000, 4000000 }; 
   uint32           ClockAccuracy;

   for ( i = 0; i < NUMBER_OF_TIMERS; i++ )
   {
      TimerStatus = OS_TimerCreate(&TimerID[i], TimerName[i], &ClockAccuracy, &(test_func));
      if ( TimerStatus != OS_SUCCESS )
      {
         printf("Error creating timer# %d: %d\n",i ,(int)TimerStatus);       
      }   
      else
      {
         printf("Timer %d Created\n", i);
      }

      printf("Timer %d Accuracy = %d microseconds \n",i ,(int)ClockAccuracy);

      TimerStatus  =  OS_TimerSet(TimerID[i], TimerStart[i], TimerInterval[i]);
      if ( TimerStatus != OS_SUCCESS )
      {
         printf("Error calling OS_TimerSet: ID = %d\n", (int)TimerID[i]);
      }
      else
      {  
         printf("Timer %d programmed\n", i);
      }

   }


   /*
   ** Let the main thread sleep 
   */     
   printf("Starting Delay loop. Linux/OSX/Cygwin will be faster, because sleep call is interrupted by timer\n");
   for (i = 0 ; i < 15; i++ )
   {
      /* 
      ** Even though this sleep call is for 1 second,
      ** the sigalarm timer for the 1hz will keep waking
      ** it up. Keep that in mind when setting the timer down
      ** to something very small.
      */
      sleep(1);
   }

   for ( i = 0; i < NUMBER_OF_TIMERS; i++ )
   {
                 
      TimerStatus =  OS_TimerDelete(TimerID[i]);
      if ( TimerStatus != OS_SUCCESS )
      {
         printf("Error calling OS_TimerDelete for timer %d: ID = %d\n", i, (int)TimerID[i]);
      }
      else
      {
         printf("Timer %d deleted. Count total = %d\n",i, (int)timer_counter[i]);
      }
 
   }
   printf("Hit control-c to end test on a desktop system.\n");

}
Example #3
0
static void test_003_005_teardown(void) {
    if (tmid != 0) {
        (void) OS_TimerSet(tmid, 0, 0);
        (void) OS_TimerDelete(tmid);
    }
}
Example #4
0
static void test_003_001_execute(void) {

    /* [3.1.1] OS_TimerCreate() is invoked with timer_id set to NULL, an
       error is expected.*/
    test_set_step(1);
    {
        int32 err;
        uint32 accuracy;

        err = OS_TimerCreate(NULL,                      /* Error.*/
                             "failing timer",
                             &accuracy,
                             tmr_callback);
        test_assert(err == OS_INVALID_POINTER, "NULL not detected");
    }

    /* [3.1.2] OS_TimerCreate() is invoked with timer_name set to NULL,
       an error is expected.*/
    test_set_step(2);
    {
        int32 err;
        uint32 tmid;
        uint32 accuracy;

        err = OS_TimerCreate(&tmid,
                             NULL,                      /* Error.*/
                             &accuracy,
                             tmr_callback);
        test_assert(err == OS_INVALID_POINTER, "NULL not detected");
    }

    /* [3.1.3] OS_TimerCreate() is invoked with accuracy set to NULL, an
       error is expected.*/
    test_set_step(3);
    {
        int32 err;
        uint32 tmid;

        err = OS_TimerCreate(&tmid,
                             "failing timer",
                             NULL,                      /* Error.*/
                             tmr_callback);
        test_assert(err == OS_INVALID_POINTER, "NULL not detected");
    }

    /* [3.1.4] OS_TimerCreate() is invoked with callback_ptr set to NULL,
       an error is expected.*/
    test_set_step(4);
    {
        int32 err;
        uint32 tmid;
        uint32 accuracy;

        err = OS_TimerCreate(&tmid,
                             "failing timer",
                             &accuracy,
                             NULL);                     /* Error.*/
        test_assert(err == OS_TIMER_ERR_INVALID_ARGS, "NULL not detected");
    }

    /* [3.1.5] OS_TimerCreate() is invoked with a very long timer name,
       an error is expected.*/
    test_set_step(5);
    {
        int32 err;
        uint32 tmid;
        uint32 accuracy;

        err = OS_TimerCreate(&tmid,
                             "very very long timer name",   /* Error.*/
                             &accuracy,
                             tmr_callback);
        test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");
    }

    /* [3.1.6] OS_TimerDelete() is invoked with timer_id set to -1, an
       error is expected.*/
    test_set_step(6);
    {
        int32 err;

        err = OS_TimerDelete((uint32)-1);
        test_assert(err == OS_ERR_INVALID_ID, "wrong timer id not detected");
    }

    /* [3.1.7] OS_TimerCreate() is invoked twice with duplicated name, an
       error is expected, then the queue is deleted using
       OS_TimerDelete().*/
    test_set_step(7);
    {
        int32 err;
        uint32 tmid1, tmid2;
        uint32 accuracy;

        err = OS_TimerCreate(&tmid1, "my timer", &accuracy, tmr_callback);
        test_assert(err == OS_SUCCESS, "timer creation failed");

        err = OS_TimerCreate(&tmid2, "my timer", &accuracy, tmr_callback);
        test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected");

        err = OS_TimerDelete(tmid1);
        test_assert(err == OS_SUCCESS, "timer deletion failed");
    }
}
Example #5
0
static void test_003_004_teardown(void) {
    if (tmid != 0) {
        (void) OS_TimerDelete(tmid);
    }
}