#include "example.h"
#define RT_ADRS 20
#define RT_SUBADRS 3
#define NB_BC_BUFFERS 3
#define NB_RT_BUFFERS 3
#define LOCAL
int main(void)
{
HMXF_SERVER server;
HMXF_DEVICE device=0;
HMXF_MODULE module=0;
HMXF_CHANNEL bc=0;
HMXF_CHANNEL bm=0;
HMXF_CHANNEL rt[NB_RT_BUFFERS];
HMXF_BUFFER bcBufferTx[NB_BC_BUFFERS];
HMXF_BUFFER bmBufferRx=0;
HMXF_BUFFER rtBuffer[NB_RT_BUFFERS];
uint32 txBufferSize=0;
uint32 rxBufferSize=0;
char errorString[256];
uint64 bus=MXF_MIL1553_BUS_A|MXF_MIL1553_BUS_B;
uint64 rxAcqStatus;
uint64 msgCount;
uint64 byteCount, indexBuffer;
uint64 rxRec;
uint32 loop=0;
uint64 address, subAddress, dir, wordCount;
uint64 deviceCount=0;
uint64 moduleCount=0;
uint64 channelCount=0;
uint32 rc;
uint64 index=0;
#ifdef LOCAL
#else
#endif
if(!rc)
{
printf("Starting ...\n\r");
}
if(!rc)
if(!rc && deviceCount)
{
if (!rc && !moduleCount)
}
if(!rc && moduleCount)
if(!rc && channelCount)
if(!rc && !channelCount)
rc = MAXT_ERROR_NOT_FOUND;
if(!rc)
if(!rc)
if(!rc)
#ifdef LOOPBACK
if(!rc)
#endif
if(!rc)
{
txBufferSize = 1024;
for (index = 0; index < NB_BC_BUFFERS && !rc; index++)
{
}
for (index = 0; index < NB_RT_BUFFERS && !rc; index++)
{
if(!rc)
if(!rc)
}
if(!rc)
{
if(!txBuffer)
rc = MAXT_ERROR_MEM;
}
}
if(!rc)
{
rxBufferSize = 10*1024;
if(!rc)
if(!rc)
{
if(!rxBuffer)
rc = MAXT_ERROR_MEM;
}
}
if(!rc)
if(!rc)
{
memset(&err, 0, sizeof(err));
if (!rc)
{
err.
errors[33] = MXF_MIL1553_STATUS_MSGERR;
}
}
if(!rc)
{
memset(&err, 0, sizeof(err));
if (!rc)
}
if(!rc)
{
memset(&err, 0, sizeof(err));
if (!rc)
}
if(!rc)
{
memset(&err, 0, sizeof(err));
}
if(!rc)
{
memset(minorFrame, 0, sizeof(minorFrame));
minorFrame[0].
buffer = bcBufferTx[0];
if (!rc)
minorFrame[1].
buffer = bcBufferTx[1];
if (!rc)
minorFrame[2].
buffer = bcBufferTx[2];
if (!rc)
{
memset( &propertiesMinorFrame, 0, sizeof(propertiesMinorFrame));
propertiesMinorFrame.
modulo = 1;
propertiesMinorFrame.
options = MXF_MIL1553_TXPERIODIC_MJRFRAME_MINOR_PROPERTIES_OPT_BRANCH_END;
}
}
if(!rc)
{
txRec1553->
data[0] = 0x0000;
for(index = 1; index < txRec1553->
dataSize/2; index++)
txRec1553->
data[index] = 0x0101*(uint16)index;
}
if(!rc)
{
txRec1553->
control = MXF_MIL1553_TXPERIODIC_REC_CTRL_ERROR_INJ;
}
if(!rc)
{
txRec1553->
data[0] = 0x0000;
for(index = 1; index < txRec1553->
dataSize/2; index++)
txRec1553->
data[index] = 0x0101*(uint16)index;
}
if(!rc)
{
txRec1553->
control = MXF_MIL1553_TXPERIODIC_REC_CTRL_ERROR_INJ;
}
if(!rc)
{
txRec1553->
control = MXF_MIL1553_TXPERIODIC_REC_CTRL_ERROR_INJ;
txRec1553->
data[0] = 0x0000;
for(index = 1; index < txRec1553->
dataSize/2; index++)
txRec1553->
data[index] = 0x0101*(uint16)index;
}
if(!rc)
{
txRec1553->
control = MXF_MIL1553_TXPERIODIC_REC_CTRL_ERROR_INJ;
}
printf("Starting BC - RT\n\r");
for (index = 0; index < NB_RT_BUFFERS && !rc; index++)
{
}
if(!rc)
if(!rc)
if(!rc)
{
do
{
rc =
mxfMIL1553RxAcqRead(bmBufferRx, 0, rxBufferSize, &rxAcqStatus, &msgCount, &byteCount, rxBuffer);
if (rc)
printf("mxfMIL1553RxAcqRead() error; rc=0x%08x\n\r", rc);
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 DataSize : %u Bus%s (0x%04x) Control : 0x%08x\n\r", address, subAddress, wordCount, (rxRec1553->
dataSize/2)-2, rxRec1553->
control & MXF_MIL1553_RX_REC_CTRL_MSG_BUS_B?
"B":
"A", rxRec1553->
data[0], rxRec1553->
control);
if (!(rxRec1553->
control&MXF_MIL1553_RX_REC_CTRL_MSG_NO_RESPONSE))
{
printf(
"\t\tRT status: Override %s\n\r", (rxRec1553->
data[msgInfo.
statusIndex[0]]&MXF_MIL1553_STATUS_MSGERR)?
"Injected":
"Not injected");
printf("\t\tRT response OK\n\r");
}
else
printf("\t\tRT response Error\n\r");
printf(
"\t\tParity %s\n\r", rxRec1553->
control&MXF_MIL1553_RX_REC_CTRL_MSG_PARITY_ERROR?
"Error":
"OK");
printf(
"\t\tData length %s\n\r", rxRec1553->
control&MXF_MIL1553_RX_REC_CTRL_MSG_DATA_LENGTH_ERROR?
"Error":
"OK");
printf(
"\t\tBit Count %s\n\r", rxRec1553->
control & MXF_MIL1553_RX_REC_CTRL_MSG_EXTRA_BIT_ERROR ?
"Error" :
"OK");
break;
case MXF_MIL1553_MSGINFO_TYPE_UNEXPECTED:
printf(
"BC to RT%llu SA%llu (unexpected command) Bus%s (0x%04x) Control : 0x%08x\n\r", address, subAddress, rxRec1553->
control & MXF_MIL1553_RX_REC_CTRL_MSG_BUS_B?
"B":
"A", rxRec1553->
data[0], rxRec1553->
control);
if (rxRec1553->
control&MXF_MIL1553_RX_REC_CTRL_MSG_NO_RESPONSE)
{
printf("\t\tRT response Error\n\r");
}
printf(
"\t\tParity %s\n\r", rxRec1553->
control&MXF_MIL1553_RX_REC_CTRL_MSG_PARITY_ERROR?
"Error":
"OK");
printf(
"\t\tData length %s\n\r", rxRec1553->
control&MXF_MIL1553_RX_REC_CTRL_MSG_DATA_LENGTH_ERROR?
"Error":
"OK");
printf(
"\t\tBit Count %s\n\r", rxRec1553->
control & MXF_MIL1553_RX_REC_CTRL_MSG_EXTRA_BIT_ERROR ?
"Error" :
"OK");
break;
}
}
}
}
loop++;
} while(loop < 10);
}
if(!rc)
{
if (!rc)
}
if(!rc)
{
printf("\nStopping BC - RT\n\r");
}
for (index = 0; index < NB_RT_BUFFERS && !rc; index++)
{
}
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 < NB_BC_BUFFERS; indexBuffer++)
{
if (bcBufferTx[indexBuffer])
{
if (rc)
printf("Free buffer failed !\n\r");
}
}
for(indexBuffer = 0; indexBuffer < NB_RT_BUFFERS; indexBuffer++)
{
if (rtBuffer[indexBuffer])
{
if (rc)
printf("Free buffer failed !\n\r");
}
}
if(bmBufferRx)
{
if (rc)
printf("Free buffer failed !\n\r");
}
printf("\n\rPress enter to terminate\n\r");
getchar();
return 0;
}