MX Foundation 4
Sending Periodic Messages

The basic logic to send periodic messages is as follows:

  • First, allocate the necessary buffers that will hold the ARINC 429 data using mxfTxPeriodicUpdateMsgBufferAlloc(). Usually, one buffer is allocated for each label to be sent. In the following example, the label is used as index to the buffer allocation, but it can be any number between 0 and 1023.
  • Second, create a schedule instance for a given channel using mxfTxPeriodicScheduleNew().
  • The simplest ARINC 429 message consists of a single list containing a single buffer. When working with such a simple message the function mxfTxPeriodicScheduleSingleMsgAdd() can be used. This function creates a message that contains a single list with a single buffer.
  • Before adding the ARINC 429 records to the message, at least one buffer list must be added using mxfTxPeriodicScheduleBufferListAdd(). The function includes an argument to specify how many buffers (ARINC 429 word) the list contains. If the list includes more than one buffer, one ARINC 429 32-bit words for each buffer included in the list is sent back-to-back at the message update rate.
  • Many buffer lists can be added to a message if desired. The function mxfTxPeriodicScheduleBufferListAdd() includes an argument to specify a time delay to be inserted between two consecutive buffer lists.
  • Set the ARINC-429 word value(s) in the MXF_A429_DATAREC for a given record using mxfA429TxPeriodicUpdateMsgWrite().
  • Start the schedule using mxfTxPeriodicScheduleRun().

ar429_periodic.c
The example below illustrates how to put it together:

#define BUFFER_SIZE 4096 // 4KB
#define TX_MSG_LABEL 5
#define TX_MSG_SDI 0
HMXF_CHANNEL txChannel;
HMXF_BUFFER txBuffer;
MXF_A429_DATAREC *rec429=NULL;
HMXF_SCHED schedule;
HMXF_SCHED_MSG msg=0;
uint64 label, sdi, data, ssm, parity;
uint32 rc;
...
// Allocates TX Periodic Update buffer
if(!rc)
rc = mxfTxPeriodicUpdateMsgBufferAlloc(txChannel, TX_MSG_LABEL, BUFFER_SIZE, &txBuffer, NULL);
// Allocates host buffer
if (!rc)
{
rec429 = (MXF_A429_DATAREC*)malloc(BUFFER_SIZE);
if (!rec429)
rc = MAXT_ERROR_MEM;
}
// Creates the periodic scheduler
rc = mxfTxPeriodicScheduleNew(txChannel, &schedule);
// Sets scheduling values: Rate=100 ms (.1sec), Phase=0 us
if(!rc)
rc = mxfTxPeriodicScheduleMsgAdd(schedule, 100000LL, 0, &msg);
// Defines the number of buffer for the list and link to it
if(!rc)
rc = mxfTxPeriodicScheduleBufferListAdd(msg, 1, 0, &txBuffer);
// Sets record for the buffer: ARINC 429 LABEL=005, SDI=0
if(!rc)
{
rec429->timeTag = 0;
rec429->control = 0;
rec429->repeatCount = 1;
rec429->reserved = 0;
label = TX_MSG_LABEL;
sdi = TX_MSG_SDI;
data = 0x7fe;
parity = VMXF_A429_PARITY_ODD;
ssm = 1;
rc = mxfA429ArwCompose(label, sdi, data, ssm, parity, &rec429->data);
if(!rc)
rc = mxfA429TxPeriodicUpdateMsgWrite(txBuffer, 1, rec429);
}
// Runs the scheduler, updates records
if(!rc)
{
printf("Running periodic transmission, please wait...\n\r");
// Runs the schedule now
rc = mxfTxPeriodicScheduleRun(schedule);
}
// Waits 10 seconds
if(!rc)
{
mxfSleep(10000);
rc = mxfTxPeriodicScheduleFree(schedule);
}
if(rec429)
free(rec429)
...
Updated 10/23/2023