#include "example.h"
#define LOCAL
uint32 eventHandler(HMXF_HANDLE asyncEvent, void* pParam);
typedef struct
{
HMXF_BUFFER bcBuffer0;
HMXF_BUFFER bcBuffer1;
HMXF_BUFFER rtBuffer;
union
{
struct
{
}data;
uint64 reserved[2];
}u;
}
EVENT_INFO;
int main(void)
{
HMXF_SERVER server;
HMXF_DEVICE device=0;
HMXF_MODULE module=0;
HMXF_CHANNEL bc=0;
HMXF_CHANNEL bm=0;
HMXF_CHANNEL rt4=0;
HMXF_CHANNEL rt5=0;
HMXF_BUFFER acq1553Buffer=0;
HMXF_BUFFER bcBuffer0=0;
HMXF_BUFFER bcBuffer1=0;
HMXF_BUFFER bcBuffer2=0;
HMXF_BUFFER rt4Buffer0=0;
HMXF_BUFFER rt4Buffer1=0;
HMXF_BUFFER rt5Buffer0=0;
HMXF_BUFFER rt5Buffer1=0;
uint32 rc;
uint32 txDataSize=0;
uint32 rxDataSize=0;
uint64 rxAcqStatus;
uint64 msgCount;
uint64 byteCount;
uint64 rxRec;
uint64 loop=0;
uint32 data;
char errorString[200];
uint64 rate;
uint64 last=0, moduleCount=0;
uint64 irigbStatus=0;
HMXF_ASYNCEVENT asyncEvent=0;
EVENT_INFO eventInfo;
#ifdef LOCAL
#else
#endif
if(!rc)
{
printf("Starting ...\n\r");
}
if(!rc)
if(!rc)
if (!rc && !moduleCount)
if(!rc)
if(!rc)
if(!rc)
if(!rc)
#ifdef LOOPBACK
if(!rc)
#endif
if(!rc)
{
txDataSize = 4096;
if(!rc)
{
if(!bcData0)
rc = MAXT_ERROR_MEM;
}
}
if(!rc)
{
txDataSize = 4096;
if(!rc)
{
if(!bcData1)
rc = MAXT_ERROR_MEM;
}
}
if(!rc)
{
txDataSize = 0;
}
if(!rc)
{
txDataSize = 4096;
if(!rc)
}
if(!rc)
{
txDataSize = 4096;
if(!rc)
if(!rc)
{
if(!rtData)
rc = MAXT_ERROR_MEM;
}
}
if(!rc)
{
rxDataSize = 10*1024;
if(!rc)
{
if(!rxData)
rc = MAXT_ERROR_MEM;
}
}
if(!rc)
{
printf("Configuring IRIG-B\n");
}
if(!rc)
if(!rc)
if(!rc)
rc =
mxfAttributeUint64Set(device, KMXF_DEVICE_IRIGB_INPUT_SIGNAL, VMXF_DEVICE_IRIGB_INPUT_SIGNAL_DIGITAL);
if(!rc)
{
do
{
}while(!rc && (irigbStatus!=MXF_IRIGB_STATUS_NO_SIGNAL) && (irigbStatus!=MXF_IRIGB_STATUS_LOCKED));
}
if(!rc)
{
if(irigbStatus == MXF_IRIGB_STATUS_LOCKED)
else
{
printf("No IRIG-B signal found\n\r");
}
}
if(!rc)
{
memset(minorFrame, 0, sizeof(minorFrame));
minorFrame[0].
buffer = bcBuffer0;
if(!rc)
{
minorFrame[1].
buffer = bcBuffer0;
minorFrame[1].
delay = 8000;
minorFrame[1].
options = MXF_MIL1553_TXPERIODIC_MJRFRAME_MSG_OPT_DELAY;
}
if(!rc)
{
minorFrame[2].
buffer = bcBuffer1;
minorFrame[2].
delay = 8000;
minorFrame[2].
options = MXF_MIL1553_TXPERIODIC_MJRFRAME_MSG_OPT_DELAY;
}
if(!rc)
{
minorFrame[3].
buffer = bcBuffer2;
minorFrame[3].
delay = 8000;
minorFrame[3].
options = MXF_MIL1553_TXPERIODIC_MJRFRAME_MSG_OPT_DELAY;
}
if(!rc)
{
minorFrame[4].
buffer = bcBuffer2;
minorFrame[4].
delay = 8000;
minorFrame[4].
options = MXF_MIL1553_TXPERIODIC_MJRFRAME_MSG_OPT_DELAY;
}
if(!rc)
}
if(!rc)
{
txRec1553->
data[0] = 0x0000;
txRec1553->
data[1] = 0x0000;
txRec1553->
data[2] = 0x1111;
txRec1553->
data[3] = 0x2222;
txRec1553->
data[4] = 0x3333;
}
if(!rc)
{
txRec1553->
data[0] = 0x0000;
txRec1553->
data[1] = 0x1234;
txRec1553->
data[2] = 0x5678;
txRec1553->
data[3] = 0x9ABC;
txRec1553->
data[4] = 0xDEF0;
}
if(!rc)
{
txRec1553->
data[0] = 0x0000;
txRec1553->
data[1] = 0xAAAA;
txRec1553->
data[2] = 0xBBBB;
txRec1553->
data[3] = 0xCCCC;
txRec1553->
data[4] = 0xDDDD;
}
if(!rc)
{
printf("Starting RT 4\n\r");
if(!rc)
if(!rc)
if(!rc)
}
if(!rc)
{
printf("Starting RT 5\n\r");
if(!rc)
if(!rc)
}
if(!rc)
{
eventInfo.u.data.rtData = rtData;
eventInfo.u.
data.bcData0 = bcData0;
eventInfo.u.
data.bcData1 = bcData1;
eventInfo.bcBuffer0 = bcBuffer0;
eventInfo.bcBuffer1 = bcBuffer1;
eventInfo.rtBuffer = rt5Buffer1;
}
if(!rc)
{
memset(&condition, 0, sizeof(condition));
condition.
condID = MXF_ASYNCEVENT_COND_TXPERIODIC_UPDATEMSG_BUFFER_THRESHOLD;
}
if(!rc)
{
memset(&bcCondition, 0, sizeof(bcCondition));
bcCondition.
condID = MXF_ASYNCEVENT_COND_TXPERIODIC_UPDATEMSG_BUFFER_THRESHOLD;
}
if(!rc)
if(!rc)
if(!rc)
if(!rc)
if(!rc)
if(!rc)
{
}
if(!rc)
{
loop=0;
do
{
rc =
mxfMIL1553RxAcqRead(acq1553Buffer, 0, rxDataSize, &rxAcqStatus, &msgCount, &byteCount, rxData);
for(rxRec=0; !rc && rxRec<msgCount; rxRec++)
{
rate = last?((rxRec1553->
timeTag - last)/1000000):0;
printf(
"%012llu ", rxRec1553->
timeTag);
printf("%03llu ", rate);
printf(
"%08X ", rxRec1553->
control);
printf(
"%04u ", (rxRec1553->
dataSize/2)-1);
for(data=0; data < min(8, rxRec1553->
dataSize/2); data++)
{
printf(
"%04X ", rxRec1553->
data[data]);
}
printf("\n\r");
}
loop++;
}
while(loop < 20);
}
printf("Stopping BC and RTs\n\r");
if(bcData0)
free(bcData0);
if(bcData1)
free(bcData1);
if(rtData)
free(rtData);
if(rxData)
free(rxData);
if(rc)
{
sprintf (errorString,"Error # 0x%08x", rc);
printf("%s\n\r", errorString);
}
if(bcBuffer0)
{
if (rc)
printf("Free buffer failed !\n\r");
}
if(bcBuffer1)
{
if (rc)
printf("Free buffer failed !\n\r");
}
if(bcBuffer2)
{
if (rc)
printf("Free buffer failed !\n\r");
}
if(rt4Buffer0)
{
if (rc)
printf("Free buffer failed !\n\r");
}
if(rt4Buffer1)
{
if (rc)
printf("Free buffer failed !\n\r");
}
if(rt5Buffer0)
{
if (rc)
printf("Free buffer failed !\n\r");
}
if(rt5Buffer1)
{
if (rc)
printf("Free buffer failed !\n\r");
}
if(acq1553Buffer)
{
if (rc)
printf("Free buffer failed !\n\r");
}
printf("\n\rPress enter to terminate\n\r");
getchar();
return 0;
}
uint32 eventHandler(HMXF_HANDLE asyncEvent, void* pParam)
{
EVENT_INFO* eventInfo=(EVENT_INFO*)pParam;
uint32 rc=0;
uint64 eventCount;
uint64 rec;
if(!rc)
{
{
case MXF_ASYNCEVENT_COND_TXPERIODIC_UPDATEMSG_BUFFER_THRESHOLD:
{
{
txRec1553->
data[0] = 0x0000;
txRec1553->
data[1] = (uint16)rec;
txRec1553->
data[2] = (uint16)rec;
txRec1553->
data[3] = (uint16)rec;
txRec1553->
data[4] = (uint16)rec;
}
}
{
{
txRec1553->
data[0] = 0x0000;
txRec1553->
data[1] = 0x1111 * (uint16)rec;
txRec1553->
data[2] = 0x1111 * (uint16)rec;
txRec1553->
data[3] = 0x1111 * (uint16)rec;
txRec1553->
data[4] = 0x1111 * (uint16)rec;
}
}
{
{
txRec1553->
data[0] = 0x0000;
txRec1553->
data[1] = (rec % 2)?0xACDC:0xCAFE;
txRec1553->
data[2] = (rec % 2)?0xACDC:0xCAFE;
txRec1553->
data[3] = (rec % 2)?0xACDC:0xCAFE;
txRec1553->
data[4] = (rec % 2)?0xACDC:0xCAFE;
}
}
break;
}
}
if(rc)
printf("event handler rc=0x%08x\n\r", rc);
return rc;
}