AR2 Receive
Edit this on GitLab
AR2 Receive Sample Application (SSK 1.x)
Overview
The AR2_Receive sample application demonstrates how to receive ARINC 429 data words using the NAI SSK 1.x API on AR2 modules. The AR2 module is a dual-channel ARINC interface with two distinct channel types:
-
Channel 1 (AR-568) — a standard ARINC 429 receive channel that delivers raw 32-bit data words from the receive FIFO.
-
Channel 2 (AR-579) — an enhanced ARINC 429 receive channel that supports parity-as-data mode, error storage control, and optional hardware timestamping of each received word.
Use this sample as a practical reference for configuring an AR2 receive channel, setting FIFO thresholds, enabling timestamps, and reading ARINC data from the receive FIFO.
Supported modules: AR2. Consult naibrd_ar.h for the complete list of AR2 module ID definitions.
Related samples:
-
AR_Receive — the AR1 variant of ARINC receive, which supports validation and mailbox modes not demonstrated in this sample
-
AR2_Transmit — the AR2 transmit companion; run it alongside this sample to verify transmit/receive operation on the same module
Prerequisites:
-
An NAI board with an AR2 module installed
-
SSK 1.x built for your target platform (Windows, Linux, or VxWorks)
-
A physical or loopback connection on the ARINC channel under test, or another device transmitting ARINC 429 data on the connected bus
How to run:
Launch the AR2_Receive executable from your SSK build output directory. On VxWorks, the entry point is AR2_Receive() rather than main().
Board Connection and Module Selection
The application begins by calling naiapp_RunBoardMenu() to establish a connection to your NAI board. This presents an interactive menu where you specify the connection type (PCI, Ethernet, etc.), IP address (if applicable), and board type. After a successful connection, you select a card index and module number.
|
Note
|
This startup sequence is common to all NAI sample applications. The board connection and module selection code shown here is not specific to ARINC. |
Configuration file: The default configuration file for this sample is default_AR2Recv.txt. This file does not ship with the SSK. It is created when you save your connection settings from the board menu. On the first run, the board menu always appears. On subsequent runs, if a saved configuration file exists, the menu can be skipped and the saved settings are loaded automatically.
static const int8_t *CONFIG_FILE = (int8_t *)"default_AR2Recv.txt";
if (naiapp_RunBoardMenu(CONFIG_FILE) == 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)
{
Run_AR2_Receive(cardIndex, module);
}
}
}
In your own application, you will call the same naibrd connection and identification functions but can skip the interactive menu entirely — just supply your card index, module number, and channel directly.
|
Important
|
Common Connection Errors
|
Program Structure
Entry Point
The entry point is main() on Windows and Linux, or AR2_Receive() on VxWorks:
#if defined (__VXWORKS__)
int32_t AR2_Receive(void)
#else
int32_t main(void)
#endif
After board connection and module selection, the program calls Run_AR2_Receive(), which presents a menu for selecting the receive channel.
Application Parameters
The sample packs the card index, module number, and channel number into a naiapp_AppParameters_t struct that is passed to each command handler. In your own code, you will track these same three values:
-
cardIndex— identifies which board (zero-based) -
module— identifies which module slot (one-based) -
channel— identifies which ARINC channel on the module (one-based): 1 for AR-568, 2 for AR-579
Command Menu
The sample presents a two-option menu for selecting which channel to receive on:
| Command | Description |
|---|---|
|
Receive on the AR-568 channel (channel 1) |
|
Receive on the AR-579 channel (channel 2) |
The menu system is a sample convenience — in your own code, call the same API functions directly without the menu infrastructure. The channel number is derived from the command index: ar2_receive_params→channel = cmd + 1.
Utility function: GetAR2Cfg() (from nai_ar_utils.c) prompts the user for card index and module number using the defaults DEF_AR_CARD_INDEX (0) and DEF_AR_MODULE (1). In your own code, supply these values directly.
Channel Initialization and FIFO Configuration
Before receiving data on either channel, RxAndDisplayFIFOMsgs() performs a standard initialization sequence. To prepare an AR2 channel for reception in your own application, follow the same steps.
/* Reset the channel */
check_status( naibrd_AR_ChannelReset( cardIndex, module, channel ) );
/* Disable Tx/Rx */
check_status( naibrd_AR_SetTxEnable( cardIndex, module, channel, AR_DISABLE ) );
check_status( naibrd_AR_SetRxEnable( cardIndex, module, channel, AR_DISABLE ) );
/* Set the Rx Almost Full Fifo Threshold to the maximum size of the FIFO
and the Almost Empty Threshold to zero */
moduleID = naibrd_GetModuleID( cardIndex, module );
AR_FIFO_Size = naibrd_AR_GetMaxFifoCount( moduleID );
check_status( naibrd_AR_SetRxFifoThresholds( cardIndex, module, channel, 0, AR_FIFO_Size - 1 ) );
Step-by-step:
-
naibrd_AR_ChannelReset()— resets the channel to a known state, clearing any pending data in the FIFO and resetting all channel configuration registers. -
naibrd_AR_SetTxEnable()/naibrd_AR_SetRxEnable()— explicitly disables both transmit and receive before reconfiguring. Always disable before changing channel settings. -
naibrd_GetModuleID()andnaibrd_AR_GetMaxFifoCount()— queries the module ID and retrieves the maximum FIFO depth for that module. This ensures your code adapts to the actual hardware rather than hardcoding a FIFO size. -
naibrd_AR_SetRxFifoThresholds()— sets the almost-empty threshold to 0 and the almost-full threshold toAR_FIFO_Size - 1. These thresholds control when the corresponding FIFO status flags assert. The sample sets them to the extremes so that the almost-full flag only triggers when the FIFO is nearly at capacity. Consult your module’s manual for the valid threshold range.
Bounded FIFO Mode
After setting thresholds, the sample configures bounded FIFO mode:
bQuit = GetARRxBoundedFIFOEnable(AR_ENABLE, &bRxBoundedFIFOenable);
if (!bQuit)
{
check_status( naibrd_AR_SetRxFifoBounded( cardIndex, module, channel, bRxBoundedFIFOenable ) );
}
-
naibrd_AR_SetRxFifoBounded()— when bounded mode is enabled, the receiver stops storing new words when the FIFO is full, preventing older data from being overwritten. When bounded mode is disabled, the FIFO wraps around and overwrites the oldest data. For most diagnostic and data-capture applications, enable bounded mode to avoid silent data loss.
Utility function: GetARRxBoundedFIFOEnable() (from nai_ar_utils.c) prompts the user to enable or disable bounded FIFO mode, defaulting to AR_ENABLE. In your own code, call naibrd_AR_SetRxFifoBounded() directly with your desired setting.
|
Important
|
Common Errors
|
AR-579 Channel Configuration (Channel 2)
The AR-579 channel supports additional configuration options that are not available on the AR-568 channel. When the selected channel is 2, the sample configures parity-as-data mode, error storage, and optional timestamping.
Parity and Error Storage
if (channel == 2) /* AR-579 */
{
/* Set the Parity Disable bit to cause the ARINC bit 32 to be treated
as an odd parity bit */
check_status( naibrd_AR_SetParityAsData( cardIndex, module, channel, AR_PAR_ODD ) );
check_status( naibrd_AR_SetRxStoreErrorDisable( cardIndex, module, channel,
AR_STORE_ON_ERROR_ENABLE ) );
}
-
naibrd_AR_SetParityAsData()— configures how bit 32 of the ARINC word is interpreted. PassingAR_PAR_ODDtreats bit 32 as a standard odd parity bit (the default ARINC 429 convention). Other options allow bit 32 to be treated as a data bit rather than parity. Consult your module’s manual for the full list of parity modes. -
naibrd_AR_SetRxStoreErrorDisable()— controls whether words with detected errors (parity, encoding, or framing) are stored in the receive FIFO. PassingAR_STORE_ON_ERROR_ENABLEcauses the receiver to store all words including those with errors, so you can inspect them. To discard error words silently, passAR_STORE_ON_ERROR_DISABLE.
Timestamp Enable
The AR-579 channel can tag each received ARINC word with a hardware timestamp. To enable timestamping in your own application, call naibrd_AR_SetRxTimeStampEn() before enabling the receiver:
/* Query for Timestamp Mode Enable */
bQuit = GetARReceiverTimestampEnabled( DEF_AR_TIMESTAMP_ENABLED, &bTimestampEnabled );
if (!bQuit)
{
/* Set Timestamp Enable */
naibrd_AR_SetRxTimeStampEn( cardIndex, module, channel, bTimestampEnabled );
}
-
naibrd_AR_SetRxTimeStampEn()— when enabled (TRUE), each word stored in the receive FIFO is accompanied by a hardware timestamp. This increases the per-word FIFO footprint (each message consumes additional FIFO space for the timestamp), but provides precise arrival timing for each ARINC word. When disabled, only the raw data word is stored.
Utility function: GetARReceiverTimestampEnabled() (from nai_ar_utils.c) prompts the user to enable or disable timestamping, defaulting to DEF_AR_TIMESTAMP_ENABLED (TRUE). In your own code, pass TRUE or FALSE directly.
|
Note
|
Timestamping is only available on the AR-579 channel (channel 2). The AR-568 channel (channel 1) does not support timestamps, and the sample does not configure timestamps for channel 1. |
|
Important
|
Common Errors
|
Receiving Data from the FIFO
After channel initialization and configuration, the sample clears the receive FIFO, enables the receiver, and enters a timed polling loop to read incoming ARINC data.
Enabling the Receiver
/* Clear Rx FIFO */
check_status( naibrd_AR_ClearRxFifo( cardIndex, module, channel ) );
/* Enable Receiver */
check_status( naibrd_AR_SetRxEnable( cardIndex, module, channel, AR_ENABLE ) );
-
naibrd_AR_ClearRxFifo()— flushes any stale data from the receive FIFO before beginning a new capture session. Always clear the FIFO after configuring the channel and before enabling the receiver. -
naibrd_AR_SetRxEnable()— passAR_ENABLEto activate the receiver. No data is captured until the receiver is enabled.
Polling and Reading the FIFO
The sample prompts for a receive duration (in seconds), then polls the FIFO in a loop for that duration:
end = time(NULL) + duration;
/* Read data */
while ( time(NULL) < end )
{
check_status( naibrd_AR_GetRxBufferCnt( cardIndex, module, channel, &nNumWordsRecv ) );
if ( nNumWordsRecv > 0 )
{
check_status( naibrd_AR_ReadFifo( cardIndex, module, channel, bTimestampEnabled,
nNumWordsRecv, RecvStatusWd, RecvData, RecvTimeStamp, &nNumMsgsRecv ) );
}
}
Step-by-step:
-
naibrd_AR_GetRxBufferCnt()— returns the number of words currently in the receive FIFO. Poll this before reading to avoid requesting more data than is available. -
naibrd_AR_ReadFifo()— reads up tonNumWordsRecvwords from the receive FIFO. The function populates three parallel output arrays:-
RecvStatusWd[]— the status word for each received message (valid on AR-579; may not be meaningful on AR-568) -
RecvData[]— the 32-bit ARINC data word -
RecvTimeStamp[]— the hardware timestamp for each message (only valid whenbTimestampEnabledisTRUE) -
nNumMsgsRecv— the actual number of complete messages read back
-
The bTimestampEnabled parameter tells the API how to parse the FIFO contents. When timestamps are enabled, each message in the FIFO consists of multiple words (data + timestamp), so the API must know the format to correctly separate the fields. Always pass the same value you used when calling naibrd_AR_SetRxTimeStampEn().
Displaying Received Data
The sample displays received data differently depending on the channel and timestamp configuration:
for ( i = 0; i < nNumMsgsRecv; i++ )
{
if (channel == 2) /* AR-579 */
{
if (bTimestampEnabled)
{
printf( "Status: 0x%08X ", RecvStatusWd[i] );
printf( "Data: 0x%08X ", RecvData[i] );
printf( "TimeStamp: 0x%08X\n", RecvTimeStamp[i] );
}
else
{
printf( "Data: 0x%08X\n", RecvData[i] );
}
}
else
{
printf( "Data: 0x%08X\n", RecvData[i] );
}
}
-
AR-568 (channel 1) — displays only the raw 32-bit data word for each received message.
-
AR-579 (channel 2) without timestamps — displays only the data word, same as AR-568.
-
AR-579 (channel 2) with timestamps — displays the status word, data word, and timestamp for each message. The status word contains receiver status information (parity errors, encoding errors, etc.). Consult your module’s manual for the status word bit definitions.
In your own application, you will parse the RecvData array to extract the ARINC 429 label, SDI, data payload, and SSM fields from each 32-bit word according to the ARINC 429 specification.
|
Important
|
Common Errors
|
Troubleshooting Reference
The following table summarizes errors and symptoms you may encounter when working with the AR2 receive API. Consult your AR2 module’s manual for hardware-specific diagnostics.
| Error / Symptom | Possible Causes | Suggested Resolution |
|---|---|---|
No board found |
Board not powered, PCI not seated, Ethernet cable disconnected |
Verify physical connections and power; check IP configuration for Ethernet |
Connection timeout |
Wrong IP address, firewall blocking port |
Confirm IP address matches board configuration; check firewall rules |
|
Module does not support the requested feature; AR1 module used instead of AR2 |
Verify module type with |
Module not present (moduleID == 0) |
No module in the selected slot |
Verify module slot number and board population |
No data received |
Receiver not enabled; FIFO not cleared; no transmitter on the bus |
Ensure |
Timestamps always zero |
Timestamp not enabled before receiver was started |
Call |
Garbled or misaligned data |
Timestamp enable flag mismatch between configuration and FIFO read |
Ensure |
FIFO overflow (missing messages) |
Polling interval too long; FIFO fills before data is read |
Increase polling frequency; enable bounded FIFO to prevent silent overwrite; consider interrupt-driven notification |
Parity errors on valid data |
Transmitter uses bit 32 as data, not parity |
Configure receiver parity mode with |
FIFO threshold flags not asserting |
Thresholds not configured |
Call |
Full Source
Full Source — AR2_Receive.c (SSK 1.x)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.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_ar_utils.h"
/* naibrd include files */
#include "nai.h"
#include "naibrd.h"
#include "functions/naibrd_ar.h"
static const int8_t *CONFIG_FILE = (int8_t *)"default_AR2Recv.txt";
/* Function prototypes */
void Run_AR2_Receive(int32_t cardIndex, int32_t module);
static nai_status_t AR_Rx568(int32_t paramCount, int32_t* p_params);
static nai_status_t AR_Rx579(int32_t paramCount, int32_t* p_params);
static bool_t RxAndDisplayFIFOMsgs( int32_t cardIndex, int32_t module, int32_t channel );
/****** Command Table *******/
enum arfuncgen_commands
{
AR_FUNCGEN_CMD_RX_568,
AR_FUNCGEN_CMD_RX_579,
AR_FUNCGEN_CMD_COUNT
};
/****** Command Tables *******/
static naiapp_cmdtbl_params_t AR_FuncGenMenuCmds[] =
{
{"568 ", "AR Receive on AR-568 Channel ", AR_FUNCGEN_CMD_RX_568, AR_Rx568},
{"579 ", "AR Receive on AR-579 Channel ", AR_FUNCGEN_CMD_RX_579, AR_Rx579}
};
#define DEF_AR_CARD_INDEX 0
#define DEF_AR_MODULE 1
#define DEF_AR_RECV_CHANNEL 2
#define DEF_AR_DATA_RATE AR_SPEED_LOW
#define DEF_AR_TIMESTAMP_ENABLED TRUE
static bool_t bTimestampEnabled = FALSE;
/**************************************************************************************************************/
/**
<summary>
The purpose of the AR_Receive is to illustrate the methods to call in the naibrd library to configure
the ARINC channel to receive ARINC messages. ARINC data messages can be retrieved as follows:
a) Using Validation to selectively receive data that match enabled SDI/Labels, or
b) Using Mailbox mode to read mailboxes of the matched SDI/Labels found in the receive FIFO, or
c) Receiving all of the transmitted data in the receive FIFO (without validation).
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.
- ClearDeviceCfg
- QuerySystemCfg
- DisplayDeviceCfg
- GetBoardSNModCfg
- SaveDeviceCfg
Note, the AR_Receive application can run in conjunction with the AR_Transmit applications to illustrate
ARINC receive and transmit operations together with the NAI ARINC module.
</summary>
*/
/**************************************************************************************************************/
#if defined (__VXWORKS__)
int32_t AR2_Receive(void)
#else
int32_t main(void)
#endif
{
bool_t stop = FALSE;
int32_t cardIndex;
int32_t moduleCnt;
int32_t module;
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)
{
Run_AR2_Receive(cardIndex, module);
}
}
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 nai_status_t AR_Rx568(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit;
p_naiapp_AppParameters_t p_ad_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ad_params->cardIndex;
int32_t module = p_ad_params->module;
int32_t channel = p_ad_params->channel;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
/* Enable Receiver and Display Data Received in the Rx FIFO */
bQuit = RxAndDisplayFIFOMsgs( cardIndex, module, channel ); /* Channel 1 is AR-568 */
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t AR_Rx579(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit;
p_naiapp_AppParameters_t p_ad_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ad_params->cardIndex;
int32_t module = p_ad_params->module;
int32_t channel = p_ad_params->channel;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
/* Enable Receiver and Display Data Received in the Rx FIFO */
bQuit = RxAndDisplayFIFOMsgs( cardIndex, module, channel ); /* Channel 2 is AR-579 */
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
/**************************************************************************************************************/
/**
<summary>
Run_AR2_Receive queries the user for the card, module and channel to configure as the ARINC receiver
as well as the data rate (high (100KHz) or low (12.5KHz)) and how to retrieve the ARINC messages.
Methods in the naibrd library are invoked to configure the ARINC channel.
</summary>
*/
/**************************************************************************************************************/
void Run_AR2_Receive(int32_t cardIndex, int32_t module)
{
bool_t bQuit = FALSE;
bool_t bContinue, bCmdFound;
int32_t cmd;
naiapp_AppParameters_t ar2_params;
p_naiapp_AppParameters_t ar2_receive_params = &ar2_params;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
bQuit = GetAR2Cfg( DEF_AR_CARD_INDEX, DEF_AR_MODULE, &cardIndex, &module );
ar2_receive_params->cardIndex = cardIndex;
ar2_receive_params->module = module;
if (!bQuit)
{
bContinue = TRUE;
naiapp_utils_LoadParamMenuCommands( AR_FUNCGEN_CMD_COUNT, AR_FuncGenMenuCmds );
while (bContinue)
{
naiapp_display_ParamMenuCommands( (int8_t *)"AR2 Receive Mode Menu" );
printf( "\nType AR2 command or %c to quit : ", NAI_QUIT_CHAR );
bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
if (!bQuit)
{
if ( inputResponseCnt > 0 )
{
bCmdFound = naiapp_utils_GetParamMenuCmdNum( inputResponseCnt, inputBuffer, &cmd );
if (bCmdFound)
{
switch (cmd)
{
case AR_FUNCGEN_CMD_RX_568: /* Channel 1 is AR-568 */
case AR_FUNCGEN_CMD_RX_579: /* Channel 2 is AR-579 */
ar2_receive_params->channel = cmd + 1;
AR_FuncGenMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)ar2_receive_params);
break;
default:
printf( "Invalid command entered\n" );
break;
}
}
else
printf( "Invalid command entered\n" );
}
}
else
bContinue = FALSE;
}
}
return;
}
static bool_t RxAndDisplayFIFOMsgs( int32_t cardIndex, int32_t module, int32_t channel )
{
time_t end;
bool_t bQuit = FALSE;
bool_t bContinue = TRUE;
int32_t i;
int32_t nNumWordsRecv, nNumMsgsRecv;
uint32_t RecvStatusWd[AR2_MAX_FIFO_COUNT];
uint32_t RecvData[AR2_MAX_FIFO_COUNT];
uint32_t RecvTimeStamp[AR2_MAX_FIFO_COUNT];
int32_t duration;
uint32_t moduleID;
int32_t AR_FIFO_Size;
bool_t bRxBoundedFIFOenable;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
/* Reset the channel */
check_status( naibrd_AR_ChannelReset( cardIndex, module, channel ) );
/* Disable Tx/Rx */
check_status( naibrd_AR_SetTxEnable( cardIndex, module, channel, AR_DISABLE ) );
check_status( naibrd_AR_SetRxEnable( cardIndex, module, channel, AR_DISABLE ) );
/* Set the Rx Almost Full Fifo Threshold to the maximum size of the FIFO and the Almost Empty Threshold to zero */
moduleID = naibrd_GetModuleID( cardIndex, module );
AR_FIFO_Size = naibrd_AR_GetMaxFifoCount( moduleID );
check_status( naibrd_AR_SetRxFifoThresholds( cardIndex, module, channel, 0, AR_FIFO_Size - 1 ) );
bQuit = GetARRxBoundedFIFOEnable(AR_ENABLE, &bRxBoundedFIFOenable);
if (!bQuit)
{
check_status( naibrd_AR_SetRxFifoBounded( cardIndex, module, channel, bRxBoundedFIFOenable ) );
if (channel == 2) /* AR-579 */
{
/* Set the Parity Disable bit to cause the ARINC bit 32 to be treated as an odd parity bit */
check_status( naibrd_AR_SetParityAsData( cardIndex, module, channel, AR_PAR_ODD ) );
check_status( naibrd_AR_SetRxStoreErrorDisable( cardIndex, module, channel, AR_STORE_ON_ERROR_ENABLE ) );
/* Query for Timestamp Mode Enable */
bQuit = GetARReceiverTimestampEnabled( DEF_AR_TIMESTAMP_ENABLED, &bTimestampEnabled );
if (!bQuit)
{
/* Set Timestamp Enable */
naibrd_AR_SetRxTimeStampEn( cardIndex, module, channel, bTimestampEnabled );
}
}
/* Clear Rx FIFO */
check_status( naibrd_AR_ClearRxFifo( cardIndex, module, channel ) );
/* Enable Receiver */
check_status( naibrd_AR_SetRxEnable( cardIndex, module, channel, AR_ENABLE ) );
bContinue = TRUE;
while (bContinue)
{
printf( "\nType duration (in seconds) for ARINC receive messages test or %c to quit (default: 300) : ", NAI_QUIT_CHAR );
bQuit = naiapp_query_ForQuitResponse( sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt );
if (!bQuit)
{
duration = 5;
if ( inputResponseCnt > 0 )
duration = (int32_t)atol( (const char*)inputBuffer );
end = time(NULL) + duration;
/* Read data */
while ( time(NULL) < end )
{
check_status( naibrd_AR_GetRxBufferCnt( cardIndex, module, channel, &nNumWordsRecv ) );
if ( nNumWordsRecv > 0 )
{
check_status( naibrd_AR_ReadFifo( cardIndex, module, channel, bTimestampEnabled, nNumWordsRecv, RecvStatusWd, RecvData, RecvTimeStamp, &nNumMsgsRecv ) ); /* read back data */
printf( "\nReading back %d messages ...\n", nNumMsgsRecv );
for ( i = 0; i < nNumMsgsRecv; i++ )
{
if (channel == 2) /* AR-579 */
{
if (bTimestampEnabled)
{
printf( "Status: 0x%08X ", RecvStatusWd[i] );
printf( "Data: 0x%08X ", RecvData[i] );
printf( "TimeStamp: 0x%08X\n", RecvTimeStamp[i] );
}
else
{
printf( "Data: 0x%08X\n", RecvData[i] );
}
}
else
{
printf( "Data: 0x%08X\n", RecvData[i] );
}
}
}
#if defined (__VXWORKS__)
taskDelay(1);
#endif
}
}
else
bContinue = FALSE;
}
}
return bQuit;
}