Invalid Expression

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
dapaul@fireboy-xintex.com
Posts: 2
Joined: 15 May 2024 16:00

Invalid Expression

#1 Post by dapaul@fireboy-xintex.com » 16 May 2024 16:46

I'm somewhat new to programming. Trying to use this framework https://github.com/kiishor/UML-State-Ma ... ree/master

Getting invalid expression on: const state_t* pState = pState_Machine[index]->Event; right before the do loop.

Code: Select all

state_machine_result_t dispatch_event(state_machine_t* const pState_Machine[]
    , uint32_t quantity
#if STATE_MACHINE_LOGGER
    , state_machine_event_logger event_logger
    , state_machine_result_logger result_logger
#endif // STATE_MACHINE_LOGGER
)
{
    state_machine_result_t result;
    uint8_t index;
    // Iterate through all state machines in the array to check if event is pending to dispatch.
    for (index = 0; index < quantity;)
    {
        if (pState_Machine[index]->Event == 0)
        {
            index++;
            continue;
        }

        const state_t* pState = pState_Machine[index]->State;
        do
        {
#if STATE_MACHINE_LOGGER
            event_logger(index, pState->Id, pState_Machine[index]->Event);
#endif // STATE_MACHINE_LOGGER
            // Call the state handler.
            result = pState->Handler(pState_Machine[index]);
#if STATE_MACHINE_LOGGER
            result_logger(pState_Machine[index]->State->Id, result);
#endif // STATE_MACHINE_LOGGER

            switch (result)
            {
            case EVENT_HANDLED:
                // Clear event, if successfully handled by state handler.
                pState_Machine[index]->Event = 0;

                // intentional fall through

                // State handler handled the previous event successfully,
                // and posted a new event to itself.
            case TRIGGERED_TO_SELF:

                index = 0;  // Restart the event dispatcher from the first state machine.
                break;

#if HIERARCHICAL_STATES
                // State handler could not handled the event.
                // Traverse to its parent state and dispatch event to parent state handler.
            case EVENT_UN_HANDLED:

                do
                {
                    // check if state has parent state.
                    if (pState->Parent == NULL)   // Is Node reached top
                    {
                        // This is a fatal error. terminate state machine.
                        return EVENT_UN_HANDLED;
                    }

                    pState = pState->Parent;        // traverse to parent state
                } while (pState->Handler == NULL);   // repeat again if parent state doesn't have handler
                continue;
#endif // HIERARCHICAL_STATES

                // Either state handler could not handle the event or it has returned
                // the unknown return code. Terminate the state machine.
            default:
                return result;
            }
            break;

        } while (1);
    }
    return EVENT_HANDLED;
}

Post Reply

Return to “mikroC PRO for PIC General”