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.

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 MAX_TX_SUBFRAMES_TO_TRANSMIT 4
uint32 rc;
HMXF_SERVER server;
HMXF_DEVICE device;
HMXF_CHANNEL txChannel;
size_t txBufferSize;
HMXF_BUFFER txBuffer;
uint64 data;
uint64 word, subframeSize=VMXF_A717_SUBFRAME_SIZE_128;
uint64 currentTime;
uint64 delay100ms = 100000;
...
// Sets timebase to 64-bit microseconds
if (!rc)
rc = mxfSystemTimeBaseSet(server, MXF_TIMEBASE_DEVICE_USEC);
// Allocates buffer for tx data
if(!rc)
{
txBufferSize = MAX_TX_SUBFRAMES_TO_TRANSMIT*sizeof(MXF_A717_DATAREC);
// Allocates TX Aperiodic static buffer for HIGH priority queue
rc=mxfTxAperiodicBufferAlloc(txChannel, MXF_TXAPERIODIC_PRIORITY_HIGH, txBufferSize, &txBuffer, NULL);
// Host buffer allocation
if(!rc)
{
txHostBuffer = (MXF_A717_DATAREC*) calloc(1, txBufferSize);
if(!txHostBuffer)
rc = MAXT_ERROR_MEM;
}
}
if(!rc)
{
// Prepares string array
rec = txHostBuffer;
for(data=0; data<MAX_TX_SUBFRAMES_TO_TRANSMIT; data++)
{
rec->timeTag = 0;
rec->control = 0;
rec->dataSize = 2 * (uint32)subframeSize; // 16 bits per word in subframe
rec->repeatCount = 1;
rec->reserved = 0;
for(word=0; word < subframeSize; word++)
{
if (word == 0)
{
// 1st word of each subframe has to be a sync word
// sync words are:
// - 0x247 for subframe #0
// - 0x5B8 for subframe #1
// - 0xA47 for subframe #2
// - 0xDB8 for subframe #3
switch (data%4)
{
case 0:
rec->data[word] = 0x247;
break;
case 1:
rec->data[word] = 0x5B8;
break;
case 2:
rec->data[word] = 0xA47;
break;
case 3:
rec->data[word] = 0xDB8;
break;
default:
break;
}
}
else
rec->data[word] = (uint16)(0x11*word);
}
rc = mxfA717NextDataRecordPtrGet(rec, &rec);
}
}
// Gets the current time
if(!rc)
rc = mxfDeviceTimerGet(device, &currentTime);
if(!rc)
{
printf("Transmitting ...\n");
// Transmits records with absolute start time
rc = mxfA717TxAperiodicWrite(txBuffer, MXF_TXAPERIODIC_FLAG_ABSOLUTE_START_TIME, currentTime+delay100ms, MAX_TX_SUBFRAMES_TO_TRANSMIT, txHostBuffer);
}
...
Updated 10/23/2023