This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I'm trying to communicate between tasks using tirtos7. I've followed this tutorial : https://dev.ti.com/tirex/explore/node?node=A__ATOcjUy6zyynCMWH-Ys6Ng__com.ti.SIMPLELINK_ACADEMY_CC13XX_CC26XX_SDK__AfkT0vQ__LATEST&search=queues
I can compile and flash without any problem but when i it get to mq_receive or mq_send nothing happens. If i stop the program I see that it is stuck in Error_raiseX() especially in this error :
if (Error_policy_D == Error_SPIN) {
for(;;) {
}
}
Do you have any clue where I could be wrong ?
Message queue init :
mqAttrs.mq_maxmsg = MSG_NUM; mqAttrs.mq_msgsize = MSG_SIZE; mqAttrs.mq_flags = 0; mqdes = mq_open ("alarm", O_RDWR | O_CREAT, 0664, &mqAttrs); if (mqdes == (mqd_t)-1) { /* mq_open() failed */ while (1); } /* Construct writer/reader Task threads */ Task_Params_init(&taskParams); taskParams.stackSize = TASKSTACKSIZE; taskParams.stack = &task1Stack; taskParams.priority = 2; Task_construct(&task1Struct, (Task_FuncPtr)mainTask, &taskParams, (void *)&mqdes); taskParams.stack = &task2Stack; taskParams.priority = 1; Task_construct(&task2Struct, (Task_FuncPtr)task1Fxn, &taskParams, (void *)&mqdes);
MainTask:
mqd_t* mqdes = arg0; int msg = 5; mq_send(*mqdes , (char *)&msg, sizeof(msg), 0);
task1Fxn:
mqd_t *mqdes = arg0; int msg; while (1) { while (mq_receive(*mqdes, (char *)&msg, sizeof(msg), NULL) != -1) { GPIO_toggle(CONFIG_GPIO_LED_0); } }
Hi Alexis,
Can you put a breakpoint on mq_recieve(), and mq_send() then step over it. This way, you can check where the crash happens.
Regards,
Sid
It seems to be at the size check:
if (msg_len < (size_t)((msgQueue->attrs).mq_msgsize))
Update: If send a msg and then call the receive function directly in the main (not the task) it's working.
So it seems that the problem is in passing the mqd_t struct to the tasks.
Hi Alexis,
if (msg_len < (size_t)((msgQueue->attrs).mq_msgsize))
What is the value of mqAttrs.mq_msgsize = MSG_SIZE; in your code?
Have you added the same define, the size_of(int)
#define MSG_SIZE sizeof(int)
If it is stuck at the size check, please can you check what hte actual values passed to msg_len and mq_msgsize.
Regards,
Sid
Yes the MSG_SIZE is sizeof(int).
There is no value in it when I enter in mq_receive() in debug. Seems like the structure hasn't been correctly passed to the task/function.
Hi Alexis,
This is something I need to test, please expect an answer on Monday
Regards,
Sid
Hi Alexis,
I just followed the tutorial as is. I was able to make it work where the characters are echoed and when I type an "X", the led toggles as expected. Please make sure you have followed each step of the tutorial.
Regards,
Sid