我无法使用perfix的机制在QNX中的进程之间实现消息传递。我尝试了很多方法但都徒劳无功。
#define PREFIX_POSITION "stat_pos"
char receiveBuffer = 0;
char replyBuffer[25];
name_attach_t *positionPrefix;
dispatch_t *dpp;
int rcvid;
dpp = dispatch_create();
if (positionPrefix = name_attach(NULL, PREFIX_POSITION, 0) == NULL){
printf("prefix - null\n");
return EXIT_FAILURE;
}
positionPrefix = name_attach(dpp, PREFIX_POSITION, 0);
while(true){
rcvid = MsgReceive(positionPrefix->chid, &receiveBuffer, sizeof(receiveBuffer), NULL);
switch(receiveBuffer){
case 'Q':
//Do something
break;
case 'H':
//Do something
break;
case 'D':
//Do something
break;
case 'S':
//Do something
break;
}
MsgReply(rcvid, REPLY_INDEX, &replyBuffer, sizeof(replyBuffer));
receiveBuffer = 0;
}
return 0;
}
name_attach ()
函数始终返回null。可能是什么问题?