src/luos.c
void Luos_Loop(void)
{
    static uint32_t last_loop_date;
    uint16_t remaining_msg_number   = 0;
    ll_service_t *oldest_ll_service = NULL;
    msg_t *returned_msg             = NULL;

    // check loop call time stat
    if ((LuosHAL_GetSystick() - last_loop_date) > luos_stats.max_loop_time_ms)
    {
        luos_stats.max_loop_time_ms = LuosHAL_GetSystick() - last_loop_date;
    }
    if (MsgAlloc_IsReseted() == SUCCEED)
    {
        // We receive a reset detection
        // Reset the data reception context
        Luos_ReceiveData(NULL, NULL, NULL);
    }
    Robus_Loop();
    // look at all received messages
    while (MsgAlloc_LookAtLuosTask(remaining_msg_number, &oldest_ll_service) != FAILED)
    {
        // There is a message available find the service linked to it
        service_t *service = Luos_GetService(oldest_ll_service);
        // check if this is a Luos Command
        uint8_t cmd   = 0;
        uint16_t size = 0;
        // There is a possibility to receive in IT a reset_detection so check task before doing any treatement
        if ((MsgAlloc_GetLuosTaskCmd(remaining_msg_number, &cmd) != SUCCEED) || (MsgAlloc_GetLuosTaskSize(remaining_msg_number, &size) != SUCCEED))
        {
            break;
        }
        //check if this msg cmd should be consumed by Luos_MsgHandler
        if (Luos_IsALuosCmd(service, cmd, size) == SUCCEED)
        {
            if (MsgAlloc_PullMsgFromLuosTask(remaining_msg_number, &returned_msg) == SUCCEED)
            {
                // be sure the content of this message need to be managed by Luos and do it if it is.
                if (Luos_MsgHandler((service_t *)service, returned_msg) == SUCCEED)
                {
                    // Luos CMD are generic for all services and have to be executed only once
                    // Clear all luos tasks related to this message (in case of multicast message)
                    MsgAlloc_ClearMsgFromLuosTasks(returned_msg);
                }
                else
                {
                    // Here we should not have polling services.
                    LUOS_ASSERT(service->service_cb != 0);
                    // This message is for the user, pass it to the user.
                    service->service_cb(service, returned_msg);
                }
            }
        }
        else
        {
            // This message is for a service
            // check if this continer have a callback?
            if (service->service_cb != 0)
            {
                // This service have a callback pull the message
                if (MsgAlloc_PullMsgFromLuosTask(remaining_msg_number, &returned_msg) == SUCCEED)
                {
                    // This message is for the user, pass it to the user.
                    service->service_cb(service, returned_msg);
                }
            }
            else
            {
                remaining_msg_number++;
            }
        }
    }
    // finish msg used
    MsgAlloc_UsedMsgEnd();
    // manage timed auto update
    Luos_AutoUpdateManager();
    // save loop date
    last_loop_date = LuosHAL_GetSystick();
}
/******************************************************************************
 * @brief Luos Loop must be call in project loop
 * @param None
 * @return None
 ******************************************************************************/
@brief Luos Loop must be call in project loop
@param None
@return None
@brief Luos Loop must be call in project loop @param None @return None
void Luos_Loop(void)
{
    static uint32_t last_loop_date;
    uint16_t remaining_msg_number   = 0;
    ll_service_t *oldest_ll_service = NULL;
    msg_t *returned_msg             = NULL;
    if ((LuosHAL_GetSystick() - last_loop_date) > luos_stats.max_loop_time_ms)
    {
        luos_stats.max_loop_time_ms = LuosHAL_GetSystick() - last_loop_date;
    }
    if (MsgAlloc_IsReseted() == SUCCEED)
    {
        Luos_ReceiveData(NULL, NULL, NULL);
    }
    Robus_Loop();
    while (MsgAlloc_LookAtLuosTask(remaining_msg_number, &oldest_ll_service) != FAILED)
    {
        service_t *service = Luos_GetService(oldest_ll_service);
        uint8_t cmd   = 0;
        uint16_t size = 0;
        if ((MsgAlloc_GetLuosTaskCmd(remaining_msg_number, &cmd) != SUCCEED) || (MsgAlloc_GetLuosTaskSize(remaining_msg_number, &size) != SUCCEED))
        {
            break;
        }
        if (Luos_IsALuosCmd(service, cmd, size) == SUCCEED)
        {
            if (MsgAlloc_PullMsgFromLuosTask(remaining_msg_number, &returned_msg) == SUCCEED)
            {
                if (Luos_MsgHandler((service_t *)service, returned_msg) == SUCCEED)
                {
                    MsgAlloc_ClearMsgFromLuosTasks(returned_msg);
                }
                else
                {
                    LUOS_ASSERT(service->service_cb != 0);
                    service->service_cb(service, returned_msg);
                }
            }
        }
        else
        {
            if (service->service_cb != 0)
            {
                if (MsgAlloc_PullMsgFromLuosTask(remaining_msg_number, &returned_msg) == SUCCEED)
                {
                    service->service_cb(service, returned_msg);
                }
            }
            else
            {
                remaining_msg_number++;
            }
        }
    }
    MsgAlloc_UsedMsgEnd();
    Luos_AutoUpdateManager();
    last_loop_date = LuosHAL_GetSystick();
}
void Luos_Loop ( void ) { static uint32_t last_loop_date ; uint16_t remaining_msg_number = 0 ; ll_service_t * oldest_ll_service = NULL ; msg_t * returned_msg = NULL ; if ( ( LuosHAL_GetSystick ( ) - last_loop_date ) > luos_stats . max_loop_time_ms ) { luos_stats . max_loop_time_ms = LuosHAL_GetSystick ( ) - last_loop_date ; } if ( MsgAlloc_IsReseted ( ) == SUCCEED ) { Luos_ReceiveData ( NULL , NULL , NULL ) ; } Robus_Loop ( ) ; while ( MsgAlloc_LookAtLuosTask ( remaining_msg_number , & oldest_ll_service ) != FAILED ) { service_t * service = Luos_GetService ( oldest_ll_service ) ; uint8_t cmd = 0 ; uint16_t size = 0 ; if ( ( MsgAlloc_GetLuosTaskCmd ( remaining_msg_number , & cmd ) != SUCCEED ) || ( MsgAlloc_GetLuosTaskSize ( remaining_msg_number , & size ) != SUCCEED ) ) { break ; } if ( Luos_IsALuosCmd ( service , cmd , size ) == SUCCEED ) { if ( MsgAlloc_PullMsgFromLuosTask ( remaining_msg_number , & returned_msg ) == SUCCEED ) { if ( Luos_MsgHandler ( ( service_t * ) service , returned_msg ) == SUCCEED ) { MsgAlloc_ClearMsgFromLuosTasks ( returned_msg ) ; } else { LUOS_ASSERT ( service -> service_cb != 0 ) ; service -> service_cb ( service , returned_msg ) ; } } } else { if ( service -> service_cb != 0 ) { if ( MsgAlloc_PullMsgFromLuosTask ( remaining_msg_number , & returned_msg ) == SUCCEED ) { service -> service_cb ( service , returned_msg ) ; } } else { remaining_msg_number ++ ; } } } MsgAlloc_UsedMsgEnd ( ) ; Luos_AutoUpdateManager ( ) ; last_loop_date = LuosHAL_GetSystick ( ) ; }
@brief Luos Loop must be call in project loop
 @param None
 @return None
@brief Luos Loop must be call in project loop @param None @return None
// check loop call time stat // We receive a reset detection // Reset the data reception context // look at all received messages // There is a message available find the service linked to it // check if this is a Luos Command // There is a possibility to receive in IT a reset_detection so check task before doing any treatement //check if this msg cmd should be consumed by Luos_MsgHandler // be sure the content of this message need to be managed by Luos and do it if it is. // Luos CMD are generic for all services and have to be executed only once // Clear all luos tasks related to this message (in case of multicast message) // Here we should not have polling services. // This message is for the user, pass it to the user. // This message is for a service // check if this continer have a callback? // This service have a callback pull the message // This message is for the user, pass it to the user. // finish msg used // manage timed auto update // save loop date