MX Foundation 4
Updating Periodic Messages

While a schedule runs, the ARINC 429 word can be updated asynchronously by the main application using the mxfA429TxPeriodicUpdateMsgWrite() function.

The next example shows how to use some functions for updating a transmission buffer.

Scheduling a Single Message

The program below shows how to define a single record with mxfTxPeriodicScheduleSingleMsgAdd() to schedule what will be later updated while the schedule runs.

The example in the next section shows how to update the records dynamically.

ar429_buffer_threshold.c

#define BUFFER_SIZE 4096 // 4KB
#define TX_MSG_LABEL 5
#define TX_MSG_SDI 0
uint32 rc;
HMXF_SCHED schedule=0;
HMXF_SCHED_MSG msgSched;
HMXF_CHANNEL txChannel;
HMXF_BUFFER txBuffer=0;
MXF_A429_DATAREC *hostBuffer=NULL;
...
// Allocates host buffer
if(!rc)
{
hostBuffer = (MXF_A429_DATAREC *)malloc(BUFFER_SIZE);
if(!hostBuffer)
rc = MAXT_ERROR_MEM;
}
// Sets the Periodic Scheduler
if(!rc)
rc = mxfTxPeriodicScheduleNew(txChannel, &schedule);
// Sets scheduling values: Rate=25 ms, Phase=0 us
if(!rc)
rc = mxfTxPeriodicScheduleSingleMsgAdd(schedule, 25000000ll, 0, txBuffer, &msgSched);
// Runs the schedule
if(!rc)
rc = mxfTxPeriodicScheduleRun(schedule);
// Sends messages for 2 seconds
if(!rc)
{
printf("Running periodic transmission...\n\r");
mxfSleep(2000);
rc = mxfTxPeriodicScheduleFree(schedule);
}
...

Updating the buffer

The value of the data sent (ARINC 429 word) can be updated while a background schedule runs.

The example below shows how the mxfA429TxPeriodicUpdateMsgWrite() function can be used to perform the update operation.

The update loop changes every 100ms and stops after five seconds.

ar429_buffer_threshold.c

#define TX_MSG_LABEL 5
#define TX_MSG_SDI 0
#define TXALMOSTFULL 7
uint32 rc=0;
uint32 i;
MXF_A429_DATAREC *recPtr=hostBuffer;
uint64 label, sdi, ssm, parity;
static uint64 data=0;
...
// Refills the FIFO in order to produce a ramp
for(i=0; !rc && i<TXALMOSTFULL; i++)
{
// Sends a parity error on first record
recPtr->timeTag=0;
recPtr->control=(i!=0)?0:MXF_A429_TX_REC_CTRL_PARITY_ERROR;
recPtr->repeatCount=1;
recPtr->reserved=0;
label = TX_MSG_LABEL;
sdi = TX_MSG_SDI;
data++;
ssm = 0;
parity = VMXF_A429_PARITY_ODD;
rc = mxfA429ArwCompose(label, sdi, data, ssm, parity, &recPtr->data);
if(!rc)
rc = mxfA429NextDataRecordPtrGet(recPtr, &recPtr);
}
// Adds more data to the buffer
if(!rc)
rc = mxfA429TxPeriodicUpdateMsgWrite(buffer, i, hostBuffer);
...
Updated 10/23/2023