2

I have a problem because I don't know how _pulse receiving works. If I have my data struct

typedef struct _my_data {
msg_header_t hdr;
int data;
} my_data_t;

and I am receiving only my msg I cant tell if it is a pulse

my_data_t msg;
...
rcvid = MsgReceive(g_Attach->chid, &msg, sizeof(msg), NULL);

when rcvid = 0 BUT how a program knows that it need to send _pulse in a form of msg (struct that I defined) or else how does it work. In addition is _IO_CONNECT a pulse? If yes why doesn't it have rcvid==0? - according to http://www.qnx.com/developers/docs/6.3.2/neutrino/lib_ref/n/name_attach.html

user3613919
  • 777
  • 1
  • 7
  • 17
  • OK, according to http://www.qnx.com/developers/docs/qnxcar2/index.jsp?topic=%2Fcom.qnx.doc.neutrino.technotes%2Ftopic%2Fasync_messaging_Example6.html _IO_CONNECT is not an error, not a pulse, therefor a message (system message I suppose). But still I dont know how is MsgReceive identify my struct. – user3613919 Oct 27 '15 at 00:34

2 Answers2

1

You need to create channel and connection, for example

chid=ChannelCreate(0);
int pid=getpid();
coid=ConnectAttach(0, pid, chid, 0, 0);

and attach channel to connection.............

Then if you have two threads...............from one thread you can to call MsgSend function, for example MsgSend(coid, &(message), sizeof(message), &rmsg, sizeof(rmsg)); and in the other thread rcvid=MsgReceive(chid, (void*)&message, sizeof(message),NULL);

1

1 - _IO_CONNECT is not used for pulse. Its used for connect system call to resource managers. Example system calls are open(), close(), etc.

2 - You need to know whether the server or client is waiting on pulse message or not. For pulse message the blocking function in the resource manager will be MsgReceivePulse() and the client will use MsgSendPulse().

MsgSend() is used for normal message and MsgSendPulse() is for sending pulse message. Similarly MsgReceive() is used for receiving normal message and MsgReceivePulse() is used for receiving pulse messages. Please refer to the QNX documents for more detailed description.

Both variants have different parameters like the functions for pulse messages do not have any parameter for return data because pulses are non blocking small messages which do not block for any reply but functions for normal messages have parameters for receive data.

Shaibal
  • 907
  • 8
  • 18