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.

syslink messageq sample oddity



Some code in the messageq sample looks like it's not doing what you intended, although it "works" as is.  For clarity, consider fixing it up.

Int32 MessageQApp_writePattern(Ptr bufPtr, UInt32 offset, UInt32 bufSize, Int32 key)

is called like this:

    status = MessageQApp_writePattern(
      msg, sizeof(MessageQ_MsgHeader),
      (MessageQ_getMsgSize(msg) - sizeof(MessageQ_MsgHeader)),
      rProcId + PATTERNKEY);

which makes it look like the intention was to fill the entire message (after the header) with a byte pattern,

but it really only writes byte pattern in the middle bytes

    for (charCount = offset; charCount < bufSize - 2; charCount++) // <-- you mean "< offset + bufSize - 1"?
    {
      pattern += key;
      buffer[charCount] = pattern;
    }
    buffer[bufSize] = '\0'; // <-- you mean "buffer[charCount]" or "buffer[offset + bufSize - 1]"?
    Cache_wbInv((Ptr) buffer, bufSize, Cache_Type_ALL, TRUE); <-- you mean "buffer + offset"?

The call to Cache_inv in MessageQApp_readPattern is similarly off.

  • Elron,

    This code does indeed look incorrect, as you have pointed out.  The plan is to eventually replace these examples with better ones.  If you have one of the more recent versions of SysLink, under <SYSLINK_INSTALL_DIR>/examples/archive, you should see a list of platforms.  For your platform, there should be a zip file named ex02_messageq.zip, which you can look at.

    Thanks,

        Janet