“Peter Stoeckigt” <stoeckigt.p@stn-atlas.de> wrote:
Hi,
if I have a multiple device resmgr, lets say ‘/dev/hw0’ and ‘/dev/hw1’, how
can I bind messages received by message_attach() to that specific device
(hw0 or hw1)?
With message_attach(), you can’t.
How do I get the corresponding resmgr_attr_t structure I
passed to resmgr_attach()?
With message_attach() I can’t.
But, in the resmgr_iofuncs_t structure, there is a “msg” callback
for handling messages with a type _IO_MSG. This is a “normal” iofuncs
callback, so all of the client → ocb lookup has been done, and your
callback gets passed an ocb. The ocb includes a pointer to the
attribute structure.
resmgr side:
resmgr_iofuncs_t io_funcs;
…
io_funcs.read = my_read_handler;
io_funcs.msg = my_msg_handler;
resmgr_attach(… );
int my_msg_handler( resmgr_context_t *ctp, io_msg_t *msg, RESMGR_OCB_T *ocb)
{
handle message here
MsgReply()
return( _RESMGR_NOREPLY );
}
client side:
struct {
struct _io_msg hdr;
…
} my_msg;
my_msg.hdr.type = _IO_MSG;
my_msg.hdr.combine_len = sizeof( my_msg.hdr );
my_msg.hdr.mgrid = _IOMGR_PRIVATE_BASE;
my_msg.hdr.subtype = your_msg_type;
/* fill in rest of data */
MsgSend( fd, &my_msg, sizeof(my_msg), … );
Basically:
– message_attach() is for non-fd (filename/pathname/device) oriented
messaging, perhaps from an agent process
– _IO_MSG is for out-of-band messaging associated with an fd (device)
-David
QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.