MX Foundation 4
Error Injection

The BC allows the user to send messages with many error types (per word basis). MIL-1553 modules contains a pool of 100 error injection structures. Each of these errors may be associated with any BC message by the periodic update message service. Each error structure may be configured with the mxfMIL1553ErrorInjectionSet() function. Any MIL-1553 channel handles of a module may be used with this function and refer to the same error pool.

In order to associate the error with a message, the mxfMIL1553TxPeriodicUpdateMsgWrite() function may be used. The MXF_MIL1553_DATAREC structure contains the errorIndex field that allows the message to be linked with a specific error index (0-99). To use this index, the MXF_MIL1553_TXPERIODIC_REC_CTRL_ERROR_INJ for periodic and MXF_MIL1553_TXAPERIODIC_REC_CTRL_ERROR_INJ for aperiodic option bits must be set in the control word.

To inject an error to a command that has no data associated to it (for example, a BC TX command), the dataSize field of MXF_MIL1553_DATAREC structure can be set to 0. That way, there is no need to provide any data.

#define BUF_SA3_RX 0
#define RT_ADRS_ERROR 5
uint32 rc;
HMXF_CHANNEL bc;
HMXF_BUFFER bcBufferTx[1];
...
// Configures injection #0, overrides address
if(!rc)
{
memset(&err, 0, sizeof(err));
rc = mxfMIL1553ErrorInjectionCompose(MXF_MIL1553_ERRORID_ADDRESS, RT_ADRS_ERROR, &err.errors[0]);
if (!rc)
rc = mxfMIL1553ErrorInjectionSet(bc, 0, &err);
}
// Sets BC data for address 20, subaddress 3, RX
if(!rc)
{
txRec1553 = (MXF_MIL1553_DATAREC *)txBuffer;
memset(txRec1553, 0, sizeof(MXF_MIL1553_DATAREC));
txRec1553->repeatCount = 1;
txRec1553->control = MXF_MIL1553_TXPERIODIC_REC_CTRL_ERROR_INJ;
txRec1553->service.txPeriodicUpdateMsg.errorIndex = 0; // override address
txRec1553->dataSize = 8; //8 bytes (command + 3 words)
txRec1553->data[0] = 0x0000; //Not used
txRec1553->data[1] = 0x0000;
txRec1553->data[2] = 0x1111;
txRec1553->data[3] = 0x2222;
rc = mxfMIL1553TxPeriodicUpdateMsgWrite(bcBufferTx[BUF_SA3_RX], 1, txBuffer);
}
...

mil1553_errors.c

Updated 10/23/2023