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 value received for each channel. 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 set a basic sampling receive application is as follows:

The MXF_ANALOG_SAMPREC structure must be used for reading an ADC message with sampling service.

Example

adc_sampling.c
The example below shows how to implement an ADC sampling receive application.

HMXF_SERVER server;
HMXF_CHANNEL rxChannel;
HMXF_BUFFER rxBuffer;
uint64 msgsCount, bytesCount;
uint32 rc;
...
// Allocates RX sampling buffer
if(!rc)
rc = mxfRxSamplingBufferAlloc(rxChannel, sizeof(recSamp), &rxBuffer, NULL);
// Starts sampling
if(!rc)
rc = mxfRxSamplingStart(rxBuffer);
...
// Reads and displays records
if(!rc)
{
rc = mxfAnalogRxSamplingRead(rxBuffer, MXF_RXSAMPLING_FLAG_DEFAULT, sizeof(recSamp), &msgsCount, &bytesCount, &recSamp);
if(!rc && msgsCount)
{
printf("Timetag %llu: %f\n", recSamp.timeTag, recSamp.data.value);
}
}
...
Updated 10/23/2023