[Feature][ZXW-65]merged P49 base code
Change-Id: I3e09c0c3d47483bc645f02310380ecb7fc6f4041
diff --git a/ap/app/msg_test/msgrcv.c b/ap/app/msg_test/msgrcv.c
new file mode 100755
index 0000000..e3e69aa
--- /dev/null
+++ b/ap/app/msg_test/msgrcv.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+// Define message queue structure
+struct msg_buffer {
+ long msg_type;
+ char msg[100];
+} message;
+main(int argc,char *argv[]) {
+ key_t my_key;
+ int msg_id;
+ int ret;
+ my_key = atoi(argv[1]); //create unique key
+ msg_id = msgget(my_key, 0666 | IPC_CREAT); //create message queue and return id
+ printf("Message id: %d\n", msg_id);
+ ret = msgrcv(msg_id, &message, sizeof(message), 1, 0); //used to receive message
+ // display the message
+ printf("Received Message len is %d, message is : %s \n", ret, message.msg);
+ //msgctl(msg_id, IPC_RMID, NULL); //destroy the message queue
+ return 0;
+}