|
板凳

楼主 |
发表于 2019-8-8 16:32:49
|
只看该作者
我的代码:
#define HOST1 "HOST1"
#define HOST2 "HOST2"
#define DSP1 "DSP1"
#define DSP2 "DSP2"
while ( OK != iRet )
{
iRet = ARM_MessageQInit(HOST2, DSP2, &Module);
if ( OK != iRet )
{
LOG_Error("Thread2 ARM_MessageQInit(%s,%s) fail", HOST2, DSP2);
continue;
}
break;
}
int ARM_MessageQInit(char *v_HostName, char *v_pDspName, App_Module *v_pModule)
{
v_pModule->hostQue = NULL;
v_pModule->slaveQue = MessageQ_INVALIDMESSAGEQ;
v_pModule->heapId = App_MsgHeapId;
v_pModule->msgSize = sizeof(App_Msg);
MessageQ_Params msgqParams;
char msgqName[32] = {0};
MessageQ_Params_init(&msgqParams);
sprintf(msgqName,"%s:%s",v_HostName, App_MsgQueName);
//创建本地消息
v_pModule->hostQue = MessageQ_create(msgqName, &msgqParams);
if ( NULL == v_pModule->hostQue )
{
LOG_Error("MessageQ_create(%s) fail", msgqName);
return FAILED;
}
LOG_Info("MessageQ_create(%s) ok", msgqName);
//打开对端消息
memset(&msgqName,0x00,sizeof(msgqName));
int status;
sprintf(msgqName, "%s:%s",v_pDspName, App_MsgQueName);
do {
status = MessageQ_open(msgqName, &v_pModule->slaveQue);
LOG_Debug("open remote MessageQ(%s)", msgqName);
sleep(1);
} while (status == MessageQ_E_NOTFOUND);
if ( status < 0 )
{
LOG_Error("MessageQ_open(%s) fail", msgqName);
return FAILED;
}
LOG_Info("ARM_MessageQInit(%s ok", msgqName);
return OK;
}
3、概率很大,很容易就出现,跑几次就出现。前提是我之前提的那个问题:arm一个线程始终open不开dsp2的消息队列。 |
|