As I am a newbie in IPC domain and facing tons of issues. I have gone through examples and I have learned a lot. There is problem when I try to run my own code I face lot of issues. At present I am stuck at a issue. I can't comprehend what I am doing wrong . But I couldn't find any thing
My work flow is as:
ARM side
1- Create messageq with name HOSTQ
while(1)
{
3-declare Message1,Message2
4-alloc Message1
5- Put Message1 to DSPQ
6- get Message2 from HOSTQ
7- free Message2
}
DSP side
1- Create messageq with name DSPQ
while(1)
{
3-declare Message1,Message2
4- get Message2 from DSPQ
5- free Message2
6- alloc Message1
7- Put Message1 to HOSTQ
}
When I load DSP program using mpmcl utility to all dsps.
then I run ARM side code on linux.
I am able to see only ones message coming from DSP0. after one message No other messages are recieved while It should keep sending and receving messages.
Similar situation is on ARM side.
What could be wrong in this scenario.
Please help me in this regard.
Can somebody say something other than running example codes.
I am attaching code here by.
DSP Code
void create_messageQ()
{
MessageQ_Handle messageQDSP0;
MessageQ_Params messageQParamsDSP0;
char QueueName[64];
MessageQ_QueueId ARMQ_Id;
Int status;
int flag =0;
int counter = 0;
System_sprintf(QueueName, "%s_%s", "SLAVE_DDR",
MultiProc_getName(MultiProc_self()));
// Create MessageQ with name DSP0Q
MessageQ_Params_init(&messageQParamsDSP0);
System_printf("Parameter Done \n");
messageQDSP0 = MessageQ_create(QueueName, &messageQParamsDSP0);
if (messageQDSP0 == NULL)
{
System_abort("MessageQ_create failed\n");
}
System_printf("created MessageQ with QueueID: 0x%x\n",MessageQ_getQueueId(messageQDSP0));
while(1)
{
if(MultiProc_self() == 1){
// getting Message from ARM
System_printf("Waiting for ARM to send \n");
MessageQ_Msg MsgDSP0, MsgDSP1;
System_printf("Number of messages in Queue are %d \n", MessageQ_count(messageQDSP0));
do{
Task_sleep(1);
status = MessageQ_get(messageQDSP0, &MsgDSP0, MessageQ_FOREVER);
//System_printf("Queue Empty \n");
}
while(status != MessageQ_S_SUCCESS);
System_printf("Message has info of 0x%x \n", (( MsgObj*)MsgDSP0)->info );
// replying to ARM
if(flag == 0)
{
do
{
System_sprintf(QueueName, "%s_%d", "HOST_DDR",MultiProc_self());
status= MessageQ_open (QueueName, &ARMQ_Id);
System_printf("Failed due to ERROR: %d \n", status);
}
while (status != MessageQ_S_SUCCESS);
System_printf("Opened MessageQ with QueueID: 0x%x\n", ARMQ_Id);
flag = 1;
}
Task_sleep(500*MultiProc_self());
MsgDSP1 = MessageQ_alloc(0, sizeof(MsgObj));
if(MsgDSP1 == NULL)
{
System_abort("Failed to Allocate Message on Heap \n");
}
((MsgObj*)MsgDSP1)->DSP = MultiProc_self();
((MsgObj*)MsgDSP1)->info = counter++;
MessageQ_setReplyQueue (messageQDSP0, MsgDSP1);
if(MessageQ_put(MessageQ_getReplyQueue(MsgDSP0), MsgDSP1) < 0)
System_abort("Failed to Put Message on HOST_DRR MessageQ\n");
status = MessageQ_free((MessageQ_Msg)MsgDSP0);
}
}
}
ARM side Code
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <ti/ipc/Std.h>
#include <ti/ipc/Ipc.h>
#include <ti/ipc/MessageQ.h>
#include <pthread.h>
#include <ti/ipc/interfaces/INetworkTransport.h>
#include <ti/ipc/interfaces/ITransport.h>
#include <ti/ipc/transports/TransportRpmsg.h>
/*
*Message Structure for MessageQ
*/
typedef struct MsgObj {
MessageQ_MsgHeader header;
int8_t DSP;
int info;
} MsgObj;
/*
*Globals
*/
MessageQ_Params msgParams;
MessageQ_Handle g_ddrMsgHandle;
Int status;
MessageQ_QueueId g_remoteQueueId_temp = (MessageQ_QueueId)0x10080;
int counter =0;
char HostQName [50];
void func_1()
{
/*while(1)
{*/
sleep(1);
MessageQ_Msg msg = (MessageQ_Msg) NULL;
msg = MessageQ_alloc(0, sizeof(MsgObj));
if (msg == NULL)
{
printf("<P>Cannot Alloc message from HEAP \n ");
Ipc_stop();
exit(EXIT_FAILURE);
}
((MsgObj*)msg)->info = 0xc000000 + counter*0x1000; // Alloc
((MsgObj*)msg)->DSP = 0;
counter++;
MessageQ_setMsgId(msg, 0);
MessageQ_setReplyQueue(g_ddrMsgHandle, msg);
if(MessageQ_put(g_remoteQueueId_temp , msg) != 0 )
printf("<P>Message Put Failed with info %d\n ", ((MsgObj*)msg)->info);
//}
}
/*
*Reader Thread for ARM
*/
void func_2(void* CoreNum)
{
/* Create the local Message Queue for receiving. */
MessageQ_Params_init(&msgParams);
sprintf(HostQName, "HOST_DDR_%d", (*((int*)CoreNum)));
g_ddrMsgHandle = MessageQ_create(HostQName, &msgParams);
if (g_ddrMsgHandle == NULL)
{
printf("Error in MessageQ_create\n");
pthread_exit(-1);
}
printf("MessageQ ARM is created with ID 0x%x \n", MessageQ_getQueueId(g_ddrMsgHandle));
while(1)
{
func_1();
sleep(1);
MessageQ_Msg MsgDSP0;
status = MessageQ_get(g_ddrMsgHandle, &MsgDSP0, MessageQ_FOREVER);
if(status != MessageQ_S_SUCCESS)
printf("Message get failed \n");
printf("Message has info of %d from DSP %d\n", (( MsgObj*)MsgDSP0)->info, (( MsgObj*)MsgDSP0)->DSP );
g_remoteQueueId_temp = MessageQ_getReplyQueue(MsgDSP0);
status = MessageQ_free((MessageQ_Msg)MsgDSP0);
if(status != 0)
printf("Message free failed \n");
}
}
/*
*Writer Thread for ARM
*/
/*
*Main Entry Point
*/
int main(void)
{
int iret1,iret2;
int32_t status;
pthread_t thread[8];
pthread_attr_t attr;
int i[8] = {1,2,3,4,5,6,7,8};
Ipc_transportConfig(&TransportRpmsg_Factory);
do
{
printf("<P1>Starting IPC \n ");
status = Ipc_start();
}
while (status < 0);
printf("<P2>Started IPC \n ");
func_2(&i[0]);
}