Skip navigation.
Home
The QNX Community Portal

View topic - Message Queue and Photon

Message Queue and Photon

For discussion of realtime and/or embedded programming.

Message Queue and Photon

Postby pault » Wed Dec 08, 2010 9:46 am

Hello,

I'm kind of a newbie on Qnx...

I'm trying to develop a little interface (some text boxes and buttons) in order to control a driver I'm developing....

So I was trying to develop a Photon Application and to exchange data with my driver application through message queues...

But if my driver succeeds in creating a queue, the Photon App never achieves to open it...(errno = 2 on mq_open)

So I tried just to create by the Photon App... impossible : ErrNo = ENOSYS !

Anybody could help me please with this ?
Thanks

Paul

PS : Don't know if this was more a GUI Topic rather than here...but seems more logical to be here...
pault
New Member
 
Posts: 6
Joined: Wed Dec 08, 2010 9:33 am

Postby Tim » Wed Dec 08, 2010 2:30 pm

Pault,

Can you post the code you use to open the mqueue queues. Both in your driver and in the Photon app.

Hard to tell what's wrong without seeing the code.

Tim
Tim
Senior Member
 
Posts: 1390
Joined: Wed Mar 10, 2004 12:28 am

Postby pault » Wed Dec 08, 2010 2:52 pm

Hello Tim,

Thanks for your answer... fuuny it came the same time I found my mistake...and I'm a little bit ashamed of it !
In my Photon App I forgot to include LIBS += mq ....on the other hand I did it in my driver App...
And so the Photon App was trying to use the mq queue server as the driver was using mqueue queue server... which was the only one running...
A stupid error but it took some time to discover it !
Anyway perhaps my experience will help some other newbie !
Thanks again for trying to help !
pault
New Member
 
Posts: 6
Joined: Wed Dec 08, 2010 9:33 am

Postby maschoen » Wed Dec 08, 2010 4:04 pm

A majority of problems are of this type, however discovering the problem often requires a more sophisticated investigation. That or someone looking over your shoulder.
maschoen
QNX Master
 
Posts: 2644
Joined: Wed Jun 25, 2003 5:18 pm

Postby pault » Thu Dec 09, 2010 1:55 pm

Yeah right !
Unfortunately, I'm coming again searching for some help...let's hope that won't be as stupid as before...;)

So I managed to make my driver app and my photon app discuss...

Next step is so to have my driver app on a computer which can carry the card I want to "drive" ...and the Photon app on a VmWare on my computer...

On each machine I did a "mount -T io-pkt lsm-qnet.so" so that they appear in /net (let's say pc1 and pc2 )

Nom my problem is : DriverApp open and creates a queue : "/FromInterface" with : (it's on pc1)
Q_FromInterface = mq_open( "/FromInterface", O_CREAT| O_RDONLY ,S_IRWXU | S_IRWXG | S_IRWXO,NULL);

and the PhotonApp tries to open it :
Q_Out = mq_open( "/net/pc1/dev/mq/FromInterface", O_WRONLY);

it never connects ! Always an errno = 2 ...

Am I missing something that is possible on a single machine that cannot be done on 2 ? Thanks for any tip

Paul
pault
New Member
 
Posts: 6
Joined: Wed Dec 08, 2010 9:33 am

Postby maschoen » Thu Dec 09, 2010 7:33 pm

I'm not sure about this, but I think that mq may not support queues across the network like this, although mqueue will.
mqueue would be slightly slower, but an insignificant amount given that you will have network transmission delay.
maschoen
QNX Master
 
Posts: 2644
Joined: Wed Jun 25, 2003 5:18 pm

Postby pault » Fri Dec 10, 2010 10:24 am

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 :
Code: Select all
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: Select all
        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);
        }


Receiving Thread :
Code: Select all
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);
    }



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 ?
pault
New Member
 
Posts: 6
Joined: Wed Dec 08, 2010 9:33 am

Postby maschoen » Fri Dec 10, 2010 5:46 pm

pault wrote:is mq_timedreceive working with mqueue ?


Yes. You should check the help under "Managing POSIX Message Queues" for differences between mqueue and mq.

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 ?


It sounds like something is different on how the two systems are setup.
maschoen
QNX Master
 
Posts: 2644
Joined: Wed Jun 25, 2003 5:18 pm


Return to Realtime and Embedded

Who is online

Users browsing this forum: No registered users and 1 guest