[SOLVED] inter-thread messaging problem with OS_PutMail

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • [SOLVED] inter-thread messaging problem with OS_PutMail

      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.
    • 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:

      A basic embOS mailbox sample application OS_Mailboxes.c can be found in every BSP in the embOS shipment:

      Source Code

      1. #define MAX_MSG_SIZE (8) // Max. number of bytes per message
      2. #define MAX_MSG_NUM (2) // Max. number of messages per Mailbox
      3. static OS_STACKPTR int StackHP[128], StackLP[128]; // Task stacks
      4. static OS_TASK TCBHP, TCBLP; // Task control blocks
      5. static OS_MAILBOX MyMailbox;
      6. static char MyMailboxBuffer[MAX_MSG_SIZE * MAX_MSG_NUM];
      7. static void HPTask(void) {
      8. char aData[MAX_MSG_SIZE];
      9. while (1) {
      10. OS_MAILBOX_GetBlocked(&MyMailbox, (void *)aData);
      11. OS_COM_SendString(aData);
      12. }
      13. }
      14. static void LPTask(void) {
      15. while (1) {
      16. OS_MAILBOX_PutBlocked(&MyMailbox, "\nHello\0");
      17. OS_MAILBOX_PutBlocked(&MyMailbox, "\nWorld!\0");
      18. }
      19. }
      20. int main(void) {
      21. OS_Init(); // Initialize embOS
      22. OS_InitHW(); // Initialize required hardware
      23. OS_TASK_CREATE(&TCBHP, "HP Task", 100, HPTask, StackHP);
      24. OS_TASK_CREATE(&TCBLP, "LP Task", 50, LPTask, StackLP);
      25. OS_MAILBOX_Create(&MyMailbox, MAX_MSG_SIZE, MAX_MSG_NUM, &MyMailboxBuffer);
      26. OS_COM_SendString("embOS OS_Mailbox example");
      27. OS_COM_SendString("\n\nDemonstrating message passing\n");
      28. OS_Start(); // Start embOS
      29. return 0;
      30. }
      Display All
      However, if necessary, I can also create a sample application like the CMSIS sample application.

      Best regards,
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.