MX Foundation 4
Acquisition with Trigger

A basic acquisition program allows capturing all data received on a bus. In some cases, it is necessary to start capturing the traffic only when a specific event is detected. In this case, the acquisition triggering service can be used. Two types of events are supported: trigger on a specific HFCE data word content and trigger on the running state of another channel.

When an acquisition with trigger is started, the received data is not available to the application until the trigger condition(s) is(are) met. In this state, the data received is kept in a circular queue. The maximum number of data records to be kept in the queue is configurable. If the queue is full, the older data are flushed to make place for newly incoming data. When the trigger conditions are realized, the acquisition goes into running state. In this state, the pre-trig data and all newly incoming data are queued until the application reads them (through the mxfHFCERxAcqRead() function).
Trigger conditions can either be "ANDed" or "ORed" together.

Example

hfce_trigger.c

HMXF_SERVER server;
HMXF_BUFFER rxBuffer;
HMXF_COND_LIST condList=0;
uint64 rxAcqStatus, trigTime=0;
time_t timeTemp;
struct tm * ptm;
char szTime[1024];
uint64 msec, usec;
...
// Sets timebase to computer 64-bit microseconds
if(!rc)
rc = mxfSystemTimeBaseSet(server, MXF_TIMEBASE_COMPUTER_USEC);
// Configures trigger
// Creates the condition list
if (!rc)
rc = mxfRxAcqTrigConditionListAlloc(server, &condList);
// The condition will be triggered when bit 0-7 of first word equal 5
if(!rc)
{
condParam.mask = 0x0000000F;
condParam.data = 0x00000005;
condParam.offset = 0;
condParam.options = MXF_RXACQ_TRIG_COND_RDATA_OPTIONS_EQUAL;
rc = mxfRxAcqTrigConditionAdd(condList, MXF_RXACQ_TRIG_COND_ID_RDATA_DW , &condParam);
}
// Set the trigger with a pretrig count of 3 which allows some records to be read before the condition was triggered.
if(!rc)
rc = mxfRxAcqTrigSet(rxBuffer, condList, 3);
if (!rc)
rc = mxfRxAcqModeSet(rxBuffer, MXF_RXACQ_MODE_CIRCULAR);
// Starts acquisition
if(!rc)
rc = mxfRxAcqStart(rxBuffer, MXF_RXACQ_FLAG_DEFAULT,0, 0);
...
// Check trigger happened
if(!rc)
rc = mxfRxAcqBufferStatusGet(rxBuffer, &rxAcqStatus, NULL, NULL, NULL);
if(!rc)
{
if(rxAcqStatus & MXF_RXACQ_STATUS_TRIG_OCCURRED)
{
// Displays the acquisition trigger time
rc = mxfRxAcqTrigTimeGet(rxBuffer, &trigTime);
if(!rc)
{
timeTemp = trigTime/1000000;
ptm = localtime(&timeTemp);
strftime(szTime, sizeof(szTime), "%Y-%m-%d %H:%M:%S", ptm);
usec = trigTime%1000;
timeTemp = trigTime/1000;
msec = timeTemp%1000;
printf("Event triggered at %s:%03llu:%03llu\n", szTime, msec, usec);
}
}
else
printf("Trigger not fired\n");
}
...
Updated 10/23/2023