MX Foundation 4
Basic Sampling

The way to set a basic sampling receive application is as follows:

The MXF_A429_SAMPREC structure must be used for reading an ARINC 429 message with sampling service.

Example

ar429_rx_sampling.c
The example below shows how to implement an ARINC 429 sampling receive application.

#define BUFFER_SIZE 4096 // 4KB
#define LABEL 3
HMXF_SERVER server;
HMXF_CHANNEL rxChannel;
HMXF_BUFFER rxBuffer;
MXF_A429_SAMPREC *hostBuffer=NULL;
uint32 label=LABEL, sdi, data, ssm, parity;
uint64 msgsCount, bytesCount;
uint64 j;
uint32 rc;
...
// Sets timebase to 64-bit microseconds
if (!rc)
rc = mxfSystemTimeBaseSet(server, MXF_TIMEBASE_DEVICE_USEC);
// Allocates host buffer
if(!rc)
{
hostBuffer = (MXF_A429_SAMPREC *)malloc(BUFFER_SIZE);
if(!hostBuffer)
rc = MAXT_ERROR_MEM;
}
// Allocates RX sampling buffer
if(!rc)
rc = mxfRxSamplingBufferAlloc(rxChannel, BUFFER_SIZE, &rxBuffer, NULL);
// Filters out a specific label
if (!rc)
rc = mxfA429RxSamplingMsgSelectSet(rxBuffer, MXF_MSG_DESELECT, 1, &label);
// Sets sampling kill time to 1 second.
if (!rc)
rc = mxfRxSamplingKilltimeSet(rxBuffer, 1000000);
// Starts sampling
if(!rc)
rc = mxfRxSamplingStart(rxBuffer);
...
// Reads and displays records
if(!rc)
{
rc = mxfA429RxSamplingRead(rxBuffer, MXF_RXSAMPLING_FLAG_DEFAULT, 0, BUFFER_SIZE, &msgsCount, &bytesCount, hostBuffer);
if(!rc)
{
printf("Read %llu messages\n\r", msgsCount);
recSamp = (MXF_A429_SAMPREC*)hostBuffer;
for (j=0; !rc && j<msgsCount; j++)
{
rc = mxfA429ArwDecompose(recSamp->data, &label, &sdi, &data, &ssm, &parity);
if(!rc)
{
printf("%02llu: Timetag %llu - ARINC word=[%03llo,%lld,%05llX,%lld,%s]\n",
j, recSamp->timeTag, label, sdi, data, ssm, (parity==VMXF_A429_PARITY_ODD)?"ODD":"EVEN");
if(!rc)
rc = mxfA429NextSamplingRecordPtrGet(recSamp, &recSamp);
}
}
}
}
...
Updated 10/23/2023