An application can register condition(s) to be monitored by the firmware.
When a callback handler is defined, the condition(s) are reported to the application asynchronously from the firmware to the handler.
The way to define a handler is as follows:
After this registration, the application can read acquisition data as usual and/or receive asynchronous events through the callback handler.
The receive buffer can also be read from the callback handler if necessary.
List of conditions
The event conditions that can be monitored are as follows:
Condition | Description |
MXF_ASYNCEVENT_COND_RXACQ_BUFFER_THRESHOLD | Acquisition buffer threshold exceeded. Read enough records from the buffer to go below the almost empty threshold to clear the event. |
Example
ar717_buffer_threshold.c
In the example below an async event handler is defined to monitor MXF_ASYNCEVENT_COND_RXACQ_BUFFER_THRESHOLD
condition and ARINC 717 RX acquisition channel is started to receive data.
uint32 asyncEventHandler(HMXF_ASYNCEVENT asyncEvent, void* param)
{
uint64 maxCount=64, pendingCount;
uint64 i;
uint32 rc;
for (i=0; !rc && i<pendingCount; i++)
{
switch(pendingList[i].condID)
{
case MXF_ASYNCEVENT_COND_TXAPERIODIC_BUFFER_THRESHOLD:
writeMsgs(pendingList[i].condition.txAperiodicBufferThreshold.buffer, (
MXF_A717_DATAREC *)param);
break;
case MXF_ASYNCEVENT_COND_RXACQ_BUFFER_THRESHOLD:
readAcquisition(pendingList[i].condition.rxAcqBufferThreshold.buffer, (
MXF_A717_DATAREC *)param);
break;
default:
printf("Unknown condID 0x%llx)", pendingList[i].condID);
break;
}
}
return rc;
}
{
uint64 status, msgsCount, bytesCount;
uint64 word, data;
uint32 rc;
rc =
mxfA717RxAcqRead(rxBuffer, 0, bufferSize, &status, &msgsCount, &bytesCount, rxHostBuffer);
if(!rc)
printf("String received count = %llu \n", msgsCount);
if(!rc)
{
recPtr = rxHostBuffer;
for(data=0; data<msgsCount && !rc; data++)
{
printf(
"\n%02llu: Timetag=%012llu, Size=%u words\n", data, recPtr->
timeTag, (recPtr->
dataSize)/2);
for(word=0; word < SUBFRAMESIZE ; word++)
printf(
"%03X ", recPtr->
data[word]);
printf("\n");
}
}
if(rc)
printf("Acquisition read failed; rc=0x%08x\n", rc);
return rc;
}
Asynchronous main logic for registering a condition handler and add conditions to be monitored.
#define TXALMOSTFULL 7
#define TXALMOSTEMPTY 3
#define RXALMOSTFULL 5
#define RXALMOSTEMPTY 2
uint32 rc;
HMXF_SERVER server;
HMXF_CHANNEL rxChannel;
HMXF_ASYNCEVENT asyncEvent;
HMXF_BUFFER rxBuffer;
size_t bufferSize;
...
if(!rc)
{
if(!hostBuffer)
rc = MAXT_ERROR_MEM;
}
if(!rc)
if(!rc)
if(!rc)
{
memset(&RXasyncEventInfo, 0, sizeof(RXasyncEventInfo));
RXasyncEventInfo.
condID = MXF_ASYNCEVENT_COND_RXACQ_BUFFER_THRESHOLD;
}
if(!rc)
if(!rc)
...
if(!rc)
if(!rc)
if(!rc)
...