This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can anyone explaine this logic?

while (1)
    {
        USARTdrv->Receive(&cmd, 1);          /* Get byte from UART */
        osSignalWait(0x01, osWaitForever);
        if (cmd == 13)                       /* CR, send greeting  */
        {
          USARTdrv->Send("\nHello World!", 12);
          osSignalWait(0x01, osWaitForever);
        }

    }

So the USARTdrv->Receive and the osSignalWait need to be ran over and over? Is the osSignalWait not sufficient by itself?

I'm trying to make this work but I see nothing that explains how it works. If the signal is set in

if (event & mask) { /* Success: Wakeup Thread */

then how is this checked in a loop? I figured this line just loops until met? osSignalWait(0x01, osWaitForever);

Is that not how it works?

  • If cmd can change outside normal program flow, ie across the osSignalWait() call, it should be defined as being volatile, especially if it is a local/auto variable where the compiler assumes other subroutines won't be changing it.

    If in doubt with things, look at the compiled code, and review the logic the CPU is applying..