[help]How to use message_attach

I’m really confused by the help of message_attach.
message_attach’s prototype is defined as :
message_attach(dispatch_t *dpp,message_attr_t *attr, int low ,int high, int
(*func)(
message_context_t *ctp, int code , unsigned flags, void *handle),void
*handle)
what do these parameters(int low, int high)mean? Which is refered as :the
range of messages that you’re interested in.
But what’s the range of messages? How to find the range of messages or when
will these range be satisfied? If I copy the example program of
message_attach and comment the message_attach sentence, I get the same
result as that of original program. Can anyone help me to illustrate how to
use message_attach? Thanks a lot!

johnsonyoung <johnsonyoung2002@yahoo.com.cn> wrote:

I’m really confused by the help of message_attach.
message_attach’s prototype is defined as :
message_attach(dispatch_t *dpp,message_attr_t *attr, int low ,int high, int
(*func)(
message_context_t *ctp, int code , unsigned flags, void *handle),void
*handle)
what do these parameters(int low, int high)mean? Which is refered as :the
range of messages that you’re interested in.
But what’s the range of messages? How to find the range of messages or when
will these range be satisfied? If I copy the example program of
message_attach and comment the message_attach sentence, I get the same
result as that of original program. Can anyone help me to illustrate how to
use message_attach? Thanks a lot!

It is a bit unclear.

Since you are working with a message-passing protocol, it is generally
assumed all messages will start out with some structure that looks kind
of like:

msg_hdr {
msg_type;
msg_len;
}

In particular when using/writing a resource manager, the messages must
start all start out with:

struct msg {
uint16_t type;

}

Now, the QNX library generates IO messages with this format, and all messages
it generates have a type field that ranges from IO_MIN to IO_MAX (256 to 511),
so your messages should not be in this range.

Now, when message_attach() is asking for a message range – it is saying
that for what values of type do you want the specified function called.

Or, say, you specify a min of 1000 and a max of 2000, then all messages
that are received with the first 16-bit int having a value in the range
of 1000 to 2000 will cause your function to be called.

Is that a bit clearer?

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com

Thanks a lot!

“David Gibbs” <dagibbs@qnx.com>

It is a bit unclear.

Since you are working with a message-passing protocol, it is generally
assumed all messages will start out with some structure that looks kind
of like:

msg_hdr {
msg_type;
msg_len;
}

In particular when using/writing a resource manager, the messages must
start all start out with:

struct msg {
uint16_t type;

}

Now, the QNX library generates IO messages with this format, and all
messages
it generates have a type field that ranges from IO_MIN to IO_MAX (256 to
511),
so your messages should not be in this range.

Now, when message_attach() is asking for a message range – it is saying
that for what values of type do you want the specified function called.

Or, say, you specify a min of 1000 and a max of 2000, then all messages
that are received with the first 16-bit int having a value in the range
of 1000 to 2000 will cause your function to be called.

Is that a bit clearer?

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com