Hi I recently ported QP 5.1 to the PSOC5 series of chips. I have having some trouble getting my events to materialize using Q_NEW(). The error that I get is is listed as "line 70" in qf_new(), caught by the assert that "Cannot run out of registered pools". This means that my event pool is too small to contain my event according to the Practical UML Statechart book, which is hard to belive since my event is the smallest even possible (code example shown below).
Listing below is the main.c file, shows how I initialize the pool and the state machine. SMALLPOOLSIZE is defined as 100U.
//Qp Events and Queues
static QEvt const *l_mainFsmQueueSto[32]; //storage for events, up to this many ADC service requests can be made
static union SmallEvent {
void *min_size;
AdcEvt ae;
//other event types go into this pool
} l_smlPoolSto[SMALLPOOLSIZE];
//subscriber list declaration
static QSubscrList l_subscrSto[MAX_PUB_SIG];
int main()
{
//instance main FSM
MainFsm_ctor();
//init board level
BSP_init();
//init framework
QF_init();
//init subscriber/publisher
QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));
//init event pools
QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));
//init main FSM
QActive_start(AO_MainFsm,
1,
l_mainFsmQueueSto, Q_DIM(l_mainFsmQueueSto),
(void *)0, 0U, (QEvt *)0);
//start main FSM
return QF_run();
}
Listing below is the Event struct, as you can see, it contains just the super object, and is as small as can be.
//create simple event for signaling that an SPI ADC needs servicing
typedef struct AdcEvtTag{
QEvt super;
}AdcEvt;
Listing below is the dynamic even reservation code, inside the ISR. The assert halts the process inside Q_NEW, and says that there's not a registered pool sized for the event.:
Am I doing somewrong? Is there something that I've forgotten? I have tried increasing the size of a "SmallEvent" object, by forming the union with a larger dummy event, but the same error occurs. I'm thinking there must be something else that I am doing wrong. Any hints?
Thanks for any help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Aren't assertions the best thing since sliced bread? I mean, imagine that the error was "silently ignored". Would you find it so quickly?
On a side note, I wouild highly recommend to upgrade your QP to the latest version (5.8.2 at this writing). There were some important bug fixes (especially for Cortex-M ports) since the version 5.1, as you can read in the QP/C Revision History.
--MMS
Last edit: Quantum Leaps 2017-02-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi I recently ported QP 5.1 to the PSOC5 series of chips. I have having some trouble getting my events to materialize using Q_NEW(). The error that I get is is listed as "line 70" in qf_new(), caught by the assert that "Cannot run out of registered pools". This means that my event pool is too small to contain my event according to the Practical UML Statechart book, which is hard to belive since my event is the smallest even possible (code example shown below).
Listing below is the main.c file, shows how I initialize the pool and the state machine. SMALLPOOLSIZE is defined as 100U.
Listing below is the Event struct, as you can see, it contains just the super object, and is as small as can be.
Listing below is the dynamic even reservation code, inside the ISR. The assert halts the process inside Q_NEW, and says that there's not a registered pool sized for the event.:
Am I doing somewrong? Is there something that I've forgotten? I have tried increasing the size of a "SmallEvent" object, by forming the union with a larger dummy event, but the same error occurs. I'm thinking there must be something else that I am doing wrong. Any hints?
Thanks for any help.
Issue resolved, event was triggering before QF_poolInit() was called
Aren't assertions the best thing since sliced bread? I mean, imagine that the error was "silently ignored". Would you find it so quickly?
On a side note, I wouild highly recommend to upgrade your QP to the latest version (5.8.2 at this writing). There were some important bug fixes (especially for Cortex-M ports) since the version 5.1, as you can read in the QP/C Revision History.
--MMS
Last edit: Quantum Leaps 2017-02-24