Pumpkin, Inc.

Pumpkin User Forums


If you can't make Salvo do what you want it to do, post it here.


Postby luben » Tue Feb 06, 2001 9:57 am


In the manual you wrote that OStypeMsgP are type const if OSENABLE_BIG_MESSAGE TRUE. But const type could be <const int> and <const char>. So, if I make
this will forward the address with two (not with one) if the type is <const int>.

So, if SALVO definition is <const int> and I want to access the data byte by byte I have to use other pointer of type const char, right?

From other side is not recommended to use other predefined type then OStypeMsgP. Is there some way to force and to ensure that the type is <const char>, when OSBIG_MESSAGES true.

Unfortunately I don't have the sources to look inside of them and to answer this question.


Posts: 324
Joined: Sun Nov 19, 2000 12:00 am
Location: Sofia, Bulgaria

Re: OStypeMsgP

Postby Salvo Tech Support » Wed Feb 07, 2001 9:31 am

Hi Luben.

The definition for OStypeMsg is located in portxyz.h. For PICmicro MCUs, here's what's in portpicc.h:

typedef void OStypeMsg;
typedef const OStypeMsg;


#define OStypeMsgP OStypeMsg *

It's important to note that since messages are passed by pointer, whether your message is a char or an int is irrelevant -- it's the size of the pointer that matters.

In PIC C, pointers to RAM (OSBIG_MESSAGE_POINTERS is FALSE) take one byte. Pointers to RAM and ROM (i.e. PIC C's const pointers, OSBIG_MESSAGE_POINTERS is TRUE) take two bytes. It doesn't matter if your messages are full of chars or ints -- if they're in RAM, the pointers will be one byte, and if they're in ROM+RAM, the pointers will be two bytes.

Salvo doesn't care what you point to -- it only keeps track of the message pointers, not the actual contents of the message.

So, the bottom line is that if you wish to have const objects in your messages, you must set OSBIG_MESSAGE_POINTERS to TRUE, and that will cause the message pointers in the event control blocks to be two bytes in size.

You must always and without exception cast your message pointers to OStypeMsgP. Do not change the typedefs for OStypeMsg or OStypeMsgP -- it's unnecessary and will break the code. With OStypeMsgP you can place anything in a message. When you extract the message, then use the correct type (i.e. the one you're intending to use for this particular message). Please see AN-3 Salvo, Banked Objects and the HI-TECH PIC C Compiler for some more info on this matter.

Here's an example, with OSBIG_MESSAGE_POINTERS is TRUE:

const char cmd1 'b';
const char cmd2 'e';

/* signal a 'b' for "begin" */
OSSignalMsg(MSG_P, (OStypeMsgP) &cmd1);
/* signal an 'e' for "end" */
OSSignalMsg(MSG_P, (OStypeMsgP) &cmd2);

void Task ( void )
char cmd;
OStypeMsgP msgP;

for (;;) {
OSWaitMsg(MSG_P, &msgP, timeout, label);

cmd = * (const char *) msgP;

switch ( cmd ) {
case 'b':
/* begin action */

case 'e':
/* end action */

/* error -- unknown command */

cmd in Task() is (obviously) not a const, but it does receive the value of the message (either 'a' or 'e'). You could change all the const char to const int (and Task()'s cmd to an int) and the program would behave identically -- the only change is that the storage requirements for cmd, cmd1 and cmd2 would rise to accomodate the larger type. But Salvo's memory requirements would not change.

[This message has been edited by Salvo Tech Support (edited February 07, 2001).]

Salvo Technical Support
Please request all tech support through the Forums.
Salvo Tech Support
Posts: 173
Joined: Sun Nov 19, 2000 12:00 am

Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest