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 MT Monitor FIFO

M1553 MT Monitor FIFO Sample Application (SSK 1.x)

Overview

The M1553 MT Monitor FIFO sample application demonstrates passive MIL-STD-1553 bus monitoring using Monitor Terminal (MT) mode with FIFO-based bulk message retrieval, using the NAI Software Support Kit (SSK 1.x). This is the FIFO-based companion to the stack-based M1553 MT Monitor sample. Both share the same initialization and filtering logic, but this variant retrieves captured messages in bulk from a hardware FIFO rather than one at a time from the stack. The FIFO approach reduces the number of API calls per monitoring cycle and is better suited to high-traffic buses where the stack-based approach may not keep up.

The key FIFO API calls demonstrated are:

  • naibrd_1553_GetMsgFIFOCount() — queries how many messages are waiting in the FIFO.

  • naibrd_1553_ReadMsgFIFO() — reads all pending messages in a single bulk operation.

  • naibrd_1553_DecodeFIFOMsg() — iteratively decodes individual messages from the bulk buffer.

  • naibrd_1553_GetMsgFIFOFullStatus() — checks whether the FIFO has overflowed and messages may have been lost.

  • naibrd_1553_ClearMsgFIFO() — clears stale data from the FIFO before starting a new monitoring session.

The sample also demonstrates message filtering using naibrd_1553_MtMessageMonitoringDisable() to selectively ignore traffic from specific RT addresses and subaddresses.

Note
For the stack-based variant that retrieves messages one at a time, see the M1553 MT Monitor guide. For a detailed explanation of MT message filtering, initialization differences between the two variants, and the MT role in 1553 communication, refer to that guide as well — this guide focuses on the FIFO-specific retrieval and decoding logic.

This sample supports the following 1553 module types:

  • FT0 through FTF — 4-channel 1553 modules

  • FTJ / FTK — 2-channel MIL-STD-1760 modules

  • CM1, CM5, CM8 — combination modules with 1553 functionality

Prerequisites

Before running this sample, make sure you have:

  • An NAI board with a 1553 module installed (FT0-FTF, FTJ, FTK, CM1, CM5, or CM8).

  • SSK 1.x installed on your development host.

  • The sample applications built. Refer to the SSK 1.x build instructions for your platform if you have not already compiled them.

How to Run

Launch the M1553_MT_Monitor_FIFO executable from your build output directory. On startup the application looks for a configuration file (default_1553_MTMonitor_FIFO.txt). On the first run, this file will not exist — the application will present an interactive board menu where you configure a board connection, card index, and module slot. You can save this configuration so that subsequent runs skip the menu and connect automatically. Once connected, the application prompts for monitoring parameters and begins capturing bus traffic via the FIFO.

Board Connection and Module Selection

Note
This startup sequence is common to all NAI sample applications. The board connection and module selection code shown here is not specific to 1553.

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

  1. Call naiapp_RunBoardMenu() to load a saved configuration file (if one exists) or present the interactive board menu. The configuration file (default_1553_MTMonitor_FIFO.txt) is not included with the SSK — it is created when the user saves their connection settings from the board menu. On the first run, the menu will always appear.

  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_GetModuleID() so downstream code can adapt to the specific 1553 variant installed.

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

   if (naiapp_RunBoardMenu(CONFIG_FILE) == TRUE)
   {
      while (stop != TRUE)
      {
         /* Query the user for the card index */
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));

            /* Query the user for the module number */
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != TRUE)
            {
               moduleID = naibrd_GetModuleID(cardIndex, module);
               if ((moduleID != 0))
               {
                  Run_M1553_MT_Monitor_FIFO(cardIndex, module, moduleID);
               }
            }
         }

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

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

   return 0;
}
Important

Common connection errors you may encounter at this stage:

  • No board found — verify that the board is powered on and physically connected. Check that the configuration file lists the correct interface and address.

  • Connection timeout — confirm network settings (for Ethernet connections) or bus configuration (for PCI/PCIe). Firewalls and IP mismatches are frequent causes.

  • Invalid card or module index — indices are zero-based for cards and one-based for modules. Ensure the values you pass match your hardware setup.

  • Module not present at selected slot — the slot you selected does not contain a 1553 module. Use the board menu to verify which slots are populated.

Program Structure

The entry point is main() on most platforms, or M1553_MT_Monitor_FIFO() on VxWorks. Both resolve to the same logic.

User Input Sequence

After the board connection is established, Run_M1553_MT_Monitor_FIFO() collects the remaining configuration through a series of prompts:

  1. MT channel — Get1553MTCfg() asks the user which 1553 channel to use for monitoring (default: channel 1). The available channels depend on the installed module type.

  2. Logical device number — Get1553LogicalDevNum() assigns a logical device handle that the naibrd API uses to identify this 1553 session (default: device 1).

  3. Monitoring duration — the application prompts for how many seconds to monitor the bus (default: 5 seconds). You can run multiple monitoring cycles without restarting.

Timed Monitoring Loop

Once configuration is complete, the application enters a loop that repeats until the user quits:

  1. Prompt for a duration in seconds.

  2. Call naibrd_1553_ClearMsgFIFO() to clear stale data from the FIFO.

  3. Call naibrd_1553_MtStart() to begin capturing bus traffic.

  4. Run MonitorMessages() for the specified duration, reading and decoding messages from the FIFO.

  5. Call naibrd_1553_MtStop() to halt capture.

  6. Prompt again — enter a new duration to monitor again, or press Q to exit.

Device Initialization

The FIFO variant’s initialization differs from the stack variant in one key way: the mode flag includes NAI_1553_MESSAGE_FIFO_MODE to enable FIFO-based message buffering.

Opening and Initializing the Device

swResult = naibrd_1553_Open(cardIndex, module, mtchan, DevNum);

swResult = naibrd_1553_Initialize(DevNum, NAI_1553_ACCESS_CARD, NAI_1553_MODE_MT | NAI_1553_MESSAGE_FIFO_MODE, 0, 0, 0);

The NAI_1553_MESSAGE_FIFO_MODE flag tells the hardware to buffer captured messages in a FIFO rather than the default stack. This is what enables the bulk retrieval pattern used in the monitoring loop. If you use NAI_1553_MODE_MT alone without the FIFO flag, the FIFO retrieval functions will fail or return no data.

Message Filtering

The sample disables monitoring for RT address 1, subaddress 3 to demonstrate filtering:

swResult = naibrd_1553_MtMessageMonitoringDisable(DevNum, RT_DISABLE, NAI_1553_MT_FILTER_ALL, 1 << SA_DISABLE);
  • RT_DISABLE (value 1) — the RT address to stop monitoring.

  • NAI_1553_MT_FILTER_ALL — disables monitoring in both Rx and Tx directions.

  • 1 << SA_DISABLE (value 1 << 3 = 8) — a bitmask identifying subaddress 3.

After this call, the MT will ignore any transaction involving RT 1, subaddress 3. For detailed guidance on filter configuration, direction constants, and subaddress masks, see the M1553 MT Monitor guide.

Clearing the FIFO

Before each monitoring cycle, the application clears the FIFO to prevent stale data from being decoded:

swResult = naibrd_1553_ClearMsgFIFO(DevNum);

This is critical. Without this step, leftover messages from a previous monitoring session will appear as current traffic when decoded.

Important

Common initialization issues you may encounter:

  • Device open or init failure — naibrd_1553_Open() or naibrd_1553_Initialize() returned a non-zero error code. Verify that the card index, module number, and channel are correct and that no other process already holds the device open.

  • Wrong mode flag — if you use NAI_1553_MODE_MT without NAI_1553_MESSAGE_FIFO_MODE but then call FIFO retrieval functions, the calls will fail or return no data. Make sure the mode flag matches the retrieval method you intend to use.

  • MT not started — forgetting to call naibrd_1553_MtStart() after initialization is a common oversight. No messages will appear in the FIFO until MtStart is called.

FIFO-Based Message Monitoring

The MonitorMessages() function reads captured messages in bulk from the hardware FIFO and decodes them iteratively. This approach makes fewer API calls per monitoring cycle than the stack variant, which matters on buses with high message rates.

Bulk Retrieval

Each iteration of the monitoring loop begins by querying the FIFO for the number of available messages:

swResult = naibrd_1553_GetMsgFIFOCount(DevNum, &fifoCount);

If fifoCount is greater than zero, the application zeroes the local buffer (to prevent old data from being decoded) and reads the entire batch:

memset(fifoData, 0, sizeof(fifoData));

swResult = naibrd_1553_ReadMsgFIFO(DevNum, fifoCount, fifoData);

This two-step pattern — count then read — retrieves all pending messages in one operation.

Iterative Decoding

After the bulk read, messages are decoded one at a time from the fifoData buffer. Each call to naibrd_1553_DecodeFIFOMsg() extracts one message starting at currBlockIndex and returns the starting index of the next message in nextBlockIndex:

do
{
   swResult = naibrd_1553_DecodeFIFOMsg(fifoData, currBlockIndex, &nextBlockIndex, &msgStruct);
   if (swResult == 0)
   {
      if ((msgStruct.wCommandWord1 & 0x0400) != 0x0400)   /* If this is a Rx message */
      {
         printf("Rx Msg Received\n");
         /* ... display decoded fields ... */
      }
      else
      {
         printf("Tx Msg Received\n");
         /* ... display decoded fields ... */
      }
   }
   else if (swResult != (uint32_t)NAI_1553_CMD_NO_MSG_TO_DECODE)
   {
      printf("Error: naibrd_1553_DecodeFIFOMsg  %d", swResult);
      return TRUE;
   }

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

   nai_msDelay(1);

} while ((swResult == NAI_SUCCESS) && (time(NULL) < end));

The loop continues as long as naibrd_1553_DecodeFIFOMsg() returns NAI_SUCCESS and the monitoring duration has not expired. When there are no more messages to decode, the function returns NAI_1553_CMD_NO_MSG_TO_DECODE, which exits the loop without treating it as an error.

Block Index Advancement

After each successful decode, you must advance the block index:

currBlockIndex = nextBlockIndex;

This line is critical. If currBlockIndex is not updated, the loop will decode the same message repeatedly and never progress through the buffer. The source code marks this with a prominent IMPORTANT comment for good reason.

FIFO Decoded Structure

The FIFO variant uses naiDecodedMessageStructureFIFO rather than the naiDecodedMessageStructure used by the stack variant. The FIFO structure includes additional fields for RT-to-RT transfers:

  • bIsCommandWord2Relevant — when true, the message is an RT-to-RT transfer and wCommandWord2 contains the second command word.

  • bIsStatus2Relevant — when true, a second RT responded to the transaction and wStatus2 contains its status word.

  • wStatus1 — the primary RT status word, always present on a successful decode.

These fields make the FIFO structure more expressive than the stack variant’s structure for diagnosing complex bus transactions.

Overflow Detection

After processing each batch of messages, the application checks whether the FIFO has overflowed:

swResult = naibrd_1553_GetMsgFIFOFullStatus(DevNum, NAI_1553_STATUS_REALTIME, &FIFOfullStatusBit);
if (swResult == NAI_SUCCESS)
{
   printf("FIFO status: %d", FIFOfullStatusBit);
   printf((FIFOfullStatusBit == TRUE) ? " Full\r\n" : " Not full\r\n");
}

A full FIFO means messages may have been lost because the buffer had no room for new arrivals. Monitoring this status after each read cycle lets you detect data loss and adjust your polling rate accordingly.

Important

Common FIFO monitoring issues you may encounter:

  • FIFO not cleared before starting — stale data — if you do not call naibrd_1553_ClearMsgFIFO() before starting a new monitoring session, the FIFO may contain leftover messages from a previous run. These stale messages will be decoded as if they were current traffic.

  • FIFO overflow — messages lost — check naibrd_1553_GetMsgFIFOFullStatus() after each read cycle. A full status indicates that the FIFO ran out of space and incoming messages were dropped. Increase your polling frequency or reduce the amount of processing done between reads.

  • Block index not advancing — same message decoded repeatedly — you must update currBlockIndex = nextBlockIndex after each call to naibrd_1553_DecodeFIFOMsg(). Failing to do so causes the loop to re-decode the same message indefinitely.

  • No messages captured — confirm that naibrd_1553_MtStart() was called, that there is active bus traffic, and that the filter configuration has not excluded all RT/subaddress combinations you need.

Troubleshooting Reference

This table summarizes common errors and symptoms covered in the sections above. For detailed context on each entry, refer to the relevant section. Consult your module’s manual for hardware-specific diagnostic procedures.

Error / Symptom Possible Causes Suggested Resolution

No board found or connection timeout

Board not powered, missing configuration file, network issue

Verify hardware and configuration. If file doesn’t exist, configure and save from board menu.

Module not recognized as 1553

Selected module is not FT-series or CM with 1553

Verify module type at the selected slot.

Device open or initialization failure

Wrong card/module/channel, or device already in use

Verify parameters. Close other applications using this channel.

Wrong mode flag for FIFO

Initialized with NAI_1553_MODE_MT only (missing NAI_1553_MESSAGE_FIFO_MODE)

OR the FIFO flag: NAI_1553_MODE_MT | NAI_1553_MESSAGE_FIFO_MODE

MT not started

naibrd_1553_MtStart() not called after initialization

Call MtStart() after all configuration and filtering.

No bus traffic present

No active BC or RTs on the bus

Verify other 1553 devices are connected and operating.

All traffic filtered out

MtMessageMonitoringDisable() disabled all relevant RT/SA combinations

Check filter state with MtMessageMonitoringGetStatus(). Re-enable needed addresses.

FIFO overflow — messages lost

FIFO buffer full before application reads

Call ReadMsgFIFO() more frequently. Check GetMsgFIFOFullStatus() after reads.

Stale data from previous session

FIFO not cleared before monitoring

Call naibrd_1553_ClearMsgFIFO() before each MtStart().

Same message decoded repeatedly

currBlockIndex not updated after DecodeFIFOMsg()

Always set currBlockIndex = nextBlockIndex after each decode.

Decode error

Raw buffer corrupted or incomplete message in FIFO

Verify ReadMsgFIFO() succeeded before decoding. Check return codes.

Full Source

The complete source for this sample is provided below for reference. The sections above explain each part in detail.

Full Source — M1553_MT_Monitor_FIFO.c (SSK 1.x)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

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

/* Common 1553 Sample Program include files */
#include "nai_1553_utils.h"

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

static const int8_t *CONFIG_FILE = (int8_t *)"default_1553_MTMonitor_FIFO.txt";

/* Function prototypes */
static bool_t Run_M1553_MT_Monitor_FIFO(int32_t cardIndex, int32_t module, uint32_t modid);
static int32_t MonitorMessages(uint16_t DevNum, int32_t duration);

static const int32_t DEF_MT_CHANNEL       = 1;
static const int16_t DEF_MT_DEV_NUM       = 1;

#define RT_DISABLE      1
#define SA_DISABLE      3

/**************************************************************************************************************/
/**
<summary>
The purpose of the M1553_MT_Monitor_FIFO is to illustrate the methods to call in the naibrd library to configure
and run the 1553 channel as a Message Monitor. If an Rx or TX message is detected on the bus, the received
data and message information will be displayed via message FIFO. This application also demonstrates message
filtering using the naibrd_1553_MtMessageMonitoringDisable() function to disable monitoring for certain
message types.

The following system configuration routines from the nai_sys_cfg.c file are called to assist with the configuration
setup for this program prior to calling the naibrd 1553 routines.
 - ConfigDevice
 - DisplayDeviceCfg
 - GetBoardSNModCfg
 - CheckModule
</summary>
*/
/**************************************************************************************************************/
#if defined (__VXWORKS__)
int32_t M1553_MT_Monitor_FIFO(void)
#else
int32_t main(void)
#endif
{
   bool_t stop = FALSE;
   int32_t cardIndex;
   int32_t moduleCnt;
   int32_t module;
   uint32_t moduleID = 0;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(CONFIG_FILE) == TRUE)
   {
      while (stop != TRUE)
      {
         /* Query the user for the card index */
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));

            /* Query the user for the module number */
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != TRUE)
            {
               moduleID = naibrd_GetModuleID(cardIndex, module);
               if ((moduleID != 0))
               {
                  Run_M1553_MT_Monitor_FIFO(cardIndex, module, moduleID);
               }
            }
         }

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

   printf("\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_MT_Monitor_FIFO(int32_t cardIndex, int32_t module, uint32_t modid)
{
   /* Variables */
   bool_t bQuit = FALSE;
   int32_t mtchan;
   int16_t DevNum           = 0;
   int32_t swResult;
   bool_t bContinue = TRUE;
   int32_t duration;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   /* Get Card, Module, Channel Numbers and Open a Handle */
   bQuit = Get1553MTCfg(modid, DEF_MT_CHANNEL, &mtchan);
   if (bQuit)
   {
      return bQuit;
   }

   /* Get Logical Device # */
   bQuit = Get1553LogicalDevNum(DEF_MT_DEV_NUM, &DevNum);
   if (bQuit)
   {
      return bQuit;
   }

   /* Associate Card, Module and Channel Numbers with the Logical Device # */
   swResult = naibrd_1553_Open(cardIndex, module, mtchan, DevNum);
   if(swResult)
   {
      bQuit = TRUE;
      printf("Error: naibrd_1553_Open  %d", swResult);
      return bQuit;
   }

   /* Simplex enable */
   /* swResult = naibrd_1553_WriteAuxReg(DevNum, 0xF, 0x0); */

   /* Initialize Device */
   swResult = naibrd_1553_Initialize(DevNum,NAI_1553_ACCESS_CARD,NAI_1553_MODE_MT | NAI_1553_MESSAGE_FIFO_MODE,0,0,0);
   if(swResult != 0)
   {
      bQuit = TRUE;
      printf("Error: naibrd_1553_Initialize  %d", swResult);
      return bQuit;
   }

   /* Disable Monitoring for RT 1, SA 3 Message Types (In default power on state, all messages are monitored) */
   swResult = naibrd_1553_MtMessageMonitoringDisable(DevNum, RT_DISABLE, NAI_1553_MT_FILTER_ALL, 1 << SA_DISABLE);
   if(swResult != 0)
   {
      bQuit = TRUE;
      printf("Error: naibrd_1553_Initialize  %d", swResult);
      return bQuit;
   }

   while (bContinue)
   {
      printf("\nType duration (in seconds) to run RT or %c to quit (default: 5) : ", NAI_QUIT_CHAR);
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         duration = 5;
         if (inputResponseCnt > 0)
         {
            duration = (int)atol((const char*)inputBuffer);
         }

         swResult = naibrd_1553_ClearMsgFIFO(DevNum);
         if (swResult != 0)
         {
            bQuit = TRUE;
            printf("Error: naibrd_1553_ClearMsgFIFO  %d", swResult);
            return bQuit;
         }

         /* Start MT */
         swResult = naibrd_1553_MtStart(DevNum);
         if(swResult != 0)
         {
            bQuit = TRUE;
            printf("Error: naibrd_1553_MtStart  %d", swResult);
            return bQuit;
         }

         /* Start the monitor and display any new messages */
         MonitorMessages(DevNum, duration);

         /* Stop MT */
         swResult = naibrd_1553_MtStop(DevNum);
         if(swResult != 0)
         {
            bQuit = TRUE;
            printf("Error: naibrd_1553_MtStop  %d", swResult);
            return bQuit;
         }
      }
      else
         bContinue = FALSE;
   }

   /* Free 1553 Device */
   swResult = naibrd_1553_Free(DevNum);
   if(swResult != 0)
   {
      bQuit = TRUE;
      printf("Error: naibrd_1553_Free  %d", swResult);
      return bQuit;
   }

   return bQuit;
}

static int MonitorMessages(uint16_t DevNum, int32_t duration)
{
   time_t end;
   uint32_t swResult;
   int32_t i;
   naiDecodedMessageStructureFIFO msgStruct;
   uint32_t fifoData[1024];
   int32_t count = 0;
   int32_t currBlockIndex = 0, nextBlockIndex = 0;
   uint32_t fifoCount;
   bool_t FIFOfullStatusBit;

   end = time(NULL) + duration;

   while (time(NULL) < end)
   {
      swResult = naibrd_1553_GetMsgFIFOCount(DevNum, &fifoCount);
      if (swResult != 0)
      {
         printf("Error: naibrd_1553_GetMsgFIFOCount  %d", swResult);
         return 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 */
            swResult = naibrd_1553_ReadMsgFIFO(DevNum, fifoCount, fifoData);
            if (swResult != 0)
            {
               printf("Error: naibrd_1553_ReadMsgFIFO  %d", swResult);
               return TRUE;
            }
            else
            {
               /* Read Messages */
               do
               {
                  swResult = naibrd_1553_DecodeFIFOMsg(fifoData, currBlockIndex, &nextBlockIndex, &msgStruct);
                  if (swResult == 0)
                  {
                     if ((msgStruct.wCommandWord1 & 0x0400) != 0x0400)   /* If this is a Rx message */
                     {
                        printf("Rx Msg Received\n");
                        printf("\n\nDecoded Message:\n\n");
                        printf("Block Status - 0x%04X\n", msgStruct.wBlockStatus);
                        printf("Time Tag - 0x%04X\n", msgStruct.wTimeTag);
                        printf("Command Word - 0x%04X\n", msgStruct.wCommandWord1);

                        if(msgStruct.bIsCommandWord2Relevant)
                           printf("Command Word 2 - 0x%04X\n", msgStruct.wCommandWord2);

                        printf("RT Status Word: 0x%04X\n", msgStruct.wStatus1);

                        if (msgStruct.bIsStatus2Relevant)
                           printf("RT Status Word 2: 0x%04X\n", msgStruct.wStatus2);

                        printf("Data Word Count - 0x%04X\n", msgStruct.wDataWordCount);

                        printf((msgStruct.wDataWordCount > 0) ? ("Data:") : (""));
                        for (i = 0; i < msgStruct.wDataWordCount; i++)
                        {
                           if (i % 8 == 0)
                           {
                              printf("\n");
                           }
                           printf("0x%04X ", msgStruct.waData[i]);
                        }
                        printf("count: %d\n", count++);
                        printf("\n\n");
                     }
                     else
                     {
                        printf("Tx Msg Received\n");
                        printf("\n\nDecoded Message:\n\n");
                        printf("Block Status - 0x%04X\n", msgStruct.wBlockStatus);
                        printf("Time Tag - 0x%04X\n", msgStruct.wTimeTag);
                        printf("Command Word - 0x%04X\n", msgStruct.wCommandWord1);

                        if (msgStruct.bIsCommandWord2Relevant)
                           printf("Command Word 2 - 0x%04X\n", msgStruct.wCommandWord2);

                        printf("RT Status Word: 0x%04X\n", msgStruct.wStatus1);

                        if (msgStruct.bIsStatus2Relevant)
                           printf("RT Status Word 2: 0x%04X\n", msgStruct.wStatus2);

                        printf("Data Word Count - 0x%04X\n", msgStruct.wDataWordCount);

                        printf((msgStruct.wDataWordCount > 0) ? ("Data:") : (""));
                        for (i = 0; i < msgStruct.wDataWordCount; i++)
                        {
                           if (i % 8 == 0)
                           {
                              printf("\n");
                           }
                           printf("0x%04X ", msgStruct.waData[i]);
                        }
                        printf("count: %d\n", count++);
                        printf("\n\n");
                     }
                  }
                  else if (swResult != (uint32_t)NAI_1553_CMD_NO_MSG_TO_DECODE)
                  {
                     printf("Error: naibrd_1553_DecodeFIFOMsg  %d", swResult);
                     return TRUE;
                  }

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

                  nai_msDelay(1);

               } while ((swResult == NAI_SUCCESS) && (time(NULL) < end));
            }

            swResult = naibrd_1553_GetMsgFIFOFullStatus(DevNum, NAI_1553_STATUS_REALTIME, &FIFOfullStatusBit);
            if (swResult == NAI_SUCCESS)
            {
               printf("FIFO status: %d", FIFOfullStatusBit);
               printf((FIFOfullStatusBit == TRUE) ? " Full\r\n" : " Not full\r\n");
            }
            else
            {
               printf("Error: naibrd_1553_GetMsgFIFOFullStatus  %d", swResult);
               return TRUE;
            }
         }
      }
   }

   return 1;
}

Help Bot

X