Integrator Resources

The official home for NAI Support

Not sure where to start? Try Quick Start Guide or ask a question below!

Toggle Components with Visual Button
JavaScript Form Processing

M1553 BC SendMsg FIFO

M1553 BC SendMsg FIFO Sample Application (SSK 2.x)

Overview

The M1553 BC SendMsg FIFO sample application demonstrates how to send MIL-STD-1553 Bus Controller (BC) messages and retrieve the results using Message FIFO mode with the NAI Software Support Kit (SSK 2.x). Unlike the standard BC SendMsg sample which retrieves message responses by message ID, this sample initializes the BC in FIFO mode so that all message transactions are stored in a hardware FIFO buffer and decoded sequentially.

FIFO mode is useful when you need to capture a complete, ordered history of all BC transactions rather than polling individual message slots. This is particularly valuable for logging, diagnostics, and automated test scenarios.

Note
FIFO mode is available for the FTA-FTF modules only. FTJ/FTK (1760) modules do not support Message FIFO mode.

For detailed 1553 protocol specifications, message formats, and hardware register descriptions, see the FTA-FTF Manual.

For the SSK 1.x version, see M1553 BC SendMessage FIFO (SSK 1.x).

Prerequisites

Before running this sample, make sure you have:

  • An NAI board with a 1553 module installed (FTA-FTF).

  • SSK 2.x installed on your development host.

  • The sample applications built. Refer to the SSK 2.x Software Development Guide for platform-specific build instructions.

  • A second 1553 device (RT) connected on the same bus to respond to BC messages.

How to Run

Launch the m1553_bc_send_msg_fifo executable from your build output directory. On startup the application looks for a configuration file (default_1553BC_SendMessage_FIFO.txt). On the first run, this file will not exist — the application will present an interactive board menu. Once connected, the application prompts for channel, message type, bus selection, and software override settings, then sends messages and decodes responses from the FIFO in a loop.

Board Connection and Module Selection

Note
This startup sequence is common to all NAI sample applications.

The main() function follows a standard SSK 2.x startup flow:

  1. Call naiapp_RunBoardMenu() to load or create a configuration file (default_1553BC_SendMessage_FIFO.txt).

  2. Query the user for a card index with naiapp_query_CardIndex().

  3. Query for a module slot with naiapp_query_ModuleNumber().

  4. Retrieve the module ID with naibrd_GetModuleName().

#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t m1553_bc_send_msg_fifo(void)
#else
int32_t main(void)
#endif
{
   int32_t cardIndex;
   int32_t moduleCnt;
   int32_t module;
   bool_t  stop = NAI_FALSE;
   uint32_t moduleID = 0;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == (bool_t)NAI_TRUE)
   {
      while (stop != NAI_TRUE)
      {
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != NAI_TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != NAI_TRUE)
            {
               check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
               if ((moduleID != 0))
               {
                  Run_m1553_bc_send_msg_fifo(cardIndex, module, moduleID);
               }
            }
         }

         naiif_printf("\r\nType Q to quit or Enter key to restart application:\r\n");
         stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      }
   }

   naiapp_access_CloseAllOpenCards();
   return 0;
}
Important

Common Connection Errors

  • No board found — verify the board is powered and the connection is active.

  • Connection timeout — check network settings and firewall rules for Ethernet connections.

  • Invalid card/module index — indices are 0-based for cards and 1-based for modules.

  • Module not present — confirm the 1553 module is physically installed in the expected slot.

Program Structure

Entry Point

The Run_m1553_bc_send_msg_fifo() function checks whether the installed module supports 1553 functionality using IsFTx1553() (note: FIFO mode only supports FTA-FTF modules, not FTJ/FTK), then queries for a channel and delegates to RunSendMessage().

Command Loop

RunSendMessage() prompts for message type, bus, and software override, then loops: each iteration writes data to the data block, clears the FIFO, starts the BC, waits, stops, reads the FIFO, and decodes the messages sequentially.

Opening and Initializing in FIFO Mode

The key difference from the standard BC sample is the initialization mode flag. FIFO mode is enabled by OR-ing NAIBRD_1553_MESSAGE_FIFO_MODE with NAIBRD_1553_MODE_BC:

/* Initialize 1553 Device in FIFO mode */
status = naibrd_1553_Init(devnum, NAIBRD_1553_ACCESS_CARD,
   NAIBRD_1553_MODE_BC | NAIBRD_1553_MESSAGE_FIFO_MODE, 0, 0, 0);

Creating Messages and Frame Hierarchy

The sample supports the same message types as the standard BC SendMsg sample (BC-to-RT, RT-to-BC, RT-to-RT, and mode codes). Message creation and frame hierarchy construction are identical — the FIFO mode only changes how responses are retrieved.

Sending Messages and Reading the FIFO

Each iteration follows this sequence:

/* Clear the FIFO before starting */
status = naibrd_1553_ClearMsgFIFO(devnum);

/* Start BC for 1 major frame */
status = naibrd_1553_BcStart(devnum, MJR, 1);
naibrd_msDelay(200);

/* Stop BC */
status = naibrd_1553_BcStop(devnum);

/* Get FIFO count */
status = naibrd_1553_GetMsgFIFOCount(devnum, &fifoCount);

/* Read all FIFO data */
memset(fifoData, 0, sizeof(fifoData));
status = naibrd_1553_ReadMsgFIFO(devnum, fifoCount, fifoData);

/* Decode messages sequentially */
do
{
   status = naibrd_1553_DecodeFIFOMsg(fifoData, currBlockIndex, &nextBlockIndex, &msgStruct);
   if (status == 0)
   {
      /* Display decoded fields */
      naiif_printf("Command Word: 0x%04X\r\n", msgStruct.commandWord1);
      naiif_printf("Block Status: 0x%04X\r\n", msgStruct.blockStatus);
      /* ... */
   }
   currBlockIndex = nextBlockIndex;
} while (status == NAI_SUCCESS);
  • naibrd_1553_ClearMsgFIFO() — clears the FIFO before each transmission to avoid stale data.

  • naibrd_1553_GetMsgFIFOCount() — returns the number of 32-bit words in the FIFO.

  • naibrd_1553_ReadMsgFIFO() — reads the raw FIFO data into a buffer.

  • naibrd_1553_DecodeFIFOMsg() — decodes one message at a time from the raw FIFO buffer, using currBlockIndex to track position. The function populates a naibrd_1553_msgstructFIFO_t structure and returns NAIBRD_1553_CMD_NO_MSG_TO_DECODE when no more messages remain.

After decoding, the sample checks the FIFO full status:

status = naibrd_1553_GetMsgFIFOFullStatus(devnum, NAIBRD_1553_STATUS_REALTIME, &FIFOfullStatusBit);

If the FIFO was full, some messages may have been lost.

Cleanup

status = naibrd_1553_Free(devnum);

Troubleshooting Reference

Error / Symptom Possible Causes Suggested Resolution

naibrd_1553_Open returns non-zero

Channel already open, invalid card/module/channel index

Verify indices, ensure no other application holds the channel

FIFO mode not supported

Module is FTJ/FTK (1760), not FTA-FTF

FIFO mode is only available on FTA-FTF modules

FIFO count is zero after BC run

Message execution did not complete, RT not responding

Increase delay after BcStart, verify RT is on the bus

FIFO full status is true

Too many messages for FIFO capacity

Read FIFO more frequently or reduce message rate

naibrd_1553_DecodeFIFOMsg returns error

Corrupted FIFO data, buffer not cleared before read

Always call naibrd_1553_ClearMsgFIFO before starting, zero the buffer with memset

No response from RT

RT not on bus, wrong bus (A/B) selected

Verify RT is active, check cabling, try other bus

Software override needed

BC_DISABLE or M1760 pins not externally driven high

Enable software override when prompted for bench testing

Full Source

Full Source — m1553_bc_send_msg_fifo.c (SSK 2.x)
/* nailib include files */
#include "nai_libs/nailib/include/naitypes.h"
#include "nai_libs/nailib/include/nailib.h"
#include "nai_libs/nailib/include/nailib_utils.h"

/* naibrd include files */
#include "nai_libs/naibrd/include/naibrd.h"
#include "nai_libs/naibrd/include/functions/naibrd_1553.h"
#include "nai_libs/naibrd/include/functions/naibrd_1553_assisted.h"
#include "nai_libs/naibrd/include/functions/naibrd_1553_1760_status.h"

/* naiif include files */
#include "nai_libs/naiif/include/naiif_stdio.h"

/* Common 1553 Sample Program include files */
#include "nai_sample_apps/naiapp_src/board_modules/1553/m1553_common_utils/m1553_common_utils.h"
#include "nai_sample_apps/naiapp_src/board_modules/1553/m1553_common_utils/BC/m1553_bc_common_utils.h"

/* Common Sample Program include files */
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_menu.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_query.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_access.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_display.h"
#include "nai_sample_apps/naiapp_common/include/naiapp_boardaccess_utils.h"

static const int8_t *DEF_CONFIG_FILE = (int8_t *)"default_1553BC_SendMessage_FIFO.txt";

/* Function prototypes */
static bool_t Run_m1553_bc_send_msg_fifo(int32_t cardIndex, int32_t module, uint32_t modid);
static bool_t RunSendMessage(int32_t cardIndex, int32_t module, int32_t channel);

/* define message constants */
#define MSG1         1

/* define opcodes */
#define OP1          1
#define OP2          2

/* define frame constants */
#define MNR1         1
#define MJR          2

/* define data block numbers */
#define DBLK1        1
#define DBLK2        2

#define DEF_M1553_CARD_INDEX                 0
#define DEF_M1553_MODULE                     1
#define DEF_M1553_CHANNEL                    1
#define DEF_M1553_DEVNUM                     1

#define RT_ADDRESS                           1
#define RT_SUBADDRESS                        2

#define RT_ADDRESS_2                         2

#define WORDCOUNT                            32

/**************************************************************************************************************/
/** \defgroup M1553_BC_SendMessage_FIFO

\brief This sample application demonstrates how to configure a channel as a Bus Controller and send a message in FIFO mode.

The purpose of the m1553_bc_send_msg_fifo is to illustrate the methods to call in the naibrd library to configure
the 1553 channel as a Bus Controller and to send a 1553 message out in FIFO mode.

Note: FIFO mode is available for the FTA-FTF only.

The main steps include:
- Querying the user for the card index and module number.
- Configuring the channel for Bus Controller functionality in FIFO mode.
- Configuring a frame with one message of a selected type.
- Starting the BC to transmit the configured message.
- Displaying the RT response and BC Status.
*/
/**************************************************************************************************************/
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t m1553_bc_send_msg_fifo(void)
#else
int32_t main(void)
#endif
{
   int32_t cardIndex;
   int32_t moduleCnt;
   int32_t module;
   bool_t  stop = NAI_FALSE;
   uint32_t moduleID = 0;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == (bool_t)NAI_TRUE)
   {
      while (stop != NAI_TRUE)
      {
         /* Select Card Index */
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != NAI_TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));

            /* Select Module */
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != NAI_TRUE)
            {
               check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
               if ((moduleID != 0))
               {
                  Run_m1553_bc_send_msg_fifo(cardIndex, module, moduleID);
               }
            }
         }

         naiif_printf("\r\nType Q to quit or Enter key to restart application:\r\n");
         stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      }
   }

   naiif_printf("\r\nType the Enter key to exit the program: ");
   naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

   naiapp_access_CloseAllOpenCards();

   return 0;
}

static bool_t Run_m1553_bc_send_msg_fifo(int32_t cardIndex, int32_t module, uint32_t modid)
{
   bool_t bQuit = NAI_FALSE;
   int32_t channel;
   int32_t MaxChannel = 4;

   if (IsFTx1553(modid))
   {
      MaxChannel = 4;
      bQuit = naiapp_query_ChannelNumber(MaxChannel, DEF_M1553_CHANNEL, &channel);
      if (!bQuit)
      {
         bQuit = RunSendMessage(cardIndex, module, channel);
      }
   }
   else
      naiif_printf("\r\nThis module does not support 1553 functionality.\r\n");

   return bQuit;
}

static bool_t RunSendMessage(int32_t cardIndex, int32_t module, int32_t channel)
{
   int32_t i;
   bool_t bQuit = NAI_FALSE;
   uint32_t usBus;
   naibrd_1553_t status;
   uint16_t increment = 0;
   uint16_t aData[32] = { 0 };
   int16_t aOpCodes[20] = { 0 };
   bool_t bContinue = NAI_TRUE;
   int16_t devnum;
   bool_t bValidModeCode;
   M1553MsgType_t msgType;
   naibrd_1553_msgstructFIFO_t msgStruct;
   bool_t bSoftware;
   M1553ModeCodes_t modeCommand;
   uint32_t fifoCount = 0;
   uint32_t fifoData[1024];
   int32_t currBlockIndex = 0, nextBlockIndex = 0;
   bool_t FIFOfullStatusBit;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;


   /* Get the Logical Device Number */
   bQuit = Get1553LogicalDevNum(DEF_M1553_DEVNUM, &devnum);
   if (!bQuit)
   {
      /* Get Msg Direction */
      bQuit = GetMsgTypeAndCheckForQuit(&msgType);
      if (!bQuit)
      {
         /* Which bus are we firing on? */
         bQuit = GetBus(&usBus);
         if (!bQuit)
         {
            bQuit = Get1553BCSoftwareOverride(NAI_TRUE, &bSoftware);
            if (!bQuit)
            {

               /* Open 1553 Device(s) */
               status = naibrd_1553_Open(cardIndex, module, channel, devnum);
               if (status != 0)
               {
                  naiif_printf("Error: naibrd_1553_Open Ch %d, status = %d", channel, status);
                  return NAI_TRUE;
               }

               if (bSoftware)
               {
                  /* Override external BC_DISABLE and M1760 (In order to configure as BC, this needs to */
                  /* be set if BC_DISABLE and M1760 pins are not driven high) */
                  naibrd_1553_WriteAuxRegister(devnum, 0x2, 0xA000);
               }
               else
               {
                  /* Do not override external BC_DISABLE and M1760 Inputs */
                  naibrd_1553_WriteAuxRegister(devnum, 0x2, 0x0000);
               }

               if ((msgType == M1553_MSGTYPE_MODECODE_TX) || (msgType == M1553_MSGTYPE_MODECODE_RX))
               {
                  do
                  {
                     bQuit = AskAndCheckForValidModeCodeAndCheckForQuit((msgType == M1553_MSGTYPE_MODECODE_TX) ?
                        M1553_MSGTYPE_MODECODE_DIRECTION_TX : M1553_MSGTYPE_MODECODE_DIRECTION_RX, &modeCommand, &bValidModeCode);

                  } while ((!bQuit) && (!bValidModeCode));
               }

               if (!bQuit)
               {
                  /* Reset Device */
                  naibrd_1553_WriteAuxRegister(devnum, 0x1, 0x1);
#if defined(NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
                  taskDelay(1);
#elif defined(LINUX)
                  usleep(100000);
#else
                  naiif_msDelay(100);
#endif
                  naibrd_1553_WriteAuxRegister(devnum, 0x1, 0x0);

                  /* Initialize 1553 Device(s) */
                  status = naibrd_1553_Init(devnum, NAIBRD_1553_ACCESS_CARD, NAIBRD_1553_MODE_BC | NAIBRD_1553_MESSAGE_FIFO_MODE, 0, 0, 0);
                  if (status != 0)
                  {
                     naiif_printf("Error: naibrd_1553_Init Ch %d, status = %d", channel, status);
                     return NAI_TRUE;
                  }

                  if ((msgType != M1553_MSGTYPE_MODECODE_TX) || (msgType != M1553_MSGTYPE_MODECODE_RX))
                  {
                     /* Create BC Data Block */
                     status = naibrd_1553_BcDataBlkCreate(devnum, DBLK1, WORDCOUNT, NULL, 0);
                     if (status != 0)
                     {
                        naiif_printf("Error: naibrd_1553_BcDataBlkCreate Ch %d, status = %d", channel, status);
                        return NAI_TRUE;
                     }
                  }
                  else if ((msgType == M1553_MSGTYPE_MODECODE_TX) || (msgType == M1553_MSGTYPE_MODECODE_RX))
                  {
                     status = naibrd_1553_BcDataBlkCreate(devnum, DBLK2, modeCommand, NULL, 0);
                     if (status != 0)
                     {
                        naiif_printf("Error: naibrd_1553_BcDataBlkCreate Ch %d, status = %d", channel, status);
                        return NAI_TRUE;
                     }
                  }

                  if (msgType == M1553_MSGTYPE_RTTOBC)
                  {
                     /* Create RT to BC Message */
                     status = naibrd_1553_BcMsgCreateRtToBc(devnum, MSG1, DBLK1, RT_ADDRESS, RT_SUBADDRESS, WORDCOUNT, 1, usBus);
                     if (status != 0)
                     {
                        naiif_printf("Error: naibrd_1553_BcMsgCreateRtToBc status = %d", status);
                        return NAI_TRUE;
                     }
                  }
                  else if (msgType == M1553_MSGTYPE_BCTORT)
                  {
                     /* Create BC to RT Message */
                     status = naibrd_1553_BcMsgCreateBcToRt(devnum, MSG1, DBLK1, RT_ADDRESS, RT_SUBADDRESS, WORDCOUNT, 1, usBus);
                     if (status != 0)
                     {
                        naiif_printf("Error: naibrd_1553_BcMsgCreateBcToRt status = %d", status);
                        return NAI_TRUE;
                     }

                  }
                  else if ((msgType == M1553_MSGTYPE_MODECODE_TX) || (msgType == M1553_MSGTYPE_MODECODE_RX))
                  {
                     /* Create Mode Code Tx Message */
                     status = naibrd_1553_BcMsgCreateMode(devnum, MSG1, DBLK1, RT_ADDRESS, (msgType == M1553_MSGTYPE_MODECODE_TX) ?
                        NAIBRD_1553_DIRECTION_TX : NAIBRD_1553_DIRECTION_RX, modeCommand, 0, usBus);
                     if (status != 0)
                     {
                        naiif_printf("Error: naibrd_1553_BcMsgCreateMode status = %d", status);
                        return NAI_TRUE;
                     }
                  }
                  else if (msgType == M1553_MSGTYPE_RTTORT)
                  {
                     /* Create RT to RT Message */
                     status = naibrd_1553_BcMsgCreateRtToRt(devnum, MSG1, DBLK1, RT_ADDRESS_2, RT_SUBADDRESS, WORDCOUNT, RT_ADDRESS, RT_SUBADDRESS, 0, usBus);
                     if (status != 0)
                     {
                        naiif_printf("Error: naibrd_1553_BcMsgCreateRtToRt status = %d", status);
                        return NAI_TRUE;
                     }
                  }

                  /* Create Execute Message Command */
                  status = naibrd_1553_BcCmdCreate(devnum, OP1, NAIBRD_1553_OPCODE_EXECUTE_MESSAGE, NAIBRD_1553_OPCODE_COND_ALWAYS, MSG1, 0, 0);
                  if (status != 0)
                  {
                     naiif_printf("Error: naibrd_1553_BcCmdCreate status = %d", status);
                     return NAI_TRUE;
                  }

                  /* Create Call Subroutine Command */
                  status = naibrd_1553_BcCmdCreate(devnum, OP2, NAIBRD_1553_OPCODE_CALL_SUBROUTINE, NAIBRD_1553_OPCODE_COND_ALWAYS, MNR1, 0, 0);
                  if (status != 0)
                  {
                     naiif_printf("Error: naibrd_1553_BcCmdCreate status = %d", status);
                     return NAI_TRUE;
                  }

                  /* Create Minor Frame */
                  aOpCodes[0] = OP1;
                  status = naibrd_1553_BcFrmCreate(devnum, MNR1, NAIBRD_1553_BC_FRAME_MINOR, aOpCodes, 1, 0, 0);
                  if (status != 0)
                  {
                     naiif_printf("Error: naibrd_1553_BcFrmCreate status = %d", status);
                     return NAI_TRUE;
                  }

                  /* Create Major Frame */
                  aOpCodes[0] = OP2;
                  status = naibrd_1553_BcFrmCreate(devnum, MJR, NAIBRD_1553_BC_FRAME_MAJOR, aOpCodes, 1, 1000, 0);
                  if (status != 0)
                  {
                     naiif_printf("Error: naibrd_1553_BcFrmCreate status = %d", status);
                     return NAI_TRUE;
                  }

                  while (bContinue)
                  {
                     /* Load BC data block with incremental data */
                     for (i = 0; i < WORDCOUNT; i++)
                     {
                        aData[i] = increment++;
                     }

                     status = naibrd_1553_BcDataBlkWrite(devnum, DBLK1, aData, WORDCOUNT, 0);
                     if (status != 0)
                     {
                        naiif_printf("Error: naibrd_1553_BcDataBlkWrite status = %d", status);
                        return NAI_TRUE;
                     }

                     status = naibrd_1553_ClearMsgFIFO(devnum);
                     if (status != 0)
                     {
                        naiif_printf("Error: naibrd_1553_ClearMsgFIFO status = %d", status);
                        return NAI_TRUE;
                     }

                     /* Start BC */
                     status = naibrd_1553_BcStart(devnum, MJR, 1);
                     if (status != 0)
                     {
                        naiif_printf("Error: naibrd_1553_BcStart status = %d", status);
                        return NAI_TRUE;
                     }

                     /* This delay is necessary to allow the BC to run */
                     naibrd_msDelay(200);

                     /* Stop BC */
                     status = naibrd_1553_BcStop(devnum);
                     if (status != 0)
                     {
                        naiif_printf("Error: naibrd_1553_BcStop status = %d", status);
                        return NAI_TRUE;
                     }

                     status = naibrd_1553_GetMsgFIFOCount(devnum, &fifoCount);
                     if (status != 0)
                     {
                        naiif_printf("Error: naibrd_1553_GetMsgFIFOCount %d", status);
                        return NAI_TRUE;
                     }
                     else
                     {
                        if (fifoCount > 0)
                        {
                           currBlockIndex = 0;

                           /* This is necessary because otherwise, fifoData array gets used over and over without getting zero'ed out. */
                           /* When the array gets decoded, old data may get decoded unintentionally */
                           memset(fifoData, 0, sizeof(fifoData));

                           /* Read Message FIFO */
                           status = naibrd_1553_ReadMsgFIFO(devnum, fifoCount, fifoData);
                           if (status != 0)
                           {
                              naiif_printf("Error: naibrd_1553_ReadMsgFIFO  %d", status);
                              return NAI_TRUE;
                           }
                           else
                           {
                              /* Read Messages */
                              do
                              {
                                 status = naibrd_1553_DecodeFIFOMsg(fifoData, currBlockIndex, &nextBlockIndex, &msgStruct);
                                 if (status == 0)
                                 {
                                    naiif_printf("Command Word: 0x%04X\r\n", msgStruct.commandWord1);

                                    if (msgStruct.isCommandWord2Relevant)
                                       naiif_printf("Command Word 2: 0x%04X\r\n", msgStruct.commandWord2);

                                    naiif_printf("Block Status: 0x%04X\r\n", msgStruct.blockStatus);
                                    naiif_printf("Time Tag: 0x%04X\r\n", msgStruct.timeTag);
                                    naiif_printf("Word Count: 0x%04X\r\n", msgStruct.dataWordCount);
                                    naiif_printf("RT Status Word: 0x%04X\r\n", msgStruct.status1);

                                    if (msgStruct.isStatus2Relevant)
                                       naiif_printf("RT Status Word 2: 0x%04X\r\n", msgStruct.status2);

                                    if ((msgType == M1553_MSGTYPE_RTTOBC) || (msgType == M1553_MSGTYPE_MODECODE_TX))
                                    {

                                       naiif_printf((msgStruct.dataWordCount > 0) ? ("Data:") : (""));
                                       for (i = 0; i < msgStruct.dataWordCount; i++)
                                       {
                                          if (i % 8 == 0)
                                          {
                                             naiif_printf("\r\n");
                                          }
                                          naiif_printf("0x%04X ", msgStruct.data[i]);
                                       }
                                    }
                                    naiif_printf("\r\n\r\n");
                                 }
                                 else if (status != NAIBRD_1553_CMD_NO_MSG_TO_DECODE)
                                 {
                                    naiif_printf("Error: naibrd_1553_DecodeFIFOMsg  %d", status);
                                    return NAI_TRUE;
                                 }

                                 /*** IMPORTANT !!! ***/
                                 currBlockIndex = nextBlockIndex;

                                 naibrd_msDelay(1);

                              } while ((status == NAI_SUCCESS) && (bContinue));
                           }

                           status = naibrd_1553_GetMsgFIFOFullStatus(devnum, NAIBRD_1553_STATUS_REALTIME, &FIFOfullStatusBit);
                           if (status == NAI_SUCCESS)
                           {
                              naiif_printf("FIFO status: %d", FIFOfullStatusBit);
                              naiif_printf((FIFOfullStatusBit == NAI_TRUE) ? " Full\r\n" : " Not full\r\n");
                           }
                           else
                           {
                              naiif_printf("Error: naibrd_1553_GetMsgFIFOFullStatus  %d", status);
                              return NAI_TRUE;
                           }
                        }
                        naiif_printf("\r\nPress any key to send another message or Q to quit.");
                        bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
                        if (bQuit)
                        {
                           bContinue = NAI_FALSE;
                        }
                     }
                  }
               }
            }
         }
      }
   }

   /* Free 1553 Device */
   status = naibrd_1553_Free(devnum);
   if (status != 0)
   {
      naiif_printf("Error: naibrd_1553_Free status = %d", status);
      return NAI_TRUE;
   }

   return bQuit;
}

Help Bot

X