This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

messageQ



平台是C6657,想用qmss从core1发一个数据到core0,自定义了一个结构体,主要代码如下:

typedef struct Msg{
MessageQ_Msg msg;
int a;
}Message;

Message *message;

if (selfId == 1) {
while(1){
message = (Message *)MessageQ_alloc(HEAP_ID, sizeof(Message));
if (message == NULL) {
System_abort("MessageQ_alloc failed\n");
}

message->a = 10000;
/* Kick off the loop */
int i;
for(i=0;i<10000000;i++);
status = MessageQ_put(nextQueueId, (MessageQ_Msg)message);
if (status < 0) {
System_abort("MessageQ_put failed\n");
break;
}
else{
System_printf("put success\n");
}}
}

else if(selfId == 0){
System_printf("core 0 for getting\n");
while(1){
status = MessageQ_get(messageQ, (MessageQ_Msg*)&message, MessageQ_FOREVER);
if (status < 0) {
System_abort("MessageQ_get failed\n");
break;
}
else{
System_printf("get success,status = %d\n",status);
}
int out;
out = message->a;
System_printf("get %d\n",out);
MessageQ_free((MessageQ_Msg)message);}
}

数据可以发送,但取出来的数据错误,不管发送的数据是多少,每次显示的都是相同的一个数,请问是哪儿出问题了?

  • 根据alloc分配的地址在memory中看到的message对应地址的数据是否赋值成功呢,另外对MessageQ_Msg msg赋不同的值然后在接收侧查看是否能够接收到呢。

  • Andy Yin1:

    您好!我把自定义的数组个数扩到了5个,即num[5],分别赋了值,并查看了对应memory中的数据,发现只有num[3]对应的数据赋值失败,且一直是0,其余均赋值正确。而在接收端,只有num[0]接收失败,并且读出来的数与对应位置上的数不同,即num[0]对应地址中的数为0x0007d580,而打印出来的数为0x00836cdc。请问会是什么原因?

    还有我不是很理解给MessageQ_Msg msg赋值的意思,因为资料里说不要在程序中修改MessageQ_Msg msg的,请问该怎么办?

  • alloc分配的地址怎么看?是sharememory的的地址0x0c000000么?