An application can register condition(s) to be monitored by the firmware.
When a callback handler is defined, the condition(s) is(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 transmit data as usual and/or received asynchronous events through the callback handler.
The transmit aperiodic buffer is normally updated from the callback handler.
List of conditions
The event conditions that can be monitored are as follows:
Condition | Description |
MXF_ASYNCEVENT_COND_TXAPERIODIC_BUFFER_THRESHOLD | TX Aperiodic buffer almost empty threshold reached. Add enough records to the buffer to go over the almost full threshold to clear the event. |
MXF_ASYNCEVENT_COND_TX_ERROR | Transmission error detected. Only late transmit is supported, check the records time tag. |
Example
ar717_buffer_threshold.c
In the example below an async event handler is defined to monitor the MXF_ASYNCEVENT_COND_TXAPERIODIC_BUFFER_THRESHOLD
condition.
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;
}
{
uint32 rc=0;
uint32 i;
uint64 word;
static uint32 TXAsyncEvents=0;
for(i=0; !rc && i<TXALMOSTFULL; i++)
{
recPtr->
dataSize = 2 * (uint32)SUBFRAMESIZE;
for(word=0; word < SUBFRAMESIZE ; word++)
{
if (word == 0)
{
switch (i%4)
{
case 0:
recPtr->
data[word] = 0x247;
break;
case 1:
recPtr->
data[word] = 0x5B8;
break;
case 2:
recPtr->
data[word] = 0xA47;
break;
case 3:
recPtr->
data[word] = 0xDB8;
break;
default:
break;
}
}
else
recPtr->
data[word] = (uint16)(0x11*word);
}
if(!rc)
}
if(!rc)
{
printf("Transmitting ...\n");
}
if(rc)
printf("Periodic Update failed; rc=0x%08x\n", rc);
else
printf("\nAsync Event %d - Writing %d records\n", ++TXAsyncEvents, i);
return rc;
}
Asynchronous main logic for registering a condition handler and add conditions to be monitored.
#define TXALMOSTFULL 7
#define TXALMOSTEMPTY 3
uint32 rc;
HMXF_SERVER server;
HMXF_CHANNEL rxChannel;
HMXF_ASYNCEVENT asyncEvent;
HMXF_BUFFER txBuffer;
size_t bufferSize;
...
if(!rc)
{
if(!hostBuffer)
rc = MAXT_ERROR_MEM;
}
if(!rc)
if(!rc)
if(!rc)
{
memset(&TXasyncEventInfo, 0, sizeof(TXasyncEventInfo));
TXasyncEventInfo.
condID = MXF_ASYNCEVENT_COND_TXAPERIODIC_BUFFER_THRESHOLD;
}
...
if(!rc)
if(!rc)
...