#include "example.h"
#define BUF_SA3_RX 0
#define BUF_SA3_TX 1
#define BUF_SA3_MC 2
#define BUF_SA5_RX 3
#define RT_ADRS 0
#define M_ADDRESS 5
#define M_SUBADDR 3
#define LOCAL
int main(void)
{
uint32 rc;
uint64 deviceCount = 0;
uint64 moduleCount = 0;
uint64 channelCount = 0;
HMXF_SERVER server;
HMXF_DEVICE device = 0;
HMXF_MODULE module[2];
HMXF_CHANNEL bc = 0;
HMXF_CHANNEL rt = 0;
HMXF_CHANNEL bm = 0;
HMXF_BUFFER bcBufferTx[4]={ 0 };
HMXF_BUFFER bcBufferRx = 0;
HMXF_BUFFER rtBuffer[4]={ 0 };
MXF_MSGID_MIL1553 bcMsgID[4] = { {MXF_MIL1553_MSGTYPE_RX,RT_ADRS,3,0},{MXF_MIL1553_MSGTYPE_TX,RT_ADRS,3,0},{MXF_MIL1553_MSGTYPE_MODECODE,RT_ADRS,16,0},{MXF_MIL1553_MSGTYPE_RX,RT_ADRS,5,0} };
MXF_MSGID_MIL1553 rtMsgID[4] = { {MXF_MIL1553_MSGTYPE_RX,0,3,0},{MXF_MIL1553_MSGTYPE_TX,0,3,0},{MXF_MIL1553_MSGTYPE_MODECODE,0,16,0},{MXF_MIL1553_MSGTYPE_RX,0,5,0} };
uint32 txBufferSize = 0;
uint32 rxBufferSize = 0;
uint64 bus = MXF_MIL1553_BUS_A | MXF_MIL1553_BUS_B;
uint64 rxAcqStatus = 0;
uint64 msgCount = 0;
uint64 byteCount = 0;
uint64 rxRec;
uint32 loop = 0;
uint64 address, subAddress, dir, wordCount, indexBuffer;
uint32 data;
uint32 msg;
char errorString[200];
#ifdef LOCAL
#else
#endif
if (!rc)
{
printf("Starting ...\n\r");
}
if (!rc)
if (!rc && !deviceCount)
if (!rc && deviceCount)
{
if (moduleCount != 2)
{
printf("This example only works for FM1553-4 or FX1553-4\n");
rc = MAXT_ERROR_MODEL;
}
}
else if (!rc && !deviceCount)
rc = MAXT_ERROR_MODEL;
if (!rc && moduleCount)
if (!rc && !channelCount)
rc = MAXT_ERROR_NOT_FOUND;
if (!rc)
if (!rc)
#ifdef LOOPBACK
if (!rc)
#endif
if (!rc)
{
txBufferSize = 1024;
for (msg = 0; msg < 4 && !rc; msg++)
{
if (!rc)
if (!rc)
}
if (!rc)
{
if (!txBuffer)
rc = MAXT_ERROR_MEM;
}
}
if (!rc)
{
rxBufferSize = 1 * 1024;
if (!rc)
if (!rc)
{
if (!rxBuffer)
rc = MAXT_ERROR_MEM;
}
}
if (!rc)
if (!rc)
if (!rc)
{
memset(&err, 0, sizeof(err));
err.
errors[0] = MXF_MIL1553_ERRORID_NOOP;
}
if (!rc)
{
memset(minorFrame, 0, sizeof(minorFrame));
rc =
mxfMIL1553CommandCompose(bcMsgID[BUF_SA3_RX].address, bcMsgID[BUF_SA3_RX].subAddress, bcMsgID[BUF_SA3_RX].type, 16, &minorFrame[0].command);
minorFrame[0].
buffer = bcBufferTx[BUF_SA3_RX];
if (!rc)
{
rc =
mxfMIL1553CommandCompose(bcMsgID[BUF_SA3_TX].address, bcMsgID[BUF_SA3_TX].subAddress, bcMsgID[BUF_SA3_TX].type, 16, &minorFrame[1].command);
minorFrame[1].
buffer = bcBufferTx[BUF_SA3_TX];
}
if (!rc)
{
rc =
mxfMIL1553CommandCompose(bcMsgID[BUF_SA3_MC].address, 0, MXF_MIL1553_MSGTYPE_TX, bcMsgID[BUF_SA3_MC].subAddress, &minorFrame[2].command);
minorFrame[2].
buffer = bcBufferTx[BUF_SA3_MC];
}
if (!rc)
}
if (!rc)
{
memset(minorFrame, 0, sizeof(minorFrame));
memset(&mfProp, 0, sizeof(mfProp));
rc =
mxfMIL1553CommandCompose(bcMsgID[BUF_SA5_RX].address, bcMsgID[BUF_SA5_RX].subAddress, bcMsgID[BUF_SA5_RX].type, 4, &minorFrame[0].command);
minorFrame[0].
buffer = bcBufferTx[BUF_SA5_RX];
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;
txRec1553->
data[0] = 0x0000;
txRec1553->
data[1] = 0xFFFF;
txRec1553->
data[2] = 0xEEEE;
txRec1553->
data[3] = 0xDDDD;
txRec1553->
data[4] = 0xCCCC;
txRec1553->
data[5] = 0xBBBB;
txRec1553->
data[6] = 0xAAAA;
txRec1553->
data[7] = 0x9999;
txRec1553->
data[8] = 0x8888;
txRec1553->
data[9] = 0x7777;
txRec1553->
data[10] = 0x6666;
txRec1553->
data[11] = 0x5555;
txRec1553->
data[12] = 0x4444;
txRec1553->
data[13] = 0x3333;
txRec1553->
data[14] = 0x2222;
txRec1553->
data[15] = 0x1111;
txRec1553->
data[16] = 0x0000;
}
if (!rc)
{
txRec1553->
control = MXF_MIL1553_TXPERIODIC_REC_CTRL_ERROR_INJ;
}
if (!rc)
{
txRec1553->
control = MXF_MIL1553_TXPERIODIC_REC_CTRL_UPDATE_COMMAND;
}
if (!rc)
{
txRec1553->
data[0] = 0x0000;
txRec1553->
data[1] = 0x1234;
txRec1553->
data[2] = 0x5678;
txRec1553->
data[3] = 0x9ABC;
txRec1553->
data[4] = 0xDEF0;
}
if (!rc)
{
printf("Starting BC and RT\n\r");
}
if (!rc)
if (!rc)
if (!rc)
{
do
{
rc =
mxfMIL1553RxAcqRead(bcBufferRx, 0, rxBufferSize, &rxAcqStatus, &msgCount, &byteCount, rxBuffer);
for (rxRec = 0; rxRec < msgCount && !rc; rxRec++)
{
if (!rc)
{
if (!rc)
{
printf(
"\n\r%llu:\t", rxRec1553->
timeTag);
{
case MXF_MIL1553_MSGINFO_TYPE_BCRT:
printf(
"BC to RT%llu SA%llu WC%llu (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%llu SA%llu WC%llu 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 %llu to RT%llu SA%llu (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 < 5);
}
if (!rc)
{
if (!rc)
}
if (!rc)
{
printf("Stopping BC and RT\n\r");
}
if (!rc)
printf("Terminating\n\r");
if (txBuffer)
free(txBuffer);
if (rxBuffer)
free(rxBuffer);
if (rc)
{
sprintf(errorString, "ERROR # 0x%08X", rc);
printf("%s\n\r", errorString);
}
for (indexBuffer = 0; indexBuffer < 4; indexBuffer++)
{
if (bcBufferTx[indexBuffer])
{
if (rc)
printf("Free buffer failed !\n\r");
}
}
for (indexBuffer = 0; indexBuffer < 4; indexBuffer++)
{
if (rtBuffer[indexBuffer])
{
if (rc)
printf("Free buffer failed !\n\r");
}
}
if (bcBufferRx)
{
if (rc)
printf("Free buffer failed !\n\r");
}
printf("\n\rPress enter to terminate\n\r");
getchar();
return 0;
}