LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Posix Message queues? (https://www.linuxquestions.org/questions/programming-9/posix-message-queues-344932/)

jfitzger68 07-26-2005 10:59 AM

Okay, here it is. These are the declarations:

typedef struct {
long type;
cmd_types command;
state_types state;
char description[80];
} SmartHubMessage_T;

#define PROJECTOR_INBOX_SIZE 16
#define PROJECTOR_INBOX_FLAGS 0
const char PROJECTOR_INBOX_NAME[] = "/home/josh/hack/projQ";
struct mq_attr projInboxAttr;
mqd_t projectorInboxId;

And here's the code:

projInboxAttr.mq_maxmsg = PROJECTOR_INBOX_SIZE;
projInboxAttr.mq_msgsize = sizeof(SmartHubMessage_T);
projInboxAttr.mq_flags = PROJECTOR_INBOX_FLAGS;
projectorInboxId = mq_open(PROJECTOR_INBOX_NAME, O_CREAT|O_RDWR|O_EXCL, S_IRWXU, &projInboxAttr);
if (projectorInboxId == (mqd_t)-1) {
perror("\nSmartHub");
exit(-1);
}

Thanks!

rstewart 07-26-2005 12:09 PM

Well, I've done some testing using my FC3 based system and I have to tell you - I am still not impressed with POSIX message queues...:confused:

After looking at the behavior of a test program based upon your code snippets, along with the man pages, I think that when the man pages claim "implementation-defined" they mean "bug". What I eventually got to work was to use a message queue name of "/msgQ" (without any other path information). Also, I had to run the executable test program as root, running as a lowly user just error-ed out even if I granted all read/write/search permissions to the root "/" directory.

I hope that this helps you, it may not be the best solution but it looks like it should work for you as a workaround unless some other brave and knowing person can offer more insights. :D

jfitzger68 07-26-2005 12:26 PM

Thanks so much for looking at this.

In the end this application will run under the eCos Real-Time OS, and I can only hope that the implementation there will be more straightforward. I had hoped to develop the app under Linux to control for the complexities of the OS and focus more on the base application logic, bus alas it seems this is not to be. :(

Anyhow, I'll try your solution. Thanks so much once again.

jfitzger68 07-26-2005 12:38 PM

Your solution worked! UNIX is a strange world sometimes.

rstewart 07-26-2005 12:46 PM

Congratulations!

Good luck on the RTOS implementation. IMHO real-time embedded work is much more fun than "conventional" programming. Real-time; nice compact ,tight, and efficient organized chaos. :p

jfitzger68 07-26-2005 04:59 PM

I agree. I am a huge fan of efficient, compact chaos.


All times are GMT -5. The time now is 06:39 AM.