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 Xmit

AR579 Xmit Sample Application (SSK 2.x)

Overview

The AR579 Xmit sample application demonstrates how to configure an ARINC 579 channel for message transmission using the NAI Software Support Kit (SSK 2.x). The application supports two transmit modes: FIFO immediate (data transmits as soon as it is loaded) and FIFO triggered (data waits for a trigger signal). The user selects the card, module, channel, and transmit mode, then enters the number of words to send.

This sample supports AR579 module types. It is designed to work with the AR579 Recv sample application for receive 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.

How to Run

Launch the ar579_xmit executable from your build output directory. On startup the application looks for a configuration file (default_AR579Xmit.txt). Once connected, the application queries for configuration parameters and begins transmitting.

Channel Configuration

The AR579_Transmit_run() function configures the transmitter:

check_status( naibrd_AR579_ChannelReset( cardIndex, module, archan ) );
check_status( naibrd_AR579_SetTxFifoThresholds( cardIndex, module, archan, 250, 750 ) );
check_status( naibrd_AR579_SetParityBitUsage( cardIndex, module, archan, NAIBRD_AR_PAR_ODD ) );
check_status( naibrd_AR579_SetTxGapTime( cardIndex, module, archan, 6 ) );
  • Tx FIFO thresholds — Almost Empty at 250, Almost Full at 750.

  • Parity — odd parity on ARINC bit 32.

  • Gap time — 6 bit-times between messages.

Transmit Modes

FIFO Immediate Mode

Data transmits as soon as it is loaded:

check_status( naibrd_AR579_SetTransmitSendMode( cardIndex, module, channel, txmode ) );
check_status( naibrd_AR579_SetTxEnable( cardIndex, module, channel, NAI_TRUE ) );
check_status( naibrd_AR579_LoadTxFifo( cardIndex, module, channel, dataIndex, SendData, &nNumWordsSent ) );

FIFO Triggered Mode

Same as immediate but requires a trigger to start:

check_status( naibrd_AR579_SetTxSendTrigger(cardIndex, module, channel) );

The application loads data in blocks of 200 words and polls for Tx FIFO Almost Empty before loading the next block, then waits for Tx FIFO Empty after all blocks are sent.

Troubleshooting Reference

Error / Symptom Possible Causes Suggested Resolution

No board found or connection timeout

Board not powered, incorrect configuration file

Verify hardware is powered and connected.

Data not received by receiver

Cable not connected, wrong channel

Verify ARINC 579 cabling.

Tx FIFO overflow

Loading data faster than transmit rate

Wait for Tx FIFO Almost Empty before loading more data.

Triggered mode does not transmit

Trigger not sent

Call naibrd_AR579_SetTxSendTrigger() after loading the FIFO.

Full Source

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

Full Source — ar579_xmit.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 = (int8_t *)"default_AR579Xmit.txt";

/* Function prototypes */
static bool_t AR579_Transmit_run();
static bool_t AR579_TxFIFO( int32_t cardIndex, int32_t module, int32_t channel, naibrd_ar579_tx_mode_t txmode );
static void waitForStatus(int32_t cardIndex, int32_t module, int32_t channel, uint32_t status);

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

/* Default channel configuration settings */
#define DEF_AR_TX_MODE                    NAIBRD_AR579_TX_SENDMODE_IMMED
#define DEF_AR_XMIT_DATA_COUNT            1



/**************************************************************************************************************/
/**
 * <summary>
 * The purpose of the AR579_Transmit is to illustrate the methods to call in the naibrd library to configure
 * the ARINC-579 channel to transmit ARINC-579 messages in FIFO mode.
 *
 * 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>
 */
/**************************************************************************************************************/
#ifdef NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS
int32_t AR579_Transmit(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_Transmit_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>
Run_AR579_Transmit queries the user for the card, module and channel to configure as the ARINC-579 transmitter
and the mode of message transmission (FIFO Immediate or FIFO Triggered). Methods in the naibrd library are
invoked to configure the ARINC channel. Once the ARINC channel is configured:
1) In FIFO Immediate mode, the user enters the number of words to transmit. When the Tx FIFO is loaded with data,
transmission begins immediately and the program polls the channel status to check Tx FIFO Almost Empty and if true,
more data (if any) is loaded into the Tx FIFO to keep the transmission going.
2) In FIFO Triggered mode, the user enters the number of words to transmit. When the Tx FIFO is loaded with data,
transmission does not begin immediately. Instead the user will be asked to send a trigger to initiate transmission
and the program polls the channel status to check Tx FIFO Almost Empty and if true, more data (if any) is loaded
into the Tx FIFO to keep the transmission going.
</summary>
*/
/**************************************************************************************************************/
static bool_t AR579_Transmit_run()
{
   int32_t archan;
   bool_t bQuit = NAI_FALSE;
   naibrd_ar579_tx_mode_t txmode;
   int32_t cardIndex, module;

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

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

      /* 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 the inter-message transmission gap time (interval rate) */
      check_status( naibrd_AR579_SetTxGapTime( cardIndex, module, archan, 6 ) );     /* 6 bit-times */

      /* Get the Tx Mode */
      bQuit = GetAR579TxMode( DEF_AR_TX_MODE, &txmode );
      if (!bQuit)
      {
         bQuit = AR579_TxFIFO( cardIndex, module, archan, txmode );
      }
   }
   return bQuit;
}

static bool_t AR579_TxFIFO( int32_t cardIndex, int32_t module, int32_t channel, naibrd_ar579_tx_mode_t txmode )
{
   bool_t bQuit = NAI_FALSE;
   int32_t nNumWordsToSend = 1;
   int32_t nNumWordsSent;
   int32_t i, j;
   int32_t blockCnt, dataCnt, dataIndex;
   int32_t increment = 0x55555555;
   uint32_t SendData[255];
   int32_t blockSize = 200;
   bool_t triggerSent = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   /* Set FIFO Transmission mode */
   check_status( naibrd_AR579_SetTransmitSendMode( cardIndex, module, channel, txmode ) );

   /* Enable transmitter */
   check_status( naibrd_AR579_SetTxEnable( cardIndex, module, channel, NAI_TRUE ) );

   while (!bQuit)
   {
      /* Query for the number of data words to send */
      bQuit = GetAR579TransmitDataCount( DEF_AR_XMIT_DATA_COUNT, &nNumWordsToSend );
      if (!bQuit)
      {
         /* Break up the FIFO updates to blocks of 200. The idea here is to load and transmit 200 ARINC words at a time  */
         /* until all of the words have been sent. The following code causes loading and re-loading of the Tx buffer to  */
         /* occur when the Tx FIFO is almost empty, which means less than 32 ARINC messages are in the FIFO and there is */
         /* room in the buffer for 200 more messages.                                                                    */
         blockCnt = nNumWordsToSend / blockSize;
         if ( blockCnt * blockSize < nNumWordsToSend )
            blockCnt++;

         dataCnt = 0;
         for ( i = 0; i < blockCnt; i++ )
         {
            dataIndex = 0;
            do
            {
               SendData[dataIndex++] = (uint32_t)increment++; /* incremental data */
               dataCnt++;
            } while ( ( dataIndex < blockSize ) && ( dataCnt < nNumWordsToSend ) );

            naiif_printf( "\r\nLoading %d words ...\r\n", dataIndex );
            for ( j = 0; j < dataIndex; j++ )
               naiif_printf( "0x%08X\r\n", SendData[j] );

            check_status( naibrd_AR579_LoadTxFifo( cardIndex, module, channel, dataIndex, SendData, &nNumWordsSent ) ); /* send data */

            if ((txmode == NAIBRD_AR579_TX_SENDMODE_TRGF) && (triggerSent == NAI_FALSE))
            {
               /* If Triggered Mode, user sends trigger signal to start transmission */
               naiif_printf("Press Enter to send trigger signal and start transmission...\r\n");
               naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
               check_status( naibrd_AR579_SetTxSendTrigger(cardIndex, module, channel) );
               triggerSent = NAI_TRUE;
            }

            naiif_printf( " %d words sent. Total words sent = %d\r\n", nNumWordsSent, dataCnt );

            /* Wait for Tx Buffer Almost Empty before loading more messages into Tx FIFO */
            waitForStatus(cardIndex, module, channel, NAIBRD_AR579_EVENT_STATUS_GENERAL_TX_FIFO_ALM_EMPTY);
         }

         /* Lastly, wait for Tx Buffer to empty */
         waitForStatus(cardIndex, module, channel, NAIBRD_AR579_EVENT_STATUS_GENERAL_TX_FIFO_EMPTY);
      }
   }

   /* Disable transmitter */
   check_status( naibrd_AR579_SetTxEnable( cardIndex, module, channel, NAI_FALSE ) );

   return bQuit;
}

/* This function waits on one or more realtime (dynamic) channel status bits as defined by the user and exits when all bits are set. */
static void waitForStatus(int32_t cardIndex, int32_t module, int32_t channel, uint32_t status)
{
   uint32_t chanStatus;

   do
   {
      check_status( naibrd_AR579_GetEventMappedStatusRaw(cardIndex, module, channel, NAI_STATUS_REALTIME, NAIBRD_AR579_EVENT_MAP_GENERAL, &chanStatus) );
      naibrd_msDelay(1);
   } while ((chanStatus & status) != status);
}

Help Bot

X