MX Foundation 4
Basic Sampling

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

The MXF_CSDB_SAMPREC structure must be used for reading a CSDB message with the sampling service.

Example

csdb_rx_sampling.c
The example below shows how to implement a CSDB sampling receive application.

#define BUFFER_SIZE 4096 // 4KB
#define LABEL 0x3
#define BLOCKCOUNT 6
HMXF_SERVER server;
HMXF_CHANNEL rxChannel;
HMXF_BUFFER rxBuffer;
MXF_CSDB_SAMPREC *hostBuffer=NULL;
uint64 label=0xA5;
uint64 msgsCount, bytesCount;
uint64 j;
uint32 rc;
...
// Set timebase to 64-bit microseconds
if (!rc)
rc = mxfSystemTimeBaseSet(server, MXF_TIMEBASE_DEVICE_USEC);
// Allocate host buffer
if(!rc)
{
hostBuffer = (MXF_CSDB_SAMPREC *)malloc(BUFFER_SIZE);
if(!hostBuffer)
rc = MAXT_ERROR_MEM;
}
// Allocate RX sampling buffer
if(!rc)
rc = mxfRxSamplingBufferAlloc(rxChannel, BUFFER_SIZE, &rxBuffer, NULL);
// Filters out a specific label/si
if (!rc)
rc = mxfCSDBRxSamplingMsgSelectSet(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 = mxfCSDBRxSamplingRead(rxBuffer, MXF_RXSAMPLING_FLAG_DEFAULT, 0, BUFFER_SIZE, &msgsCount, &bytesCount, hostBuffer);
if(!rc)
{
printf("Read %llu messages\n\r", msgsCount);
recSamp = (MXF_CSDB_SAMPREC*)hostBuffer;
for (j=0; !rc && j<msgsCount; j++)
{
printf("%02llu: Timetag=%016llu: CSDB data=[ ", j, recSamp->timeTag);
for (dataIndex=0; dataIndex<BLOCKCOUNT; dataIndex++)
printf("0x%02X ", recSamp->data[dataIndex]);
printf("]\n\r");
mxfCSDBNextSamplingRecordPtrGet(recSamp, &recSamp);
}
}
}
...
Updated 10/23/2023