Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Opening a message queue: (3 Items)
   
Opening a message queue  
Hi,

I am using a Freescale i.mx35 board. I try to open a mq queue.

I first issue the "mq" command on my board. I see that the directory /dev/mq appears.
Then I execute the code below. The call to mq_open returns error code 89 (ENOSYS)

What did I do wrong?

Note that the same code works for me when run from within a io_net shim driver.

Thanks.


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#include <mqueue.h>

#define QUEUE_MESSAGE_SIZE 2048

static mqd_t open_queue(char *name)
{
    mqd_t queue;
    struct mq_attr attr;

    printf("OPENING QUEUE %s\n", name);

    memset((void*)&attr, 0, sizeof(struct mq_attr));
    attr.mq_maxmsg  = 128;
    attr.mq_msgsize = QUEUE_MESSAGE_SIZE;

    queue = mq_open(name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR, &attr);
    if (queue == -1)
        printf("Couldn't open queue error is %s(%d)\n", strerror(errno), errno);

    return queue;
}

int main(int argc, char **argv)
{
    printf("MAIN!!!\n");

    open_queue("/tmpq");

    return 0;
}
Re: Opening a message queue  
I'm just taking a guess.

Have you read the docs on mq and mqueue implementation and the differences?
http://www.qnx.com/developers/docs/6.4.1/neutrino/technotes/managing_mq_mqueue.html
http://www.qnx.com/developers/docs/6.4.1/neutrino/utilities/m/mq.html

Specifically:
-----
In order to use the mq implementation, you must link your application(s) against the libmq library. In a manual build, 
specify the -l mq option; in automatic/recursive builds, use this setting in your common.mk file:

LIBS += mq

Note: 	When relinking applications to use the alternative implementation, be sure to change all affected components. We 
require such explicit intervention to use the alternate implementation because of potential incompatibilities if your 
code isn't strictly conforming to POSIX.
-----

Maybe this information will help.

Regards,

Eric
Re: Opening a message queue  
Hi Eric,

Thank you for you reply.
I already did what you suggested and it solved the problem.

Best regards,
Yuri

Eric Fausett wrote:
> I'm just taking a guess.
>
> Have you read the docs on mq and mqueue implementation and the differences?
> http://www.qnx.com/developers/docs/6.4.1/neutrino/technotes/managing_mq_mqueue.html
> http://www.qnx.com/developers/docs/6.4.1/neutrino/utilities/m/mq.html
>
> Specifically:
> -----
> In order to use the mq implementation, you must link your application(s) against the libmq library. In a manual build,
 specify the -l mq option; in automatic/recursive builds, use this setting in your common.mk file:
>
> LIBS += mq
>
> Note: 	When relinking applications to use the alternative implementation, be sure to change all affected components. 
We require such explicit intervention to use the alternate implementation because of potential incompatibilities if your
 code isn't strictly conforming to POSIX.
> -----
>
> Maybe this information will help.
>
> Regards,
>
> Eric
>
>
>
> _______________________________________________
>
> QNX Momentics Community Support
> http://community.qnx.com/sf/go/post46437
>
>
>