MX Foundation 4
Sending Periodic Messages

The basic logic to send periodic messages is as follows:

The example below illustrates how to put it together:

ar708_periodic.c

#define BUFFER_SIZE 4096 // 4KB
uint32 rc;
HMXF_CHANNEL txChannel;
HMXF_BUFFER txBuffer;
MXF_A708_DATAREC* txHostBuffer;
HMXF_SCHED schedule;
HMXF_SCHED_MSG msg=0;
uint64 data, word;
...
// Set timebase to 64-bit microseconds
if (!rc)
rc = mxfSystemTimeBaseSet(server, MXF_TIMEBASE_DEVICE_USEC);
// Allocate TX Periodic Update buffer
if(!rc)
rc = mxfTxPeriodicUpdateMsgBufferAlloc(txChannel, 0, BUFFER_SIZE, &txBuffer, NULL);
// Allocate host buffer
if (!rc)
{
txHostBuffer = (MXF_A708_DATAREC*)malloc(BUFFER_SIZE);
if (!txHostBuffer)
rc = MAXT_ERROR_MEM;
}
// Create the periodic scheduler
rc = mxfTxPeriodicScheduleNew(txChannel, &schedule);
// Set scheduling values: Rate=5 ms, Phase=0 us
if(!rc)
rc = mxfTxPeriodicScheduleMsgAdd(schedule, 5000, 0, &msg);
// Define the number of buffer for the list and link to it
if(!rc)
rc = mxfTxPeriodicScheduleBufferListAdd(msg, 1, 0, txBuffer);
// Set records for the buffers
if(!rc)
{
rec = txHostBuffer;
//Prepares records to send for basic transmission/reception test
for(data=0; data<MAX_TX_RECORDS_TO_TRANSMIT; data++)
{
rec->timeTag = 0;
rec->control = 0;
rec->repeatCount = 1;
rec->manchesterBitErr = 0;
rec->dataSize = 200; //200 bytes corresponds to 1600 bits (see ARINC 708 specification)
for(word=0; word < rec->dataSize/2; word++) //The first 8 bits of each message have to be 0xB4
{
switch(word)
{
case 0:
rec->data[word] = 055;
break;
case 1:
case 2:
case 3:
case 4:
rec->data[word] = 0x0000;
break;
default:
rec->data[word] = (uint16)(0x0101*data);
}
}
rc = mxfA708NextDataRecordPtrGet(rec, &rec);
}
}
if (!rc)
rc = mxfA708TxPeriodicUpdateMsgWrite(*txBuffer, MAX_TX_RECORDS_TO_TRANSMIT, txHostBuffer);
// Run the scheduler, update records
if(!rc)
{
printf("Running periodic transmission, please wait...\n\r");
// Run the schedule now
rc = mxfTxPeriodicScheduleRun(schedule);
}
// Wait 1 second
if(!rc)
{
mxfSleep(1000);
rc = mxfTxPeriodicScheduleFree(schedule);
}
...
Updated 10/23/2023