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

Explanation

About the Sample Code for Interacting with North Atlantic Industries' Embedded Function Modules

This sample application code is written in C and provided by North Atlantic Industries (NAI) for interacting with their embedded function modules through their Software Support Kit (SSK). The code demonstrates basic operations for NAI’s RG Module, focusing on configuring, querying, and managing various aspects such as interrupt handling and Daylight Savings Time (DST) settings.

Code Structure and Key Components

Includes and Macros

The code starts by including standard libraries and NAI-specific header files: - Standard libraries: <stdint.h>, <stdio.h>, <stdlib.h>, <string.h>, <time.h>, <ctype.h> - NAI-specific header files for board access and utilities.

#include "include/naiapp_boardaccess_menu.h"
#include "include/naiapp_boardaccess_query.h"
#include "include/naiapp_boardaccess_access.h"
#include "include/naiapp_boardaccess_display.h"
#include "include/naiapp_boardaccess_utils.h"
#include "nai.h"
#include "naibrd.h"
#include "functions/naibrd_irig.h"
#include "advanced/nai_ether_adv.h"
#include "boards/naibrd_gen5.h"

Constants and Macros

  • SAMPLE_PGM_NAME contains the name of the sample program.

  • CONFIG_FILE specifies the configuration file used.

  • DEFAULT_CHANNEL is set to 1, indicating the default channel.

Main Function

The entry function for the application is main (or RG_BasicOps for VXWORKS). It initializes key variables, runs the board menu, queries card and module information, and executes the main command loop until the user quits.

int32_t main(void)
{
    bool_t bQuit = 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) == TRUE)
    {
        while (!bQuit)
        {
            naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
            naibrd_GetModuleCount(cardIndex, &moduleCount);
            naiapp_query_ModuleNumber(moduleCount, 1, &module);
            modId = naibrd_GetModuleID(cardIndex, module);
            bQuit = RGBasicOps_run(cardIndex, module, modId);
        }

        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;
}

Function Prototypes

Function prototypes for various operations are declared, categorized into basic operations, interrupt management, and DST settings. Each function serves a specific purpose, such as setting IRIG protocol, configuring interrupts, or managing DST.

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);

Command Structures and Enumerations

Command structures and enumerations are defined to map various commands to their corresponding functions. Enumerations categorize commands into basic operations, interrupts, and DST settings.

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
};
...
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}
};

Command Handling Functions

Each command handling function performs specific operations on the RG module. For instance, setting the IRIG protocol, configuring interrupts, or managing DST settings. These functions illustrate how to interact with the naibrd library to perform these operations.

static nai_status_t RGBasicOps_setIRIGProtocol(int32_t paramCount, int32_t* p_params) {
    // Function body
}
...
static nai_status_t RGBasicOps_runBasicMenu(int32_t paramCount, int32_t* p_params) {
    // Function body
}
...
static nai_status_t RGBasicOps_runDSTMenu(int32_t paramCount, int32_t* p_params) {
    // Function body
}

Summary

This sample application code provides a structured approach to interact with NAI’s embedded function modules. It includes initializing and configuring the modules, handling user commands, and demonstrating how to utilize the NAI libraries (naibrd, naiapp, etc.) for various operations. The provided functions and structures ensure comprehensive coverage of module functionalities, making it a valuable resource for developers working with NAI’s hardware.

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>

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

/* naibrd include files */
#include "nai.h"
#include "naibrd.h"
#include "functions/naibrd_irig.h"
#include "advanced/nai_ether_adv.h"
#include "boards/naibrd_gen5.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][50] =
{
   "VME",
   "ARM Custom Application (On Board 0)",
   "NAI Ethernet Listener Application (On Board 1)",
   "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 = 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) == TRUE)
   {
      while (!bQuit)
      {
         naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         naibrd_GetModuleCount(cardIndex, &moduleCount);
         naiapp_query_ModuleNumber(moduleCount, 1, &module);
         modId = naibrd_GetModuleID(cardIndex, module);
         bQuit = RGBasicOps_run(cardIndex, module, modId);
      }

      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 (WIN32)
   UNREFERENCED_PARAMETER(modId);
   UNREFERENCED_PARAMETER(displayHex);
#endif

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

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

		printf(" %x             ", protocol);

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

		printf("%d              ", pulseWidth);

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

		printf("%d            ", gain);

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

		printf("%d                ", driftThreshold);

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

		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));
		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));
		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));
      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 = FALSE;
   naibrd_irig_interrupt_trigger_type_t trigType = NAIBRD_IRIG_EDGE_INTERRUPT;
   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_APP;
   naibrd_int_steering_t generalSteering = NAIBRD_INT_STEERING_CPCI_APP;

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

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

   for (statusType = (uint32_t)NAIBRD_IRIG_EVTMAP_STATUS_BIT_DATA_LOSS_LATCHED; statusType < NAIBRD_IRIG_EVTMAP_STATUS_TYPE_ENUM_COUNT; statusType += 2u)
   {
      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));
      printf("     (%d/%d)        ", rtStatus, status);
      check_status(naibrd_IRIG_GetEventMappedInterruptEnable(cardIndex, module, channel, (naibrd_irig_event_mapped_status_type_t)statusType, &enable));
      printf("     %9s          ", enableDisableStrings[enable]);
      check_status(naibrd_IRIG_GetEventMappedInterruptTriggerType(cardIndex, module, channel, (naibrd_irig_event_mapped_status_type_t)statusType, &trigType));
      printf("%6s\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));
   printf("\n      Latched BIT Status in Hex: 0x%08X", statusHexLatchedBit);
   printf("\n     Realtime BIT Status in Hex: 0x%08X", statusHexRealtimeBit);
   printf("\n  Latched General Status in Hex: 0x%08X", statusHexLatchedGeneral);
   printf("\n Realtime General Status in Hex: 0x%08X", statusHexRealtimeGeneral);
   printf("\n           BIT Interrupt Vector: 0x%08X", bitVector);
   printf("\n       General Interrupt Vector: 0x%08X", generalVector);
   printf("\n         BIT Interrupt Steering: %-50s", interruptSteeringStrings[(int32_t)bitSteering - 1]);
   printf("\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 (WIN32)
   UNREFERENCED_PARAMETER(modId);
   UNREFERENCED_PARAMETER(displayHex);
#endif

   printf("\n\n ================================================================================================================================\n");
   printf("Channel   DST Status   DST Offset   DST Start: Month   Week   Day   Hour   Minute   DST End: Month   Week   Day   Hour   Minute\n");
   printf(" --------------------------------------------------------------------------------------------------------------------------------\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));
      printf("   %1d       ", channel);
      printf("%8s    ", enableDisableStrings[dstStatus]);
      printf("0x%08X              ", dstOffset);
      printf("%5d   ", dstStartStruct.month);
      printf("%4d   ", dstStartStruct.week);
      printf("%3d   ", dstStartStruct.day);
      printf("%4d   ", dstStartStruct.hour);
      printf("%6d            ", dstStartStruct.minute);
      printf("%5d   ", dstEndStruct.month);
      printf("%4d   ", dstEndStruct.week);
      printf("%3d   ", dstEndStruct.day);
      printf("%4d   ", dstEndStruct.hour);
      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 = FALSE;
   bool_t bCmdFound = 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);
   printf("%d", rg_basicOps_params->maxChannels );
   rg_basicOps_params->modId = modId;
   rg_basicOps_params->displayHex = FALSE;

   do
   {
      naiapp_utils_LoadParamMenuCommands(RG_BASICOPS_COUNT, RG_BasicOpsCmds);
      naiapp_display_ParamMenuCommands((int8_t*)SAMPLE_PGM_NAME);
      printf("\n\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
            {
               printf("Invalid command entered\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 = FALSE;
   bool_t bCmdFound = 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 (WIN32)
   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);
      printf("\n\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
            {
               printf("Invalid command entered\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 = FALSE;
   bool_t bCmdFound = 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 (WIN32)
   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);
      printf("\n\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
            {
               printf("Invalid command entered\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 = FALSE;
   bool_t bCmdFound = 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 (WIN32)
   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);
      printf("\n\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
            {
               printf("Invalid command entered\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 = 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)
		{
			printf("\nSelect format:\n");
			printf("       '1' for R/W IRIG Format A\n");
			printf("       '2' for R/W IRIG Format B\n");
			printf("       '7' for R/W IRIG Format G\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
			{
				printf("Invalid selection.\n");
				return NAI_ERROR_INVALID_VALUE;
			}

			printf("\nSelect modulation:\n");
			printf("       '0' for R/W IRIG Modulation DCLS\n");
			printf("       '1' for R/W IRIG Modulation AM ASK\n");
			printf("       '2' for R/W IRIG Modulation DC Manchester\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
			{
				printf("Invalid selection.\n");
				return NAI_ERROR_INVALID_VALUE;
			}

			printf("\nSelect carrier frequency:\n");
			printf("       '0' for R/W Carrier Frequency No Carrier\n");
			printf("       '1' for R/W Carrier Frequency 100 Hz\n");
			printf("       '2' for R/W Carrier Frequency 1 kHz\n");
			printf("       '3' for R/W Carrier Frequency 10 kHz\n");
			printf("       '4' for R/W Carrier Frequency 100 kHz\n");
			printf("       '5' for R/W Carrier Frequency 1 MHz\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
			{
				printf("Invalid selection.\n");
				return NAI_ERROR_INVALID_VALUE;
			}

			printf("\nSelect code expression:\n");
			printf("       '0' for R/W Code Expression BCDTOY, CF, SBS\n");
			printf("       '1' for R/W Code Expression BCDTOY, CF\n");
			printf("       '2' for R/W Code Expression BCDTOY\n");
			printf("       '3' for R/W Code Expression BCDTOY, SBS\n");
			printf("       '4' for R/W Code Expression BCDTOY, BCDYEAR, CF, SBS\n");
			printf("       '5' for R/W Code Expression BCDTOY, BCDYEAR, CF\n");
			printf("       '6' for R/W Code Expression BCDTOY, BCDYEAR\n");
			printf("       '7' for R/W Code Expression BCDTOY, BCDYEAR, SBS\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
			{
				printf("Invalid selection.\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)
			{
				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 = 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)
		{
			printf("\nSelect format:\n");
			printf("0 - 0x1000, 1 - 0x1001, 2 - 0x1002, 3 - 0x1003, 4 - 0x1004, 5 - 0x1005, 6 - 0x1006, 7 - 0x1007\n");
			printf("8 - 0x1130, 9 - 0x1131, 10 - 0x1132, 11 - 0x1133, 12 - 0x1134, 13 - 0x1135, 14 - 0x1136, 15 - 0x1137\n");
			printf("16 - 0x2000, 17 - 0x2001, 18 - 0x2002, 19 - 0x2003, 20 - 0x2004, 21 - 0x2005, 22 - 0x2006, 23 - 0x2007\n");
			printf("24 - 0x2120, 25 - 0x2121, 26 - 0x2122, 27 - 0x2123, 28 - 0x2124, 29 - 0x2125, 30 - 0x2126, 31 - 0x2127\n");
			printf("32 - 0x7001, 33 - 0x7002, 34 - 0x7005, 35 - 0x7006\n");
			printf("36 - 0x7141, 37 - 0x7142, 38 - 0x7145, 39 - 0x7146\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)
			{
				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 = 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)
   {
		printf("\nEnter last two digits of year 20XX:\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 = 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)
        {
            printf("\nEnter two digit hour:\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &hour);
            eventTime.hours = hour;

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

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

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

            printf("\nEnter one digit hundreth:\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 = 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;

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

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

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

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

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

			printf("\nEnter two digit microseconds:\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 = 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)
        {
            printf("\nEnter two digit month:\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &month);
            time.month = month;

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

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

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

            printf("\nEnter two digit minute:\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 = 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)
        {
            printf("\nEnter two digit month:\n");
            bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            sscanf((const char*)inputBuffer, "%u", &month);
            time.month = month;

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

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

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

            printf("\nEnter two digit minute:\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 = 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)
		{
			printf("\nEnter two digit hour:\n");
			bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
			sscanf((const char*)inputBuffer, "%u", &hour);
			time.hour = hour;

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

			printf("\nEnter two digit seconds:\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);

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

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

			printf("\nEnter two digit day:\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)
    {
        printf("\nSets RTC if the ready bit is on. Tries to set it 5 times and returns status.\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)
			{
                printf("\nFailed to set, timed out.\n");
			}
            else if (status == NAI_SUCCESS)
			{
                printf("\nRTC set.\n");
				return NAI_SUCCESS;
			}
            else
			{
                printf("\nFailed to set (didn't time out).\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 = 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)
   {
		printf("\nEnter PPS1 Pulse Width (in microseconds):\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 = 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)
   {
		printf("\nEnter time zone offset (valid range: -1439 to 1439):\n");

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

		if(!bQuit)
		{
			sscanf((const char*)inputBuffer, "%u", &timeZoneOffset);
            printf("\nG - General Time Zone Offset\n");
            printf("R - Realtime Clock (RTC) Offset\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 = 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)
   {
		printf("\nEnter periodic interrupt period:\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 = 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)
   {
	    printf("\nEnter Propagation Offset. Positive is future, negative is past. Range: +/- 5.0 seconds. (valid range: -1199999999 to 1199999999):\n");
		bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
		sscanf((const char*)inputBuffer, "%u", &propOffset);

		if(!bQuit)
		{
			printf("\nSelect Prop Offset to Change:\n");
			printf("A - Mode A\n");
			printf("B - Mode B\n");
			printf("G - Mode G\n");
			printf("D - DCLS\n");
			printf("R - RTC\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 = 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)
    {
        printf("\nEnter DST offset in HMM (1 digit hour and 2 digit minutes):\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 = FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
		printf("\nT - Enable Input Analog Term:\n");
		printf("F - Disable Input Analog Term:\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 = FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
		printf("\nR - Rising edge\n");
		printf("F - Falling edge\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 = FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
		printf("\nT - Enable Input Analog Term\n");
		printf("F - Disable Input Analog Term\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 = 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)
   {
		printf("\n232 - Signal Level RS232\n");
		printf("485 - Signal Level RS485\n");

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

		if(!bQuit)
		{
			if (toupper(inputBuffer[0]) == '232')
				signalLevel = NAIBRD_IRIG_SIGNAL_LEVEL_RS232;
			else if (toupper(inputBuffer[0]) == '485')
				signalLevel = NAIBRD_IRIG_SIGNAL_LEVEL_RS485;
			else
				return NAI_ERROR_INVALID_VALUE;

		   printf("\nD - Signal Type Digital Out\n");
		   printf("P - Signal Type 1PPS Out Event In\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 = FALSE;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int8_t inputBuffer[80];
    int32_t inputResponseCnt;

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

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

        if (!bQuit)
        {
            if (toupper(inputBuffer[0]) == '232')
                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 (toupper(inputBuffer[0]) == '485')
                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 = FALSE;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int8_t inputBuffer[80];
    int32_t inputResponseCnt;

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

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

        if (!bQuit)
        {
            if (toupper(inputBuffer[0]) == '232')
                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 (toupper(inputBuffer[0]) == '485')
                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 = 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)
   {
		printf("\nEnter output gain level (0 to 255):\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 = 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)
   {
		printf("\nEnter drift threshold (16 bits):\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 = FALSE;
   int channel;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
		printf("\n0 - IRIG\n");
		printf("3 - RTC\n");
		printf("7 - No reference (disables IRIG signal), also used for Free-Running time\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 = 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)
   {
		printf("\nEnter IRIG user bits to send (loaded at the beginning of an IRIG Tx Frame). Bits 0 to 26 are valid:\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)
			printf("\nIRIG user bits received (loaded at the beginning of an IRIG Tx Frame):%d\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)
			printf("\nDST Status:%x\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 = 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)
   {
		printf("\n0 - BIT Data Loss Latched\n1 - BIT Data Loss Realtime\n2 - BIT Soft Fault Latched\n");
		printf("3 - BIT Soft Fault Realtime\n4 - REF Loss Latched\n5 - REF Loss Realtime\n6 - RX REF Latched\n");
		printf("7 - RX REF Realtime\n8 - REF Pulse RX Latched\n9 - REF Pulse RX Realtime\n10 - Interrupt 1PPS Output High Latched\n");
	    printf("11 - Interrupt 1PPS Output High Realtime\n12 - RX Control Bits Changed Latched\n13 - RX Control Bits Changed Realtime\n");
	    printf("14 - Control Bits RX Latched\n15 - RX Control Bits RX Realtime\n16 - Change REF Source Latched\n");
	    printf("17 - Change REF Source Realtime\n18 - Event Detached Latched\n19 - Event Detached Realtime\n");
	    printf("20 - User Interrupt Latched\n21 - User Interrupt Realtime\n22 - DST Adjust Latched\n");
	    printf("23 - DST Adjust Realtime\n24 - Test Interrupt Latched\n22 - Test Interrupt Realtime\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)
				printf("\nStatus:%x\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 = FALSE;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int8_t inputBuffer[80];
    int32_t inputResponseCnt;
    int eventStatus;

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

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

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

            printf("E - Enable\n");
            printf("D - Disable\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 = FALSE;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int8_t inputBuffer[80];
    int32_t inputResponseCnt;
    int eventStatus;

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

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

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

            printf("E - Edge\n");
            printf("L - Level\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 = 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)
   {
      printf("\nEnter Status Category Type:\n0 - BIT\n1 - General\n");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if ((inputResponseCnt > 0) && (!bQuit))
      {
         categoryType = (int)inputBuffer[0] - 48;
         printf("\nEnter vector:\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 = 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)
   {
      printf("\nEnter Status Category Type:\n0 - BIT\n1 - General\n");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if ((inputResponseCnt > 0) && (!bQuit))
      {
         categoryType = (int)inputBuffer[0] - 48;
         printf("V - VME\n");
         printf("O0 - On-Board 0\n");
         printf("O1 - On-Board 1\n");
         printf("O2 - On-Board 2\n");
         printf("P - PCIE App\n");
         printf("C - CPCI App\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') && (toupper(inputBuffer[1]) == '1'))
               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_ON_BOARD_0);
            if ((toupper(inputBuffer[0]) == 'O') && (toupper(inputBuffer[1]) == '2'))
               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_ON_BOARD_1);
            if ((toupper(inputBuffer[0]) == 'O') && (toupper(inputBuffer[1]) == '3'))
               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_ON_BOARD_2);
            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_APP);
            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_APP);
         }
      }
   }
   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 = 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)
    {
        printf("\n0 - BIT Data Loss Latched\n1 - BIT Data Loss Realtime\n2 - BIT Soft Fault Latched\n");
        printf("3 - BIT Soft Fault Realtime\n4 - REF Loss Latched\n5 - REF Loss Realtime\n6 - RX REF Latched\n");
        printf("7 - RX REF Realtime\n8 - REF Pulse RX Latched\n9 - REF Pulse RX Realtime\n10 - Interrupt 1PPS Output High Latched\n");
        printf("11 - Interrupt 1PPS Output High Realtime\n12 - RX Control Bits Changed Latched\n13 - RX Control Bits Changed Realtime\n");
        printf("14 - Control Bits RX Latched\n15 - RX Control Bits RX Realtime\n16 - Change REF Source Latched\n");
        printf("17 - Change REF Source Realtime\n18 - Event Detached Latched\n19 - Event Detached Realtime\n");
        printf("20 - User Interrupt Latched\n21 - User Interrupt Realtime\n22 - DST Adjust Latched\n");
        printf("23 - DST Adjust Realtime\n24 - Test Interrupt Latched\n22 - Test Interrupt Realtime\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)
                printf("\nStatus:%x\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 = FALSE;
    int channel;
    nai_status_t status = NAI_ERROR_UNKNOWN;
    int8_t inputBuffer[80];
    int32_t inputResponseCnt;
    int eventStatus;

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