MX Foundation 4
Sampling Service

The sampling service is useful when not all the traffic needs to be captured, but only a snapshot (for display for example). The sampling logic keeps the last ARINC 708 record received for each label. The service also allows the discarding of the latest data from the queue if it becomes obsolete after a period of time called, kill time.

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

The MXF_A708_SAMPREC structure must be used for reading a ARINC 708 message with the sampling service.

Example

ar708_sampling.c

#define MAX_TX_RECORDS_TO_TRANSMIT 10
#define BUFFER_SIZE MAX_TX_RECORDS_TO_TRANSMIT*sizeof(MXF_A708_DATAREC)
HMXF_SERVER server;
HMXF_CHANNEL rxChannel;
HMXF_BUFFER rxBuffer;
MXF_A708_SAMPREC* hostBuffer=NULL;
uint32 rc;
uint64 i, msgsCount, bytesCount;
...
// Sets timebase to RTC usec
if(!rc)
rc = mxfSystemTimeBaseSet(server, MXF_TIMEBASE_DEVICE_USEC);
// Allocate RX sampling buffer
if(!rc)
rc = mxfRxSamplingBufferAlloc(rxChannel, BUFFER_SIZE, &rxBuffer, NULL);
// Sets sampling kill time to 5 seconds.
if (!rc)
rc = mxfRxSamplingKilltimeSet(rxBuffer, 5000000);
// Start sampling
if(!rc)
rc = mxfRxSamplingStart(rxBuffer);
if(!rc)
printf("Sampling started\n\r");
...
// Read and display records for 5 seconds
for(i=0; i<10 && !rc; i++)
{
rc = mxfA708RxSamplingRead(rxBuffer, MXF_RXSAMPLING_FLAG_DEFAULT, 0, BUFFER_SIZE, &msgsCount, &bytesCount, hostBuffer);
if(!rc)
{
uint64 iRec,
iData;
MXF_A708_SAMPREC *p=hostBuffer;
printf("Read %llu messages\n\r", msgsCount);
printf("\n");
for(iRec=0; iRec < msgsCount; iRec++)
{
printf("%03llu %010llu 0x%08x %02u ", iRec, p->timeTag, p->control, p->dataSize);
for(iData=0; iData < p->dataSize/2; iData++)
{
printf("%04x ", p->data[iData]);
if(!((iData+1)%8) && (iData+1 < p->dataSize/2))
printf("\n ");
}
printf("\n");
}
}
if(rc)
printf("Sampling read failed; rc=0x%08x\n", rc);
else
mxfSleep(500);
}
// Stop sampling
if(!rc)
rc = mxfRxSamplingStop(rxBuffer);
...
Updated 10/23/2023