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_FLEXANALOG_SAMPREC structure must be used for reading an ADC message with sampling service.

Example

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

HMXF_SERVER server;
HMXF_MODULE module;
HMXF_CHANNEL rxChn[64];
HMXF_BUFFER rxBuffer;
uint64 msgsCount, bytesCount;
uint32 rc;
int iPort;
float value;
uint64 index;
...
// Allocates RX sampling buffer
if(!rc)
rc = mxfRxSamplingBufferAlloc(module, sizeof(recSamp), &rxBuffer, NULL);
// Starts sampling
if(!rc)
rc = mxfRxSamplingStart(rxBuffer);
...
// Reads and displays records
if(!rc)
{
iPort = 0;
index = 0;
rc = mxfFlexAnalogRxSamplingRead(rxBuffer, MXF_RXSAMPLING_FLAG_DEFAULT, sizeof(recSamp), &msgsCount, &bytesCount, &recSamp);
if(!rc && msgsCount)
{
do
{
if(recSamp.dataMask & 0x1)
{
rc = mxfFlexAdcDataConvert(rxChn[iPort], recSamp.data[index], &value);
if(!rc)
printf( "Value of ADC %d is %.3f. V\n\r", iPort, value);
index++;
}
recSamp.dataMask >>= 1;
iPort++;
}while(!rc && recSamp.dataMask);
}
}
...
Updated 10/23/2023