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;
uint32 rc;
uint64 i, msgsCount, bytesCount;
...
if(!rc)
if(!rc)
if (!rc)
if(!rc)
if(!rc)
printf("Sampling started\n\r");
...
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;
printf("Read %llu messages\n\r", msgsCount);
printf("\n");
for(iRec=0; iRec < msgsCount; iRec++)
{
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
}
if(!rc)
...