QPCPP QM state machine SIGNAL POST

Hi,
I'm using QM State Machine modeling for Arduino Due, but I´m not sucessful in posting or dispatching a signal from one state of an AO1 to another state in AO2, like I used to do with Arduino Uno and QPN

QACTIVE_POST((QActive *)&AO_AO2, CMD_SIG, 0U); in QPN.

For QPCPP, it may be AO2->post() or AO2->dispatch()...
I need more examples, but not DPP or BLINKY because they don´t pass signals from one AO to another.

blinkLED-sam.ino (7.8 KB)
blinky.hpp (1.9 KB)
bsp.cpp (7.9 KB)
bsp.hpp (1.4 KB)

Please examine the DPP example a bit closer because it demonstrates both posting and publishing events. For example, the "Philo" Active Object (AO) posts an event to the "Table" AO in the entry action to state "hungry":

TableEvt *pe = Q_NEW(TableEvt, HUNGRY_SIG);
pe->philoNum = PHILO_ID(this);
AO_Table->POST(pe, this);

And here is how a "Philo" AO publishes an event to "Table" in the exit action from state "eating":

TableEvt *pe = Q_NEW(TableEvt, DONE_SIG);
pe->philoNum = PHILO_ID(this);
QP::QF::PUBLISH(pe, this);

Please note that in QPCPP, you typically work with pointers to AOs (e.g., AO_Table->POST()), whereas in QPN you work with whole objects (QACTIVE_POST((QActive *)&AO_AO2...)). Please note the absence of the address-of operator (AO_Table->) in QPCPP.

Finally, regarding direct synchronous dispatching of events, you typically should not need to do this for Active Objects. Direct dispatching is for passive state machines, such as "Orthogonal Components", but this is a bit more advanced concept.

I hope this helps.
--MMS

I have TableEvt: QEvt and also added in AO1 substate entry:

TableEvt *pe = Q_NEW(TableEvt, CMD_SIG);
AO2->POST(pe, this);

Arduino Due compilation is successful but running the Due freezes.

I´ve tried DPP example using Arduino Due and QPCPP, with some POST additions, but when running Arduino Due it freezes. Still a mistery for me.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.