Thanks Timesys Support for the quick response.
I double checked my program, but it still doesn't work properly. I didn't mention that I would like to examine the timing of the MCC. I did this with the mcc_recv_copy function and I would like to do the same with mcc_recv_nocopy, because I read that this function should be faster.
I also attached two screen shots of the outputs of both cores. I'm still wondering why the M4 is not able to free the buffer. And the program stops after nine repetitions but it should stop after ten. So I don't get the "Finish" message from the A5. Thanks again for your help.
Best,
Christian
Here is the full code for the A5:
/*
* zeit_nocpy_a5.c
*/
// Bibliotheken
#include <string.h>
#include "stdio.h"
#include "stdlib.h"
#include "libmcc.h"
#include "time.h"
#define MCC_MQX_NODE_A5 0
#define MCC_MQX_NODE_M4 0
FILE *txt;
int main()
{
int ret_value;
int u = 0;
float senddata = 1.2345;
float zeit;
void* recv_buffer_ptr_a5;
void* app_buffer_ptr_a5[255];
float blubb;
//void *p_recv_data; // void pointer
//p_recv_data = &recv_data; // Empfangspointer für nocopy
clock_t begin, end;
// Endpoint-Definition
MCC_ENDPOINT linux_endpoint_a5 = {0,0,1};
MCC_ENDPOINT mqx_endpoint_m4 = {1,0,2};
MCC_MEM_SIZE num_available_msgs;
MCC_MEM_SIZE num_of_received_bytes;
printf("Hello, I'm A5.\n");
// MCC-Init
ret_value = mcc_initialize(MCC_MQX_NODE_A5);
if(0==ret_value)printf("MCCinit check\n");
else printf("MCCinit fail\n\n");
// Endpoint-Create
ret_value = mcc_create_endpoint(&linux_endpoint_a5, 1);
if(0==ret_value)printf("endpoint create check\n");
else printf("create fail\n\n");
// for begin
printf("Eingabe:\n");
scanf("%f", &blubb);
txt = fopen("mcc_float_nocopy.txt", "a+");
if (txt == NULL)
{
printf("Fehler beim Oeffnen der Datei.");
return 1;
}
while(u<10) // 10 x
{
begin = clock(); // start time
// msg to M4
ret_value = mcc_send(&mqx_endpoint_m4, &senddata, sizeof(senddata)+1, 5000000);
if(0==ret_value)printf("send check\n");
else printf("send fail\n\n");
printf("%f\n", senddata);
// wait for msg
mcc_msgs_available(&linux_endpoint_a5, &num_available_msgs);
while(num_available_msgs==0)
{
mcc_msgs_available(&linux_endpoint_a5, &num_available_msgs);
}
// get msg
ret_value = mcc_recv_nocopy(&linux_endpoint_a5, (void**)&recv_buffer_ptr_a5, &num_of_received_bytes, 5000000);
if(0==ret_value)printf("receive check\n");
else printf("receive fail\n\n");
// copy msg
memcpy((void*)app_buffer_ptr_a5, (void*)recv_buffer_ptr_a5, num_of_received_bytes);
printf("%f\n", *((float*)app_buffer_ptr_a5));
// free buffer
ret_value = mcc_free_buffer(recv_buffer_ptr_a5);
if(0==ret_value)printf("free check\n");
else printf("free fail\n\n");
end = clock(); // end time
// time in seconds
zeit = end - begin;
zeit /= CLOCKS_PER_SEC;
// time and msg to textfile
fprintf(txt, "%f | %f\n", zeit, *((float*)app_buffer_ptr_a5));
u++;
}
fclose(txt);
printf("Finish!!\n");
return 0;
}
Code for the M4:
/*
* zeit_nocpy_m4.c
*/
#include <mqx.h>
#include <bsp.h>
// Multi-Core Communication
#include "mcc_config.h"
#include "mcc_common.h"
#include "mcc_api.h"
#include "mcc_mqx.h"
#define MAIN_TASK 10
#define MCC_MQX_NODE_A5 0
#define MCC_MQX_NODE_M4 0
// FUNCTION PROTOTYPES
extern void main_task(uint_32);
// TASK Declaration
#if PSP_MQX_CPU_IS_VYBRID_M4
TASK_TEMPLATE_STRUCT MQX_template_list[] =
{
// Task Index, Function, Stack, Priority, Name, Attributes, Param, Time Slice
{ MAIN_TASK, main_task, 2000, 9, "Main", MQX_AUTO_START_TASK, MCC_MQX_NODE_M4, 0 },
{ 0 }
};
#endif
MCC_ENDPOINT linux_endpoint_a5 = {0,0,1};
MCC_ENDPOINT mqx_endpoint_m4 = {1,0,2};
void main_task(uint_32 node_num)
{
int ret_value;
float senddata = 1.2345;
void* recv_buffer_ptr_m4;
void* app_buffer_ptr_m4[255];
//void *p_recv_datam4;
//p_recv_datam4 = &recv_data;
MCC_MEM_SIZE num_available_msgs;
MCC_MEM_SIZE num_of_received_bytes;
printf("Hello, I'm M4!\n\n");
// MCC Init & Endpoint Init
ret_value = mcc_initialize(MCC_MQX_NODE_M4);
if(0==ret_value)printf("MCCinit check\n");
else printf("MCCinit fail\n\n");
ret_value = mcc_create_endpoint(&mqx_endpoint_m4, 2);
if(0==ret_value)printf("endpoint create check\n");
else printf("create fail\n\n");
while(1)
{
// wait for msg
mcc_msgs_available(&mqx_endpoint_m4, &num_available_msgs);
while(num_available_msgs==0)
{
mcc_msgs_available(&mqx_endpoint_m4, &num_available_msgs);
}
// get msg
ret_value = mcc_recv_nocopy(&mqx_endpoint_m4, (void**)&recv_buffer_ptr_m4, &num_of_received_bytes, 5000000);
if(0==ret_value)printf("receive check\n");
else printf("receive fail\n\n");
// copy msg
memcpy((void*)app_buffer_ptr_m4, (void*)recv_buffer_ptr_m4, num_of_received_bytes);
printf("%f\n", *((float*)app_buffer_ptr_m4));
// free buffer
ret_value = mcc_free_buffer(recv_buffer_ptr_m4);
if(0==ret_value)printf("free check\n");
else printf("free fail\n\n");
// send msg
ret_value = mcc_send(&linux_endpoint_a5, &senddata, sizeof(senddata)+1, 5000000);
if(0==ret_value)printf("send check\n");
else printf("send fail\n\n");
}
}
A5 screen shot:

M4 screen shot:
