45 lines
912 B
C
45 lines
912 B
C
|
|
|
|
|
|
|
|
|
|
GWEN_MSG *AQH_CmdDataIpc_WaitForSpecificIpcMessage(GWEN_MSG_ENDPOINT *epTcp, int msgCode, int timeoutInSeconds)
|
|
{
|
|
time_t startTime;
|
|
|
|
startTime=time(NULL);
|
|
|
|
for (;;) {
|
|
GWEN_MSG *msg;
|
|
time_t now;
|
|
|
|
while( (msg=GWEN_MsgEndpoint_TakeFirstReceivedMessage(epTcp)) ) {
|
|
uint16_t code;
|
|
|
|
code=GWEN_IpcMsg_GetCode(msg);
|
|
if (code==msgCode) {
|
|
DBG_INFO(NULL, "Received expected IPC message");
|
|
return msg;
|
|
}
|
|
else if (code==AQH_MSGTYPE_IPC_DATA_RESULT) {
|
|
DBG_INFO(NULL, "Received IPC result message");
|
|
return msg;
|
|
}
|
|
else {
|
|
DBG_INFO(NULL, "Received unexpected message %d (%x)", code, code);
|
|
}
|
|
GWEN_Msg_free(msg);
|
|
}
|
|
now=time(NULL);
|
|
if (now-startTime>timeoutInSeconds) {
|
|
DBG_INFO(NULL, "Timeout");
|
|
break;
|
|
}
|
|
GWEN_MsgEndpoint_IoLoop(epTcp, 2000); /* 2000 ms */
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
|