The way to set a basic sampling receive application is as follows:
The MXF_CANBUS_SAMPREC
structure must be used for reading an CAN message with sampling service.
Example
canbus_sampling.c
The example below shows how to implement an CAN sampling receive application.
#define BUFFER_SIZE 4096 // 4KB
HMXF_SERVER server;
HMXF_CHANNEL rxChannel;
HMXF_BUFFER rxBuffer;
uint64 ID=0x08120000;
uint64 msgsCount, bytesCount;
uint64 j;
uint32 rc;
...
if (!rc)
if(!rc)
{
if(!hostBuffer)
rc = MAXT_ERROR_MEM;
}
if(!rc)
if (!rc)
if (!rc)
if(!rc)
...
if(!rc)
{
recSamp = hostBuffer;
for (j = 0; j < msgsCount && !rc; j++)
{
printf(
" %03llu: Timetag=%012llu, Size=%u", j, recSamp->
timeTag, recSamp->
dataSize);
printf(" OK");
else
printf(" Error");
printf("\n Data=");
for (byte = 0; byte<recSamp->
dataSize; byte++)
{
printf(
"%02X ", recSamp->
data[byte]);
}
printf("\n");
}
}
...