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

RG BasicOps

RG BasicOps Sample Application (SSK 2.x)

Overview

The RG BasicOps sample application demonstrates how to configure and operate IRIG time code (RG) modules using the NAI Software Support Kit (SSK 2.x). It covers the core IRIG operations you will need in your own application: setting the IRIG protocol, configuring AM output gain, setting drift threshold and reference source, managing control bits, setting time zone and propagation offsets, configuring pulse width and free-running time, managing RTC (real-time clock) time, handling capture events, configuring serial signal level, setting periodic interrupt period, and managing interrupt and DST (daylight saving time) settings.

This sample supports RG1 IRIG time code modules. The application is organized into three sub-menus: Basic (protocol and timing configuration), Interrupt (event-mapped status and interrupt configuration), and DST (daylight saving time settings). Each menu command maps directly to one or more naibrd_IRIG_*() API calls that you can lift into your own code.

For the SSK 1.x version, see RG BasicOps (SSK 1.x).

Prerequisites

Before running this sample, make sure you have:

  • An NAI board with an RG1 IRIG time code 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 rg_basic_ops executable from your build output directory. On startup the application looks for a configuration file (default_RG_BasicOps.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, a top-level menu lets you choose between Basic, Interrupt, and DST sub-menus.

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

The main() function follows a standard SSK 2.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_RG_BasicOps.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_GetModuleName() so downstream code can adapt to the specific module variant installed.

#if defined (__VXWORKS__)
int32_t RG_BasicOps(void)
#else
int32_t main(void)
#endif
{
   bool_t bQuit = NAI_FALSE;
   int32_t cardIndex = -1;
   int32_t module = 0;
   uint32_t modId = 0u;
   int32_t moduleCount;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(CONFIG_FILE) == NAI_TRUE)
   {
      while (!bQuit)
      {
         naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         naibrd_GetModuleCount(cardIndex, &moduleCount);
         naiapp_query_ModuleNumber(moduleCount, 1, &module);
         check_status(naibrd_GetModuleName(cardIndex, module, &modId));
         bQuit = RGBasicOps_run(cardIndex, module, modId);
      }

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

   naiapp_access_CloseAllOpenCards();

   return 0;
}

Note the SSK 2.x differences from SSK 1.x in this startup sequence:

  • This sample does not include a VxWorks-specific entry point. Most SSK 2.x samples use NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS for VxWorks builds.

  • The module identifier is retrieved with naibrd_GetModuleName() (SSK 1.x uses naibrd_GetModuleID()).

  • Boolean constants are NAI_TRUE / NAI_FALSE (SSK 1.x uses TRUE / FALSE).

  • Console output uses naiif_printf() from the platform abstraction layer (SSK 1.x uses printf() directly).

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 an RG module. Use the board menu to verify which slots are populated.

Program Structure

Entry Point

On VxWorks the entry point is RG_BasicOps(); on all other platforms it is main(). The preprocessor guard __VXWORKS__ selects between them. After board connection and module selection, the application calls RGBasicOps_run() which presents the top-level menu with three sub-menus.

Command Loop

The top-level menu presents three sub-menus. Each sub-menu has its own command table, display function, and command loop. The display functions show current configuration, interrupt settings, or DST settings depending on which sub-menu is active.

Command Description

BAS

Open the Basic configuration sub-menu (protocol, gain, timing, control bits).

INT

Open the Interrupt sub-menu (event status, interrupt enable, steering, trigger type).

DST

Open the DST (Daylight Saving Time) sub-menu (status, offset, start/end).

Basic Configuration Sub-Menu

The Basic sub-menu provides comprehensive IRIG time code configuration. The display shows the current protocol, 1PPS pulse width, gain, drift threshold, reference source, IRIG time, master time, and free-running time.

Command Description

PR

Set the IRIG protocol (predefined options).

PRV

Set the IRIG protocol by raw value.

G

Set the AM output gain control.

D

Set the drift threshold.

RS

Set the reference source.

CB

Set control bits to send.

CBR

View control bits received.

DI / DO

Set digital input / output.

TZO

Set time zone offset.

O

Set propagation offset.

Y

Set IRIG year.

PW

Set 1PPS pulse width.

FRT

Set free-running time.

RTCT

Set RTC time.

RTCC

Set RTC control.

CET

Set capture event time.

CEE

Set capture event edge.

SSL

Set serial signal level.

PIP

Set periodic interrupt period.

Set Protocol

To configure the IRIG time code protocol in your own application, call naibrd_IRIG_SetProtocol() with a naibrd_irig_protocol_t structure that specifies the format, modulation, carrier frequency, and code expression. This determines how the module encodes and decodes the IRIG signal. You can also call naibrd_IRIG_SetProtocolByValue() with a raw protocol value if you already know the exact register value.

naibrd_irig_protocol_t protocol;
nai_status_t status;

/* Configure IRIG-B with AM modulation, 1 kHz carrier, BCDTOY+CF+SBS */
protocol.irigFormat = NAIBRD_IRIG_CTRL_MODE_IRIG_FORMAT_B;
protocol.irigModulation = NAIBRD_IRIG_CTRL_MODE_IRIG_MODULATION_AM_ASK;
protocol.carrierFreq = NAIBRD_IRIG_MODE_CARRIER_FREQUENCY_1KHZ;
protocol.codeExpression = NAIBRD_IRIG_CTRL_MODE_CODE_EXP_BCDTOY_CF_SBS;

/* Apply to all channels */
for (channel = 1; channel <= maxChannels; channel++)
   status = naibrd_IRIG_SetProtocol(cardIndex, module, channel, protocol);
  • cardIndex — identifies the board.

  • module — the slot containing the RG module.

  • channel — the IRIG channel to configure.

  • protocol.irigFormat — NAIBRD_IRIG_CTRL_MODE_IRIG_FORMAT_A, _FORMAT_B, or _FORMAT_G.

  • protocol.irigModulation — NAIBRD_IRIG_CTRL_MODE_IRIG_MODULATION_DCLS, _AM_ASK, or _DC_MANCHESTER.

  • protocol.carrierFreq — carrier frequency from NAIBRD_IRIG_MODE_CARRIER_FREQUENCY_NONE through _1MHZ.

  • protocol.codeExpression — code expression variant (e.g., NAIBRD_IRIG_CTRL_MODE_CODE_EXP_BCDTOY_CF_SBS).

Note
Not all combinations of format, modulation, carrier, and code expression are valid. If you pass an invalid combination, the API returns NAI_ERROR_INVALID_VALUE.

Set Propagation Offset

The propagation offset compensates for cable delay between the IRIG source and the module. Each IRIG mode (A, B, G, DCLS, RTC) has its own propagation offset register. Pass a signed integer representing the offset in sub-microsecond units. The valid range is +/-1199999999, corresponding to +/-5.0 seconds.

int32_t propOffset = 500; /* sub-microsecond units */
nai_status_t status;

/* Set Mode B propagation offset for all channels */
for (channel = 1; channel <= maxChannels; channel++)
   status = naibrd_IRIG_SetModeBPropOffset(cardIndex, module, channel, propOffset);
  • cardIndex — identifies the board.

  • module — the slot containing the RG module.

  • channel — the IRIG channel to configure.

  • propOffset — signed offset value. Positive values shift the decoded time forward (compensating for cable delay), negative values shift it backward. Valid range: -1199999999 to 1199999999.

The sample provides separate API calls for each mode: naibrd_IRIG_SetModeAPropOffset(), naibrd_IRIG_SetModeBPropOffset(), naibrd_IRIG_SetModeGPropOffset(), naibrd_IRIG_SetDclsPropOffset(), and naibrd_IRIG_SetRTCPropOffset().

Read IRIG Time and Master Time

To read the current IRIG time from the module, call naibrd_IRIG_GetActualIRIGDateAndTime(). This returns a naibrd_irig_master_timer_info_t structure containing day, year, hour, minute, second, microsecond, and seconds-since-midnight fields. The master time (the module’s internal synchronized clock) is available through naibrd_IRIG_GetMasterTime().

naibrd_irig_master_timer_info_t timer;
uint32_t frameErrorCnt;

/* Read the actual IRIG date and time */
naibrd_IRIG_GetActualIRIGDateAndTime(cardIndex, module, channel, &timer, &frameErrorCnt);
naiif_printf("IRIG Time: Day %d, Year %d, %d:%d:%d.%03d\n",
   timer.day, timer.year, timer.hour, timer.minute,
   timer.second, timer.microSecond / 1000u);

/* Read the master time */
naibrd_IRIG_GetMasterTime(cardIndex, module, channel, &timer);
naiif_printf("Master Time: Day %d, Year %d, %d:%d:%d.%03d\n",
   timer.day, timer.year, timer.hour, timer.minute,
   timer.second, timer.microSecond / 1000u);
  • timer.day — day of year (1-366).

  • timer.year — two-digit year.

  • timer.hour, timer.minute, timer.second — time of day.

  • timer.microSecond — sub-second precision in microseconds.

  • timer.secondsSinceMidnight — total seconds elapsed since midnight.

  • frameErrorCnt — number of frame errors detected on the IRIG input.

Set Free-Running Time

The free-running time is an independent timer that operates regardless of the IRIG reference signal. It is useful for applications that need a local time source when no external IRIG reference is available. To use free-running time as the master time source, set the reference source to 7 (no reference). Call naibrd_IRIG_SetFreeRunningTimeAndDate() with a fully populated naibrd_irig_master_timer_info_t structure.

naibrd_irig_master_timer_info_t time;

time.year = 25;       /* 2025 */
time.day = 100;       /* Day of year */
time.hour = 14;
time.minute = 30;
time.second = 0;
time.microSecond = 0;

for (channel = 1; channel <= maxChannels; channel++)
   naibrd_IRIG_SetFreeRunningTimeAndDate(cardIndex, module, channel, time);
  • The time structure uses the same naibrd_irig_master_timer_info_t type as the read functions.

  • Free-running time appears in the Master Time display when the reference source is set to 7.

Set RTC Time and Date

The real-time clock (RTC) maintains time independently of the IRIG signal and can serve as an alternative reference source (reference source 3). Setting the RTC involves two steps: first set the time with naibrd_IRIG_SetRTCTime(), then set the date with naibrd_IRIG_SetRTCDate(), and finally commit the RTC with naibrd_IRIG_SetRTC().

naibrd_irig_rtc_time_t rtcTime;
naibrd_irig_rtc_date_t rtcDate;
nai_status_t status;

/* Set the RTC time */
rtcTime.hour = 14;
rtcTime.minute = 30;
rtcTime.second = 0;
for (channel = 1; channel <= maxChannels; channel++)
   naibrd_IRIG_SetRTCTime(cardIndex, module, channel, rtcTime);

/* Set the RTC date */
rtcDate.year = 25;
rtcDate.month = 6;
rtcDate.day = 15;
for (channel = 1; channel <= maxChannels; channel++)
   naibrd_IRIG_SetRTCDate(cardIndex, module, channel, rtcDate);

/* Commit the RTC -- retries if the ready bit is not yet set */
status = naibrd_IRIG_SetRTC(cardIndex, module, channel);
  • rtcTime.hour, rtcTime.minute, rtcTime.second — the time to set.

  • rtcDate.year, rtcDate.month, rtcDate.day — the date to set.

  • naibrd_IRIG_SetRTC() commits the RTC values. It returns NAI_ERROR_TIMEOUT if the ready bit is not set within the timeout period.

Set Drift Threshold and Reference Source

The drift threshold controls how much the IRIG reference time is allowed to deviate from the module’s internal clock before a drift event is flagged. The reference source selects which time reference the module uses: IRIG (0), RTC (3), or no reference / free-running (7).

uint32_t driftThreshold = 1000;

/* Set the drift threshold */
for (channel = 1; channel <= maxChannels; channel++)
   naibrd_IRIG_SetDriftThreshold(cardIndex, module, channel, driftThreshold);

/* Set the reference source to IRIG */
for (channel = 1; channel <= maxChannels; channel++)
   naibrd_IRIG_SetReferenceSource(cardIndex, module, channel, 0u);
  • driftThreshold — a 16-bit unsigned value representing the maximum allowable drift.

  • Reference source values: 0 = IRIG, 3 = RTC, 7 = no reference (free-running).

Set AM Output Gain and 1PPS Pulse Width

The AM output gain controls the amplitude of the IRIG AM output signal (0-255). The 1PPS pulse width sets the duration of the one-pulse-per-second output in microseconds.

/* Set AM output gain to 128 */
for (channel = 1; channel <= maxChannels; channel++)
   naibrd_IRIG_SetAMOutputGain(cardIndex, module, channel, (uint8_t)128);

/* Set 1PPS pulse width to 500000 microseconds (0.5 seconds) */
for (channel = 1; channel <= maxChannels; channel++)
   naibrd_IRIG_Set1PPSPulseWidth(cardIndex, module, channel, 500000);
  • The gain value ranges from 0 (minimum) to 255 (maximum).

  • The pulse width is specified in microseconds.

Set Time Zone Offset

The time zone offset adjusts the decoded IRIG time to account for the local time zone. The value is specified in minutes and can range from -1439 to +1439. The sample supports both a general time zone offset and an RTC-specific offset.

int32_t timeZoneOffset = -300; /* UTC-5 (Eastern Standard Time) */

/* Set the general time zone offset */
for (channel = 1; channel <= maxChannels; channel++)
   naibrd_IRIG_SetTimeZoneOffset(cardIndex, module, channel, timeZoneOffset);

/* Or set the RTC time zone offset */
for (channel = 1; channel <= maxChannels; channel++)
   naibrd_IRIG_SetRTCTimeZoneOffset(cardIndex, module, channel, timeZoneOffset);
  • timeZoneOffset — signed value in minutes. For example, -300 for UTC-5, +60 for UTC+1.

Set Control Bits and Serial Signal Level

Control bits are user-defined data embedded in the IRIG frame. Call naibrd_IRIG_SetCtrlBitsToSend() to set the bits to transmit and naibrd_IRIG_GetCtrlBitsReceived() to read received bits. Bits 0 through 26 are valid.

uint32_t ctrlbits = 0x00000005u;

/* Set control bits to send */
for (channel = 1; channel <= maxChannels; channel++)
   naibrd_IRIG_SetCtrlBitsToSend(cardIndex, module, channel, ctrlbits);

/* Read received control bits */
uint32_t receivedBits = 0u;
naibrd_IRIG_GetCtrlBitsReceived(cardIndex, module, channel, &receivedBits);

To configure the serial signal level for the digital output or 1PPS/event output, call naibrd_IRIG_SetDigitalLevel():

/* Set the digital output to RS-485 */
for (channel = 1; channel <= maxChannels; channel++)
   naibrd_IRIG_SetDigitalLevel(cardIndex, module, channel,
      NAIBRD_IRIG_SIGNAL_DIGITAL_OUT, NAIBRD_IRIG_SIGNAL_LEVEL_RS485);
  • Signal types: NAIBRD_IRIG_SIGNAL_DIGITAL_OUT or NAIBRD_IRIG_SIGNAL_1PPS_OUT_EVENT_IN.

  • Signal levels: NAIBRD_IRIG_SIGNAL_LEVEL_RS232 or NAIBRD_IRIG_SIGNAL_LEVEL_RS485.

Interrupt Sub-Menu

The Interrupt sub-menu configures event-mapped interrupt settings. The display shows all event types with their latched/real-time status, interrupt enable state, and trigger type. The IRIG module supports a rich set of event types including BIT data loss, software fault, reference lost, reference received, 1PPS output, control bits changed, reference source change, event detected, user interrupt, DST adjust, and test interrupt.

Command Description

C

Clear all event-mapped status bits for a channel.

CS

Clear a specific event-mapped status bit.

E

Set event-mapped interrupt enable.

S

Set event-mapped interrupt steering.

V

Set event-mapped interrupt vector.

EL

Set event-mapped interrupt edge/level trigger type.

Read and Clear Event Status

To read the status of a specific event type, call naibrd_IRIG_GetEventMappedStatus() with the desired status type. Each event type has both a latched and a real-time variant. Latched status bits remain asserted until explicitly cleared; real-time bits reflect the current instantaneous state.

nai_status_bit_t status;
nai_status_bit_t rtStatus;

/* Read BIT Data Loss -- latched and real-time */
naibrd_IRIG_GetEventMappedStatus(cardIndex, module, channel,
   NAIBRD_IRIG_EVTMAP_STATUS_BIT_DATA_LOSS_LATCHED, &status);
naibrd_IRIG_GetEventMappedStatus(cardIndex, module, channel,
   NAIBRD_IRIG_EVTMAP_STATUS_BIT_DATA_LOSS_REALTIME, &rtStatus);

/* Clear a specific latched status bit */
naibrd_IRIG_ClearEventMappedStatus(cardIndex, module, channel,
   NAIBRD_IRIG_EVTMAP_STATUS_BIT_DATA_LOSS_LATCHED);
  • status — NAI_STATUS_BIT_HI if the event has occurred (latched), NAI_STATUS_BIT_LO otherwise.

  • Event types include NAIBRD_IRIG_EVTMAP_STATUS_BIT_DATA_LOSS_LATCHED, _BIT_SOFTWARE_FAULT_LATCHED, _IRIG_REFERENCE_LOST_LATCHED, _RECEIVING_IRIG_REFERENCE_LATCHED, and others.

Configure Interrupt Enable, Steering, and Trigger Type

To enable interrupts for a specific event, call naibrd_IRIG_SetEventMappedInterruptEnable(). The steering function routes the interrupt to a specific bus (VME, ARM, PCIe, CPCI). The trigger type sets whether the interrupt fires on an edge transition or while the condition is held at a level.

/* Enable interrupt for BIT Data Loss event */
naibrd_IRIG_SetEventMappedInterruptEnable(cardIndex, module, channel,
   NAIBRD_IRIG_EVTMAP_STATUS_BIT_DATA_LOSS_LATCHED, NAI_TRUE);

/* Steer the BIT category interrupts to PCIe */
naibrd_IRIG_SetEventMappedInterruptSteering(cardIndex, module, channel,
   NAIBRD_IRIG_EVTMAP_CATEGORY_BIT, NAIBRD_INT_STEERING_PCIE);

/* Set the BIT interrupt vector */
naibrd_IRIG_SetEventMappedInterruptVector(cardIndex, module, channel,
   NAIBRD_IRIG_EVTMAP_CATEGORY_BIT, 0x00000001u);

/* Set edge trigger type */
naibrd_IRIG_SetEventMappedInterruptTriggerType(cardIndex, module, channel,
   NAIBRD_IRIG_EVTMAP_STATUS_BIT_DATA_LOSS_LATCHED, NAIBRD_INT_TRIGGER_TYPE_EDGE);
  • Interrupt steering options: NAIBRD_INT_STEERING_VME, NAIBRD_INT_STEERING_ON_BOARD_0 (ARM), NAIBRD_INT_STEERING_PCIE, NAIBRD_INT_STEERING_CPCI.

  • Interrupt categories for vector and steering: NAIBRD_IRIG_EVTMAP_CATEGORY_BIT and NAIBRD_IRIG_EVTMAP_CATEGORY_GENERAL.

  • Trigger types: NAIBRD_INT_TRIGGER_TYPE_EDGE or NAIBRD_INT_TRIGGER_TYPE_LEVEL.

DST Sub-Menu

The DST sub-menu manages daylight saving time settings. When DST is configured, the module automatically adjusts the decoded IRIG time by the specified offset during the DST window. You configure the DST start and end using a month/week/day/hour/minute structure that supports recurring annual transitions.

Command Description

DSTS

Get the current DST status.

OFF

Set the DST offset.

START

Set the DST start date/time.

END

Set the DST end date/time.

Get DST Status and Set Offset

To check whether DST is currently active, call naibrd_IRIG_GetDSTStatus(). The DST offset register uses the format 0xXXXXXHMM, where byte 2 is hours and bytes 0-1 are minutes.

naibrd_irig_dst_status_type_t dstStatus;
uint32_t dstOffset;

/* Read the current DST status */
naibrd_IRIG_GetDSTStatus(cardIndex, module, channel, &dstStatus);
/* dstStatus is NAIBRD_IRIG_DST_STATUS_DISABLED or NAIBRD_IRIG_DST_STATUS_ENABLED */

/* Set DST offset to 1 hour (0x100 in HMM format) */
naibrd_IRIG_SetDSTOffset(cardIndex, module, channel, 0x100u);
  • dstStatus — NAIBRD_IRIG_DST_STATUS_DISABLED (0) or NAIBRD_IRIG_DST_STATUS_ENABLED (1).

  • dstOffset — the offset in HMM format. For example, 0x100 = 1 hour 00 minutes, 0x030 = 0 hours 30 minutes.

Set DST Start and End

The DST start and end are configured using a naibrd_irig_dst_timer_info_t structure that specifies the month, day of week, week number within the month, hour, and minute. This allows recurring annual DST transitions.

naibrd_irig_dst_timer_info_t dstStart;
naibrd_irig_dst_timer_info_t dstEnd;

/* DST starts second Sunday of March at 02:00 */
dstStart.month = 3;
dstStart.day = 0;    /* 0 = Sunday */
dstStart.week = 2;   /* Second week */
dstStart.hour = 2;
dstStart.minute = 0;

/* DST ends first Sunday of November at 02:00 */
dstEnd.month = 11;
dstEnd.day = 0;      /* 0 = Sunday */
dstEnd.week = 1;     /* First week */
dstEnd.hour = 2;
dstEnd.minute = 0;

for (channel = 1; channel <= maxChannels; channel++)
{
   naibrd_IRIG_SetDSTStart(cardIndex, module, channel, dstStart);
   naibrd_IRIG_SetDSTEnd(cardIndex, module, channel, dstEnd);
}
  • month — 1-12.

  • day — day of week (0 = Sunday, 1 = Monday, …​, 6 = Saturday).

  • week — week number within the month (1 = first, 2 = second, etc.).

  • hour — hour of transition (0-23).

  • minute — minute of transition (0-59).

Troubleshooting Reference

Error / Symptom Possible Causes Suggested Resolution

Module not recognized as RG

The selected module slot does not contain an IRIG time code module.

Verify the module type in the slot. See the RG1 Manual.

IRIG time not updating

No IRIG reference signal is connected, or the protocol does not match the source.

Verify the IRIG signal connection and set the correct protocol.

Reference source shows 0

The module is using the internal reference. No external IRIG source detected.

Connect an external IRIG reference signal if external synchronization is desired.

Drift threshold exceeded

The time difference between the IRIG reference and the internal clock exceeds the threshold.

Increase the drift threshold or verify the IRIG reference signal quality.

BIT data loss status active

The module is not receiving valid IRIG data.

Check the IRIG signal connection and verify the protocol setting.

Control bits not received

The IRIG format may not include control bits, or the source is not sending them.

Verify that the IRIG protocol supports control bits and that the source is configured to send them.

1PPS output not visible

The pulse width may be set too narrow, or the output is not connected.

Increase the 1PPS pulse width and verify the output wiring.

DST adjustment not applied

DST settings may not be configured, or the current date is outside the DST window.

Verify the DST start and end dates and ensure the DST offset is set.

Full Source

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

Full Source — rg_basic_ops.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_irig.h"
#include "nai_libs/naibrd/src/maps/nai_map_irig.h"

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

static const int8_t *SAMPLE_PGM_NAME = (const int8_t *)"RG Module Basic Operation Program";
static const int8_t *CONFIG_FILE = (const int8_t *)"default_RG_BasicOps.txt";

#define DEFAULT_CHANNEL 1

/* Function prototypes */
static bool_t RGBasicOps_run(int32_t cardIndex, int32_t module, uint32_t modId);
static nai_status_t RGBasicOps_runBasicMenu(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_runInterruptMenu(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_runDSTMenu(int32_t paramCount, int32_t* p_params);
static void RGBasicOps_displayConfigurations(int32_t cardIndex, int32_t module, uint32_t modId, int32_t maxChannels, bool_t displayHex);
static void RGBasicOps_displayInterrupts(int32_t cardIndex, int32_t module, uint32_t modId, int32_t maxChannels, bool_t displayHex);
static void RGBasicOps_displayDSTSettings(int32_t cardIndex, int32_t module, uint32_t modId, int32_t maxChannels, bool_t displayHex);

/* RG Basic Ops Command Functions */
static nai_status_t RGBasicOps_setIRIGProtocol(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGProtocolByValue(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGAMOutputGain(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGDriftThreshold(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGReferenceSource(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGCtrlBitsToSend(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_getIRIGCtrlBitsReceived(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGDigitalInput(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGDigitalOutput(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGTimeZoneOffset(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGPropOffset(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGYear(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGPulseWidth(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGFreeRunningTime(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGRTCTime(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGRTCControl(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGCaptureEventTime(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGCaptureEventEdge(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGSerialSignalLevel(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOps_setIRIGPeriodicInterruptPeriod(int32_t paramCount, int32_t* p_params);

static nai_status_t RGBasicOpsInterrupts_setIRIGInterruptEnable(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsInterrupts_setIRIGInterruptSteering(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsInterrupts_setIRIGInterruptEdgeLevel(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsInterrupts_setIRIGInterruptVector(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsInterrupts_clearIRIGEventMappedStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsInterrupts_getIRIGEventMappedStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsInterrupts_clearIRIGChannelStatus(int32_t paramCount, int32_t* p_params);

static nai_status_t RGBasicOpsDST_getIRIGDSTStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsDST_setIRIGDSTOffset(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsDST_setIRIGDSTStart(int32_t paramCount, int32_t* p_params);
static nai_status_t RGBasicOpsDST_setIRIGDSTEnd(int32_t paramCount, int32_t* p_params);

/****** Command Table *******/
/* Invariant: enumeration of cmd table starts from 0 and increments by 1 */

enum rg_basicOps_commands
{
   RG_BASICOPS_BASIC_MENU,
   RG_BASICOPS_INTERRUPT_MENU,
   RG_BASICOPS_DST_MENU,
   RG_BASICOPS_COUNT
};

enum rg_basicOps_basic_commands
{
   RG_BASICOPS_CMD_SET_PROTOCOL,
   RG_BASICOPS_CMD_SET_PROTOCOL_BY_VALUE,
   RG_BASICOPS_CMD_SET_GAIN,
   RG_BASICOPS_CMD_SET_DRIFT_THRESHOLD,
   RG_BASICOPS_CMD_SET_REFERENCE_SOURCE,
   RG_BASICOPS_CMD_SET_CONTROL_BITS,
   RG_BASICOPS_CMD_GET_CONTROL_BITS_RECEIVED,
   RG_BASICOPS_CMD_SET_DIGITAL_INPUT,
   RG_BASICOPS_CMD_SET_DIGITAL_OUTPUT,
   RG_BASICOPS_CMD_SET_TIME_ZONE_OFFSET,
   RG_BASICOPS_CMD_SET_PROP_OFFSET,
   RG_BASICOPS_CMD_SET_YEAR,
   RG_BASICOPS_CMD_SET_PULSE_WIDTH,
   RG_BASICOPS_CMD_SET_PERIOD_INTERRUPT_PERIOD,
   RG_BASICOPS_CMD_SET_FREE_RUNNING_TIME,
   RG_BASICOPS_CMD_SET_CAPTURE_EVENT_TIME,
   RG_BASICOPS_CMD_SET_CAPTURE_EVENT_EDGE,
   RG_BASICOPS_CMD_SET_SERIAL_SIGNAL_LEVEL,
   RG_BASICOPS_CMD_SET_RTC_TIME,
   RG_BASICOPS_CMD_SET_RTC_CONTROL,
   RG_BASICOPS_CMD_COUNT
};

enum rg_basicOps_Interrupts_commands
{
   RG_BASICOPS_INTERRUPTS_CLEAR,
   RG_BASICOPS_INTERRUPTS_CLEARSPECIFIC,
   RG_BASICOPS_INTERRUPTS_ENABLE,
   RG_BASICOPS_INTERRUPTS_STEERING,
   RG_BASICOPS_INTERRUPTS_EDGELEVEL,
   RG_BASICOPS_INTERRUPTS_VECTOR,
   RG_BASICOPS_INTERRUPTS_CMD_COUNT
};

enum rg_basicOps_DST_commands
{
   RG_BASICOPS_DST_CMD_GET_DST_STATUS,
   RG_BASICOPS_DST_CMD_SET_DST_OFFSET,
   RG_BASICOPS_DST_CMD_SET_DST_START,
   RG_BASICOPS_DST_CMD_SET_DST_END,
   RG_BASICOPS_DST_CMD_COUNT
};

naiapp_cmdtbl_params_t RG_BasicOpsCmds[] =
{
   {"BAS", "IRIG Basic Menu",                       RG_BASICOPS_BASIC_MENU,     RGBasicOps_runBasicMenu},
   {"INT", "IRIG Interrupt Menu",                   RG_BASICOPS_INTERRUPT_MENU, RGBasicOps_runInterruptMenu},
   {"DST", "IRIG DST (Daylight Savings Time) Menu", RG_BASICOPS_DST_MENU,       RGBasicOps_runDSTMenu}
};

naiapp_cmdtbl_params_t RG_BasicOps_BasicCmds[] =
{
   {"PR",      "Set IRIG Protocol",                RG_BASICOPS_CMD_SET_PROTOCOL,                RGBasicOps_setIRIGProtocol },
   {"PRV",     "Set IRIG Protocol by Value",       RG_BASICOPS_CMD_SET_PROTOCOL_BY_VALUE,       RGBasicOps_setIRIGProtocolByValue },
   {"G",       "Set IRIG Gain Control",            RG_BASICOPS_CMD_SET_GAIN,                    RGBasicOps_setIRIGAMOutputGain },
   {"D",       "Set IRIG Drift Threshold",         RG_BASICOPS_CMD_SET_DRIFT_THRESHOLD,         RGBasicOps_setIRIGDriftThreshold },
   {"RS",      "Set IRIG Reference Source",        RG_BASICOPS_CMD_SET_REFERENCE_SOURCE,        RGBasicOps_setIRIGReferenceSource },
   {"CB",      "Set IRIG Control Bits to Send",    RG_BASICOPS_CMD_SET_CONTROL_BITS,            RGBasicOps_setIRIGCtrlBitsToSend },
   {"CBR",     "View IRIG Control Bits Received",  RG_BASICOPS_CMD_GET_CONTROL_BITS_RECEIVED,   RGBasicOps_getIRIGCtrlBitsReceived },
   {"DI",      "Set IRIG Digital Input",           RG_BASICOPS_CMD_SET_DIGITAL_INPUT,           RGBasicOps_setIRIGDigitalInput },
   {"DO",      "Set IRIG Digital Output",          RG_BASICOPS_CMD_SET_DIGITAL_OUTPUT,          RGBasicOps_setIRIGDigitalOutput },
   {"TZO",     "Set IRIG Time Zone Offset",        RG_BASICOPS_CMD_SET_TIME_ZONE_OFFSET,        RGBasicOps_setIRIGTimeZoneOffset },
   {"O",       "Set Prop Offset",                  RG_BASICOPS_CMD_SET_PROP_OFFSET,             RGBasicOps_setIRIGPropOffset },
   {"Y",       "Set IRIG Year",                    RG_BASICOPS_CMD_SET_YEAR,                    RGBasicOps_setIRIGYear },
   {"PW",      "Set 1PPS Pulse Width",             RG_BASICOPS_CMD_SET_PULSE_WIDTH,             RGBasicOps_setIRIGPulseWidth },
   {"FRT",     "Set Free Running Time",            RG_BASICOPS_CMD_SET_FREE_RUNNING_TIME,       RGBasicOps_setIRIGFreeRunningTime },
   {"RTCT",    "Set RTC Time",                     RG_BASICOPS_CMD_SET_RTC_TIME,                RGBasicOps_setIRIGRTCTime },
   {"RTCC",    "Set RTC Control",                  RG_BASICOPS_CMD_SET_RTC_CONTROL,             RGBasicOps_setIRIGRTCControl },
   {"CET",     "Set Capture Event Time",           RG_BASICOPS_CMD_SET_CAPTURE_EVENT_TIME,      RGBasicOps_setIRIGCaptureEventTime },
   {"CEE",     "Set Capture Event Edge",           RG_BASICOPS_CMD_SET_CAPTURE_EVENT_EDGE,      RGBasicOps_setIRIGCaptureEventEdge },
   {"SSL",     "Set Serial Signal Level",          RG_BASICOPS_CMD_SET_SERIAL_SIGNAL_LEVEL,     RGBasicOps_setIRIGSerialSignalLevel },
   {"PIP",     "Set Period Interrupt Period",      RG_BASICOPS_CMD_SET_PERIOD_INTERRUPT_PERIOD, RGBasicOps_setIRIGPeriodicInterruptPeriod }
};

naiapp_cmdtbl_params_t RG_BasicOps_InterruptCmds[] =
{
   {"C",     "Clear All Event Mapped Status Bits",   RG_BASICOPS_INTERRUPTS_CLEAR,                                    RGBasicOpsInterrupts_clearIRIGChannelStatus },
   {"CS",    "Clear Specific Event Mapped Status Bit",RG_BASICOPS_INTERRUPTS_CLEARSPECIFIC,                           RGBasicOpsInterrupts_clearIRIGEventMappedStatus },
   {"E",     "Set Event Mapped Interrupt Enable",    RG_BASICOPS_INTERRUPTS_ENABLE,                                   RGBasicOpsInterrupts_setIRIGInterruptEnable },
   {"S",     "Set Event Mapped Interrupt Steering",  RG_BASICOPS_INTERRUPTS_STEERING,                                 RGBasicOpsInterrupts_setIRIGInterruptSteering },
   {"V",     "Set Event Mapped Interrupt Vector",    RG_BASICOPS_INTERRUPTS_VECTOR,                                   RGBasicOpsInterrupts_setIRIGInterruptVector },
   {"EL",    "Set Event Mapped Interrupt Edge Level",RG_BASICOPS_INTERRUPTS_EDGELEVEL,                                RGBasicOpsInterrupts_setIRIGInterruptEdgeLevel }
};

naiapp_cmdtbl_params_t RG_BasicOps_DSTCmds[] =
{
   {"DSTS",    "Get DST Status",         RG_BASICOPS_DST_CMD_GET_DST_STATUS,             RGBasicOpsDST_getIRIGDSTStatus },
   {"OFF",     "Set DST Offset",         RG_BASICOPS_DST_CMD_SET_DST_OFFSET,             RGBasicOpsDST_setIRIGDSTOffset },
   {"START",   "Set DST Start",          RG_BASICOPS_DST_CMD_SET_DST_START,              RGBasicOpsDST_setIRIGDSTStart  },
   {"END",     "Set DST End",            RG_BASICOPS_DST_CMD_SET_DST_END,                RGBasicOpsDST_setIRIGDSTEnd    }
};

int8_t interruptTypeStrings[NAIBRD_IRIG_EVTMAP_STATUS_TYPE_ENUM_COUNT][40] =
{
   "BIT Data Loss",
   "BIT Data Loss",
   "BIT Software Fault",
   "BIT Software Fault",
   "IRIG Reference Lost",
   "IRIG Reference Lost",
   "Receiving IRIG Reference",
   "Receiving IRIG Reference",
   "IRIG Reference Pulse Received",
   "IRIG Reference Pulse Received",
   "Interrupt on 1PPS Output Going High",
   "Interrupt on 1PPS Output Going High",
   "Received Control Bits Changed",
   "Received Control Bits Changed",
   "Control Bits Received",
   "Control Bits Received",
   "Change In Reference Source",
   "Change In Reference Source",
   "Event Detected",
   "Event Detected",
   "Programmable-Duration User Interrupt",
   "Programmable-Duration User Interrupt",
   "Did a DST Adjust",
   "Did a DST Adjust",
   "Test Interrupt",
   "Test Interrupt"
};

int8_t enableDisableStrings[2][10] =
{
   "DISABLED",
   "ENABLED "
};

int8_t interruptTriggerTypeStrings[2][10] =
{
   "EDGE ",
   "LEVEL"
};

int8_t interruptSteeringStrings[6][75] =
{
   "VME",
   "ARM Custom Application (On Board 0) / NAI Ethernet Listener Application",
   "On Board 1 (Unused)",
   "On Board 2 (Unused)",
   "PCIe Bus",
   "CPCI Bus"
};

/*****************************************************************************/
/**
 * <summary>
 * The purpose of the AD_BasicOps is to illustrate the methods to call in the
 * naibrd library to perform basic operations with the AD modules for
 * configuration setup and reading the channels.
 *
 * 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 AD routines.
 * - ConfigDevice
 * - DisplayDeviceCfg
 * - GetBoardSNModCfg
 * - CheckModule
 * </summary>
 */
 /*****************************************************************************/
#if defined (__VXWORKS__)
int32_t RG_BasicOps(void)
#else
int32_t main(void)
#endif
{
   bool_t bQuit = NAI_FALSE;
   int32_t cardIndex = -1;
   int32_t module = 0;
   uint32_t modId = 0u;
   int32_t moduleCount;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(CONFIG_FILE) == NAI_TRUE)
   {
      while (!bQuit)
      {
         naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         naibrd_GetModuleCount(cardIndex, &moduleCount);
         naiapp_query_ModuleNumber(moduleCount, 1, &module);
         check_status(naibrd_GetModuleName(cardIndex, module, &modId));
         bQuit = RGBasicOps_run(cardIndex, module, modId);
      }

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

   naiapp_access_CloseAllOpenCards();

   return 0;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_displayConfigurations illustrates the methods to call in the naibrd library
 * to retrieve the basic operation configuration states and status states
 * for all channels on the module.
 * </summary>
 */
 /*****************************************************************************/
static void RGBasicOps_displayConfigurations(int32_t cardIndex, int32_t module, uint32_t modId, int32_t maxChannels, bool_t displayHex)
{
   int channel;
   naibrd_irig_protocol_value_t protocol;
   naibrd_irig_master_timer_info_t timer;
   uint8_t gain;
   uint32_t driftThreshold, frameErrorCnt, refSource, pulseWidth;

#if defined (NAIBSP_CONFIG_SOFTWARE_OS_WINDOWS)
   UNREFERENCED_PARAMETER(modId);
   UNREFERENCED_PARAMETER(displayHex);
#endif

    naiif_printf("\r\n\r\n ===============================================================================================================================================================\r\n");
    naiif_printf(" Protocol       1PPS Pulse Width     Gain     Drift Threshold    Ref. Source       IRIG Time                        Master Time              Free-Running Time\r\n");
    naiif_printf(" ---------------------------------------------------------------------------------------------------------------------------------------------------------------\r\n");

   for (channel = 1; channel <= maxChannels; channel++)
    {
      check_status(naibrd_IRIG_GetProtocolByValue(cardIndex, module, channel, &protocol));

      naiif_printf(" %x             ", protocol);

      check_status(naibrd_IRIG_Get1PPSPulseWidth(cardIndex, module, channel, &pulseWidth));

      naiif_printf("%d              ", pulseWidth);

      check_status(naibrd_IRIG_GetAMOutputGain(cardIndex, module, channel, &gain));

      naiif_printf("%d            ", gain);

      check_status(naibrd_IRIG_GetDriftThreshold(cardIndex, module, channel, &driftThreshold));

      naiif_printf("%d                ", driftThreshold);

      check_status(naibrd_IRIG_GetActualReferenceSource(cardIndex, module, channel, &refSource));

      naiif_printf("%d        ", refSource);

      //check_status(naibrd_IRIG_GetMasterDateAndTime(cardIndex, module, channel, &timer));
      check_status(naibrd_IRIG_GetActualIRIGDateAndTime(cardIndex, module, channel, &timer, &frameErrorCnt));
      //check_status(naibrd_IRIG_GetIRIGFreeRunningTimeAndDate(cardIndex, module, channel, &timer));
      naiif_printf("%d/%d %d:%d:%d.%03d SBS:%d       ", timer.day, timer.year, timer.hour, timer.minute, timer.second, timer.microSecond / 1000u,
                                                      timer.secondsSinceMidnight);

      check_status(naibrd_IRIG_GetMasterTime(cardIndex, module, channel, &timer));
      //check_status(naibrd_IRIG_GetIRIGFreeRunningTimeAndDate(cardIndex, module, channel, &timer));
      naiif_printf("%d/%d %d:%d:%d.%03d SBS:%d       ", timer.day, timer.year, timer.hour, timer.minute, timer.second, timer.microSecond / 1000u,
                                                      timer.secondsSinceMidnight);

      check_status(naibrd_IRIG_GetFreeRunningTimeAndDate(cardIndex, module, channel, &timer));
      naiif_printf("%d/%d %d:%d:%d.%03d SBS:%d       ", timer.day, timer.year, timer.hour, timer.minute, timer.second, timer.microSecond / 1000u,
                                                      timer.secondsSinceMidnight);
   }
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_displayInterrupts illustrates the methods to call in the naibrd library
 * to retrieve and set interrupt configuration settings for the RG module.
 * </summary>
 */
 /*****************************************************************************/
static void RGBasicOps_displayInterrupts(int32_t cardIndex, int32_t module, uint32_t modId, int32_t maxChannels, bool_t displayHex)
{
   int channel = maxChannels;
   bool_t enable = NAI_FALSE;
   naibrd_int_trigger_type_t trigType = NAIBRD_INT_TRIGGER_TYPE_EDGE;
   uint32_t statusType = (uint32_t)NAIBRD_IRIG_EVTMAP_STATUS_BIT_DATA_LOSS_LATCHED;
   uint32_t bitVector = 0u;
   uint32_t generalVector = 0u;
   uint32_t statusHexLatchedBit = 0u;
   uint32_t statusHexRealtimeBit = 0u;
   uint32_t statusHexLatchedGeneral = 0u;
   uint32_t statusHexRealtimeGeneral = 0u;
   nai_status_bit_t status;
   nai_status_bit_t rtStatus;
   naibrd_int_steering_t bitSteering = NAIBRD_INT_STEERING_CPCI;
   naibrd_int_steering_t generalSteering = NAIBRD_INT_STEERING_CPCI;

#if defined (NAIBSP_CONFIG_SOFTWARE_OS_WINDOWS)
   UNREFERENCED_PARAMETER(modId);
   UNREFERENCED_PARAMETER(displayHex);
#endif

   naiif_printf("\r\n\r\n ================================================================================================================================\r\n");
   naiif_printf("                          Status Type    Status (R/L)    Interrupt Enable   Trigger Type\r\n");
   naiif_printf("                                         On(1)/Off(0)                                   \r\n");
   naiif_printf(" --------------------------------------------------------------------------------------------------------------------------------\r\n");

   for (statusType = (uint32_t)NAIBRD_IRIG_EVTMAP_STATUS_BIT_DATA_LOSS_LATCHED; statusType < NAIBRD_IRIG_EVTMAP_STATUS_TYPE_ENUM_COUNT; statusType += 2u)
   {
      naiif_printf("%37s", interruptTypeStrings[statusType]);
      check_status(naibrd_IRIG_GetEventMappedStatus(cardIndex, module, channel, (naibrd_irig_event_mapped_status_type_t)statusType, &status));
      check_status(naibrd_IRIG_GetEventMappedStatus(cardIndex, module, channel, (naibrd_irig_event_mapped_status_type_t)(statusType + 1u), &rtStatus));
      naiif_printf("     (%d/%d)        ", rtStatus, status);
      check_status(naibrd_IRIG_GetEventMappedInterruptEnable(cardIndex, module, channel, (naibrd_irig_event_mapped_status_type_t)statusType, &enable));
      naiif_printf("     %9s          ", enableDisableStrings[enable]);
      check_status(naibrd_IRIG_GetEventMappedInterruptTriggerType(cardIndex, module, channel, (naibrd_irig_event_mapped_status_type_t)statusType, &trigType));
      naiif_printf("%6s\r\n", interruptTriggerTypeStrings[trigType]);
   }
   check_status(naibrd_IRIG_GetEventMappedInterruptVector(cardIndex, module, channel, NAIBRD_IRIG_EVTMAP_CATEGORY_BIT, &bitVector));
   check_status(naibrd_IRIG_GetEventMappedInterruptVector(cardIndex, module, channel, NAIBRD_IRIG_EVTMAP_CATEGORY_GENERAL, &generalVector));
   check_status(naibrd_IRIG_GetEventMappedInterruptSteering(cardIndex, module, channel, NAIBRD_IRIG_EVTMAP_CATEGORY_BIT, &bitSteering));
   check_status(naibrd_IRIG_GetEventMappedInterruptSteering(cardIndex, module, channel, NAIBRD_IRIG_EVTMAP_CATEGORY_GENERAL,
                                                            &generalSteering));
   check_status(naibrd_IRIG_GetEventMappedStatusRaw(cardIndex, module, channel, NAIBRD_IRIG_EVTMAP_CATEGORY_BIT, NAI_STATUS_LATCHED, &statusHexLatchedBit));
   check_status(naibrd_IRIG_GetEventMappedStatusRaw(cardIndex, module, channel, NAIBRD_IRIG_EVTMAP_CATEGORY_BIT, NAI_STATUS_REALTIME, &statusHexRealtimeBit));
   check_status(naibrd_IRIG_GetEventMappedStatusRaw(cardIndex, module, channel, NAIBRD_IRIG_EVTMAP_CATEGORY_GENERAL, NAI_STATUS_LATCHED, &statusHexLatchedGeneral));
   check_status(naibrd_IRIG_GetEventMappedStatusRaw(cardIndex, module, channel, NAIBRD_IRIG_EVTMAP_CATEGORY_GENERAL, NAI_STATUS_REALTIME, &statusHexRealtimeGeneral));
   naiif_printf("\r\n      Latched BIT Status in Hex: 0x%08X", statusHexLatchedBit);
   naiif_printf("\r\n     Realtime BIT Status in Hex: 0x%08X", statusHexRealtimeBit);
   naiif_printf("\r\n  Latched General Status in Hex: 0x%08X", statusHexLatchedGeneral);
   naiif_printf("\r\n Realtime General Status in Hex: 0x%08X", statusHexRealtimeGeneral);
   naiif_printf("\r\n       BIT Interrupt Vector: 0x%08X", bitVector);
   naiif_printf("\r\n   General Interrupt Vector: 0x%08X", generalVector);
   naiif_printf("\r\n     BIT Interrupt Steering: %-50s", interruptSteeringStrings[(int32_t)bitSteering - 1]);
   naiif_printf("\r\n General Interrupt Steering: %-50s", interruptSteeringStrings[(int32_t)generalSteering - 1]);
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_displayDSTSettings illustrates the methods to call in the
 * naibrd library to retrieve and set DST (Daylight Savings Time)
 * configuration settings for the RG module.
 * </summary>
 */
 /*****************************************************************************/
static void RGBasicOps_displayDSTSettings(int32_t cardIndex, int32_t module, uint32_t modId, int32_t maxChannels, bool_t displayHex)
{
   int channel = maxChannels;
   naibrd_irig_dst_status_type_t dstStatus = NAIBRD_IRIG_DST_STATUS_DISABLED;
   uint32_t dstOffset = 0u;
   naibrd_irig_dst_timer_info_t dstStartStruct;
   naibrd_irig_dst_timer_info_t dstEndStruct;
   memset(&dstStartStruct, 0, sizeof(naibrd_irig_dst_timer_info_t));
   memset(&dstEndStruct, 0, sizeof(naibrd_irig_dst_timer_info_t));

#if defined (NAIBSP_CONFIG_SOFTWARE_OS_WINDOWS)
   UNREFERENCED_PARAMETER(modId);
   UNREFERENCED_PARAMETER(displayHex);
#endif

   naiif_printf("\r\n\r\n ================================================================================================================================\r\n");
   naiif_printf("Channel   DST Status   DST Offset   DST Start: Month   Week   Day   Hour   Minute   DST End: Month   Week   Day   Hour   Minute\r\n");
   naiif_printf(" --------------------------------------------------------------------------------------------------------------------------------\r\n");

   for (channel = 1; channel <= maxChannels; channel++)
   {
      check_status(naibrd_IRIG_GetDSTStatus(cardIndex, module, channel, &dstStatus));
      check_status(naibrd_IRIG_GetDSTOffset(cardIndex, module, channel, &dstOffset));
      check_status(naibrd_IRIG_GetDSTStart(cardIndex, module, channel, &dstStartStruct));
      check_status(naibrd_IRIG_GetDSTEnd(cardIndex, module, channel, &dstEndStruct));
      naiif_printf("   %1d       ", channel);
      naiif_printf("%8s    ", enableDisableStrings[dstStatus]);
      naiif_printf("0x%08X              ", dstOffset);
      naiif_printf("%5d   ", dstStartStruct.month);
      naiif_printf("%4d   ", dstStartStruct.week);
      naiif_printf("%3d   ", dstStartStruct.day);
      naiif_printf("%4d   ", dstStartStruct.hour);
      naiif_printf("%6d            ", dstStartStruct.minute);
      naiif_printf("%5d   ", dstEndStruct.month);
      naiif_printf("%4d   ", dstEndStruct.week);
      naiif_printf("%3d   ", dstEndStruct.day);
      naiif_printf("%4d   ", dstEndStruct.hour);
      naiif_printf("%6d", dstEndStruct.minute);
   }
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_run allows the user to choose to go to either the Basic Menu
 * or the Interrupt Menu. Returns TRUE if the user enters the Quit Command
 * at any point within its scope.
 * </summary>
 */
 /*****************************************************************************/
static bool_t RGBasicOps_run(int32_t cardIndex, int32_t module, uint32_t modId)
{
   bool_t bQuit = NAI_FALSE;
   bool_t bCmdFound = NAI_FALSE;
   int32_t cmd;
   naiapp_AppParameters_t  rg_basicops_params;
   p_naiapp_AppParameters_t rg_basicOps_params = &rg_basicops_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   rg_basicOps_params->cardIndex = cardIndex;
   rg_basicOps_params->module = module;
   rg_basicOps_params->channel = DEFAULT_CHANNEL;
   rg_basicOps_params->maxChannels = naibrd_IRIG_GetChannelCount(modId);
   naiif_printf("%d", rg_basicOps_params->maxChannels );
   rg_basicOps_params->modId = modId;
   rg_basicOps_params->displayHex = NAI_FALSE;

   do
   {
      naiapp_utils_LoadParamMenuCommands(RG_BASICOPS_COUNT, RG_BasicOpsCmds);
      naiapp_display_ParamMenuCommands((int8_t*)SAMPLE_PGM_NAME);
      naiif_printf("\r\n\r\nPlease enter a command or 'q' to quit:");
      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)
            {
               RG_BasicOpsCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)rg_basicOps_params);
            }
            else
            {
               naiif_printf("Invalid command entered\r\n");
            }
         }
      }

   } while (!bQuit);
   return bQuit;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_runBasicMenu illustrates the channel configuration and prepares the menu
 * which will handle user command requests. Returns TRUE if the user enters
 * the Quit Command at any point within its scope.
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_runBasicMenu(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   bool_t bCmdFound = NAI_FALSE;
   int32_t cmd;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   p_naiapp_AppParameters_t p_RG_basicOps_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_RG_basicOps_params->cardIndex;
   int32_t module = p_RG_basicOps_params->module;
   int32_t MAX_CHANNELS = p_RG_basicOps_params->maxChannels;
   uint32_t modId = p_RG_basicOps_params->modId;
   bool_t displayHex = p_RG_basicOps_params->displayHex;

#if defined (NAIBSP_CONFIG_SOFTWARE_OS_WINDOWS)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   do
   {
      naiapp_utils_LoadParamMenuCommands(RG_BASICOPS_CMD_COUNT, RG_BasicOps_BasicCmds);
      RGBasicOps_displayConfigurations(cardIndex, module, modId, MAX_CHANNELS, displayHex);
      naiapp_display_ParamMenuCommands((int8_t*)SAMPLE_PGM_NAME);
      naiif_printf("\r\n\r\nPlease enter a command or 'q' to quit:");
      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)
            {
               RG_BasicOps_BasicCmds[cmd].func(APP_PARAM_COUNT, p_params);
            }
            else
            {
               naiif_printf("Invalid command entered\r\n");
            }
         }
      }

   } while (!bQuit);
   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_runInterruptMenu allows the user to set Interrupt Enable,
 * Trigger Type, Vector, and Steering for the RG module. Returns TRUE if
 * the user enters the Quit Command at any point within its scope.
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_runInterruptMenu(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   bool_t bCmdFound = NAI_FALSE;
   int32_t cmd;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   p_naiapp_AppParameters_t p_RG_basicOps_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_RG_basicOps_params->cardIndex;
   int32_t module = p_RG_basicOps_params->module;
   int32_t MAX_CHANNELS = p_RG_basicOps_params->maxChannels;
   uint32_t modId = p_RG_basicOps_params->modId;
   bool_t displayHex = p_RG_basicOps_params->displayHex;

#if defined (NAIBSP_CONFIG_SOFTWARE_OS_WINDOWS)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   do
   {
      naiapp_utils_LoadParamMenuCommands(RG_BASICOPS_INTERRUPTS_CMD_COUNT, RG_BasicOps_InterruptCmds);
      RGBasicOps_displayInterrupts(cardIndex, module, modId, MAX_CHANNELS, displayHex);
      naiapp_display_ParamMenuCommands((int8_t*)SAMPLE_PGM_NAME);
      naiif_printf("\r\n\r\nPlease enter a command or 'q' to quit:");
      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)
            {
               RG_BasicOps_InterruptCmds[cmd].func(APP_PARAM_COUNT, p_params);
            }
            else
            {
               naiif_printf("Invalid command entered\r\n");
            }
         }
      }

   } while (!bQuit);
   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_runDSTMenu allows the user to set DST (Daylight Savings Time)
 * settings for the RG module. Returns TRUE if the user enters the
 * Quit Command at any point within its scope.
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_runDSTMenu(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   bool_t bCmdFound = NAI_FALSE;
   int32_t cmd = 0;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt = 0;
   p_naiapp_AppParameters_t p_RG_basicOps_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_RG_basicOps_params->cardIndex;
   int32_t module = p_RG_basicOps_params->module;
   int32_t MAX_CHANNELS = p_RG_basicOps_params->maxChannels;
   uint32_t modId = p_RG_basicOps_params->modId;
   bool_t displayHex = p_RG_basicOps_params->displayHex;

#if defined (NAIBSP_CONFIG_SOFTWARE_OS_WINDOWS)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   do
   {
      naiapp_utils_LoadParamMenuCommands(RG_BASICOPS_DST_CMD_COUNT, RG_BasicOps_DSTCmds);
      RGBasicOps_displayDSTSettings(cardIndex, module, modId, MAX_CHANNELS, displayHex);
      naiapp_display_ParamMenuCommands((int8_t*)SAMPLE_PGM_NAME);
      naiif_printf("\r\n\r\nPlease enter a command or 'q' to quit:");
      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)
            {
               RG_BasicOps_DSTCmds[cmd].func(APP_PARAM_COUNT, p_params);
            }
            else
            {
               naiif_printf("Invalid command entered\r\n");
            }
         }
      }
   } while (!bQuit);
   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGProtocol handles the user request to set Protocol by protocol types
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGProtocol(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   naibrd_irig_protocol_t protocol;

   if (APP_PARAM_COUNT == paramCount)
   {
      while (!bQuit)
      {
         naiif_printf("\r\nSelect format:\r\n");
         naiif_printf("       '1' for R/W IRIG Format A\r\n");
         naiif_printf("       '2' for R/W IRIG Format B\r\n");
         naiif_printf("       '7' for R/W IRIG Format G\r\n");

         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if (toupper(inputBuffer[0]) == '1')
         {
            protocol.irigFormat = NAIBRD_IRIG_CTRL_MODE_IRIG_FORMAT_A;
         }
         else if (toupper(inputBuffer[0]) == '2')
         {
            protocol.irigFormat = NAIBRD_IRIG_CTRL_MODE_IRIG_FORMAT_B;
         }
         else if (toupper(inputBuffer[0]) == '7')
         {
            protocol.irigFormat = NAIBRD_IRIG_CTRL_MODE_IRIG_FORMAT_G;
         }
         else
         {
            naiif_printf("Invalid selection.\r\n");
            return NAI_ERROR_INVALID_VALUE;
         }

         naiif_printf("\r\nSelect modulation:\r\n");
         naiif_printf("       '0' for R/W IRIG Modulation DCLS\r\n");
         naiif_printf("       '1' for R/W IRIG Modulation AM ASK\r\n");
         naiif_printf("       '2' for R/W IRIG Modulation DC Manchester\r\n");

         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if (toupper(inputBuffer[0]) == '0')
         {
            protocol.irigModulation = NAIBRD_IRIG_CTRL_MODE_IRIG_MODULATION_DCLS;
         }
         else if (toupper(inputBuffer[0]) == '1')
         {
            protocol.irigModulation = NAIBRD_IRIG_CTRL_MODE_IRIG_MODULATION_AM_ASK;
         }
         else if (toupper(inputBuffer[0]) == '2')
         {
            protocol.irigModulation = NAIBRD_IRIG_CTRL_MODE_IRIG_MODULATION_DC_MANCHESTER;
         }
         else
         {
            naiif_printf("Invalid selection.\r\n");
            return NAI_ERROR_INVALID_VALUE;
         }

         naiif_printf("\r\nSelect carrier frequency:\r\n");
         naiif_printf("       '0' for R/W Carrier Frequency No Carrier\r\n");
         naiif_printf("       '1' for R/W Carrier Frequency 100 Hz\r\n");
         naiif_printf("       '2' for R/W Carrier Frequency 1 kHz\r\n");
         naiif_printf("       '3' for R/W Carrier Frequency 10 kHz\r\n");
         naiif_printf("       '4' for R/W Carrier Frequency 100 kHz\r\n");
         naiif_printf("       '5' for R/W Carrier Frequency 1 MHz\r\n");

         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if (toupper(inputBuffer[0]) == '0')
         {
            protocol.carrierFreq = NAIBRD_IRIG_MODE_CARRIER_FREQUENCY_NONE;
         }
         else if (toupper(inputBuffer[0]) == '1')
         {
            protocol.carrierFreq = NAIBRD_IRIG_MODE_CARRIER_FREQUENCY_100HZ;
         }
         else if (toupper(inputBuffer[0]) == '2')
         {
            protocol.carrierFreq = NAIBRD_IRIG_MODE_CARRIER_FREQUENCY_1KHZ;
         }
         else if (toupper(inputBuffer[0]) == '3')
         {
            protocol.carrierFreq = NAIBRD_IRIG_MODE_CARRIER_FREQUENCY_10KHZ;
         }
         else if (toupper(inputBuffer[0]) == '4')
         {
            protocol.carrierFreq = NAIBRD_IRIG_MODE_CARRIER_FREQUENCY_100KHZ;
         }
         else if (toupper(inputBuffer[0]) == '5')
         {
            protocol.carrierFreq = NAIBRD_IRIG_MODE_CARRIER_FREQUENCY_1MHZ;
         }
         else
         {
            naiif_printf("Invalid selection.\r\n");
            return NAI_ERROR_INVALID_VALUE;
         }

         naiif_printf("\r\nSelect code expression:\r\n");
         naiif_printf("       '0' for R/W Code Expression BCDTOY, CF, SBS\r\n");
         naiif_printf("       '1' for R/W Code Expression BCDTOY, CF\r\n");
         naiif_printf("       '2' for R/W Code Expression BCDTOY\r\n");
         naiif_printf("       '3' for R/W Code Expression BCDTOY, SBS\r\n");
         naiif_printf("       '4' for R/W Code Expression BCDTOY, BCDYEAR, CF, SBS\r\n");
         naiif_printf("       '5' for R/W Code Expression BCDTOY, BCDYEAR, CF\r\n");
         naiif_printf("       '6' for R/W Code Expression BCDTOY, BCDYEAR\r\n");
         naiif_printf("       '7' for R/W Code Expression BCDTOY, BCDYEAR, SBS\r\n");

         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if (toupper(inputBuffer[0]) == '0')
         {
            protocol.codeExpression = NAIBRD_IRIG_CTRL_MODE_CODE_EXP_BCDTOY_CF_SBS;
         }
         else if (toupper(inputBuffer[0]) == '1')
         {
            protocol.codeExpression = NAIBRD_IRIG_CTRL_MODE_CODE_EXP_BCDTOY_CF;
         }
         else if (toupper(inputBuffer[0]) == '2')
         {
            protocol.codeExpression = NAIBRD_IRIG_CTRL_MODE_CODE_EXP_BCDTOY;
         }
         else if (toupper(inputBuffer[0]) == '3')
         {
            protocol.codeExpression = NAIBRD_IRIG_CTRL_MODE_CODE_EXP_BCDTOY_SBS;
         }
         else if (toupper(inputBuffer[0]) == '4')
         {
            protocol.codeExpression = NAIBRD_IRIG_CTRL_MODE_CODE_EXP_BCDTOY_BCDYEAR_CF_SBS;
         }
         else if (toupper(inputBuffer[0]) == '5')
         {
            protocol.codeExpression = NAIBRD_IRIG_CTRL_MODE_CODE_EXP_BCDTOY_BCDYEAR_CF;
         }
         else if (toupper(inputBuffer[0]) == '6')
         {
            protocol.codeExpression = NAIBRD_IRIG_CTRL_MODE_CODE_EXP_BCDTOY_BCDYEAR;
         }
         else if (toupper(inputBuffer[0]) == '7')
         {
            protocol.codeExpression = NAIBRD_IRIG_CTRL_MODE_CODE_EXP_BCDTOY_BCDYEAR_SBS;
         }
         else
         {
            naiif_printf("Invalid selection.\r\n");
            return NAI_ERROR_INVALID_VALUE;
         }

         for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                  status = naibrd_IRIG_SetProtocol(p_rg_params->cardIndex, p_rg_params->module, channel, protocol);

         if(status == NAI_ERROR_INVALID_VALUE)
         {
            naiif_printf("Invalid protocol combination.");
         }
         break;
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGProtocolByValue handles the user request to set Protocol from the list of accepted Protocols
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGProtocolByValue(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   int prot;

   if (APP_PARAM_COUNT == paramCount)
   {
      while (!bQuit)
      {
         naiif_printf("\r\nSelect format:\r\n");
         naiif_printf("0 - 0x1000, 1 - 0x1001, 2 - 0x1002, 3 - 0x1003, 4 - 0x1004, 5 - 0x1005, 6 - 0x1006, 7 - 0x1007\r\n");
         naiif_printf("8 - 0x1130, 9 - 0x1131, 10 - 0x1132, 11 - 0x1133, 12 - 0x1134, 13 - 0x1135, 14 - 0x1136, 15 - 0x1137\r\n");
         naiif_printf("16 - 0x2000, 17 - 0x2001, 18 - 0x2002, 19 - 0x2003, 20 - 0x2004, 21 - 0x2005, 22 - 0x2006, 23 - 0x2007\r\n");
         naiif_printf("24 - 0x2120, 25 - 0x2121, 26 - 0x2122, 27 - 0x2123, 28 - 0x2124, 29 - 0x2125, 30 - 0x2126, 31 - 0x2127\r\n");
         naiif_printf("32 - 0x7001, 33 - 0x7002, 34 - 0x7005, 35 - 0x7006\r\n");
         naiif_printf("36 - 0x7141, 37 - 0x7142, 38 - 0x7145, 39 - 0x7146\r\n");

         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

         if (inputBuffer[1] != '\0')
            prot = (10 * ((int)inputBuffer[0] - 48)) + (int)inputBuffer[1] - 48;
         else
            prot = (int)inputBuffer[0] - 48;

         for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
            status = naibrd_IRIG_SetProtocolByValue(p_rg_params->cardIndex, p_rg_params->module, channel, (naibrd_irig_protocol_value_t)validIRIGProtocols[prot]);

         if(status == NAI_ERROR_INVALID_VALUE)
         {
            naiif_printf("Invalid protocol combination.");
         }
         break;
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGYear handles the user request to set the calendar Year
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGYear(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t year;
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\nEnter last two digits of year 20XX:\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         sscanf((const char*)inputBuffer, "%u", &year);
         for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
            status = naibrd_IRIG_SetYear(p_rg_params->cardIndex, p_rg_params->module, channel, year);
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGCaptureEventTime handles the user request to set the Capture Event time in hours, minutes, seconds, tenths, hundredths. (HHMMSSTH)
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGCaptureEventTime(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   uint32_t hour, min, sec, ten, hun;
   int32_t inputResponseCnt;
   naibrd_irig_capture_event_time_t eventTime;

   if (APP_PARAM_COUNT == paramCount)
   {
       bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

        while (!bQuit)
        {
            naiif_printf("\r\nEnter two digit hour:\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &hour);
            eventTime.hours = hour;

            naiif_printf("\r\nEnter two digit minutes:\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &min);
            eventTime.minutes = min;

            naiif_printf("\r\nEnter two digit seconds:\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &sec);
            eventTime.seconds = sec;

            naiif_printf("\r\nEnter one digit tenth:\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &ten);
            eventTime.tenths = ten;

            naiif_printf("\r\nEnter one digit hundreth:\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &hun);
            eventTime.hundredths = hun;

            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                status = naibrd_IRIG_SetCaptureEventTime(p_rg_params->cardIndex, p_rg_params->module, channel, eventTime);
            break;
        }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGFreeRunningTime handles the user request to set the Free Running Time in yy:ddd:hh:mm:ss:th
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGFreeRunningTime(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t year, day, hour, min, sec, microSec;
   int32_t inputResponseCnt;
   naibrd_irig_master_timer_info_t time;

   naiif_printf("\r\nFree-running time will appear in Master Time if Reference Source is set to 7.\r\n");
   if (APP_PARAM_COUNT == paramCount)
   {
      while(!bQuit)
      {
         naiif_printf("\r\nEnter last two digits of year 20XX:\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         sscanf((const char*)inputBuffer, "%u", &year);
         time.year = year;

         naiif_printf("\r\nEnter three digit day (max: 365):\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         sscanf((const char*)inputBuffer, "%u", &day);
         time.day = day;

         naiif_printf("\r\nEnter two digit hour:\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         sscanf((const char*)inputBuffer, "%u", &hour);
         time.hour = hour;

         naiif_printf("\r\nEnter two digit minute:\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         sscanf((const char*)inputBuffer, "%u", &min);
         time.minute = min;

         naiif_printf("\r\nEnter two digit seconds:\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         sscanf((const char*)inputBuffer, "%u", &sec);
         time.second = sec;

         naiif_printf("\r\nEnter two digit microseconds:\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         sscanf((const char*)inputBuffer, "%u", &microSec);
         time.microSecond = microSec;

         for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
            status = naibrd_IRIG_SetFreeRunningTimeAndDate(p_rg_params->cardIndex, p_rg_params->module, channel, time);
         break;
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
* <summary>
* RGBasicOps_setIRIGDSTStart handles the user request to set when DST should start, in the structure of Month, Day of Week,
Number of Week, Hour, and Minute.
* </summary>
*/
/*****************************************************************************/
static nai_status_t RGBasicOpsDST_setIRIGDSTStart(int32_t paramCount, int32_t* p_params)
{
    p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
    bool_t bQuit = NAI_FALSE;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int8_t inputBuffer[80];
    int32_t month, day, hour, min, week;
    int32_t inputResponseCnt;
    naibrd_irig_dst_timer_info_t time;

    if (APP_PARAM_COUNT == paramCount)
    {
        while (!bQuit)
        {
            naiif_printf("\r\nEnter two digit month:\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &month);
            time.month = month;

            naiif_printf("\r\nEnter 1 digit day of week (0 - Sunday, 1 - Monday, ...):\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &day);
            time.day = day;

            naiif_printf("\r\nEnter one digit week number (1 - First week of month, 2 - Second week of month, ...):\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &week);
            time.week = week;

            naiif_printf("\r\nEnter two digit hour:\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &hour);
            time.hour = hour;

            naiif_printf("\r\nEnter two digit minute:\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &min);
            time.minute = min;

            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                status = naibrd_IRIG_SetDSTStart(p_rg_params->cardIndex, p_rg_params->module, channel, time);
            break;
        }
    }
    else
    {
        status = NAI_ERROR_INVALID_VALUE;
    }

    return status;
}

/*****************************************************************************/
/**
* <summary>
* RGBasicOps_setIRIGDSTEnd handles the user request to set when DST should end, in the structure of Month, Day of Week,
Number of Week, Hour, and Minute.
* </summary>
*/
/*****************************************************************************/
static nai_status_t RGBasicOpsDST_setIRIGDSTEnd(int32_t paramCount, int32_t* p_params)
{
    p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
    bool_t bQuit = NAI_FALSE;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int8_t inputBuffer[80];
    int32_t month, day, hour, min, week;
    int32_t inputResponseCnt;
    naibrd_irig_dst_timer_info_t time;

    if (APP_PARAM_COUNT == paramCount)
    {
        while (!bQuit)
        {
            naiif_printf("\r\nEnter two digit month:\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &month);
            time.month = month;

            naiif_printf("\r\nEnter 1 digit day of week (0 - Sunday, 1 - Monday, ...):\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &day);
            time.day = day;

            naiif_printf("\r\nEnter one digit week number (1 - First week of month, 2 - Second week of month, ...):\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &week);
            time.week = week;

            naiif_printf("\r\nEnter two digit hour:\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &hour);
            time.hour = hour;

            naiif_printf("\r\nEnter two digit minute:\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &min);
            time.minute = min;

            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                status = naibrd_IRIG_SetDSTEnd(p_rg_params->cardIndex, p_rg_params->module, channel, time);
            break;
        }
    }
    else
    {
        status = NAI_ERROR_INVALID_VALUE;
    }

    return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGRTCT handles the user request to set the RTC (real-time clock) in hh:mm:ss and 00yy/mm/dd
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGRTCTime(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t hour, min, sec;
   int32_t inputResponseCnt;
   naibrd_irig_rtc_time_t time;
   naibrd_irig_rtc_date_t date;

   if (APP_PARAM_COUNT == paramCount)
   {
      while(!bQuit)
      {
         naiif_printf("\r\nEnter two digit hour:\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         sscanf((const char*)inputBuffer, "%u", &hour);
         time.hour = hour;

         naiif_printf("\r\nEnter two digit minute:\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         sscanf((const char*)inputBuffer, "%u", &min);
         time.minute = min;

         naiif_printf("\r\nEnter two digit seconds:\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         sscanf((const char*)inputBuffer, "%u", &sec);
         time.second = sec;

         for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
            status = naibrd_IRIG_SetRTCTime(p_rg_params->cardIndex, p_rg_params->module, channel, time);

         naiif_printf("\r\nEnter two digit year:\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         sscanf((const char*)inputBuffer, "%u", &hour);
         date.year = hour;

         naiif_printf("\r\nEnter two digit month:\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         sscanf((const char*)inputBuffer, "%u", &min);
         date.month = min;

         naiif_printf("\r\nEnter two digit day:\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         sscanf((const char*)inputBuffer, "%u", &sec);
         date.day = sec;

         for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
            status = naibrd_IRIG_SetRTCDate(p_rg_params->cardIndex, p_rg_params->module, channel, date);
         break;
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
* <summary>
* RGBasicOps_setIRIGRTCT sets the RTC for the specified IRIG channel if the ready bit is set.
* </summary>
*/
/*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGRTCControl(int32_t paramCount, int32_t* p_params)
{
    p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int i = 0;

    if (APP_PARAM_COUNT == paramCount)
    {
        naiif_printf("\r\nSets RTC if the ready bit is on. Tries to set it 5 times and returns status.\r\n");

        for (i = 0; i < 5; i++)
        {
            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                status = naibrd_IRIG_SetRTC(p_rg_params->cardIndex, p_rg_params->module, channel);

            if (status == NAI_ERROR_TIMEOUT)
            {
               naiif_printf("\r\nFailed to set, timed out.\r\n");
            }
            else if (status == NAI_SUCCESS)
            {
               naiif_printf("\r\nRTC set.\r\n");
               return NAI_SUCCESS;
            }
            else
            {
               naiif_printf("\r\nFailed to set (didn't time out).\r\n");
            }
        }
    }
    else
    {
        status = NAI_ERROR_INVALID_VALUE;
    }

    return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGPulseWidth handles the user request to set the 1PPS Pulse Width
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGPulseWidth(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t pulseWidth;
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\nEnter PPS1 Pulse Width (in microseconds):\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         sscanf((const char*)inputBuffer, "%u", &pulseWidth);
         for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
            status = naibrd_IRIG_Set1PPSPulseWidth(p_rg_params->cardIndex, p_rg_params->module, channel, pulseWidth);
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGTimeZoneOffset handles the user request to set the Number of minutes to be added to or subtracted from received IRIG reference time to accommodate time zone
differences. Range : +/-1439
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGTimeZoneOffset(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t timeZoneOffset;
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\nEnter time zone offset (valid range: -1439 to 1439):\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         sscanf((const char*)inputBuffer, "%u", &timeZoneOffset);
         naiif_printf("\r\nG - General Time Zone Offset\r\n");
         naiif_printf("R - Realtime Clock (RTC) Offset\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

         if (!bQuit)
         {
            if (toupper(inputBuffer[0]) == 'G')
               for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                  status = naibrd_IRIG_SetTimeZoneOffset(p_rg_params->cardIndex, p_rg_params->module, channel, timeZoneOffset);
            if (toupper(inputBuffer[0]) == 'R')
               for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                  status = naibrd_IRIG_SetRTCTimeZoneOffset(p_rg_params->cardIndex, p_rg_params->module, channel, timeZoneOffset);
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGPeriodicInterruptPeriod handles the user request to set the periodic interrupt period.
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGPeriodicInterruptPeriod(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   uint32_t periodicInterrupt;
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\nEnter periodic interrupt period:\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         sscanf((const char*)inputBuffer, "%u", &periodicInterrupt);
         for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
            status = naibrd_IRIG_SetPeriodicInterruptPeriod(p_rg_params->cardIndex, p_rg_params->module, channel, periodicInterrupt);
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGPropOffset handles the user request to set IRIG Prop Offset based on the current format.
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGPropOffset(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t propOffset;
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
       naiif_printf("\r\nEnter Propagation Offset. Positive is future, negative is past. Range: +/- 5.0 seconds. (valid range: -1199999999 to 1199999999):\r\n");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      sscanf((const char*)inputBuffer, "%u", &propOffset);

      if(!bQuit)
      {
         naiif_printf("\r\nSelect Prop Offset to Change:\r\n");
         naiif_printf("A - Mode A\r\n");
         naiif_printf("B - Mode B\r\n");
         naiif_printf("G - Mode G\r\n");
         naiif_printf("D - DCLS\r\n");
         naiif_printf("R - RTC\r\n");

         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

         if(!bQuit)
         {
            if(toupper(inputBuffer[0]) == 'A')
            {
               for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                  status = naibrd_IRIG_SetModeAPropOffset(p_rg_params->cardIndex, p_rg_params->module, channel, propOffset);
            }
            else if(toupper(inputBuffer[0]) == 'B')
            {
               for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                  status = naibrd_IRIG_SetModeBPropOffset(p_rg_params->cardIndex, p_rg_params->module, channel, propOffset);
            }
            else if(toupper(inputBuffer[0]) == 'G')
            {
               for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                  status = naibrd_IRIG_SetModeGPropOffset(p_rg_params->cardIndex, p_rg_params->module, channel, propOffset);
            }
            else if(toupper(inputBuffer[0]) == 'D')
            {
               for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
               status = naibrd_IRIG_SetDclsPropOffset(p_rg_params->cardIndex, p_rg_params->module, channel, propOffset);
            }
            else if(toupper(inputBuffer[0]) == 'R')
            {
               for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
               status = naibrd_IRIG_SetRTCPropOffset(p_rg_params->cardIndex, p_rg_params->module, channel, propOffset);
            }
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
* <summary>
* RGBasicOps_setIRIGDSTOffset handles the user request to set IRIG DST offset in HMM. The format of the
DST Offset register is 0xXXXXXHMM, where bytes 0 and 1 are minutes and byte 2 is hours.
* </summary>
*/
/*****************************************************************************/
static nai_status_t RGBasicOpsDST_setIRIGDSTOffset(int32_t paramCount, int32_t* p_params)
{
    p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
    bool_t bQuit = NAI_FALSE;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int8_t inputBuffer[80];
    uint32_t dstOffset;
    int32_t inputResponseCnt;

    if (APP_PARAM_COUNT == paramCount)
    {
        naiif_printf("\r\nEnter DST offset in HMM (1 digit hour and 2 digit minutes):\r\n");
        bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
        sscanf((const char*)inputBuffer, "%x", &dstOffset);

        if (!bQuit)
        {
            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                status = naibrd_IRIG_SetDSTOffset(p_rg_params->cardIndex, p_rg_params->module, channel, dstOffset);
        }
    }
    else
    {
        status = NAI_ERROR_INVALID_VALUE;
    }

    return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGInputAnalogTermEnable handles the user request to Enable or disable IRIG input analog termination.
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGInputAnalogTermEnable(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\nT - Enable Input Analog Term:\r\n");
      naiif_printf("F - Disable Input Analog Term:\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         if (toupper(inputBuffer[0]) == 'T')
            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
               status = naibrd_IRIG_SetInputAnalogTermEnable(p_rg_params->cardIndex, p_rg_params->module, channel, 1);
         else if (toupper(inputBuffer[0]) == 'F')
            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
               status = naibrd_IRIG_SetInputAnalogTermEnable(p_rg_params->cardIndex, p_rg_params->module, channel, 0);
         else
            status = NAI_ERROR_INVALID_VALUE;
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGCaptureEventEdge handles the user request to set the event edge as rising edge or falling edge.
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGCaptureEventEdge(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\nR - Rising edge\r\n");
      naiif_printf("F - Falling edge\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         if (toupper(inputBuffer[0]) == 'T')
            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
               status = naibrd_IRIG_SetCaptureEventEdge(p_rg_params->cardIndex, p_rg_params->module, channel, NAIBRD_IRIG_CAPTURE_EVENT_RISING_EDGE);
         else if (toupper(inputBuffer[0]) == 'F')
            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
               status = naibrd_IRIG_SetCaptureEventEdge(p_rg_params->cardIndex, p_rg_params->module, channel, NAIBRD_IRIG_CAPTURE_EVENT_FALLING_EDGE);
         else
            status = NAI_ERROR_INVALID_VALUE;
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGInputDigitalTermEnable handles the user request to Enable or disable IRIG input digital termination.
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGInputDigitalTermEnable(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\nT - Enable Input Analog Term\r\n");
      naiif_printf("F - Disable Input Analog Term\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         if (toupper(inputBuffer[0]) == 'T')
            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
               status = naibrd_IRIG_SetInputDigitalTermEnable(p_rg_params->cardIndex, p_rg_params->module, channel, 1);
         else if (toupper(inputBuffer[0]) == 'F')
            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
               status = naibrd_IRIG_SetInputDigitalTermEnable(p_rg_params->cardIndex, p_rg_params->module, channel, 0);
         else
            status = NAI_ERROR_INVALID_VALUE;
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGSerialSignalLevel handles the user request to set the serial signal setting RS232 or RS485.
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGSerialSignalLevel(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   naibrd_irig_signal_type_t signalType;
   naibrd_irig_signal_level_t signalLevel;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\n232 - Signal Level RS232\r\n");
      naiif_printf("485 - Signal Level RS485\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         if (0 == strncmp((char*)inputBuffer, "232", strlen((char*)inputBuffer)))
            signalLevel = NAIBRD_IRIG_SIGNAL_LEVEL_RS232;
         else if (0 == strncmp((char*)inputBuffer, "485", strlen((char*)inputBuffer)))
            signalLevel = NAIBRD_IRIG_SIGNAL_LEVEL_RS485;
         else
            return NAI_ERROR_INVALID_VALUE;
      }

      naiif_printf("\r\nD - Signal Type Digital Out\r\n");
      naiif_printf("P - Signal Type 1PPS Out Event In\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         if (toupper(inputBuffer[0]) == 'D')
            signalType = NAIBRD_IRIG_SIGNAL_DIGITAL_OUT;
         else if (toupper(inputBuffer[0]) == 'P')
            signalType = NAIBRD_IRIG_SIGNAL_1PPS_OUT_EVENT_IN;
         else
            return NAI_ERROR_INVALID_VALUE;
      }

      for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
         status = naibrd_IRIG_SetDigitalLevel(p_rg_params->cardIndex, p_rg_params->module, channel, signalType, signalLevel);
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
* <summary>
* RGBasicOps_setIRIGDigitalInput handles the user request to set the digital input signal level setting RS232 or RS485.
* </summary>
*/
/*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGDigitalInput(int32_t paramCount, int32_t* p_params)
{
    p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
    bool_t bQuit = NAI_FALSE;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int8_t inputBuffer[80];
    int32_t inputResponseCnt;

    if (APP_PARAM_COUNT == paramCount)
    {
        naiif_printf("\r\n232 - Signal Level RS232\r\n");
        naiif_printf("485 - Signal Level RS485\r\n");

        bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

        if (!bQuit)
        {
            if (0 == strncmp((char*)inputBuffer, "232", strlen((char*)inputBuffer)))
                for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                    status = naibrd_IRIG_SetDigitalInput(p_rg_params->cardIndex, p_rg_params->module, channel, NAIBRD_IRIG_SIGNAL_LEVEL_RS232);
            else if (0 == strncmp((char*)inputBuffer, "485", strlen((char*)inputBuffer)))
                for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                    status = naibrd_IRIG_SetDigitalInput(p_rg_params->cardIndex, p_rg_params->module, channel, NAIBRD_IRIG_SIGNAL_LEVEL_RS485);
            else
                status = NAI_ERROR_INVALID_VALUE;
        }
    }
    else
    {
        status = NAI_ERROR_INVALID_VALUE;
    }

    return status;
}

/*****************************************************************************/
/**
* <summary>
* RGBasicOps_setIRIGDigitalOutput handles the user request to set the digital input signal level setting RS232 or RS485.
* </summary>
*/
/*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGDigitalOutput(int32_t paramCount, int32_t* p_params)
{
    p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
    bool_t bQuit = NAI_FALSE;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int8_t inputBuffer[80];
    int32_t inputResponseCnt;

    if (APP_PARAM_COUNT == paramCount)
    {
        naiif_printf("\r\n232 - Signal Level RS232\r\n");
        naiif_printf("485 - Signal Level RS485\r\n");

        bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

        if (!bQuit)
        {
            if (0 == strncmp((char*)inputBuffer, "232", strlen((char*)inputBuffer)))
                for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                    status = naibrd_IRIG_SetDigitalLevel(p_rg_params->cardIndex, p_rg_params->module, channel,
                                                         NAIBRD_IRIG_SIGNAL_DIGITAL_OUT, NAIBRD_IRIG_SIGNAL_LEVEL_RS232);
            else if (0 == strncmp((char*)inputBuffer, "485", strlen((char*)inputBuffer)))
                for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                    status = naibrd_IRIG_SetDigitalLevel(p_rg_params->cardIndex, p_rg_params->module, channel,
                                                         NAIBRD_IRIG_SIGNAL_DIGITAL_OUT, NAIBRD_IRIG_SIGNAL_LEVEL_RS485);
            else
                status = NAI_ERROR_INVALID_VALUE;
        }
    }
    else
    {
        status = NAI_ERROR_INVALID_VALUE;
    }

    return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGAMOutputGain handles the user request to set the IRIG AM output gain level (0 to 255)
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGAMOutputGain(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   uint32_t level;
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\nEnter output gain level (0 to 255):\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         sscanf((const char*)inputBuffer, "%u", &level);
         for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
            status = naibrd_IRIG_SetAMOutputGain(p_rg_params->cardIndex, p_rg_params->module, channel, (uint8_t)level);
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGDriftThreshold handles the user request to set the IRIG drift threshold (16 bits)
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGDriftThreshold(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   uint32_t driftThreshold;
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\nEnter drift threshold (16 bits):\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         sscanf((const char*)inputBuffer, "%u", &driftThreshold);
         for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
            status = naibrd_IRIG_SetDriftThreshold(p_rg_params->cardIndex, p_rg_params->module, channel, driftThreshold);
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGReferenceSource handles the user request to set the requested reference source.
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGReferenceSource(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\n0 - IRIG\r\n");
      naiif_printf("3 - RTC\r\n");
      naiif_printf("7 - No reference (disables IRIG signal), also used for Free-Running time\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         if (toupper(inputBuffer[0]) == '0')
            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
               status = naibrd_IRIG_SetReferenceSource(p_rg_params->cardIndex, p_rg_params->module, channel, 0u);
         else if (toupper(inputBuffer[0]) == '3')
            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
               status = naibrd_IRIG_SetReferenceSource(p_rg_params->cardIndex, p_rg_params->module, channel, 3u);
         else if (toupper(inputBuffer[0]) == '7')
            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
               status = naibrd_IRIG_SetReferenceSource(p_rg_params->cardIndex, p_rg_params->module, channel, 7u);
         else
            status = NAI_ERROR_INVALID_VALUE;
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}


/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_setIRIGCtrlBitsToSend handles the user request to set the IRIG user bits to send, which are loaded at the beginning of an IRIG Tx frame. (bits 0 to 26)
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGCtrlBitsToSend(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   uint32_t ctrlbits;
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\nEnter IRIG user bits to send (loaded at the beginning of an IRIG Tx Frame). Bits 0 to 26 are valid:\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         sscanf((const char*)inputBuffer, "%u", &ctrlbits);
         for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
            status = naibrd_IRIG_SetCtrlBitsToSend(p_rg_params->cardIndex, p_rg_params->module, channel, ctrlbits);
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_getIRIGCtrlBitsReceived handles the user request to receive the IRIG user bits sent, which are loaded at the beginning of an IRIG Tx frame. (bits 0 to 26)
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_getIRIGCtrlBitsReceived(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   uint32_t ctrlbits = 0u;

   if (APP_PARAM_COUNT == paramCount)
   {
      for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
         status = naibrd_IRIG_GetCtrlBitsReceived(p_rg_params->cardIndex, p_rg_params->module, channel, &ctrlbits);

      if(status == NAI_SUCCESS)
         naiif_printf("\r\nIRIG user bits received (loaded at the beginning of an IRIG Tx Frame):%d\r\n", ctrlbits);
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_getIRIGDSTStatus handles the user request to view DST status.
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOpsDST_getIRIGDSTStatus(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   naibrd_irig_dst_status_type_t dstStatus = NAIBRD_IRIG_DST_STATUS_DISABLED;

   if (APP_PARAM_COUNT == paramCount)
   {
      for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
         status = naibrd_IRIG_GetDSTStatus(p_rg_params->cardIndex, p_rg_params->module, channel, &dstStatus);

      if(status == NAI_SUCCESS)
         naiif_printf("\r\nDST Status:%x\r\n", dstStatus);
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * RGBasicOps_getIRIGEventMappedStatus handles the user request to view BIT status depending on desired event.
 * </summary>
 */
 /*****************************************************************************/
static nai_status_t RGBasicOps_getIRIGEventMappedStatus(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   nai_status_bit_t bitStatus;
   int eventStatus;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\n0 - BIT Data Loss Latched\r\n1 - BIT Data Loss Realtime\r\n2 - BIT Soft Fault Latched\r\n");
      naiif_printf("3 - BIT Soft Fault Realtime\r\n4 - REF Loss Latched\r\n5 - REF Loss Realtime\r\n6 - RX REF Latched\r\n");
      naiif_printf("7 - RX REF Realtime\r\n8 - REF Pulse RX Latched\r\n9 - REF Pulse RX Realtime\r\n10 - Interrupt 1PPS Output High Latched\r\n");
       naiif_printf("11 - Interrupt 1PPS Output High Realtime\r\n12 - RX Control Bits Changed Latched\r\n13 - RX Control Bits Changed Realtime\r\n");
       naiif_printf("14 - Control Bits RX Latched\r\n15 - RX Control Bits RX Realtime\r\n16 - Change REF Source Latched\r\n");
       naiif_printf("17 - Change REF Source Realtime\r\n18 - Event Detached Latched\r\n19 - Event Detached Realtime\r\n");
       naiif_printf("20 - User Interrupt Latched\r\n21 - User Interrupt Realtime\r\n22 - DST Adjust Latched\r\n");
       naiif_printf("23 - DST Adjust Realtime\r\n24 - Test Interrupt Latched\r\n22 - Test Interrupt Realtime\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if(!bQuit)
      {
         eventStatus = (int)inputBuffer[0] - 48;

         for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
            status = naibrd_IRIG_GetEventMappedStatus(p_rg_params->cardIndex, p_rg_params->module, channel, (naibrd_irig_event_mapped_status_type_t)eventStatus, &bitStatus);

         if(status == NAI_SUCCESS)
            naiif_printf("\r\nStatus:%x\r\n", bitStatus);
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
* <summary>
* RGBasicOpsInterrupts_setIRIGInterruptEnable handles the user request set Interrupt Enable for the Event status
* </summary>
*/
/*****************************************************************************/
static nai_status_t RGBasicOpsInterrupts_setIRIGInterruptEnable(int32_t paramCount, int32_t* p_params)
{
    p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
    bool_t bQuit = NAI_FALSE;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int8_t inputBuffer[80];
    int32_t inputResponseCnt;
    int eventStatus;

    if (APP_PARAM_COUNT == paramCount)
    {
        naiif_printf("\r\n0 - BIT Data Loss Latched\r\n1 - BIT Data Loss Realtime\r\n2 - BIT Soft Fault Latched\r\n");
        naiif_printf("3 - BIT Soft Fault Realtime\r\n4 - REF Loss Latched\r\n5 - REF Loss Realtime\r\n6 - RX REF Latched\r\n");
        naiif_printf("7 - RX REF Realtime\r\n8 - REF Pulse RX Latched\r\n9 - REF Pulse RX Realtime\r\n10 - Interrupt 1PPS Output High Latched\r\n");
        naiif_printf("11 - Interrupt 1PPS Output High Realtime\r\n12 - RX Control Bits Changed Latched\r\n13 - RX Control Bits Changed Realtime\r\n");
        naiif_printf("14 - Control Bits RX Latched\r\n15 - RX Control Bits RX Realtime\r\n16 - Change REF Source Latched\r\n");
        naiif_printf("17 - Change REF Source Realtime\r\n18 - Event Detached Latched\r\n19 - Event Detached Realtime\r\n");
        naiif_printf("20 - User Interrupt Latched\r\n21 - User Interrupt Realtime\r\n22 - DST Adjust Latched\r\n");
        naiif_printf("23 - DST Adjust Realtime\r\n24 - Test Interrupt Latched\r\n22 - Test Interrupt Realtime\r\n");

        bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

        if (!bQuit)
        {
            eventStatus = (int)inputBuffer[0] - 48;

            naiif_printf("E - Enable\r\n");
            naiif_printf("D - Disable\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

            if (!bQuit)
            {
                if (toupper(inputBuffer[0]) == 'E')
                    for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                        status = naibrd_IRIG_SetEventMappedInterruptEnable(p_rg_params->cardIndex, p_rg_params->module, channel, (naibrd_irig_event_mapped_status_type_t)eventStatus, 1);
                if (toupper(inputBuffer[0]) == 'D')
                    for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                        status = naibrd_IRIG_SetEventMappedInterruptEnable(p_rg_params->cardIndex, p_rg_params->module, channel, (naibrd_irig_event_mapped_status_type_t)eventStatus, 0);
            }
        }
    }
    else
    {
        status = NAI_ERROR_INVALID_VALUE;
    }

    return status;
}

/*****************************************************************************/
/**
* <summary>
* RGBasicOpsInterrupts_setIRIGInterruptEdgeLevel handles the user request set Interrupt Edge Level for the Event status
* </summary>
*/
/*****************************************************************************/
static nai_status_t RGBasicOpsInterrupts_setIRIGInterruptEdgeLevel(int32_t paramCount, int32_t* p_params)
{
    p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
    bool_t bQuit = NAI_FALSE;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int8_t inputBuffer[80];
    int32_t inputResponseCnt;
    int eventStatus;

    if (APP_PARAM_COUNT == paramCount)
    {
        naiif_printf("\r\n0 - BIT Data Loss Latched\r\n1 - BIT Data Loss Realtime\r\n2 - BIT Soft Fault Latched\r\n");
        naiif_printf("3 - BIT Soft Fault Realtime\r\n4 - REF Loss Latched\r\n5 - REF Loss Realtime\r\n6 - RX REF Latched\r\n");
        naiif_printf("7 - RX REF Realtime\r\n8 - REF Pulse RX Latched\r\n9 - REF Pulse RX Realtime\r\n10 - Interrupt 1PPS Output High Latched\r\n");
        naiif_printf("11 - Interrupt 1PPS Output High Realtime\r\n12 - RX Control Bits Changed Latched\r\n13 - RX Control Bits Changed Realtime\r\n");
        naiif_printf("14 - Control Bits RX Latched\r\n15 - RX Control Bits RX Realtime\r\n16 - Change REF Source Latched\r\n");
        naiif_printf("17 - Change REF Source Realtime\r\n18 - Event Detached Latched\r\n19 - Event Detached Realtime\r\n");
        naiif_printf("20 - User Interrupt Latched\r\n21 - User Interrupt Realtime\r\n22 - DST Adjust Latched\r\n");
        naiif_printf("23 - DST Adjust Realtime\r\n24 - Test Interrupt Latched\r\n22 - Test Interrupt Realtime\r\n");

        bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

        if (!bQuit)
        {
            eventStatus = (int)inputBuffer[0] - 48;

            naiif_printf("E - Edge\r\n");
            naiif_printf("L - Level\r\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

            if (!bQuit)
            {
                if (toupper(inputBuffer[0]) == 'E')
                    for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                        status = naibrd_IRIG_SetEventMappedInterruptTriggerType(p_rg_params->cardIndex, p_rg_params->module, channel, (naibrd_irig_event_mapped_status_type_t)eventStatus, 0);
                if (toupper(inputBuffer[0]) == 'L')
                    for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                        status = naibrd_IRIG_SetEventMappedInterruptTriggerType(p_rg_params->cardIndex, p_rg_params->module, channel, (naibrd_irig_event_mapped_status_type_t)eventStatus, 1);
            }
        }
    }
    else
    {
        status = NAI_ERROR_INVALID_VALUE;
    }

    return status;
}

/*****************************************************************************/
/**
* <summary>
* RGBasicOpsInterrupts_setIRIGInterruptVector handles the user request set Interrupt Vector for the Event status
* </summary>
*/
/*****************************************************************************/
static nai_status_t RGBasicOpsInterrupts_setIRIGInterruptVector(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   uint32_t vector;
   int32_t inputResponseCnt;
   uint32_t categoryType = 0u;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\nEnter Status Category Type:\r\n0 - BIT\r\n1 - General\r\n");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if ((inputResponseCnt > 0) && (!bQuit))
      {
         categoryType = (int)inputBuffer[0] - 48;
         naiif_printf("\r\nEnter vector:\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

         if ((inputResponseCnt > 0) && (!bQuit))
         {
            sscanf((const char*)inputBuffer, "%u", &vector);
            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
               status = naibrd_IRIG_SetEventMappedInterruptVector(p_rg_params->cardIndex, p_rg_params->module, channel,
                                                                  (naibrd_irig_event_mapped_category_type_t)categoryType, vector);
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
* <summary>
* RGBasicOpsInterrupts_setIRIGInterruptSteering handles the user request set Interrupt Steering for the Event status
* </summary>
*/
/*****************************************************************************/
static nai_status_t RGBasicOpsInterrupts_setIRIGInterruptSteering(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   uint32_t categoryType = 0u;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\nEnter Status Category Type:\r\n0 - BIT\r\n1 - General\r\n");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if ((inputResponseCnt > 0) && (!bQuit))
      {
         categoryType = (int)inputBuffer[0] - 48;
         naiif_printf("V - VME\r\n");
         naiif_printf("O - On-Board ARM\r\n");
         naiif_printf("P - PCIE App\r\n");
         naiif_printf("C - CPCI App\r\n");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

         if ((inputResponseCnt > 0) && (!bQuit))
         {
            if (toupper(inputBuffer[0]) == 'V')
               for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                  status = naibrd_IRIG_SetEventMappedInterruptSteering(p_rg_params->cardIndex, p_rg_params->module, channel, (naibrd_irig_event_mapped_category_type_t)categoryType, NAIBRD_INT_STEERING_VME);
            if (toupper(inputBuffer[0]) == 'O')
               for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                  status = naibrd_IRIG_SetEventMappedInterruptSteering(p_rg_params->cardIndex, p_rg_params->module, channel, (naibrd_irig_event_mapped_category_type_t)categoryType, NAIBRD_INT_STEERING_ONBOARD_ARM);
            if (toupper(inputBuffer[0]) == 'P')
               for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                  status = naibrd_IRIG_SetEventMappedInterruptSteering(p_rg_params->cardIndex, p_rg_params->module, channel, (naibrd_irig_event_mapped_category_type_t)categoryType, NAIBRD_INT_STEERING_PCIE);
            if (toupper(inputBuffer[0]) == 'C')
               for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                  status = naibrd_IRIG_SetEventMappedInterruptSteering(p_rg_params->cardIndex, p_rg_params->module, channel, (naibrd_irig_event_mapped_category_type_t)categoryType, NAIBRD_INT_STEERING_CPCI);
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

/*****************************************************************************/
/**
* <summary>
* RGBasicOps_getIRIGEventMappedStatus handles the user request to view BIT status depending on desired event.
* </summary>
*/
/*****************************************************************************/
static nai_status_t RGBasicOps_setIRIGEventMappedStatus(int32_t paramCount, int32_t* p_params)
{
    p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
    bool_t bQuit = NAI_FALSE;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int8_t inputBuffer[80];
    int32_t inputResponseCnt;
    nai_status_bit_t bitStatus;
    int eventStatus;

    if (APP_PARAM_COUNT == paramCount)
    {
        naiif_printf("\r\n0 - BIT Data Loss Latched\r\n1 - BIT Data Loss Realtime\r\n2 - BIT Soft Fault Latched\r\n");
        naiif_printf("3 - BIT Soft Fault Realtime\r\n4 - REF Loss Latched\r\n5 - REF Loss Realtime\r\n6 - RX REF Latched\r\n");
        naiif_printf("7 - RX REF Realtime\r\n8 - REF Pulse RX Latched\r\n9 - REF Pulse RX Realtime\r\n10 - Interrupt 1PPS Output High Latched\r\n");
        naiif_printf("11 - Interrupt 1PPS Output High Realtime\r\n12 - RX Control Bits Changed Latched\r\n13 - RX Control Bits Changed Realtime\r\n");
        naiif_printf("14 - Control Bits RX Latched\r\n15 - RX Control Bits RX Realtime\r\n16 - Change REF Source Latched\r\n");
        naiif_printf("17 - Change REF Source Realtime\r\n18 - Event Detached Latched\r\n19 - Event Detached Realtime\r\n");
        naiif_printf("20 - User Interrupt Latched\r\n21 - User Interrupt Realtime\r\n22 - DST Adjust Latched\r\n");
        naiif_printf("23 - DST Adjust Realtime\r\n24 - Test Interrupt Latched\r\n22 - Test Interrupt Realtime\r\n");

        bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

        if (!bQuit)
        {
            eventStatus = (int)inputBuffer[0] - 48;

            for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
                status = naibrd_IRIG_GetEventMappedStatus(p_rg_params->cardIndex, p_rg_params->module, channel, (naibrd_irig_event_mapped_status_type_t)eventStatus, &bitStatus);

            if (status == NAI_SUCCESS)
                naiif_printf("\r\nStatus:%x\r\n", bitStatus);
        }
    }
    else
    {
        status = NAI_ERROR_INVALID_VALUE;
    }

    return status;
}

/*****************************************************************************/
/**
* <summary>
* RGBasicOps_getIRIGEventMappedStatus handles the user request to view BIT status depending on desired event.
* </summary>
*/
/*****************************************************************************/
static nai_status_t RGBasicOpsInterrupts_clearIRIGEventMappedStatus(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   int eventStatus;

   if (APP_PARAM_COUNT == paramCount)
   {
      naiif_printf("\r\n0 - BIT Data Loss Latched\r\n");
      naiif_printf("1 - BIT Soft Fault Latched\r\n");
      naiif_printf("2 - REF Loss Latched\r\n");
      naiif_printf("3 - RX REF Latched\r\n");
      naiif_printf("4 - REF Pulse RX Latched\r\n");
      naiif_printf("5 - Interrupt 1PPS Output High Latched\r\n");
      naiif_printf("6 - RX Control Bits Changed Latched\r\n");
      naiif_printf("7 - Control Bits RX Latched\r\n");
      naiif_printf("8 - Change REF Source Latched\r\n");
      naiif_printf("9 - Event Detached Latched\r\n");
      naiif_printf("10 - User Interrupt Latched\r\n");
      naiif_printf("11 - DST Adjust Latched\r\n");
      naiif_printf("12 - Test Interrupt Latched\r\n");

      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);

      if (!bQuit)
      {
      if (inputBuffer[1] != '\0')
         eventStatus = (10 * ((int)inputBuffer[0] - 48)) + (int)inputBuffer[1] - 48;
      else
         eventStatus = (int)inputBuffer[0] - 48;

      eventStatus *= 2;

         for (channel = 1; channel <= p_rg_params->maxChannels; channel++)
               status = naibrd_IRIG_ClearEventMappedStatus(p_rg_params->cardIndex, p_rg_params->module, channel, (naibrd_irig_event_mapped_status_type_t)eventStatus);
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }

   return status;
}

static nai_status_t RGBasicOpsInterrupts_clearIRIGChannelStatus(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_rg_params = (p_naiapp_AppParameters_t)p_params;
   nai_status_t status = NAI_ERROR_UNKNOWN;

#if defined (NAIBSP_CONFIG_SOFTWARE_OS_WINDOWS)
   UNREFERENCED_PARAMETER(paramCount);
#endif

   status = naibrd_IRIG_ClearEventMappedStatusRaw(p_rg_params->cardIndex, p_rg_params->module, 1, NAIBRD_IRIG_EVTMAP_CATEGORY_GENERAL, 0xFFFFFFFF);
   return status;
}

Help Bot

X