MX Foundation 4
Transmission with Absolute Timing

The option MXF_TXAPERIODIC_FLAG_ABSOLUTE_START_TIME is used for starting a transmission at a specific start time in the future.

csdb_aperiodic.c
In this example, the transmission start time is based on the device clock + 100ms in the future, then the records are sent back-to-back.

#define BUFFER_SIZE 4096 // 4KB
#define MAX_TX_RECORDS_TO_TRANSMIT 8
#define BLOCKCOUNT 6
HMXF_SERVER server;
HMXF_DEVICE device;
HMXF_CHANNEL txChannel;
HMXF_BUFFER txBuffer=0;
HMXF_CSDB_DATAREC *recCsdb=NULL;
HMXF_CSDB_DATAREC *rec;
uint32 record;
uint64 delay100ms = 100000;
uint32 rc;
uint64 currentTime;
...
// Set timebase to 64-bit microseconds
if (!rc)
rc = mxfSystemTimeBaseSet(server, MXF_TIMEBASE_DEVICE_USEC);
// Allocate Aperiodic TX static buffer for HIGH priority queue
if (!rc)
rc = mxfTxAperiodicBufferAlloc(txChannel, MXF_TXAPERIODIC_PRIORITY_HIGH, BUFFER_SIZE, &txBuffer, NULL);
// Allocate host buffer
if (!rc)
{
recCsdb = (MXF_CSDB_DATAREC*)malloc(BUFFER_SIZE);
if (!recCsdb)
rc = MAXT_ERROR_MEM;
}
// Get the current time
if(!rc)
rc = mxfDeviceTimerGet(device, &currentTime);
// Set the record
rec = recCsdb;
for (record=0; record < MAX_TX_RECORDS_TO_TRANSMIT && !rc; record++)
{
if(record == 0)
{
// Set sync block
rec->timeTag = 0;
rec->control = 0;
rec->repeatCount = 1;
rec->reserved = 0;
for(dataIdx=0; dataIdx<BLOCKCOUNT; dataIdx++)
rec->data[dataIdx] = 0xA5;
}
else
{
// Set each record: LABEL=6, SI=1
rec->timeTag = 0;
rec->control = 0;
rec->repeatCount = 1;
rec->reserved = 0;
rec->data[0] = 6;
rec->data[1] = 1;
for(dataIdx=2; dataIdx<BLOCKCOUNT; dataIdx++)
rec->data[dataIdx] = (uint8)record;
}
}
// Transmit the array of records
if (!rc)
rc = mxfCSDBTxAperiodicWrite(txBuffer, MXF_TXAPERIODIC_FLAG_ABSOLUTE_START_TIME, currentTime+delay100ms, MAX_TX_RECORDS_TO_TRANSMIT, recCsdb);
if (recCsdb)
free(recCsdb);
...
Updated 10/23/2023