Hi, we're porting code from a CMSIS-RTOS environment to embOS ver 4 and are having trouble with inter-thread messaging.
We've put in place code to perform the same as the code example at this link, section "Code Example".
That code essentially demonstrates how two threads can send a mail message via osMailPut (Thread 1) to another (Thread 2) and intercept the message via osMailGet and act upon it.
Do you have a code snippet to do the same using embOS APIs, showing the complete workflow just like the link above?
All our attempts to do the exact same have failed so far, where OS_PutMail generates a runtime exception.
Thanks!
Damien.

[SOLVED] inter-thread messaging problem with OS_PutMail
-
-
Dear Damien,
do you already have an embOS license?
Why do you use embOS V4? The latest embOS version is 5.18.0.Would it be possible to share your code? You don't need to publish it here, but you can also contact us directly:
https://www.segger.com/doc/UM01001_embOS.html#SupportA basic embOS mailbox sample application OS_Mailboxes.c can be found in every BSP in the embOS shipment:
Code
Display More#define MAX_MSG_SIZE (8) // Max. number of bytes per message #define MAX_MSG_NUM (2) // Max. number of messages per Mailbox static OS_STACKPTR int StackHP[128], StackLP[128]; // Task stacks static OS_TASK TCBHP, TCBLP; // Task control blocks static OS_MAILBOX MyMailbox; static char MyMailboxBuffer[MAX_MSG_SIZE * MAX_MSG_NUM]; static void HPTask(void) { char aData[MAX_MSG_SIZE]; while (1) { OS_MAILBOX_GetBlocked(&MyMailbox, (void *)aData); OS_COM_SendString(aData); } } static void LPTask(void) { while (1) { OS_MAILBOX_PutBlocked(&MyMailbox, "\nHello\0"); OS_MAILBOX_PutBlocked(&MyMailbox, "\nWorld!\0"); } } int main(void) { OS_Init(); // Initialize embOS OS_InitHW(); // Initialize required hardware OS_TASK_CREATE(&TCBHP, "HP Task", 100, HPTask, StackHP); OS_TASK_CREATE(&TCBLP, "LP Task", 50, LPTask, StackLP); OS_MAILBOX_Create(&MyMailbox, MAX_MSG_SIZE, MAX_MSG_NUM, &MyMailboxBuffer); OS_COM_SendString("embOS OS_Mailbox example"); OS_COM_SendString("\n\nDemonstrating message passing\n"); OS_Start(); // Start embOS return 0; }
However, if necessary, I can also create a sample application like the CMSIS sample application.
Best regards,
Til
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!