MX Foundation 4
Basic Sampling

The way to setup a basic sampling receive application is as follows:

The MXF_MIL1553_SAMPREC structure must be used for reading MIL-1553 messages with sampling service.

Example

mil1553_bc_buserror_trigger.c

HMXF_SERVER server;
HMXF_CHANNEL bm;
HMXF_BUFFER samp1553Buffer;
uint32 rc;
void* rxData=0;
MXF_MIL1553_SAMPREC *sampRec1553;
uint64 msgCount, byteCount;
uint64 rxRec;
uint64 loop=0;
uint32 data;
uint64 rxDataSize = 10*1024;
...
// Sets timebase to RTC nsec
if(!rc)
rc = mxfSystemTimeBaseSet(server, MXF_TIMEBASE_DEVICE_NSEC);
// Allocates 10KB buffer for 1553 sampling data
if(!rc)
rc = mxfRxSamplingBufferAlloc(bm, rxDataSize, &samp1553Buffer, NULL);
if(!rc)
rc = mxfRxSamplingKilltimeSet(samp1553Buffer, 2000000000);
// Host allocation
if(!rc)
{
rxData = malloc(rxDataSize);
if(!rxData)
rc = MAXT_ERROR_MEM;
}
...
// Starts BM sampling
if(!rc)
rc = mxfRxSamplingStart(samp1553Buffer);
printf("Sampling started for 5 seconds, waiting...\n");
mxfSleep(5000);
// Reads and displays received messages
if(!rc)
{
rc = mxfMIL1553RxSamplingRead(samp1553Buffer, 0, 0, rxDataSize, &msgCount, &byteCount, rxData);
sampRec1553 = (MXF_MIL1553_SAMPREC*)rxData;
for(rxRec=0; !rc && rxRec<msgCount; rxRec++)
{
printf("%012llu ", sampRec1553->timeTag);
printf("%03u ", sampRec1553->rate);
printf("%08X ", sampRec1553->control);
printf("%04u ", (sampRec1553->dataSize/2)-1);
for(data=0; data < min(5, sampRec1553->dataSize/2); data++)
{
printf("%04X ", sampRec1553->data[data]);
}
printf("\n\r");
// Gets next msg
mxfMIL1553NextSamplingRecordPtrGet(sampRec1553, &sampRec1553);
}
}
// Stops sampling
if(!rc)
rc = mxfRxSamplingStop(samp1553Buffer);
...
Updated 10/23/2023