Exemple #1
0
void test_task
   (
      uint_32 initial_data
   )
{
   MQX_TICK_STRUCT ticks;
   _mqx_uint       result;
   _mqx_uint       n;

   _time_init_ticks(&ticks, 10);

   result = _watchdog_create_component(BSP_TIMER_INTERRUPT_VECTOR, 
      handle_watchdog_expiry);
   if (result != MQX_OK) {
      printf("\nError creating watchdog component.");
      _task_block();
   }

   n = 100;
   while (TRUE) {
      result = _watchdog_start_ticks(&ticks);
      n = waste_time(n);
      _watchdog_stop();
      printf("\n %d", n);
   }

}
/*****************************************************************************//**
* @brief This function is the task that handles the communication with the
*  remote servers.  Each communication may take several seconds so this
*  tasks allows the communication to occur in its own thread so it doesn't
*  block the scheduler. 
*
* @param temp is a unused variable.
* @return nothing.
* @author Neal Shurmantine
* @version
* 04/19/2015    Created.
*******************************************************************************/
void *RMT_remote_server_task(void * temp)
{
    //holds the event bits that were set when the task wakes up
    uint16_t event_active;
    
    //the task will wake up on this timeout if no events have occurred.
    RMT_WaitTime = WAIT_TIME_INFINITE;

    //create the event for this task plus mailboxes and timer
    RMT_EventHandle = OS_EventCreate(0,false);

    RMT_RegisterEventMbox = OS_MboxCreate(RMT_EventHandle,RMT_REGISTER_EVENT); 
    RMT_ActionResponseMbox = OS_MboxCreate(RMT_EventHandle,RMT_ACTION_RESPONSE_EVENT); 
    RMT_ExpectedEvents = RMT_REMOTE_CONNECT_EVENT
                        | RMT_REMOTE_ACTION_EVENT
                        | RMT_FW_CHECK_EVENT
                        | RMT_TIME_SERVER_EVENT
                        | RMT_FAULT_EVENT
                        | RMT_REFRESH_REMOTE_DATA_EVENT
                        | RMT_REGISTER_EVENT
                        | RMT_UNREGISTER_EVENT
                        | RMT_ACTION_RESPONSE_EVENT;

printf("RMT_remote_server_task\n");
    while(1) {
        _watchdog_stop();
        event_active = OS_TaskWaitEvents(RMT_EventHandle, RMT_ExpectedEvents, RMT_WaitTime);
        event_active &= RMT_ExpectedEvents;
        _watchdog_start(RMT_WATCHDOG_INTERVAL);
        if (event_active & RMT_TIME_SERVER_EVENT) {
            OS_EventClear(RMT_EventHandle,RMT_TIME_SERVER_EVENT);
            RMT_handle_time_server();
        }
        if (event_active & RMT_REMOTE_CONNECT_EVENT) {
            OS_EventClear(RMT_EventHandle,RMT_REMOTE_CONNECT_EVENT);
            RMT_handle_remote_connect();
        }
        if (event_active & RMT_FW_CHECK_EVENT) {
            OS_EventClear(RMT_EventHandle,RMT_FW_CHECK_EVENT);
            
            // marker 05/03/2016 - send firmware check request to slave hubs (access points)
            RMT_handle_fw_check();
            sendTextMessageToSlaveHubs("check firmware");
        }
        if (event_active & RMT_REMOTE_ACTION_EVENT) {
            OS_EventClear(RMT_EventHandle,RMT_REMOTE_ACTION_EVENT);
            RMT_handle_remote_action();
        }
        if (event_active & RMT_FAULT_EVENT) {
            OS_EventClear(RMT_EventHandle,RMT_FAULT_EVENT);
            RMT_report_fault();
        }
        if (event_active & RMT_REFRESH_REMOTE_DATA_EVENT) {
            OS_EventClear(RMT_EventHandle,RMT_REFRESH_REMOTE_DATA_EVENT);
            RMT_refresh_remote_data();
        }
        if (event_active & RMT_REGISTER_EVENT) {
            RMT_register_hub();
        }
        if (event_active & RMT_UNREGISTER_EVENT) {
            OS_EventClear(RMT_EventHandle,RMT_UNREGISTER_EVENT);
            RMT_unregister_hub();
        }
        if (event_active & RMT_ACTION_RESPONSE_EVENT) {
            RMT_handle_action_response(NULL_TOKEN);
        }
    }
}