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 CSDB 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) 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 is flushed to make place for newly incoming data. When the trigger conditions are realized, the acquisition goes into a running state. In this state, the pre-trig data and all newly incoming data are queued until the application reads them (through the mxfCSDBRxAcqRead() function).
Trigger conditions can be "ANDed" or "ORed" together.

Acquisition Trigger Service

The following functions are defined for the trigger service:

csdb_rx_acquisition_trigger.c

#define LABEL 0x7
#define SI 0
HMXF_SERVER server;
HMXF_BUFFER rxBuffer;
HMXF_COND_LIST condList=0;
uint64 status, trigTime=0;
time_t timeTemp;
struct tm * ptm;
char szTime[1024];
uint64 msec, usec;
...
// Sets timebase to computer time 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 on bit 7 value of byte 1 of LABEL/SI
if(!rc)
{
condParam.mask = 0x000083ff;
condParam.data = (SI << 8) | LABEL;
condParam.offset = 0;
condParam.options = MXF_RXACQ_TRIG_COND_RDATA_OPTIONS_EQUAL;
rc = mxfRxAcqTrigConditionAdd(condList, MXF_RXACQ_TRIG_COND_ID_RDATA_DW , &condParam);
}
// Sets the trigger with a pretrig count of 30 which allows some records to be read before the condition was triggered.
// For the CSDB protocol this number is rounded to the closest internal acquisition buffer size.
if(!rc)
rc = mxfRxAcqTrigSet(rxBuffer, condList, 30);
...
// Checks trigger happened
if(!rc)
rc = mxfRxAcqBufferStatusGet(rxBuffer, &status, NULL, NULL, NULL);
if(!rc)
{
if(status & 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