#include "example.h"
#define M_ADDRESS 5
#define M_SUBADDR 3
int main(void)
{
HMXF_SERVER server;
HMXF_DEVICE device=0;
HMXF_MODULE mil1553Module=0;
HMXF_MODULE discreteModule=0;
HMXF_CHANNEL bc=0;
HMXF_CHANNEL discreteOut=0;
#ifdef LOOPBACK
HMXF_CHANNEL discreteIn=0;
#endif
HMXF_BUFFER acq1553Buffer=0;
HMXF_BUFFER txDiscreteBuffer=0;
HMXF_BUFFER txMsg1553Buffer=0;
HMXF_BUFFER txMsg1553Buffer2=0;
uint32 rc;
uint64 appCount;
uint64 moduleCount=0;
uint32 txBufferSize=0;
uint32 rxBufferSize=0;
uint64 rxAcqStatus;
uint64 msgCount;
uint64 byteCount;
uint64 rxRec;
uint64 loop=0;
uint64 address, subAddress, dir, wordCount;
uint32 data;
char errorString[200];
#ifdef LOCAL
#else
#endif
printf("Starting ...\n\r");
if(!rc)
if(!rc)
if(!rc)
{
if(!rc && !moduleCount)
rc = MAXT_ERROR_NOT_FOUND;
}
if(!rc)
{
if(!rc && !moduleCount)
rc = MAXT_ERROR_NOT_FOUND;
}
if(!rc)
if(!rc)
#ifdef LOOPBACK
if(!rc)
if(!rc)
if(!rc)
#endif
if(!rc)
{
txBufferSize = 64*1024;
if(!rc)
if(!rc)
{
if(!txBuffer)
rc = MAXT_ERROR_MEM;
}
}
if(!rc)
{
rxBufferSize = 10*1024;
if(!rc)
{
if(!rxBuffer)
rc = MAXT_ERROR_MEM;
}
}
if(!rc)
if(!rc)
if(!rc)
{
memset(minorFrame, 0, sizeof(minorFrame));
minorFrame[0].
buffer = txMsg1553Buffer;
if(!rc)
{
minorFrame[1].
buffer = txMsg1553Buffer2;
}
if(!rc)
{
minorFrame[2].
buffer = txMsg1553Buffer2;
}
if(!rc)
}
if(!rc)
{
txRec1553->
data[0] = 0x0000;
txRec1553->
data[1] = 0x0000;
txRec1553->
data[2] = 0x1111;
txRec1553->
data[3] = 0x2222;
txRec1553->
data[4] = 0x3333;
txRec1553->
data[5] = 0x4444;
txRec1553->
data[6] = 0x5555;
txRec1553->
data[7] = 0x6666;
txRec1553->
data[8] = 0x7777;
txRec1553->
data[9] = 0x8888;
txRec1553->
data[10] = 0x9999;
txRec1553->
data[11] = 0xAAAA;
txRec1553->
data[12] = 0xBBBB;
txRec1553->
data[13] = 0xCCCC;
txRec1553->
data[14] = 0xDDDD;
txRec1553->
data[15] = 0xEEEE;
txRec1553->
data[16] = 0xFFFF;
}
if(!rc)
if(!rc)
{
memset(&majorProperties, 0, sizeof(majorProperties));
majorProperties.
options = MXF_MIL1553_TXPERIODIC_MJRFRAME_PROPERTIES_OPT_EXTCLOCK_MODE_RISING;
}
if(!rc)
{
uint32 pulseCount;
uint64 timer=0;
uint64 c50ms = 50000000;
memset(dioRec, 0, sizeof(dioRec));
if(!rc)
if(!rc)
{
for (pulseCount=0; !rc && pulseCount<100; pulseCount++)
{
timer+=c50ms;
timer+=c50ms;
if (rc)
printf("mxfDiscreteTxAperiodicWrite() error; rc=0x%08x (count=%d)\n\r", rc, pulseCount);
}
}
}
if(!rc)
{
do
{
rc =
mxfMIL1553RxAcqRead(acq1553Buffer, 0, rxBufferSize, &rxAcqStatus, &msgCount, &byteCount, rxBuffer);
if (rc)
printf("mxfMIL1553RxAcqRead() error; rc=0x%08x\n\r", rc);
{
if(!rc)
{
if(!rc)
{
printf(
"\n\r%llu:\t", rxRec1553->
timeTag);
{
case MXF_MIL1553_MSGINFO_TYPE_BCRT:
printf(
"BC to RT%lld SA%lld WC%lld (0x%04x)\n\r", address, subAddress, wordCount, rxRec1553->
data[0]);
printf(
"\t\tRT status: 0x%04x\n\r", rxRec1553->
data[msgInfo.
statusIndex[0]]);
break;
case MXF_MIL1553_MSGINFO_TYPE_RTBC:
printf(
"RT%lld SA%lld WC%lld to BC (0x%04x)\n\r", address, subAddress, wordCount, rxRec1553->
data[0]);
printf(
"\t\tRT status: 0x%04x\n\r", rxRec1553->
data[msgInfo.
statusIndex[0]]);
printf("\t\tRT data:");
for(data=0; data<msgInfo.dataWordCount; data++)
{
if(data && !(data%4))
printf("\n\r\t\t\t");
}
printf("\n\r");
break;
case MXF_MIL1553_MSGINFO_TYPE_MODECODE_TXDATA:
printf(
"BC Mode Command %lld to RT%lld SA%lld (0x%04x)\n\r", wordCount, address, subAddress, rxRec1553->
data[0]);
{
printf(
"\t\tRT status: 0x%04x\n\r", rxRec1553->
data[msgInfo.
statusIndex[0]]);
printf(
"\t\tRT data: 0x%04x\n\r", rxRec1553->
data[msgInfo.
dataIndex]);
}
break;
}
}
}
}
loop++;
} while(loop < 25);
}
printf("Stopping\n\r");
if(!rc)
if(!rc)
if(txBuffer)
free(txBuffer);
if(rxBuffer)
free(rxBuffer);
if(rc)
{
sprintf (errorString,"ERROR # 0x%08x", rc);
printf("%s\n\r", errorString);
}
if(!rc)
{
if(appCount > 1)
else
{
if(txMsg1553Buffer)
{
if (rc)
printf("Free buffer failed !\n\r");
}
if(txMsg1553Buffer2)
{
if (rc)
printf("Free buffer failed !\n\r");
}
if(acq1553Buffer)
{
if (rc)
printf("Free buffer failed !\n\r");
}
if(txDiscreteBuffer)
{
if (rc)
printf("Free buffer failed !\n\r");
}
}
}
printf("\nPress enter to terminate\n\r");
getchar();
return 0;
}