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

AR579 Recv

AR579 Recv Sample Application (SSK 2.x)

Overview

The AR579 Recv sample application demonstrates how to configure an ARINC 579 channel for message reception using the NAI Software Support Kit (SSK 2.x). The application configures the receiver with FIFO thresholds, bounded FIFO mode, odd parity checking, store-on-error, and optional timestamping, then polls for incoming messages over a user-specified duration.

ARINC 579 is a variant of the ARINC protocol. This sample supports AR579 module types. It is designed to work with the AR579 Xmit sample application for transmit testing.

This sample is new to SSK 2.x and has no SSK 1.x counterpart.

Prerequisites

Before running this sample, make sure you have:

  • An NAI board with an AR579 module installed.

  • 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.

  • An ARINC 579 transmitter connected to the receive channel.

How to Run

Launch the ar579_recv executable from your build output directory. On startup the application looks for a configuration file (default_AR579Recv.txt). Once connected, the application queries for configuration parameters, sets up the receiver, and polls for incoming messages.

Channel Configuration

The AR579_Receive_run() function configures the receiver:

check_status( naibrd_AR579_ChannelReset( cardIndex, module, archan ) );
check_status( naibrd_AR579_SetRxFifoThresholds( cardIndex, module, archan, 250, 750 ) );
check_status( naibrd_AR579_SetRxFifoBounded( cardIndex, module, archan, bRxBoundedFIFOenable ) );
check_status( naibrd_AR579_SetParityBitUsage( cardIndex, module, archan, NAIBRD_AR_PAR_ODD ) );
check_status( naibrd_AR579_SetRxStoreOnErrorEnable( cardIndex, module, archan, NAI_TRUE ) );
check_status( naibrd_AR579_SetRxTimeStampEn( cardIndex, module, archan, bTimestampEnabled ) );
  • Rx FIFO thresholds — Almost Empty at 250, Almost Full at 750.

  • Bounded FIFO — optionally enabled to prevent data overwrite.

  • Parity — odd parity checking on ARINC bit 32.

  • Store on error — enabled, so all messages are stored regardless of error flags.

  • Timestamp — optionally enabled for each received message.

Data Reception

The application clears the Rx FIFO, enables the receiver, and polls for data:

check_status( naibrd_AR579_ClearRxFifo( cardIndex, module, channel ) );
check_status( naibrd_AR579_SetRxEnable( cardIndex, module, channel, NAI_TRUE ) );

while ( duration < timeout )
{
   status = naibrd_AR579_GetRxFifoCnt( cardIndex, module, channel, &nNumWordsRecv );
   if (status == NAI_SUCCESS && nNumWordsRecv > 0)
   {
      status = naibrd_AR579_ReadRxFifo( cardIndex, module, channel, bTimestampEnabled, nNumWordsRecv,
         RecvStatusWd, RecvData, RecvTimeStamp, &nNumMsgsRecv );
      for ( i = 0; i < nNumMsgsRecv; i++ )
      {
         if (bTimestampEnabled)
         {
            naiif_printf( "Status: 0x%08X Data: 0x%08X TimeStamp: 0x%08X\r\n",
               RecvStatusWd[i], RecvData[i], RecvTimeStamp[i] );
         }
         else
         {
            naiif_printf( "Data: 0x%08X\r\n", RecvData[i] );
         }
      }
   }
   duration++;
   naiif_msDelay(1000);
}

When timestamps are enabled, each received message includes a status word, data word, and timestamp word. Without timestamps, only the data word is displayed.

Troubleshooting Reference

Error / Symptom Possible Causes Suggested Resolution

No messages received

Transmitter not running, cable not connected

Ensure the AR579 Xmit sample or external transmitter is running.

Rx FIFO overflow

Messages arriving faster than read rate

Increase read frequency or enable bounded FIFO mode.

Parity errors in status word

Transmitter using different parity

Verify both endpoints use odd parity.

No board found or connection timeout

Board not powered, incorrect configuration file

Verify hardware is powered and connected.

Full Source

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

Full Source — ar579_recv.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"

/* naiif include files */
#include "nai_libs/naiif/include/naiif_stdio.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"


/* AD Sample App include files */
#include "nai_sample_apps/naiapp_src/board_modules/ar579/ar579_common_utils/ar579_common_utils.h"

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

static bool_t AR579_Receive_run();
static bool_t RxAndDisplayFIFOMsgs( int32_t cardIndex, int32_t module, int32_t channel );

/* Default channel selection */
#define DEF_AR_CARD_INDEX                 0
#define DEF_AR_MODULE                     1
#define DEF_AR_RECV_CHANNEL               2

/* Default channel configuration settings */
#define DEF_AR_TIMESTAMP_ENABLED          NAI_TRUE

/* Global Variables */
static bool_t bTimestampEnabled = NAI_FALSE;

#define AR_ENABLE                      1

/*****************************************************************************/
/**
 * <summary>
 * The purpose of AR579_Receive is to illustrate the methods to call in the naibrd
 * library to configure the ARINC-579 channel to receive ARINC-579 messages and store
 * received messages in a receive FIFO.
 *
 * 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 ARINC routines.
 * - ConfigDevice
 * - DisplayDeviceCfg
 * - GetBoardSNModCfg
 * - CheckModule
 * </summary>
 */
/*****************************************************************************/
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t AR579_Receive(void)
#else
int32_t main(void)
#endif
{
   bool_t bQuit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(CONFIG_FILE) == (bool_t)NAI_TRUE)
   {
      while (!bQuit)
      {
         bQuit = AR579_Receive_run();
      }

      naiif_printf("Type the Enter key to exit the program: ");
      naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   }

   naiapp_access_CloseAllOpenCards();

   return 0;
}
/*****************************************************************************/
/**
 * <summary>
 * AR579_Receive_run queries the user for the card, module and channel to configure
 * the ARINC-579 receiver. The receiving ARINC-579 channel is configured for FIFO receive mode.
 * </summary>
 */
/*****************************************************************************/
static bool_t AR579_Receive_run()
{
   bool_t bQuit = NAI_FALSE;
   int32_t archan;
   int32_t cardIndex, module;
   bool_t bRxBoundedFIFOenable;

   bQuit = GetAR579Cfg( DEF_AR_CARD_INDEX, DEF_AR_MODULE, DEF_AR_RECV_CHANNEL, &cardIndex, &module, &archan );
   if (!bQuit)
   {
      /* Reset the channel */
      check_status( naibrd_AR579_ChannelReset( cardIndex, module, archan ) );

      /* Set the Rx Fifo Almost Empty Threshold to 250 and the Rx Fifo Almost Full Threshold to 750 */
      /* If the number of messages in the Rx FIFO falls below 250, the Rx FIFO Almost Empty Status will be set */
      /* If the number of messages in the Rx FIFO rises above 750, the Rx FIFO Almost Full Status will be set */
      check_status( naibrd_AR579_SetRxFifoThresholds( cardIndex, module, archan, 250, 750 ) );

      bQuit = GetAR579RxBoundedFIFOEnabled(AR_ENABLE, &bRxBoundedFIFOenable);
      if (!bQuit)
      {
         check_status( naibrd_AR579_SetRxFifoBounded( cardIndex, module, archan, bRxBoundedFIFOenable ) );

         /* Set the Parity Bit Usage to treat ARINC bit 32 as an odd parity bit and perform parity checking */
         check_status( naibrd_AR579_SetParityBitUsage( cardIndex, module, archan, NAIBRD_AR_PAR_ODD ) );

         /* Set Store On Error to "Enable". In other words, store all received messages regardless of whether or not the message was flagged with an error. */
         check_status( naibrd_AR579_SetRxStoreOnErrorEnable( cardIndex, module, archan, NAI_TRUE ) );

         /* Query for Timestamp Mode Enable */
         bQuit = GetAR579ReceiverTimestampEnabled( DEF_AR_TIMESTAMP_ENABLED, &bTimestampEnabled );
         if (!bQuit)
         {
            /* Set Timestamp Enable */
            check_status( naibrd_AR579_SetRxTimeStampEn( cardIndex, module, archan, bTimestampEnabled ) );

            /* Enable Receiver and Display Data Received in the Rx FIFO */
            bQuit = RxAndDisplayFIFOMsgs( cardIndex, module, archan );
         }
      }
   }

   return bQuit;
}

static bool_t RxAndDisplayFIFOMsgs( int32_t cardIndex, int32_t module, int32_t channel )
{
   bool_t bQuit = NAI_FALSE;
   bool_t bContinue = NAI_TRUE;
   int32_t i;
   int32_t nNumWordsRecv;
   int32_t nNumMsgsRecv;
   uint32_t RecvStatusWd[NAIBRD_AR2_MAX_FIFO_COUNT];
   uint32_t RecvData[NAIBRD_AR2_MAX_FIFO_COUNT];
   uint32_t RecvTimeStamp[NAIBRD_AR2_MAX_FIFO_COUNT];
   int32_t duration;
   int32_t timeout;
   nai_status_t status;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   /* Clear Rx FIFO to start with an empty buffer */
   check_status( naibrd_AR579_ClearRxFifo( cardIndex, module, channel ) );

   /* Enable Receiver */
   check_status( naibrd_AR579_SetRxEnable( cardIndex, module, channel, NAI_TRUE ) );

   bContinue = NAI_TRUE;
   while (bContinue)
   {
      naiif_printf( "\r\nType duration (in seconds) for ARINC-579 receive messages test or %c to quit (default: 5) : ", NAI_QUIT_CHAR );
      bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
      if (!bQuit)
      {
         duration = 0;
         timeout = 5;
         if ( inputResponseCnt > 0 )
            timeout = (int32_t)atol( (const char*)inputBuffer );

         /* Read data */
         while ( duration < timeout )
         {
            /* Get count of received 32-bit words in Rx FIFO */
            status = naibrd_AR579_GetRxFifoCnt( cardIndex, module, channel, &nNumWordsRecv );
            if (status == NAI_SUCCESS)
            {
               /* If Rx count is greater than 0, read out as many messages from the Rx FIFO */
               if ( nNumWordsRecv > 0 )
               {
                  status = naibrd_AR579_ReadRxFifo( cardIndex, module, channel, bTimestampEnabled, nNumWordsRecv, RecvStatusWd, RecvData, RecvTimeStamp, &nNumMsgsRecv ); /* read back data */
                  if (status == NAI_SUCCESS)
                  {
                     naiif_printf( "\r\nReading back %d messages ...\r\n", nNumMsgsRecv );
                     for ( i = 0; i < nNumMsgsRecv; i++ )
                     {
                        if (bTimestampEnabled)
                        {
                           naiif_printf( "Status: 0x%08X ", RecvStatusWd[i] );
                           naiif_printf( "Data: 0x%08X ", RecvData[i] );
                           naiif_printf( "TimeStamp: 0x%08X\r\n", RecvTimeStamp[i] );
                        }
                        else
                        {
                           naiif_printf( "Data: 0x%08X\r\n", RecvData[i] );
                        }
                     }
                  }
                  else
                  {
                     naiif_printf("naibrd_AR579_ReadRxFifo status: %s\r\n", naiif_GetStatusString(status));
                  }
               }
            }
            else
            {
               naiif_printf("naibrd_AR579_GetRxFifoCnt status: %s\r\n", naiif_GetStatusString(status));
            }
            duration++;
            naiif_msDelay(1000);
         }
      }
      else
         bContinue = NAI_FALSE;
   }
   return bQuit;
}

Help Bot

X