Ok seems to be ok ! That was finally stupid too…avan if after I read the doc again and again and did not see this ! Thanks.
is mq_timedreceive working with mqueue ?
Because …I launch my Queue on pc1 :
Driver App :
QDesc_ToInterface = mq_open( TO_INTERFACE_QUEUE_NAME, O_CREAT| O_RDWR,S_IRWXU | S_IRWXG | S_IRWXO,NULL);
On Pc2 : Photon App :
Initialisation : [code] printf("\t\tInterface : Opening Receiving Queue\n");
QDesc_ToInterface = mq_open( pcToInterfaceQueueName, O_RDONLY);// ,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,NULL);
with pcToInterfaceQName = “/net/pc1/dev/mqueueTO_INTERFACE_QUEUE_NAME”
if (QueueDescriptor_ToInterface != -1)
{
printf("\t\tInterface : Creating Receiving thread now.\n");
Ret = pthread_create(&ToInterface_ThreadPtr, NULL, &ToInterfaceTask ,NULL);
if (Ret !=EOK )
{
Error = errno;
printf("\t\tInterface : Error on Creating Receiving thread Error = %d. Errno = %d\n",Ret,Error);
}
else
{
pthread_mutex_init(&exit_mutex, NULL);
printf("\t\tInterface : Receiving Thread was created. (%d) \n ",ToInterface_ThreadPtr);
}
}
else
{
Error = errno;
printf("\t\tInterface : Invalid Receiving Queue errno = %d \n",Error);
}[/code]
Receiving Thread :
[code]while (bOk && !Error)
{
clock_gettime(CLOCK_REALTIME, &tm);
tm.tv_sec += 5;
printf("\t\tInterface : Ready to receive %d\n",tm.tv_sec );
MessageSize = mq_timedreceive( QueueDescriptor_ToInterface, buf, 4096, NULL,&tm );
if (MessageSize < 0)
{
printf("\t\tInterface : Nothing \n");
}
else
{
if (MessageSize < 4096)
{
buf[MessageSize] = 0;
}
else
{
buf[4096-1] = 0;
}
printf("\t\tInterface : buf = %s \n",buf);
if (bOk)
{
printf("\t\tInterface : Mutex ForceQuit %d\n",ForceQuit);
pthread_mutex_lock( &exit_mutex );
if (ForceQuit)
{
printf("\t\tInterface : ForceQuit \n");
bOk = 0;
}
pthread_mutex_unlock( &exit_mutex );
}
}
if (QDesc_ToInterface != -1)
{
printf("\t\tInterface : closing Receiving Queue\n");
mq_close(QDescriptor_ToInterface);
}[/code]
An the same machine…everuthing goes fine…
But on 2 Pcs… it blocks :
it goas 2 times in ready to receive (printf("\t\tInterface : Ready to receive %d\n",tm.tv_sec )
but seems to never go out of mq_timedreceive …strange…any idea on what I did wrong ?