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

LVDT BasicOps

LVDT BasicOps Sample Application (SSK 2.x)

Overview

The LVDT BasicOps sample application demonstrates how to configure and read LVDT/RVDT (Linear/Rotary Variable Differential Transformer) channels using the NAI Software Support Kit (SSK 2.x). It provides a comprehensive set of operations organized into sub-menus: Operation (latch control), Configuration (mode, thresholds, signal inversion, bandwidth, scale), Status (read and clear status registers), Test (test position, D0/D3 test enable, power-on BIT), and Floating-Point (hardware floating-point conversion mode with position/velocity offset and scale). The application also supports hex/decimal display toggling and module power reset.

This sample supports the following LVDT module types: LD1 through LD5, LD6, LR2, and LL2. For LL2 modules, the application presents a simplified menu with configuration, status, and test sub-menus tailored to that module variant.

For the SSK 1.x version, see LVDT BasicOps (SSK 1.x). For detailed module specifications, refer to the LD1-LD5 Manual.

Prerequisites

Before running this sample, make sure you have:

  • An NAI board with an LVDT module installed (LD1-LD5).

  • SSK 2.x installed on your development host.

  • The sample applications built. Refer to the SSK 2.x Software Development Guide for platform-specific build instructions.

How to Run

Launch the lvdt_basic_ops executable from your build output directory. On startup the application looks for a configuration file (default_LVDT_BasicOps.txt). On the first run, this file will not exist — the application will present an interactive board menu where you configure a board connection, card index, and module slot. Once connected, the application displays measurement data for all channels and presents a top-level menu with sub-menu navigation.

Board Connection and Module Selection

Note
This startup sequence is common to all NAI sample applications. The board connection and module selection code shown here is not specific to LVDT.

The main() function follows a standard SSK 2.x startup flow:

  1. Call naiapp_RunBoardMenu() to load a saved configuration file (if one exists) or present the interactive board menu. The configuration file (default_LVDT_BasicOps.txt) is not included with the SSK — it is created when the user saves their connection settings from the board menu. On the first run, the menu will always appear.

  2. Query the user for a card index with naiapp_query_CardIndex().

  3. Query for a module slot with naiapp_query_ModuleNumber().

  4. Retrieve the module ID with naibrd_GetModuleName() so downstream code can adapt to the specific LVDT variant installed.

#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t LVDT_BasicOps(void)
#else
int32_t main(void)
#endif
{
   int32_t cardIndex;
   int32_t moduleCnt;
   int32_t module;
   bool_t  stop = NAI_FALSE;
   uint32_t moduleID = 0;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == (bool_t)NAI_TRUE)
   {
      while (stop != NAI_TRUE)
      {
         /* Select Card Index */
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != NAI_TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));

            /* Select Module */
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != NAI_TRUE)
            {
               check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
               if ((moduleID != 0))
               {
                  Run_LVDTBasicMenu(cardIndex, module, moduleID);
               }
            }
         }
         naiif_printf("\r\nType Q to quit or Enter key to restart application:\r\n");
         stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      }
   }
   naiif_printf("\r\nType the Enter key to exit the program: ");
   naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   naiapp_access_CloseAllOpenCards();
   return 0;
}

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

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

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

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

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

Important

Common connection errors you may encounter at this stage:

  • No board found — verify that the board is powered on and physically connected. Check that the configuration file lists the correct interface and address.

  • Connection timeout — confirm network settings (for Ethernet connections) or bus configuration (for PCI/PCIe). Firewalls and IP mismatches are frequent causes.

  • Invalid card or module index — indices are zero-based for cards and one-based for modules. Ensure the values you pass match your hardware setup.

  • Module not present at selected slot — the slot you selected does not contain an LVDT module. Use the board menu to verify which slots are populated.

Program Structure

Entry Point

On standard platforms (Petalinux, Windows) the entry point is main(). On VxWorks the entry point is LVDT_BasicOps():

#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t LVDT_BasicOps(void)
#else
int32_t main(void)
#endif

Command Loop

After connecting to the board and selecting a module, the application calls Run_LVDTBasicMenu(). For LL2 modules, a simplified menu is loaded; for all other LVDT modules, the full menu is loaded. The top-level menu loop displays measurement data for all channels and presents the following sub-menus:

Command Description

O

Operation Menu — Latch control.

C

Configuration Menu — Mode, thresholds, signal inversion, bandwidth, scale.

S

Status Menu — Read and clear status registers.

T

Test Menu — Test position, D0/D3 test enable, power-on BIT check.

F

Floating-Point Menu — Position/velocity offset and scale factors.

E

Enable/Disable hardware floating-point conversion mode (module-wide).

H

Toggle between hex and decimal display.

RESET

Enter the module power reset submenu.

Displaying Measurements

Before each command prompt, the application displays a measurement table showing all channels. The LVDTBasicMenu_displayMeasurements() function reads position, frequency, voltages, signal magnitudes, detect values, and status for every channel.

In decimal mode, the sample reads engineering-unit values:

float64_t position, frequency, sigvolt, refvolt, va, vb, vaVb, vaDetect, vbDetect;
nai_status_bit_t BitStatus, SigLoss, RefLoss;

check_status(naibrd_LVDT_GetPosition(cardIndex, module, channel, &position));
check_status(naibrd_LVDT_GetFrequency(cardIndex, module, channel, &frequency));
check_status(naibrd_LVDT_GetSignalVoltage(cardIndex, module, channel, &sigvolt));
check_status(naibrd_LVDT_GetRefVoltage(cardIndex, module, channel, &refvolt));
check_status(naibrd_LVDT_GetSignalMagnitude(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_VA, &va));
check_status(naibrd_LVDT_GetSignalMagnitude(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_VB, &vb));
check_status(naibrd_LVDT_GetSignalMagnitude(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_VA_AND_VB, &vaVb));
check_status(naibrd_LVDT_GetDetectValue(cardIndex, module, channel, NAIBRD_LVDT_VA_DETECT, &vaDetect));
check_status(naibrd_LVDT_GetDetectValue(cardIndex, module, channel, NAIBRD_LVDT_VB_DETECT, &vbDetect));
check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_REALTIME, &BitStatus));
check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_LOW_REALTIME, &SigLoss));
check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_REALTIME, &RefLoss));

When hex display mode is enabled, the raw register values are read instead using naibrd_LVDT_GetChannelRaw():

uint32_t positionRaw, frequencyRaw, sigVoltRaw, refVoltRaw;
uint32_t vaRaw, vbRaw, vaVbRaw, vaDetectRaw, vbDetectRaw;

check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_RAW_POSITION, &positionRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_RAW_FREQUENCY, &frequencyRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_RAW_SIGNAL_VOLTAGE, &sigVoltRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_RAW_REF_VOLTAGE, &refVoltRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_RAW_VA, &vaRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_RAW_VB, &vbRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_RAW_VA_AND_VB, &vaVbRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_RAW_VA_DETECT, &vaDetectRaw));
check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_RAW_VB_DETECT, &vbDetectRaw));
  • cardIndex — identifies the board.

  • module — the slot containing the LVDT module.

  • channel — the channel to read (1-based, iterated over all channels).

The function also checks naibrd_GetRunningInFloatingPointMode() to display whether hardware floating-point conversion mode is enabled.

Operation Sub-Menu

The Operation sub-menu provides latch control. Latching freezes all channel readings at the same instant, which is useful when you need a coherent snapshot across channels. The LVDTBasicMenu_displayOperation() function reads position, frequency, voltages, and the latch state for each channel.

To read the latch state and position in decimal mode:

uint32_t latch;
float64_t position, frequency, sigvolt, refvolt;

check_status(naibrd_LVDT_GetFrequency(cardIndex, module, channel, &frequency));
check_status(naibrd_LVDT_GetSignalVoltage(cardIndex, module, channel, &sigvolt));
check_status(naibrd_LVDT_GetRefVoltage(cardIndex, module, channel, &refvolt));
check_status(naibrd_LVDT_GetLatch(cardIndex, module, channel, &latch));
check_status(naibrd_LVDT_GetPosition(cardIndex, module, channel, &position));
Note
The latch register is automatically un-latched when the position is read from the board.

To set the latch state in your own application, call naibrd_LVDT_SetLatch():

/* Latch all channel readings (freeze) */
naibrd_LVDT_SetLatch(cardIndex, module, channel, 1);

/* Un-latch (return to free-running mode) */
naibrd_LVDT_SetLatch(cardIndex, module, channel, 0);

For raw register access (hex mode), use naibrd_LVDT_SetRaw() with NAIBRD_LVDT_RAW_LATCH:

naibrd_LVDT_SetRaw(cardIndex, module, NAIBRD_LVDT_RAW_LATCH, latchRaw);
  • cardIndex — identifies the board.

  • module — the slot containing the LVDT module.

  • channel — the channel to latch.

Configuration Sub-Menu

The Configuration sub-menu provides commands to set channel mode, enable status monitoring, configure fault thresholds, control signal inversion, set the bandwidth filter, and adjust the LVDT scale factor.

Set Channel Mode

To configure the wire mode on a channel, call naibrd_LVDT_SetChanMode() with the desired format. Valid modes include NAIBRD_LVDT_4WIRE (3/4-wire) and NAIBRD_LVDT_2WIRE (2-wire).

naibrd_lvdt_format_t mode = NAIBRD_LVDT_4WIRE; /* or NAIBRD_LVDT_2WIRE */

naibrd_LVDT_SetChanMode(cardIndex, module, channel, mode);
  • cardIndex — identifies the board.

  • module — the slot containing the LVDT module.

  • channel — the channel to configure.

  • mode — NAIBRD_LVDT_4WIRE for 3/4-wire mode, NAIBRD_LVDT_2WIRE for 2-wire mode.

Set Channel Status Enable

To enable or disable status monitoring on a channel, call naibrd_LVDT_SetChanStatusEnable():

/* Enable status monitoring on a channel */
naibrd_LVDT_SetChanStatusEnable(cardIndex, module, channel, 1);

/* Disable status monitoring */
naibrd_LVDT_SetChanStatusEnable(cardIndex, module, channel, 0);

Set Fault Thresholds

The sample configures signal and reference fault thresholds using naibrd_LVDT_SetThreshold() in decimal mode, or naibrd_LVDT_SetChannelRaw() in hex mode. All four threshold types follow the same pattern:

float64_t threshold = 90.0; /* volts */

/* Signal fault low threshold (signal loss) */
naibrd_LVDT_SetThreshold(cardIndex, module, channel,
   NAIBRD_LVDT_SIG_FAULT_LO_THRESHOLD, threshold);

/* Reference fault low threshold (reference loss) */
naibrd_LVDT_SetThreshold(cardIndex, module, channel,
   NAIBRD_LVDT_REF_FAULT_LO_THRESHOLD, threshold);

/* Signal fault high threshold */
naibrd_LVDT_SetThreshold(cardIndex, module, channel,
   NAIBRD_LVDT_SIG_FAULT_HI_THRESHOLD, threshold);

/* Reference fault high threshold */
naibrd_LVDT_SetThreshold(cardIndex, module, channel,
   NAIBRD_LVDT_REF_FAULT_HI_THRESHOLD, threshold);

For raw register access (hex mode):

uint32_t thresholdRaw = 0x2328u; /* 90V at 10mV/count */

naibrd_LVDT_SetChannelRaw(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_RAW_SIG_FAULT_LOW_THRESHOLD, thresholdRaw);
naibrd_LVDT_SetChannelRaw(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_RAW_REF_FAULT_LOW_THRESHOLD, thresholdRaw);
naibrd_LVDT_SetChannelRaw(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_RAW_SIG_FAULT_HIGH_THRESHOLD, thresholdRaw);
naibrd_LVDT_SetChannelRaw(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_RAW_REF_FAULT_HIGH_THRESHOLD, thresholdRaw);

Open and short thresholds use the same naibrd_LVDT_SetThreshold() API with NAIBRD_LVDT_OPEN_THRESHOLD and NAIBRD_LVDT_SHORT_THRESHOLD:

naibrd_LVDT_SetThreshold(cardIndex, module, channel,
   NAIBRD_LVDT_OPEN_THRESHOLD, threshold);
naibrd_LVDT_SetThreshold(cardIndex, module, channel,
   NAIBRD_LVDT_SHORT_THRESHOLD, threshold);
  • threshold — the threshold value in volts. Signal thresholds range from 0.0 to 90.0 V; reference thresholds range from 0.0 to 115.0 V.

Set Signal Inversion

To configure signal inversion on a channel, call naibrd_LVDT_SetSignalInversion(). The sample supports multiple inversion settings depending on the signal type:

naibrd_lvdt_sig_type_t sigType = /* signal type from user selection */;

/* Non-inverted options */
naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType,
   NAIBRD_LVDT_RESP_NON_INVERTED_VA);
naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType,
   NAIBRD_LVDT_RESP_NON_INVERTED_VB);
naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType,
   NAIBRD_LVDT_RESP_NON_INVERTED_REF);

/* Inverted options */
naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType,
   NAIBRD_LVDT_RESP_INVERTED_VA);
naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType,
   NAIBRD_LVDT_RESP_INVERTED_VB);
naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType,
   NAIBRD_LVDT_RESP_INVERTED_REF);

/* Differential options */
naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType,
   NAIBRD_LVDT_RESP_DIFF_VA_VB);
naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType,
   NAIBRD_LVDT_RESP_DIFF_VB_VA);

Set Bandwidth

To configure the low-pass filter bandwidth on a channel, call naibrd_LVDT_SetBandwidth(). Valid values range from 2 Hz to 1280 Hz:

uint32_t bw = 100; /* Hz */

naibrd_LVDT_SetBandwidth(cardIndex, module, channel, bw);

To select automatic or manual bandwidth mode, call naibrd_LVDT_SetBandwidthSelect():

/* Manual bandwidth selection */
naibrd_LVDT_SetBandwidthSelect(cardIndex, module, channel, NAIBRD_LVDT_BW_MANUAL);

/* Automatic bandwidth selection */
naibrd_LVDT_SetBandwidthSelect(cardIndex, module, channel, NAIBRD_LVDT_BW_AUTOMATIC);

Set Scale

To set the LVDT scale factor on a channel, call naibrd_LVDT_SetLVDTScale():

uint32_t scale = /* user-specified scale value */;

naibrd_LVDT_SetLVDTScale(cardIndex, module, channel, scale);
  • scale — the scale value as an unsigned 32-bit integer (range 0 to 4,294,967,295).

Status Sub-Menu

The Status sub-menu displays both realtime and latched status for every channel, and provides commands to clear latched status registers. The display function reads all status types using naibrd_LVDT_GetChanMappedStatus():

nai_status_bit_t bitStatusLatched, bitStatusRealtime;
nai_status_bit_t sigLossLatched, sigLossRealtime;
nai_status_bit_t refLossLatched, refLossRealtime;
nai_status_bit_t sigHiLatched, sigHiRealtime;
nai_status_bit_t refHiLatched, refHiRealtime;
nai_status_bit_t openLatched, openRealtime;
nai_status_bit_t shortLatched, shortRealtime;
nai_status_bit_t summaryLatched, summaryRealtime;
nai_status_bit_t deltaPosLatched, deltaPosRealtime;

check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED, &bitStatusLatched));
check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_REALTIME, &bitStatusRealtime));
check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_LOW_LATCHED, &sigLossLatched));
check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED, &refLossLatched));
check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_OPEN_LATCHED, &openLatched));
check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_SHORT_LATCHED, &shortLatched));
check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_LATCHED, &summaryLatched));
check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_DELTA_POS_LATCHED, &deltaPosLatched));

In hex mode, the raw status registers are read with naibrd_LVDT_GetChanMappedStatusRaw() using the same status type constants.

Clear Status

To clear a specific latched status type for a single channel, call naibrd_LVDT_ClearChanMappedStatus() with the appropriate status constant:

/* Clear BIT latched status */
naibrd_LVDT_ClearChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED);

/* Clear signal fault low (signal loss) latched status */
naibrd_LVDT_ClearChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_LOW_LATCHED);

/* Clear reference fault low (reference loss) latched status */
naibrd_LVDT_ClearChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED);

/* Clear open fault latched status */
naibrd_LVDT_ClearChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_OPEN_LATCHED);

/* Clear short fault latched status */
naibrd_LVDT_ClearChanMappedStatus(cardIndex, module, channel,
   NAIBRD_LVDT_CHAN_MAPPED_STATUS_SHORT_LATCHED);

To clear all status types at once, the sample calls naibrd_LVDT_ClearChanMappedStatus() for each status type in sequence. To clear all channels, it loops over every channel and repeats the clear sequence.

  • cardIndex — identifies the board.

  • module — the slot containing the LVDT module.

  • channel — the channel whose status to clear.

  • The status type constant selects which latched status register to clear.

Available status types include: BIT_LATCHED, SIGNAL_FAULT_LOW_LATCHED, REF_FAULT_LOW_LATCHED, SIGNAL_FAULT_HIGH_LATCHED, REF_FAULT_HIGH_LATCHED, OPEN_LATCHED, SHORT_LATCHED, SUMMARY_LATCHED, and DELTA_POS_LATCHED.

Test Sub-Menu

The Test sub-menu provides built-in test controls for setting a test position, enabling D0/D3 test modes, and checking power-on BIT results.

Set Test Position

To set a test position value, call naibrd_LVDT_SetTestPosition() in decimal mode or naibrd_LVDT_SetRaw() with NAIBRD_LVDT_RAW_TEST_POSITION in hex mode:

float64_t position = /* user-specified test position */;

/* Decimal mode -- set test position as a floating-point value */
naibrd_LVDT_SetTestPosition(cardIndex, module, position);

For raw register access (hex mode):

uint32_t rawPosition = /* user-specified raw hex value */;

naibrd_LVDT_SetRaw(cardIndex, module, NAIBRD_LVDT_RAW_TEST_POSITION, rawPosition);

Enable D0 Test

D0 test mode is controlled through the raw test enable register using a bitmask. The sample reads the current register value, sets or clears bit 0, then writes the value back:

uint32_t valueToSet = 0u;
uint32_t enableChannelMask = 0x1u;

/* Read current test enable register */
naibrd_LVDT_GetRaw(cardIndex, module, NAIBRD_LVDT_RAW_TEST_ENABLE, &valueToSet);

/* Enable D0 test */
valueToSet |= enableChannelMask;
naibrd_LVDT_SetRaw(cardIndex, module, NAIBRD_LVDT_RAW_TEST_ENABLE, valueToSet);

/* Disable D0 test */
valueToSet &= ~enableChannelMask;
naibrd_LVDT_SetRaw(cardIndex, module, NAIBRD_LVDT_RAW_TEST_ENABLE, valueToSet);

Enable D3 Test

D3 test mode uses bit 3 of the same test enable register, following the same read-modify-write pattern:

uint32_t valueToSet = 0u;
uint32_t enableChannelMask = 0x8u;

naibrd_LVDT_GetRaw(cardIndex, module, NAIBRD_LVDT_RAW_TEST_ENABLE, &valueToSet);

/* Enable D3 test */
valueToSet |= enableChannelMask;
naibrd_LVDT_SetRaw(cardIndex, module, NAIBRD_LVDT_RAW_TEST_ENABLE, valueToSet);

Check Power-On BIT

The power-on BIT check verifies whether the module’s built-in self-test has completed and, if so, reads the per-channel BIT status. This feature is supported on LD2 modules:

bool_t pbitComplete;
nai_status_bit_t bitFailed;

/* Check if PBIT has completed */
naibrd_LVDT_CheckPowerOnBITComplete(cardIndex, module, &pbitComplete);

if (pbitComplete)
{
   /* Read per-channel BIT results */
   for (channel = 1; channel <= channelCount; channel++)
   {
      naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
         NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED, &bitFailed);
   }
}
  • pbitComplete — NAI_TRUE if the power-on BIT has completed.

  • bitFailed — NAI_STATUS_BIT_HI if the channel failed BIT.

Note
Power-on BIT is only supported on LD2 modules. On other module types the API returns NAI_ERROR_NOT_SUPPORTED.

Floating-Point Sub-Menu

The Floating-Point sub-menu provides control over hardware floating-point conversion mode. These settings allow the module to convert raw position and velocity data to engineering units directly in hardware.

Enable Floating-Point Mode

To enable or disable hardware floating-point conversion mode on the module, call naibrd_SetFloatingPointModeEnable():

/* Enable floating-point mode */
naibrd_SetFloatingPointModeEnable(cardIndex, module, 0x1);

/* Disable floating-point mode */
naibrd_SetFloatingPointModeEnable(cardIndex, module, 0x0);
  • cardIndex — identifies the board.

  • module — the slot containing the LVDT module.

  • The third parameter — 0x1 to enable, 0x0 to disable.

Set Floating-Point Attributes

Position and velocity offset and scale factors are configured per-channel using naibrd_LVDT_SetFloatingPointAttributes(). The attribute type constant selects which parameter to set:

float64_t offset = /* user-specified offset */;
float64_t scaleFactor = /* user-specified scale factor */;

/* Position A-side offset and scale */
naibrd_LVDT_SetFloatingPointAttributes(cardIndex, module, channel,
   NAIBRD_LVDT_POSITION_OFFSET_A, offset);
naibrd_LVDT_SetFloatingPointAttributes(cardIndex, module, channel,
   NAIBRD_LVDT_POSITION_SCALE_A, scaleFactor);

/* Position B-side offset and scale (2-wire mode) */
naibrd_LVDT_SetFloatingPointAttributes(cardIndex, module, channel,
   NAIBRD_LVDT_POSITION_OFFSET_2WIRE_B, offset);
naibrd_LVDT_SetFloatingPointAttributes(cardIndex, module, channel,
   NAIBRD_LVDT_POSITION_SCALE_2WIRE_B, scaleFactor);

/* Velocity A-side offset and scale */
naibrd_LVDT_SetFloatingPointAttributes(cardIndex, module, channel,
   NAIBRD_LVDT_VELOCITY_OFFSET_A, offset);
naibrd_LVDT_SetFloatingPointAttributes(cardIndex, module, channel,
   NAIBRD_LVDT_VELOCITY_SCALE_A, scaleFactor);

/* Velocity B-side offset and scale (2-wire mode) */
naibrd_LVDT_SetFloatingPointAttributes(cardIndex, module, channel,
   NAIBRD_LVDT_VELOCITY_OFFSET_2WIRE_B, offset);
naibrd_LVDT_SetFloatingPointAttributes(cardIndex, module, channel,
   NAIBRD_LVDT_VELOCITY_SCALE_2WIRE_B, scaleFactor);

To read the current floating-point attributes, use naibrd_LVDT_GetFloatingPointAttributes() with the same attribute constants:

float64_t posOffsetA, posScaleA, posOffsetB, posScaleB;

check_status(naibrd_LVDT_GetFloatingPointAttributes(cardIndex, module, channel,
   NAIBRD_LVDT_POSITION_OFFSET_A, &posOffsetA));
check_status(naibrd_LVDT_GetFloatingPointAttributes(cardIndex, module, channel,
   NAIBRD_LVDT_POSITION_SCALE_A, &posScaleA));
check_status(naibrd_LVDT_GetFloatingPointAttributes(cardIndex, module, channel,
   NAIBRD_LVDT_POSITION_OFFSET_2WIRE_B, &posOffsetB));
check_status(naibrd_LVDT_GetFloatingPointAttributes(cardIndex, module, channel,
   NAIBRD_LVDT_POSITION_SCALE_2WIRE_B, &posScaleB));
  • cardIndex — identifies the board.

  • module — the slot containing the LVDT module.

  • channel — the channel to configure.

  • The attribute type constant selects which parameter: position/velocity, offset/scale, A-side/B-side.

Note
Floating-point attributes can only be set when the module is in floating-point mode. This feature applies to Gen5 modules only.

Troubleshooting Reference

Error / Symptom Possible Causes Suggested Resolution

No board found

Board not powered, cable disconnected, or wrong interface selected.

Verify power, cables, and interface type.

Connection timeout

Incorrect IP address, firewall blocking communication, or network misconfiguration.

Confirm the board IP address. Disable or configure firewall rules.

Position reads as zero for all channels

LVDT sensor not connected, or excitation output not enabled.

Verify sensor wiring and that the excitation source is active.

Signal loss status set

Signal voltage below the configured signal loss threshold.

Check LVDT sensor connections. Adjust the signal loss threshold if appropriate.

Reference loss status set

Reference voltage below the configured reference loss threshold.

Verify the reference excitation source. Adjust the reference loss threshold if appropriate.

BIT status set

Built-in test has detected a fault condition.

Clear the status and monitor. If it reoccurs, check sensor health and wiring.

Open/Short fault detected

The LVDT winding has an open or short circuit condition.

Inspect the LVDT sensor for physical damage. Check cable connections.

Floating-point mode not available

Module firmware may not support hardware floating-point conversion.

Verify firmware version supports this feature.

LL2 module shows limited menu

LL2 modules use a simplified menu without operation and floating-point sub-menus.

This is expected behavior. LL2 modules support configuration, status, and test only.

Test position not reflected in readings

D0 or D3 test mode not enabled.

Enable the appropriate test mode before setting the test position.

Full Source

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

Note
This source file is very large (approximately 4,200 lines) due to the extensive set of sub-menus covering operation, configuration, status, test, and floating-point commands, with separate handling for LL2 modules.
Full Source — lvdt_basic_ops.c (SSK 2.x)
/* nailib include files */
#include "nai_libs/nailib/include/naitypes.h"
#include "nai_libs/nailib/include/nailib.h"
#include "nai_libs/nailib/include/nailib_utils.h"

/* naibrd include files */
#include "nai_libs/naibrd/include/naibrd.h"
#include "nai_libs/naibrd/include/functions/naibrd_lvdt.h"

/* naiif include files */
#include "nai_libs/naiif/include/naiif.h"
#include "nai_libs/naiif/include/naiif_stdio.h"

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

#define THRESHOLD_RAW_115V       (0x2CECu)
#define THRESHOLD_RAW_90V        (0x2328u)
#define THRESHOLD_RAW_0V         (0x0u)
#define THRESHOLD_115V           (115.0)
#define THRESHOLD_90V            (90.0)
#define THRESHOLD_0V             (0.0)
#define BW_2HZ                   (2u)
#define BW_1280HZ                (1280u)
#define DEF_LVDT_CHANNEL         (1)
#define MSG_LENGTH               (18)
#define SIG_INV_MSG_LENGTH       (37)
#define LVDT_CHAN_STATUS_ENABLED (1)

static const int8_t *DEF_CONFIG_FILE = (const int8_t *)"default_LVDT_BasicOps.txt";

/* Function prototypes */
static nai_status_t Run_LVDTBasicMenu(int32_t cardIndex, int32_t module, uint32_t modId);
static void LVDTBasicMenu_displayOperation(int32_t cardIndex, int32_t module, uint32_t modId);
static void LVDTBasicMenu_displayMeasurements(int32_t cardIndex, int32_t module, uint32_t modId);
static void LVDTBasicMenu_displayMode(naibrd_lvdt_format_t mode);
/* LL2 */
static void LVDTBasicMenu_LL2_displayMeasurements(int32_t cardIndex, int32_t module, uint32_t modId);

/* LVDT Basic Ops Command Functions */
static nai_status_t LVDTBasicMenu_Operation(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_Configuration(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_Status(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_Test(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_FloatingPoint(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_Hex(int32_t paramCount, int32_t* p_params);
static nai_status_t Configure_LVDT_ModulePowerResetMenu(int32_t paramCount, int32_t* p_params);
static nai_status_t Configure_LVDT_ClearModulePowerResetStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t Configure_LVDT_SetModulePowerReset(int32_t paramCount, int32_t* p_params);
/* LL2 */
static nai_status_t LVDTBasicMenu_LL2_Configuration(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTBasicMenu_LL2_Status(int32_t paramCount, int32_t* p_params);

/* LVDT Operation Functions*/
static nai_status_t LVDT_Operation_SetLatch(int32_t paramCount, int32_t* p_params);

/* LVDT Configuration Functions*/
static nai_status_t LVDT_Config_SetMode(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_Config_SetChanStatEnb(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_Config_SetSigLossThreshold(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_Config_SetRefLossThreshold(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_Config_SetSigHiThreshold(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_Config_SetRefHiThreshold(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_Config_SetOpenThreshold(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_Config_SetShortThreshold(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_Config_SetSignalInversion(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_Config_SetBandWidth(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_Config_SetBandWidthSelect(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_Config_SetLVDTScale(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_Config_SetTRValue(int32_t paramCount, int32_t* p_params);
static void LVDTBasicMenu_displayConfigTable(int32_t cardIndex, int32_t module, uint32_t modId);
/* LL2 */
static nai_status_t LVDT_Config_LL2_SetSignalInversion(int32_t paramCount, int32_t* p_params);
static void LVDTBasicMenu_LL2_displayConfigTable(int32_t cardIndex, int32_t module, uint32_t modId);

/* LVDT Status Functions*/
static nai_status_t LVDTStatusMenu_ClearStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTStatusMenu_ClearStatusAllChannels(int32_t paramCount, int32_t* p_params);
static void LVDTStatusMenu_displayStatusTable(int32_t cardIndex, int32_t module, uint32_t modId);
/* LL2 */
static nai_status_t LVDTStatusMenu_LL2_ClearStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTStatusMenu_LL2_ClearStatusAllChannels(int32_t paramCount, int32_t* p_params);
static void LVDTStatusMenu_LL2_displayStatusTable(int32_t cardIndex, int32_t module, uint32_t modId);

/* LVDT Test Functions*/
static nai_status_t LVDTTestMenu_SetTestPosition(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTTestMenu_SetD0TestEnable(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTTestMenu_SetD3TestEnable(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDTTestMenu_CheckPowerOnBIT(int32_t paramCount, int32_t* p_params);
static void LVDTTestMenu_displayTestTable(int32_t cardIndex, int32_t module, uint32_t modId);
/* LL2 */
static void LVDTTestMenu_LL2_displayTestTable(int32_t cardIndex, int32_t module, uint32_t modId);

/* LVDT Floating-Point Mode Functions */
static nai_status_t LVDT_FloatingPoint_SetFloatingPointMode(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_FloatingPoint_SetFloatingPointPositionOffsetA(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_FloatingPoint_SetFloatingPointPositionScaleA(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_FloatingPoint_SetFloatingPointPositionOffsetB(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_FloatingPoint_SetFloatingPointPositionScaleB(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_FloatingPoint_SetFloatingPointVelocityOffsetA(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_FloatingPoint_SetFloatingPointVelocityScaleA(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_FloatingPoint_SetFloatingPointVelocityOffsetB(int32_t paramCount, int32_t* p_params);
static nai_status_t LVDT_FloatingPoint_SetFloatingPointVelocityScaleB(int32_t paramCount, int32_t* p_params);
static void LVDT_FloatingPoint_displayFloatingPointTable(int32_t cardIndex, int32_t module, uint32_t modId);

static bool_t DisplayAsHex = NAI_FALSE;

/****** Command Table *******/
enum lvdt_basicOpsMenu_commands
{
   LVDT_BASICMENU_CMD_OPERATION,
   LVDT_BASICMENU_CMD_CONFIGURATION,
   LVDT_BASICMENU_CMD_STATUS,
   LVDT_BASICMENU_CMD_TEST,
   LVDT_BASICMENU_CMD_FLOATING_POINT,
   LVDT_BASICMENU_CMD_FLOATING_POINT_MODE,
   LVDT_BASICMENU_CMD_DISPLAY_HEX,
   LVDT_BASICOP_CMD_MODULE_POWER_RESET,
   LVDT_BASICMENU_CMD_COUNT
};

enum lvdt_ll2_basicOpsMenu_commands
{
   LVDT_LL2_BASICMENU_CMD_CONFIGURATION,
   LVDT_LL2_BASICMENU_CMD_STATUS,
   LVDT_LL2_BASICMENU_CMD_TEST,
   LVDT_LL2_BASICMENU_CMD_DISPLAY_HEX,
   LVDT_LL2_BASICMENU_CMD_COUNT
};

enum lvdt_OperationMenu_commands
{
   LVDT_OPERATION_CMD_LATCH,
   LVDT_OPERATION_CMD_COUNT
};

enum lvdt_ConfigurationMenu_commands
{
   LVDT_CONFIG_CMD_MODE,
   LVDT_CONFIG_CMD_CHAN_STATUS_ENABLE,
   LVDT_CONFIG_CMD_SIG_THRESHOLD,
   LVDT_CONFIG_CMD_REF_THRESHOLD,
   LVDT_CONFIG_CMD_SIG_HI_THRESHOLD,
   LVDT_CONFIG_CMD_REF_HI_THRESHOLD,
   LVDT_CONFIG_CMD_OPEN_THRESHOLD,
   LVDT_CONFIG_CMD_SHORT_THRESHOLD,
   LVDT_CONFIG_CMD_SIGNAL_INVERSION,
   LVDT_CONFIG_CMD_BW,
   LVDT_CONFIG_CMD_BW_SELECT,
   LVDT_CONFIG_CMD_SCALE,
   LVDT_CONFIG_CMD_COUNT
};

enum lvdt_ll2_ConfigurationMenu_commands
{
   LVDT_LL2_CONFIG_CMD_CHAN_STATUS_ENABLE,
   LVDT_LL2_CONFIG_CMD_REF_THRESHOLD,
   LVDT_LL2_CONFIG_CMD_SIG_HI_THRESHOLD,
   LVDT_LL2_CONFIG_CMD_REF_HI_THRESHOLD,
   LVDT_LL2_CONFIG_CMD_SIGNAL_INVERSION,
   LVDT_LL2_CONFIG_CMD_BW,
   LVDT_LL2_CONFIG_CMD_BW_SELECT,
   LVDT_LL2_CONFIG_CMD_TR_VALUE,
   LVDT_LL2_CONFIG_CMD_COUNT
};

enum lvdt_statusMenu_commands
{
   LVDT_STATUSMENU_CMD_CLEAR_STATUS,
   LVDT_STATUSMENU_CMD_CLEAR_STATUS_ALL,
   LVDT_STATUSMENU_CMD_COUNT
};

enum lvdt_testMenu_commands
{
   LVDT_TESTMENU_CMD_SET_TEST_POSITION,
   LVDT_TESTMENU_CMD_ENABLE_D0_TEST,
   LVDT_TESTMENU_CMD_ENABLE_D3_TEST,
   LVDT_TESTMENU_CMD_CHECK_PBIT,
   LVDT_TESTMENU_CMD_COUNT
};

enum lvdt_floatingPointMenu_commands
{
   LVDT_FLOATINGPOINTMENU_CMD_SET_FLOATING_POINT_MODE_ENABLE,
   LVDT_FLOATINGPOINTMENU_CMD_SET_POS_OFFSET_A,
   LVDT_FLOATINGPOINTMENU_CMD_SET_POS_SCALE_A,
   LVDT_FLOATINGPOINTMENU_CMD_SET_POS_OFFSET_B,
   LVDT_FLOATINGPOINTMENU_CMD_SET_POS_SCALE_B,
   LVDT_FLOATINGPOINTMENU_CMD_SET_VEL_OFFSET_A,
   LVDT_FLOATINGPOINTMENU_CMD_SET_VEL_SCALE_A,
   LVDT_FLOATINGPOINTMENU_CMD_SET_VEL_OFFSET_B,
   LVDT_FLOATINGPOINTMENU_CMD_SET_VEL_SCALE_B,
   LVDT_FLOATINGPOINTMENU_CMD_COUNT
};

enum lvdt_module_power_reset_commands
{
   LVDT_MODULE_POWER_RESET_CMD_BACK,
   LVDT_MODULE_POWER_RESET_CMD_CLEAR_MODULE_POWER_RESET_STATUS,
   LVDT_MODULE_POWER_RESET_CMD_SET_MODULE_POWER_RESET,
   LVDT_MODULE_POWER_RESET_CMD_COUNT
};

naiapp_cmdtbl_params_t LVDT_ModulePowerResetMenuCmds[LVDT_MODULE_POWER_RESET_CMD_COUNT] =
{
   {"BACK",  "Back to Main Menu",               LVDT_MODULE_POWER_RESET_CMD_BACK,                            NULL},
   {"CLEAR", "Clear Module Power Reset Status", LVDT_MODULE_POWER_RESET_CMD_CLEAR_MODULE_POWER_RESET_STATUS, Configure_LVDT_ClearModulePowerResetStatus},
   {"SET",   "Set Module Power Reset Request",  LVDT_MODULE_POWER_RESET_CMD_SET_MODULE_POWER_RESET,          Configure_LVDT_SetModulePowerReset}
};
static naiapp_cmdtbl_params_t LVDT_BasicOpMenuCmds[] = {
   /* steer to Menu 2*/
   {"O",       "Operation Menu",                 LVDT_BASICMENU_CMD_OPERATION,               LVDTBasicMenu_Operation             },
   /* steer to Menu 3*/
   {"C",       "Configuration Menu",             LVDT_BASICMENU_CMD_CONFIGURATION,           LVDTBasicMenu_Configuration         },
   /* steer to Menu 4*/
   {"S",       "Status Menu",                    LVDT_BASICMENU_CMD_STATUS,                  LVDTBasicMenu_Status                },
   /* steer to Menu 5*/
   {"T",       "Test Menu",                      LVDT_BASICMENU_CMD_TEST,                    LVDTBasicMenu_Test                  },
   /* steer to Menu 6*/
   {"F",       "Floating-Point Menu",            LVDT_BASICMENU_CMD_FLOATING_POINT,          LVDTBasicMenu_FloatingPoint         },
   /* enable/disable floating-point mode*/
   {"E", "Enable/Disable Hardware Floating-Point Conversion Mode", LVDT_BASICMENU_CMD_FLOATING_POINT_MODE, LVDT_FloatingPoint_SetFloatingPointMode},
   /* steer to Menu 7*/
   {"H",       "Display Hex",                    LVDT_BASICMENU_CMD_DISPLAY_HEX,             LVDTBasicMenu_Hex                   },
   /* steer to reset menu */
   {"RESET",  "Show Module Power Reset Menu Options",   LVDT_BASICOP_CMD_MODULE_POWER_RESET,  Configure_LVDT_ModulePowerResetMenu}
};

static naiapp_cmdtbl_params_t LVDT_LL2_BasicOpMenuCmds[] = {
   {"C",   "Configuration Menu",        LVDT_LL2_BASICMENU_CMD_CONFIGURATION,   LVDTBasicMenu_LL2_Configuration },
   {"S",   "Status Menu",               LVDT_LL2_BASICMENU_CMD_STATUS,          LVDTBasicMenu_LL2_Status        },
   {"T",   "Test Menu",                 LVDT_LL2_BASICMENU_CMD_TEST,            LVDTBasicMenu_Test              },
   {"H",   "Display Hex",               LVDT_LL2_BASICMENU_CMD_DISPLAY_HEX,     LVDTBasicMenu_Hex               }
};

static naiapp_cmdtbl_params_t LVDT_OperationMenuCmds[] = {
   {"L",       "Set Latch",                      LVDT_OPERATION_CMD_LATCH,                   LVDT_Operation_SetLatch            }
};

static naiapp_cmdtbl_params_t LVDT_ConfigurationMenuCmds[] = {
   {"M",       "Set Mode",                       LVDT_CONFIG_CMD_MODE,                       LVDT_Config_SetMode                },
   {"E",       "Set Chan Status Enable",         LVDT_CONFIG_CMD_CHAN_STATUS_ENABLE,         LVDT_Config_SetChanStatEnb         },
   {"SL",      "Set Sig Loss Threshold",         LVDT_CONFIG_CMD_SIG_THRESHOLD,              LVDT_Config_SetSigLossThreshold    },
   {"RL",      "Set Ref Loss Threshold",         LVDT_CONFIG_CMD_REF_THRESHOLD,              LVDT_Config_SetRefLossThreshold    },
   {"SH",      "Set Sig Fault High Threshold",   LVDT_CONFIG_CMD_SIG_HI_THRESHOLD,           LVDT_Config_SetSigHiThreshold      },
   {"RH",      "Set Ref Fault High Threshold",   LVDT_CONFIG_CMD_REF_HI_THRESHOLD,           LVDT_Config_SetRefHiThreshold      },
   {"OT",      "Set Open Threshold",             LVDT_CONFIG_CMD_OPEN_THRESHOLD,             LVDT_Config_SetOpenThreshold       },
   {"ST",      "Set Short Threshold",            LVDT_CONFIG_CMD_SHORT_THRESHOLD,            LVDT_Config_SetShortThreshold      },
   {"INV",     "Set Signal Inversion Control",   LVDT_CONFIG_CMD_SIGNAL_INVERSION,           LVDT_Config_SetSignalInversion     },
   {"BW",      "Set Band Width",                 LVDT_CONFIG_CMD_BW,                         LVDT_Config_SetBandWidth           },
   {"BWS",     "Set Band Width Select",          LVDT_CONFIG_CMD_BW_SELECT,                  LVDT_Config_SetBandWidthSelect     },
   {"SS",      "Set Scale",                      LVDT_CONFIG_CMD_SCALE,                      LVDT_Config_SetLVDTScale           }
};

static naiapp_cmdtbl_params_t LVDT_LL2_ConfigurationMenuCmds[] = {
   {"E",     "Set Chan Status Enable",         LVDT_LL2_CONFIG_CMD_CHAN_STATUS_ENABLE,   LVDT_Config_SetChanStatEnb         },
   {"RL",    "Set Ref Loss Threshold",         LVDT_LL2_CONFIG_CMD_REF_THRESHOLD,        LVDT_Config_SetRefLossThreshold    },
   {"SH",    "Set Sig Fault High Threshold",   LVDT_LL2_CONFIG_CMD_SIG_HI_THRESHOLD,     LVDT_Config_SetSigHiThreshold      },
   {"RH",    "Set Ref Fault High Threshold",   LVDT_LL2_CONFIG_CMD_REF_HI_THRESHOLD,     LVDT_Config_SetRefHiThreshold      },
   {"INV",   "Set Signal Inversion Control",   LVDT_LL2_CONFIG_CMD_SIGNAL_INVERSION,     LVDT_Config_LL2_SetSignalInversion },
   {"BW",    "Set Band Width",                 LVDT_LL2_CONFIG_CMD_BW,                   LVDT_Config_SetBandWidth           },
   {"BWS",   "Set Band Width Select",          LVDT_LL2_CONFIG_CMD_BW_SELECT,            LVDT_Config_SetBandWidthSelect     },
   {"TR",    "Set TR Value",                   LVDT_LL2_CONFIG_CMD_TR_VALUE,             LVDT_Config_SetTRValue             }
};

static naiapp_cmdtbl_params_t LVDT_StatusMenuCmds[] = {
   {"C",    "Clear LVDT Status",                      LVDT_STATUSMENU_CMD_CLEAR_STATUS,           LVDTStatusMenu_ClearStatus              },
   {"R",    "Clear LVDT Status All Channels",         LVDT_STATUSMENU_CMD_CLEAR_STATUS_ALL,       LVDTStatusMenu_ClearStatusAllChannels   }
};

static naiapp_cmdtbl_params_t LVDT_LL2_StatusMenuCmds[] = {
   {"C",   "Clear LL2 Status",                LVDT_STATUSMENU_CMD_CLEAR_STATUS,       LVDTStatusMenu_LL2_ClearStatus },
   {"R",   "Clear LL2 Status All Channels",   LVDT_STATUSMENU_CMD_CLEAR_STATUS_ALL,   LVDTStatusMenu_LL2_ClearStatusAllChannels }
};

static naiapp_cmdtbl_params_t LVDT_TestMenuCmds[] = {
   {"S",    "Set LVDT Test Position",                 LVDT_TESTMENU_CMD_SET_TEST_POSITION,        LVDTTestMenu_SetTestPosition            },
   {"E",    "Enable Or Disable D0 Test",              LVDT_TESTMENU_CMD_ENABLE_D0_TEST,           LVDTTestMenu_SetD0TestEnable            },
   {"D3",   "Enable Or Disable D3 Test",              LVDT_TESTMENU_CMD_ENABLE_D3_TEST,           LVDTTestMenu_SetD3TestEnable            },
   {"P",    "Check Power-On BIT",                     LVDT_TESTMENU_CMD_CHECK_PBIT,               LVDTTestMenu_CheckPowerOnBIT }
};

static naiapp_cmdtbl_params_t LVDT_FloatingPointMenuCmds[] = {
   {"E", "Enable/Disable Hardware Floating-Point Conversion Mode",                   LVDT_FLOATINGPOINTMENU_CMD_SET_FLOATING_POINT_MODE_ENABLE, LVDT_FloatingPoint_SetFloatingPointMode},
   {"1", "Set Hardware Floating-Point Conversion Mode Position A-Side Offset",       LVDT_FLOATINGPOINTMENU_CMD_SET_POS_OFFSET_A,               LVDT_FloatingPoint_SetFloatingPointPositionOffsetA},
   {"2", "Set Hardware Floating-Point Conversion Mode Position A-Side Scale Factor", LVDT_FLOATINGPOINTMENU_CMD_SET_POS_SCALE_A,                LVDT_FloatingPoint_SetFloatingPointPositionScaleA},
   {"3", "Set Hardware Floating-Point Conversion Mode Position B-Side Offset",       LVDT_FLOATINGPOINTMENU_CMD_SET_POS_OFFSET_B,               LVDT_FloatingPoint_SetFloatingPointPositionOffsetB},
   {"4", "Set Hardware Floating-Point Conversion Mode Position B-Side Scale Factor", LVDT_FLOATINGPOINTMENU_CMD_SET_POS_SCALE_B,                LVDT_FloatingPoint_SetFloatingPointPositionScaleB},
   {"5", "Set Hardware Floating-Point Conversion Mode Velocity A-Side Offset",       LVDT_FLOATINGPOINTMENU_CMD_SET_VEL_OFFSET_A,               LVDT_FloatingPoint_SetFloatingPointVelocityOffsetA},
   {"6", "Set Hardware Floating-Point Conversion Mode Velocity A-Side Scale Factor", LVDT_FLOATINGPOINTMENU_CMD_SET_VEL_SCALE_A,                LVDT_FloatingPoint_SetFloatingPointVelocityScaleA},
   {"7", "Set Hardware Floating-Point Conversion Mode Velocity B-Side Offset",       LVDT_FLOATINGPOINTMENU_CMD_SET_VEL_OFFSET_B,               LVDT_FloatingPoint_SetFloatingPointVelocityOffsetB},
   {"8", "Set Hardware Floating-Point Conversion Mode Velocity B-Side Scale Factor", LVDT_FLOATINGPOINTMENU_CMD_SET_VEL_SCALE_B,                LVDT_FloatingPoint_SetFloatingPointVelocityScaleB}
};

/*****************************************************************************/
/**
 * <summary>
 * The purpose of the LVDT_BasicOpsMenu is to illustrate the methods to call in the
 * naibrd library to perform basic operations with the LVDT 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 LVDT routines.
 * - ConfigDevice
 * - DisplayDeviceCfg
 * - GetBoardSNModCfg
 * - CheckModule
 * </summary>
 */
/*****************************************************************************/
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t LVDT_BasicOps(void)
#else
int32_t main(void)
#endif
{
   int32_t cardIndex;
   int32_t moduleCnt;
   int32_t module;
   bool_t  stop = NAI_FALSE;
   uint32_t moduleID = 0;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == (bool_t)NAI_TRUE)
   {
      while (stop != NAI_TRUE)
      {
         /* Select Card Index */
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != NAI_TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));

            /* Select Module */
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != NAI_TRUE)
            {
               check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
               if ((moduleID != 0))
               {
                  Run_LVDTBasicMenu(cardIndex, module, moduleID);
               }
            }
         }
         naiif_printf("\r\nType Q to quit or Enter key to restart application:\r\n");
         stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      }
   }
   naiif_printf("\r\nType the Enter key to exit the program: ");
   naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   naiapp_access_CloseAllOpenCards();
   return 0;
}

/*****************************************************************************/
/**
 * <summary>
 * Run_LVDTBasicMenu illustrates the channel configuration and prepares the menu
 * which will handle user command requests. Returns NAI_TRUE if the user enters
 * the Quit Command at any point within its scope.
 * </summary>
 */
/*****************************************************************************/
static nai_status_t Run_LVDTBasicMenu(int32_t cardIndex, int32_t module, uint32_t modId)
{
   bool_t bQuit = NAI_FALSE;
   int32_t cmd;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   naiapp_AppParameters_t lvdtParams;
   p_naiapp_AppParameters_t p_lvdtParams = &lvdtParams;
   memset(&lvdtParams, 0, sizeof(naiapp_AppParameters_t));
   p_lvdtParams->cardIndex = cardIndex;
   p_lvdtParams->module = module;
   p_lvdtParams->modId = modId;

   if (modId == NAIBRD_MODULE_ID_LL2)
   {
      naiapp_utils_LoadParamMenuCommands(LVDT_LL2_BASICMENU_CMD_COUNT, LVDT_LL2_BasicOpMenuCmds);
      do
      {
         LVDTBasicMenu_LL2_displayMeasurements(p_lvdtParams->cardIndex, p_lvdtParams->module, p_lvdtParams->modId);
         naiapp_display_ParamMenuCommands((int8_t*)"LVDT LL2 Basic Menu");
         naiif_printf("\r\n Type command or %c to quit : ", NAI_QUIT_CHAR);
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if ((!bQuit) && (inputResponseCnt > 0))
         {
            if (naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd) == NAI_TRUE)
               LVDT_LL2_BasicOpMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)p_lvdtParams);
            else
               naiif_printf(" Invalid command entered\r\n");
         }
      } while (!bQuit);
   }
   else
   {
      naiapp_utils_LoadParamMenuCommands(LVDT_BASICMENU_CMD_COUNT, LVDT_BasicOpMenuCmds);
      do
      {
         LVDTBasicMenu_displayMeasurements(p_lvdtParams->cardIndex, p_lvdtParams->module, p_lvdtParams->modId);
         naiapp_display_ParamMenuCommands((int8_t*)"MENU_TITLE");
         naiif_printf("\r\n Type command or %c to quit : ", NAI_QUIT_CHAR);
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if (!bQuit && inputResponseCnt > 0)
         {
            if (naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd) == NAI_TRUE)
               LVDT_BasicOpMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)p_lvdtParams);
            else
               naiif_printf(" Invalid command entered\r\n");
         }
      } while (!bQuit);
   }
   return (nai_status_t)bQuit;
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTBasicMenu_displayMeasurements illustrates the methods to call in the naibrd library
 * to retrieve the basic operation configuration states and status states
 * as well as the current lvdt reading for all channels.
 * </summary>
 */
/*****************************************************************************/
static void LVDTBasicMenu_displayMeasurements(int32_t cardIndex, int32_t module, uint32_t modId)
{
   int32_t channel, MAX_CHANNEL = naibrd_LVDT_GetChannelCount(modId);
   naibrd_lvdt_format_t mode;
   uint32_t positionRaw, frequencyRaw, sigVoltRaw, refVoltRaw, vaRaw, vbRaw, vaVbRaw, vaDetectRaw, vbDetectRaw;
   float64_t position, frequency, sigvolt, refvolt, va, vb, vaVb, vaDetect, vbDetect;
   bool_t fpEnable = NAI_FALSE;
   nai_status_bit_t BitStatus = NAI_STATUS_BIT_LO, SigLoss = NAI_STATUS_BIT_LO, RefLoss = NAI_STATUS_BIT_LO;


   naiif_printf("\r\n\r\n ==========================================================================================================================================================\r\n");
   switch (modId)
   {
      case NAIBRD_MODULE_ID_LD1:
      case NAIBRD_MODULE_ID_LD2:
      case NAIBRD_MODULE_ID_LD3:
      case NAIBRD_MODULE_ID_LD4:
      case NAIBRD_MODULE_ID_LD6:
      case NAIBRD_MODULE_ID_LR2:
         naiif_printf("%7s%8s%17s%12s%12s%12s%5s%2s%10s%2s%8s%5s%5s%9s%3s%9s%2s%6s%10s%10s\r\n", "Chan", "Mode", "Position", "Frequency", "RefVolt",
            "SigVolt", "", "Va", "", "Vb", "", "Va+Vb", "", "Va Detect", "", "Vb Detect", "", "BIT", "SigLoss", "RefLoss");
         break;
      default:
         break;
   }
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      naiif_printf("%4d", channel);
      check_status(naibrd_LVDT_GetChanMode(cardIndex, module, channel, &mode));
      LVDTBasicMenu_displayMode(mode);
      /*   uint32_t positionRaw, frequencyRaw, vaRaw, vbRaw, sigVoltRaw, refVoltRaw; */
      if (DisplayAsHex)
      {
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_POSITION, &positionRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_FREQUENCY, &frequencyRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_SIGNAL_VOLTAGE, &sigVoltRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_REF_VOLTAGE, &refVoltRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_VA, &vaRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_VB, &vbRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_VA_AND_VB, &vaVbRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_VA_DETECT, &vaDetectRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_VB_DETECT, &vbDetectRaw));
         check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_REALTIME,
            &BitStatus));
         check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
            NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_LOW_REALTIME, &SigLoss));
         check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
            NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_REALTIME, &RefLoss));
         naiif_printf("      0x%08X  0x%08X  0x%08X  0x%08X 0x%08X 0x%08X 0x%08X  0x%08X  0x%08X   %4d%8d  %8d", positionRaw, frequencyRaw,
            refVoltRaw, sigVoltRaw, vaRaw, vbRaw, vaVbRaw, vaDetectRaw, vbDetectRaw, BitStatus, SigLoss, RefLoss);
      }
      else
      {
         check_status(naibrd_LVDT_GetPosition(cardIndex, module, channel, &position));
         check_status(naibrd_LVDT_GetFrequency(cardIndex, module, channel, &frequency));
         check_status(naibrd_LVDT_GetSignalVoltage(cardIndex, module, channel, &sigvolt));
         check_status(naibrd_LVDT_GetRefVoltage(cardIndex, module, channel, &refvolt));
         check_status(naibrd_LVDT_GetSignalMagnitude(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_VA, &va));
         check_status(naibrd_LVDT_GetSignalMagnitude(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_VB, &vb));
         check_status(naibrd_LVDT_GetSignalMagnitude(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_VA_AND_VB, &vaVb));
         check_status(naibrd_LVDT_GetDetectValue(cardIndex, module, channel, NAIBRD_LVDT_VA_DETECT, &vaDetect));
         check_status(naibrd_LVDT_GetDetectValue(cardIndex, module, channel, NAIBRD_LVDT_VB_DETECT, &vbDetect));
         check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_REALTIME,
            &BitStatus));
         check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
            NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_LOW_REALTIME, &SigLoss));
         check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
            NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_REALTIME, &RefLoss));
         naiif_printf("    %10.4f%12.4f%12.4f%12.4f%12.4f%12.4f%12.4f%12.4f%12.4f %5d%8d  %8d", position, frequency, refvolt, sigvolt, va,
                      vb, vaVb, vaDetect, vbDetect, BitStatus, SigLoss, RefLoss);
      }
      naiif_printf("\r\n");
   }

   check_status(naibrd_GetRunningInFloatingPointMode(cardIndex, module, &fpEnable));
   naiif_printf("\r\n H/W Floating Point Mode: %s\r\n", (fpEnable == NAI_FALSE ? "DISABLED" : "ENABLED"));
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTBasicMenu_LL2_displayMeasurements illustrates the methods to call in the naibrd library
 * to retrieve the basic operation configuration states and status states
 * as well as the current lvdt reading for all channels.
 * This function is used for LL2 modules only.
 * </summary>
 */
/*****************************************************************************/
static void LVDTBasicMenu_LL2_displayMeasurements(int32_t cardIndex, int32_t module, uint32_t modId)
{
   int32_t channel, MAX_CHANNEL = naibrd_LVDT_GetChannelCount(modId);
   uint32_t positionRaw, frequencyRaw, sigVoltRaw, refVoltRaw, velocityRaw;
   float64_t position, frequency, sigvolt, refvolt, velocity;
   nai_status_bit_t BitStatus = NAI_STATUS_BIT_LO, RefLoss = NAI_STATUS_BIT_LO;


   naiif_printf("\r\n\r\n ==========================================================================================================================================================\r\n");
   switch (modId)
   {
      case NAIBRD_MODULE_ID_LL2:
         naiif_printf("%7s%17s%12s%12s%12s%13s%12s%10s\r\n", "Chan", "Position", "Frequency", "RefVolt",
            "SigVolt", "Velocity", "BIT", "RefLoss");
         break;
      default:
         break;
   }
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      naiif_printf("%4d", channel);
      /*   uint32_t positionRaw, frequencyRaw, sigVoltRaw, refVoltRaw; */
      if (DisplayAsHex)
      {
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_POSITION, &positionRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_FREQUENCY, &frequencyRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_SIGNAL_VOLTAGE, &sigVoltRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_REF_VOLTAGE, &refVoltRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_VELOCITY, &velocityRaw));
         check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_REALTIME,
            &BitStatus));
         check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
            NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_REALTIME, &RefLoss));
         naiif_printf("           0x%08X  0x%08X   0x%08X  0x%08X  0x%08X      %4d  %8d", positionRaw, frequencyRaw,
            refVoltRaw, sigVoltRaw, velocityRaw, BitStatus, RefLoss);
      }
      else
      {
         check_status(naibrd_LVDT_GetPosition(cardIndex, module, channel, &position));
         check_status(naibrd_LVDT_GetFrequency(cardIndex, module, channel, &frequency));
         check_status(naibrd_LVDT_GetSignalVoltage(cardIndex, module, channel, &sigvolt));
         check_status(naibrd_LVDT_GetRefVoltage(cardIndex, module, channel, &refvolt));
         check_status(naibrd_LVDT_GetVelocity(cardIndex, module, channel, &velocity));
         check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_REALTIME,
            &BitStatus));
         check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel,
            NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_REALTIME, &RefLoss));
         naiif_printf("         %10.4f%12.4f %12.4f%12.4f%12.4f       %5d  %8d", position, frequency, refvolt, sigvolt, velocity,
            BitStatus, RefLoss);
      }
      naiif_printf("\r\n");
   }

   naiif_printf("\r\n H/W Floating Point Mode: %s\r\n", "NOT SUPPORTED");
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTBasicMenu_displayMode prints mode value.
 * </summary>
 */
/*****************************************************************************/
static void LVDTBasicMenu_displayMode(naibrd_lvdt_format_t mode)
{
   uint8_t msg[MSG_LENGTH];
   memset(msg, 0, sizeof(msg));
   if (DisplayAsHex)
   {
      naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%X", "0x", mode);
      naiif_printf("   %8s  ", msg);
   }
   else
   {
      if (mode == NAIBRD_LVDT_4WIRE)
         naiif_printf("     %8s", "4-Wire");
      else if (mode == NAIBRD_LVDT_2WIRE)
         naiif_printf("     %8s", "2-Wire");
      else
         naiif_printf("     %8s", "UNKNOWN");
   }
}

/*Begin: This section is Status implementation*/
static nai_status_t LVDTBasicMenu_Status(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   int32_t MAX_CHANNELS;
   int32_t cmd, CommandCount;
   int32_t channel = 0;
   nai_status_t status = NAI_SUCCESS;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   MAX_CHANNELS = naibrd_LVDT_GetChannelCount(plvdtPara->modId);
   naiapp_utils_LoadParamMenuCommands(LVDT_STATUSMENU_CMD_COUNT, LVDT_StatusMenuCmds);
   do
   {
      LVDTStatusMenu_displayStatusTable(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->modId);
      naiapp_display_ParamMenuCommands((int8_t*)"LVDT Status Menu\r\n           Clear/Set Latch Status Only");
      naiif_printf("\r\n Type command or %c to quit : ", NAI_QUIT_CHAR);
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
         CommandCount = LVDT_STATUSMENU_CMD_COUNT;
         if ((cmd >= 0) && (cmd < CommandCount))
         {
            /*if ((cmd != LVDT_STATUSMENU_CMD_CLEAR_STATUS_ALL) && (cmd != LVDT_STATUSMENU_CMD_SET_STATUS_ALL))*/
            if (cmd != LVDT_STATUSMENU_CMD_CLEAR_STATUS_ALL)
            {
               naiapp_query_ChannelNumber(MAX_CHANNELS, 1, &channel);
               plvdtPara->channel = channel;
            }
            LVDT_StatusMenuCmds[cmd].func(paramCount, p_params);
         }
         else
            naiif_printf(" Invalid command entered\r\n");
      }
      else if (bQuit)
      {
         naiapp_utils_LoadParamMenuCommands(LVDT_BASICMENU_CMD_COUNT, LVDT_BasicOpMenuCmds);
      }
      else /* if ((inputResponseCnt < 0) && (!bQuit)) */
      {
         naiif_printf("Invalid command entered\r\n");
      }
   } while (!bQuit);
   return status;
}

static nai_status_t LVDTBasicMenu_LL2_Status(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   int32_t MAX_CHANNELS;
   int32_t cmd, CommandCount;
   int32_t channel = 0;
   nai_status_t status = NAI_SUCCESS;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   MAX_CHANNELS = naibrd_LVDT_GetChannelCount(plvdtPara->modId);
   naiapp_utils_LoadParamMenuCommands(LVDT_STATUSMENU_CMD_COUNT, LVDT_LL2_StatusMenuCmds);
   do
   {
      LVDTStatusMenu_LL2_displayStatusTable(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->modId);
      naiapp_display_ParamMenuCommands((int8_t*)"LVDT LL2 Status Menu\r\n           Clear/Set Latch Status Only");
      naiif_printf("\r\n Type command or %c to quit : ", NAI_QUIT_CHAR);
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if ((!bQuit) && (inputResponseCnt > 0))
      {
         naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
         CommandCount = LVDT_STATUSMENU_CMD_COUNT;
         if ((cmd >= 0) && (cmd < CommandCount))
         {
            /*if ((cmd != LVDT_STATUSMENU_CMD_CLEAR_STATUS_ALL) && (cmd != LVDT_STATUSMENU_CMD_SET_STATUS_ALL))*/
            if (cmd != LVDT_STATUSMENU_CMD_CLEAR_STATUS_ALL)
            {
               naiapp_query_ChannelNumber(MAX_CHANNELS, 1, &channel);
               plvdtPara->channel = channel;
            }
            LVDT_LL2_StatusMenuCmds[cmd].func(paramCount, p_params);
         }
         else
            naiif_printf(" Invalid command entered\r\n");
      }
      else if (bQuit)
      {
         naiapp_utils_LoadParamMenuCommands(LVDT_LL2_BASICMENU_CMD_COUNT, LVDT_LL2_BasicOpMenuCmds);
      }
      else /* if ((inputResponseCnt <= 0) && (!bQuit)) */
      {
         naiif_printf("Invalid command entered\r\n");
      }
   } while (!bQuit);
   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTStatusMenu_displayStatusTable illustrates the methods to call in the naibrd library
 * to retrieve the basic operation configuration states and status states
 * as well as the current LVDT reading for all channels.
 * </summary>
 */
/*****************************************************************************/
static void LVDTStatusMenu_displayStatusTable(int32_t cardIndex, int32_t module, uint32_t modId)
{
   int32_t MAX_CHANNEL = naibrd_LVDT_GetChannelCount(modId);
   naibrd_lvdt_format_t mode = (naibrd_lvdt_format_t)0;
   int32_t channel = 0u;
   uint32_t positionRaw = 0u;
   uint32_t frequencyRaw = 0u;
   uint32_t sigVoltRaw = 0u;
   uint32_t refVoltRaw = 0u;
   float64_t position = 0.0f;
   float64_t frequency = 0.0f;
   float64_t sigVolt = 0.0f;
   float64_t refVolt = 0.0f;
   nai_status_bit_t bitStatusLatched = NAI_STATUS_BIT_LO;
   uint32_t rawBitStatusLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t sigLossLatched = NAI_STATUS_BIT_LO;
   uint32_t rawSigLossLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t refLossLatched = NAI_STATUS_BIT_LO;
   uint32_t rawRefLossLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t sigHiLatched = NAI_STATUS_BIT_LO;
   uint32_t rawSigHiLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t refHiLatched = NAI_STATUS_BIT_LO;
   uint32_t rawRefHiLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t openLatched = NAI_STATUS_BIT_LO;
   uint32_t rawOpenLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t shortLatched = NAI_STATUS_BIT_LO;
   uint32_t rawShortLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t summaryLatched = NAI_STATUS_BIT_LO;
   uint32_t rawSummaryLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t deltaPosLatched = NAI_STATUS_BIT_LO;
   uint32_t rawDeltaPosLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t bitStatusRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawBitStatusRealtime = NAI_STATUS_BIT_LO;
   nai_status_bit_t sigLossRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawSigLossRealtime = NAI_STATUS_BIT_LO;
   nai_status_bit_t refLossRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawRefLossRealtime = NAI_STATUS_BIT_LO;
   nai_status_bit_t sigHiRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawSigHiRealtime = NAI_STATUS_BIT_LO;
   nai_status_bit_t refHiRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawRefHiRealtime = NAI_STATUS_BIT_LO;
   nai_status_bit_t openRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawOpenRealtime = NAI_STATUS_BIT_LO;
   nai_status_bit_t shortRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawShortRealtime = NAI_STATUS_BIT_LO;
   nai_status_bit_t summaryRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawSummaryRealtime = NAI_STATUS_BIT_LO;
   nai_status_bit_t deltaPosRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawDeltaPosRealtime = NAI_STATUS_BIT_LO;
   MAX_CHANNEL = naibrd_LVDT_GetChannelCount(modId);
   naiif_printf("\r\n\r\n =================================================================\r\n");
   switch (modId)
   {
      case NAIBRD_MODULE_ID_LD1:
      case NAIBRD_MODULE_ID_LD2:
      case NAIBRD_MODULE_ID_LD3:
      case NAIBRD_MODULE_ID_LD4:
      case NAIBRD_MODULE_ID_LD6:
      case NAIBRD_MODULE_ID_LR2:
      {
         naiif_printf("%5s%12s%12s%12s%12s%12s\r\n", " Chan", "Mode", "Position", "Freq.", "RefVolt", "SigVolt");
         naiif_printf("%5s%12s%12s%12s%12s%12s\r\n", "", "", "", "", "", "");
      }
      break;
      default:
         /* Nothing to do here; all cases already covered */
         break;
   }
   naiif_printf(" =================================================================\r\n");
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      naiif_printf(" %1d   ", channel);
      check_status(naibrd_LVDT_GetChanMode(cardIndex, module, channel, &mode));
      LVDTBasicMenu_displayMode(mode);
         /*   uint32_t positionRaw, frequencyRaw, vaRaw, vbRaw, sigVoltRaw, refVoltRaw;*/
      if (DisplayAsHex)
      {
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_POSITION, &positionRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_FREQUENCY, &frequencyRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_SIGNAL_VOLTAGE, &sigVoltRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_REF_VOLTAGE, &refVoltRaw));
         naiif_printf("   0x%08X  0x%08X  0x%08X  0x%08X\r\n", positionRaw, frequencyRaw, refVoltRaw, sigVoltRaw);
      }
      else
      {
         check_status(naibrd_LVDT_GetPosition(cardIndex, module, channel, &position));
         check_status(naibrd_LVDT_GetFrequency(cardIndex, module, channel, &frequency));
         check_status(naibrd_LVDT_GetSignalVoltage(cardIndex, module, channel, &sigVolt));
         check_status(naibrd_LVDT_GetRefVoltage(cardIndex, module, channel, &refVolt));
         naiif_printf(" %10.4f%12.4f%12.4f%12.4f\r\n", position, frequency, refVolt, sigVolt);
      }
   }
   switch (modId)
   {
      case NAIBRD_MODULE_ID_LD1:
      case NAIBRD_MODULE_ID_LD2:
      case NAIBRD_MODULE_ID_LD3:
      case NAIBRD_MODULE_ID_LD4:
      case NAIBRD_MODULE_ID_LD6:
      case NAIBRD_MODULE_ID_LR2:
      {
         naiif_printf("\r\n\r\n ================================================================================\r\n");
         naiif_printf("%6s%6s%10s%10s%8s%8s%6s%7s%9s%10s\r\n", " Chan",
            "  BIT ", " REF LOSS ", " SIG LOSS ", " REF HI ", " SIG HI ", " OPEN ", " SHORT ", " SUMMARY ", " DELTA POS");
         naiif_printf("%6s%6s%10s%10s%8s%8s%6s%7s%9s%10s\r\n", "",
            "(R/L)", "(R/L)   ", "(R/L)   ", "(R/L)  ", "(R/L)  ", "(R/L)", "(R/L) ", "(R/L)  ", "(R/L)  ");
         naiif_printf(" ================================================================================\r\n");
      }
      break;
      default:
         /* Nothing to do here; all cases already covered */
         break;
   }
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED, &bitStatusLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_REALTIME, &bitStatusRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_LOW_LATCHED, &sigLossLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_LOW_REALTIME, &sigLossRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED, &refLossLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_REALTIME, &refLossRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_LATCHED, &sigHiLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_REALTIME, &sigHiRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_LATCHED, &refHiLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_REALTIME, &refHiRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_OPEN_LATCHED, &openLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_OPEN_REALTIME, &openRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SHORT_LATCHED, &shortLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SHORT_REALTIME, &shortRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_LATCHED, &summaryLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_REALTIME, &summaryRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_DELTA_POS_LATCHED, &deltaPosLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_DELTA_POS_REALTIME, &deltaPosRealtime));
      naiif_printf("  %1d    (%1d/%1d)  (%1d/%1d)     (%1d/%1d)    (%1d/%1d)   (%1d/%1d)   (%1d/%1d) (%1d/%1d)   (%1d/%1d)     (%1d/%1d)\r\n", channel,
                   bitStatusRealtime, bitStatusLatched, refLossRealtime, refLossLatched, sigLossRealtime, sigLossLatched,
                   refHiRealtime, refHiLatched, sigHiRealtime, sigHiLatched, openRealtime, openLatched, shortRealtime, shortLatched,
                   summaryRealtime, summaryLatched, deltaPosRealtime, deltaPosLatched);
   }
   naiif_printf("\r\n");
   if (DisplayAsHex)
   {
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED,
         &rawBitStatusLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_REALTIME,
         &rawBitStatusRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_LOW_LATCHED,
         &rawSigLossLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_LOW_REALTIME,
         &rawSigLossRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED,
         &rawRefLossLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_REALTIME,
         &rawRefLossRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_LATCHED,
         &rawSigHiLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_REALTIME,
         &rawSigHiRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_LATCHED,
         &rawRefHiLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_REALTIME,
         &rawRefHiRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_OPEN_LATCHED,
         &rawOpenLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_OPEN_REALTIME,
         &rawOpenRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SHORT_LATCHED,
         &rawShortLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SHORT_REALTIME,
         &rawShortRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_LATCHED,
         &rawSummaryLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_REALTIME,
         &rawSummaryRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_DELTA_POS_LATCHED,
         &rawDeltaPosLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_DELTA_POS_REALTIME,
         &rawDeltaPosRealtime));
      naiif_printf("Raw BIT Status (R/L):     (0x%08X/0x%08X)\r\n", rawBitStatusRealtime, rawBitStatusLatched);
      naiif_printf("Raw Ref Loss (R/L):       (0x%08X/0x%08X)\r\n", rawRefLossRealtime, rawRefLossLatched);
      naiif_printf("Raw Sig Loss (R/L):       (0x%08X/0x%08X)\r\n", rawSigLossRealtime, rawSigLossLatched);
      naiif_printf("Raw Ref Fault High (R/L): (0x%08X/0x%08X)\r\n", rawRefHiRealtime, rawRefHiLatched);
      naiif_printf("Raw Sig Fault High (R/L): (0x%08X/0x%08X)\r\n", rawSigHiRealtime, rawSigHiLatched);
      naiif_printf("Raw Open Status (R/L):    (0x%08X/0x%08X)\r\n", rawOpenRealtime, rawOpenLatched);
      naiif_printf("Raw Short Status (R/L):   (0x%08X/0x%08X)\r\n", rawShortRealtime, rawShortLatched);
      naiif_printf("Raw Summary Status (R/L): (0x%08X/0x%08X)\r\n", rawSummaryRealtime, rawSummaryLatched);
      naiif_printf("Raw Delta Position (R/L): (0x%08X/0x%08X)\r\n", rawDeltaPosRealtime, rawDeltaPosLatched);
   }
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTStatusMenu_LL2_displayStatusTable illustrates the methods to call in the naibrd library
 * to retrieve the basic operation configuration states and status states
 * as well as the current LVDT reading for all channels.
 * </summary>
 */
/*****************************************************************************/
static void LVDTStatusMenu_LL2_displayStatusTable(int32_t cardIndex, int32_t module, uint32_t modId)
{
   int32_t MAX_CHANNEL = 0;
   int32_t channel = 0;
   uint32_t positionRaw = 0u;
   uint32_t frequencyRaw = 0u;
   uint32_t sigVoltRaw = 0u;
   uint32_t refVoltRaw = 0u;
   float64_t position = 0.0f;
   float64_t frequency = 0.0f;
   float64_t sigVolt = 0.0f;
   float64_t refVolt = 0.0f;
   nai_status_bit_t bitStatusLatched = NAI_STATUS_BIT_LO;
   uint32_t rawBitStatusLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t refLossLatched = NAI_STATUS_BIT_LO;
   uint32_t rawRefLossLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t sigHiLatched = NAI_STATUS_BIT_LO;
   uint32_t rawSigHiLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t refHiLatched = NAI_STATUS_BIT_LO;
   uint32_t rawRefHiLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t summaryLatched = NAI_STATUS_BIT_LO;
   uint32_t rawSummaryLatched = NAI_STATUS_BIT_LO;
   nai_status_bit_t bitStatusRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawBitStatusRealtime = NAI_STATUS_BIT_LO;
   nai_status_bit_t refLossRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawRefLossRealtime = NAI_STATUS_BIT_LO;
   nai_status_bit_t sigHiRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawSigHiRealtime = NAI_STATUS_BIT_LO;
   nai_status_bit_t refHiRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawRefHiRealtime = NAI_STATUS_BIT_LO;
   nai_status_bit_t summaryRealtime = NAI_STATUS_BIT_LO;
   uint32_t rawSummaryRealtime = NAI_STATUS_BIT_LO;

   MAX_CHANNEL = naibrd_LVDT_GetChannelCount(modId);
   naiif_printf("\r\n\r\n =================================================================\r\n");
   naiif_printf("%5s%12s%12s%12s%12s\r\n", " Chan", "Position", "Freq.", "RefVolt", "SigVolt");
   naiif_printf("%5s%12s%12s%12s%12s\r\n", "", "", "", "", "");
   naiif_printf(" =================================================================\r\n");
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      naiif_printf(" %1d   ", channel);
      if (DisplayAsHex)
      {
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_POSITION, &positionRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_FREQUENCY, &frequencyRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_SIGNAL_VOLTAGE, &sigVoltRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_REF_VOLTAGE, &refVoltRaw));
         naiif_printf("   0x%08X   0x%08X  0x%08X  0x%08X\r\n", positionRaw, frequencyRaw, refVoltRaw, sigVoltRaw);
      }
      else
      {
         check_status(naibrd_LVDT_GetPosition(cardIndex, module, channel, &position));
         check_status(naibrd_LVDT_GetFrequency(cardIndex, module, channel, &frequency));
         check_status(naibrd_LVDT_GetSignalVoltage(cardIndex, module, channel, &sigVolt));
         check_status(naibrd_LVDT_GetRefVoltage(cardIndex, module, channel, &refVolt));
         naiif_printf("  %10.4f%12.4f%12.4f%12.4f\r\n", position, frequency, refVolt, sigVolt);
      }
   }

   naiif_printf("\r\n\r\n ================================================================================\r\n");
   naiif_printf("%6s%6s%10s%8s%8s%9s\r\n", " Chan",
      "  BIT ", " REF LOSS ", " REF HI ", " SIG HI ", " SUMMARY ");
   naiif_printf("%6s%6s%10s%8s%8s%9s\r\n", "",
      "(R/L)", "(R/L)   ", "(R/L)  ", "(R/L)  ", "(R/L)  ");
   naiif_printf(" ================================================================================\r\n");

   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED, &bitStatusLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_REALTIME, &bitStatusRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED, &refLossLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_REALTIME, &refLossRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_LATCHED, &sigHiLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_REALTIME, &sigHiRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_LATCHED, &refHiLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_REALTIME, &refHiRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_LATCHED, &summaryLatched));
      check_status(naibrd_LVDT_GetChanMappedStatus(cardIndex, module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_REALTIME, &summaryRealtime));
      naiif_printf("  %1d    (%1d/%1d)  (%1d/%1d)    (%1d/%1d)   (%1d/%1d)    (%1d/%1d)\r\n", channel,
                   bitStatusRealtime, bitStatusLatched, refLossRealtime, refLossLatched, refHiRealtime, refHiLatched,
                   sigHiRealtime, sigHiLatched, summaryRealtime, summaryLatched);
   }
   naiif_printf("\r\n");
   if (DisplayAsHex)
   {
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED,
         &rawBitStatusLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_REALTIME,
         &rawBitStatusRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED,
         &rawRefLossLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_REALTIME,
         &rawRefLossRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_LATCHED,
         &rawSigHiLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_REALTIME,
         &rawSigHiRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_LATCHED,
         &rawRefHiLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_REALTIME,
         &rawRefHiRealtime));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_LATCHED,
         &rawSummaryLatched));
      check_status(naibrd_LVDT_GetChanMappedStatusRaw(cardIndex, module, NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_REALTIME,
         &rawSummaryRealtime));
      naiif_printf("Raw BIT Status (R/L):     (0x%08X/0x%08X)\r\n", rawBitStatusRealtime, rawBitStatusLatched);
      naiif_printf("Raw Ref Loss (R/L):       (0x%08X/0x%08X)\r\n", rawRefLossRealtime, rawRefLossLatched);
      naiif_printf("Raw Ref Fault High (R/L): (0x%08X/0x%08X)\r\n", rawRefHiRealtime, rawRefHiLatched);
      naiif_printf("Raw Sig Fault High (R/L): (0x%08X/0x%08X)\r\n", rawSigHiRealtime, rawSigHiLatched);
      naiif_printf("Raw Summary Status (R/L): (0x%08X/0x%08X)\r\n", rawSummaryRealtime, rawSummaryLatched);
   }
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTStatusMenu_ClearStatus clears the user-specified LVDT status of the
 * user-specified LVDT channel.
 * </summary>
 */
/*****************************************************************************/
static nai_status_t LVDTStatusMenu_ClearStatus(int32_t paramCount, int32_t* p_params)
{
   uint32_t statnum = 0u;
   bool_t bQuit = NAI_FALSE;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   nai_status_t status = NAI_SUCCESS;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naibrd_LVDT_GetChannelCount(plvdtPara->modId);
      naiif_printf("Select Latch Status Type to be cleared ('0' = BIT, '1' = Signal Loss, '2' = Ref Loss, '3' = Signal High, '4' = Ref High,");
      naiif_printf("'5' = Open, '6' = Short, '7' = Summary, '8' = Delta Position, '9' = All Statuses): ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if ((!bQuit) && (inputResponseCnt > 0))
      {
         statnum = atoi((const char*)inputBuffer);
         if (statnum > 9)
         {
            naiif_printf("\r\nError! Invalid Status Type\r\n");
         }
         else
         {
            if (statnum == 0)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED));
            }
            else if (statnum == 1)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_LOW_LATCHED));
            }
            else if (statnum == 2)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED));
            }
            else if (statnum == 3)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_LATCHED));
            }
            else if (statnum == 4)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_LATCHED));
            }
            else if (statnum == 5)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_OPEN_LATCHED));
            }
            else if (statnum == 6)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_SHORT_LATCHED));
            }
            else if (statnum == 7)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_LATCHED));
            }
            else if (statnum == 8)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_DELTA_POS_LATCHED));
            }
            else if (statnum == 9)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED));
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_LOW_LATCHED));
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED));
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_LATCHED));
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_LATCHED));
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_OPEN_LATCHED));
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_SHORT_LATCHED));
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_LATCHED));
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_DELTA_POS_LATCHED));
            }
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTStatusMenu_ClearStatusAllChannels clears the user-specified LVDT status
 * of all of the LVDT channels.
 * </summary>
 */
/*****************************************************************************/
static nai_status_t LVDTStatusMenu_ClearStatusAllChannels(int32_t paramCount, int32_t* p_params)
{
   uint32_t statnum = 0u;
   bool_t bQuit = NAI_FALSE;
   int32_t MAX_CHANNEL = 0;
   int32_t channel = 0;
   nai_status_t status = NAI_SUCCESS;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   p_naiapp_AppParameters_t plvdtParams = (p_naiapp_AppParameters_t)p_params;
   if (paramCount == APP_PARAM_COUNT)
   {
      MAX_CHANNEL = naibrd_LVDT_GetChannelCount(plvdtParams->modId);
      naiif_printf("Select Latch Status Type to be cleared ('0' = BIT, '1' = Signal Loss, '2' = Ref Loss, '3' = Signal High, '4' = Ref High,");
      naiif_printf("'5' = Open, '6' = Short, '7' = Summary, '8' = Delta Position, '9' = All Statuses): ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if ((!bQuit) && (inputResponseCnt > 0))
      {
         statnum = atoi((const char*)inputBuffer);
         if (statnum > 9)
         {
            naiif_printf("\r\nError! Invalid Status Type\r\n");
         }
         else
         {
            for (channel = 1; channel <= MAX_CHANNEL; channel++)
            {
               if (statnum == 0)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED));
               }
               else if (statnum == 1)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_LOW_LATCHED));
               }
               else if (statnum == 2)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED));
               }
               else if (statnum == 3)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_LATCHED));
               }
               else if (statnum == 4)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_LATCHED));
               }
               else if (statnum == 5)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_OPEN_LATCHED));
               }
               else if (statnum == 6)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_SHORT_LATCHED));
               }
               else if (statnum == 7)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_LATCHED));
               }
               else if (statnum == 8)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_DELTA_POS_LATCHED));
               }
               else if (statnum == 9)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED));
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_LOW_LATCHED));
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED));
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_LATCHED));
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_LATCHED));
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_OPEN_LATCHED));
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_SHORT_LATCHED));
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_LATCHED));
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_DELTA_POS_LATCHED));
               }
            }
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTStatusMenu_LL2_ClearStatus clears the user-specified LVDT status of the
 * user-specified LVDT channel.
 * </summary>
 */
/*****************************************************************************/
static nai_status_t LVDTStatusMenu_LL2_ClearStatus(int32_t paramCount, int32_t* p_params)
{
   uint32_t statnum = 0u;
   bool_t bQuit = NAI_FALSE;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   nai_status_t status = NAI_SUCCESS;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naibrd_LVDT_GetChannelCount(plvdtPara->modId);
      naiif_printf("Select Latch Status Type to be cleared ('0' = BIT, '1' = Ref Loss, '2' = Signal High, '3' = Ref High,");
      naiif_printf("'4' = Summary, '5' = All Statuses): ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if ((!bQuit) && (inputResponseCnt > 0))
      {
         statnum = atoi((const char*)inputBuffer);
         if (statnum > 5)
         {
            naiif_printf("\r\nError! Invalid Status Type\r\n");
         }
         else
         {
            if (statnum == 0)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED));
            }
            else if (statnum == 1)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED));
            }
            else if (statnum == 2)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_LATCHED));
            }
            else if (statnum == 3)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_LATCHED));
            }
            else if (statnum == 4)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_LATCHED));
            }
            else if (statnum == 5)
            {
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED));
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED));
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_LATCHED));
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_LATCHED));
               status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_LATCHED));
            }
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTStatusMenu_LL2_ClearStatusAllChannels clears the user-specified LVDT status
 * of all of the LVDT channels.
 * </summary>
 */
/*****************************************************************************/
static nai_status_t LVDTStatusMenu_LL2_ClearStatusAllChannels(int32_t paramCount, int32_t* p_params)
{
   uint32_t statnum = 0u;
   bool_t bQuit = NAI_FALSE;
   int32_t MAX_CHANNEL = 0;
   int32_t channel = 0;
   nai_status_t status = NAI_SUCCESS;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   p_naiapp_AppParameters_t plvdtParams = (p_naiapp_AppParameters_t)p_params;
   if (paramCount == APP_PARAM_COUNT)
   {
      MAX_CHANNEL = naibrd_LVDT_GetChannelCount(plvdtParams->modId);
      naiif_printf("Select Latch Status Type to be cleared ('0' = BIT, '1' = Ref Loss, '2' = Signal High, '3' = Ref High,");
      naiif_printf("'4' = Summary, '5' = All Statuses): ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if ((!bQuit) && (inputResponseCnt > 0))
      {
         statnum = atoi((const char*)inputBuffer);
         if (statnum > 5)
         {
            naiif_printf("\r\nError! Invalid Status Type\r\n");
         }
         else
         {
            for (channel = 1; channel <= MAX_CHANNEL; channel++)
            {
               if (statnum == 0)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED));
               }
               else if (statnum == 1)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED));
               }
               else if (statnum == 2)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_LATCHED));
               }
               else if (statnum == 3)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_LATCHED));
               }
               else if (statnum == 4)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_LATCHED));
               }
               else if (statnum == 5)
               {
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED));
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_LOW_LATCHED));
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_SIGNAL_FAULT_HIGH_LATCHED));
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_REF_FAULT_HIGH_LATCHED));
                  status = check_status(naibrd_LVDT_ClearChanMappedStatus(plvdtParams->cardIndex, plvdtParams->module, channel,
                     NAIBRD_LVDT_CHAN_MAPPED_STATUS_SUMMARY_LATCHED));
               }
            }
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}
/*END: This section is Status implementation*/

/*Begin: This section is Test implementation*/
static nai_status_t LVDTBasicMenu_Test(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   int32_t MAX_CHANNELS;
   int32_t cmd, CommandCount;
   int32_t channel = 0;
   nai_status_t status = NAI_SUCCESS;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   MAX_CHANNELS = naibrd_LVDT_GetChannelCount(plvdtPara->modId);
   naiapp_utils_LoadParamMenuCommands(LVDT_TESTMENU_CMD_COUNT, LVDT_TestMenuCmds);
   do
   {
      if ((plvdtPara->modId) == NAIBRD_MODULE_ID_LL2)
      {
         LVDTTestMenu_LL2_displayTestTable(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->modId);
         naiapp_display_ParamMenuCommands((int8_t*)"LVDT LL2 Test Menu");
      }
      else
      {
         LVDTTestMenu_displayTestTable(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->modId);
         naiapp_display_ParamMenuCommands((int8_t*)"LVDT Test Menu");
      }
      naiif_printf("\r\n Type command or %c to quit : ", NAI_QUIT_CHAR);
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
         CommandCount = LVDT_TESTMENU_CMD_COUNT;
         if ((cmd >= 0) && (cmd < CommandCount))
         {
            if ((cmd != LVDT_TESTMENU_CMD_ENABLE_D0_TEST) && (cmd != LVDT_TESTMENU_CMD_SET_TEST_POSITION) &&
                (cmd != LVDT_TESTMENU_CMD_ENABLE_D3_TEST))
            {
               naiapp_query_ChannelNumber(MAX_CHANNELS, 1, &channel);
               plvdtPara->channel = channel;
            }

            LVDT_TestMenuCmds[cmd].func(paramCount, p_params);
         }
         else
            naiif_printf(" Invalid command entered\r\n");
      }
      else if (bQuit)
      {
         if ((plvdtPara->modId) == NAIBRD_MODULE_ID_LL2)
         {
            naiapp_utils_LoadParamMenuCommands(LVDT_LL2_BASICMENU_CMD_COUNT, LVDT_LL2_BasicOpMenuCmds);
         }
         else
         {
            naiapp_utils_LoadParamMenuCommands(LVDT_BASICMENU_CMD_COUNT, LVDT_BasicOpMenuCmds);
         }
      }
      else /* if ((inputResponseCnt < 0) && (!bQuit)) */
      {
         naiif_printf("Invalid command entered\r\n");
      }
   } while (!bQuit);
   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTTestMenu_displayTestTable illustrates the methods to call in the naibrd library
 * to retrieve the basic operation configuration states and test states
 * as well as the current LVDT reading for all channels.
 * </summary>
 */
/*****************************************************************************/
static void LVDTTestMenu_displayTestTable(int32_t cardIndex, int32_t module, uint32_t modId)
{
   int32_t MAX_CHANNEL = naibrd_LVDT_GetChannelCount(modId);
   naibrd_lvdt_format_t mode = (naibrd_lvdt_format_t)0;
   int32_t channel = 0;
   uint32_t mask = 0x1u;
   uint32_t positionRaw = 0u;
   uint32_t frequencyRaw = 0u;
   uint32_t sigVoltRaw = 0u;
   uint32_t refVoltRaw = 0u;
   uint32_t testPositionRaw = 0u;
   uint32_t testEnableRaw = 0u;
   float64_t position = 0.0f;
   float64_t frequency = 0.0f;
   float64_t sigVolt = 0.0f;
   float64_t refVolt = 0.0f;
   uint32_t d0TestEnable = 0u;
   uint32_t d3TestEnable = 0u;
   float64_t testPosition = 0.0f;
   char* sD0TestEnable = "";
   char* sD3TestEnable = "";
   naiif_printf("\r\n\r\n=====================================================================\r\n");
   switch (modId)
   {
      case NAIBRD_MODULE_ID_LD1:
      case NAIBRD_MODULE_ID_LD2:
      case NAIBRD_MODULE_ID_LD3:
      case NAIBRD_MODULE_ID_LD4:
      case NAIBRD_MODULE_ID_LD6:
      case NAIBRD_MODULE_ID_LR2:
         naiif_printf("%7s%9s%17s%13s%10s%12s\r\n", "Chan", " Mode", "Position", " Frequency", "RefVolt", " SigVolt");
         break;
      default:
         /* Nothing to do here; all cases already covered */
         break;
   }
   check_status(naibrd_LVDT_GetRaw(cardIndex, module, NAIBRD_LVDT_RAW_TEST_ENABLE, &testEnableRaw));
   d0TestEnable = (testEnableRaw & mask);
   if (d0TestEnable == 0u)
   {
      sD0TestEnable = "DISABLED";
   }
   else /* if (d0TestEnable != 0u) */
   {
      sD0TestEnable = "ENABLED ";
   }
   d3TestEnable = ((testEnableRaw >> 3) & mask);
   if (d3TestEnable == 0u)
   {
      sD3TestEnable = "DISABLED";
   }
   else /* if (d3TestEnable != 0u) */
   {
      sD3TestEnable = "ENABLED ";
   }
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      naiif_printf("%4d", channel);
      check_status(naibrd_LVDT_GetChanMode(cardIndex, module, channel, &mode));
      LVDTBasicMenu_displayMode(mode);
      if (DisplayAsHex)
      {
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_POSITION, &positionRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_FREQUENCY, &frequencyRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_SIGNAL_VOLTAGE, &sigVoltRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_REF_VOLTAGE, &refVoltRaw));
         naiif_printf("        0x%08X  0x%08X  0x%08X  0x%08X\r\n", positionRaw, frequencyRaw, refVoltRaw, sigVoltRaw);
      }
      else
      {
         check_status(naibrd_LVDT_GetPosition(cardIndex, module, channel, &position));
         check_status(naibrd_LVDT_GetFrequency(cardIndex, module, channel, &frequency));
         check_status(naibrd_LVDT_GetSignalVoltage(cardIndex, module, channel, &sigVolt));
         check_status(naibrd_LVDT_GetRefVoltage(cardIndex, module, channel, &refVolt));
         naiif_printf("      %10.4f%12.4f%10.4f %12.4f\r\n", position, frequency, refVolt, sigVolt);
      }
   }
   naiif_printf("\r\n");
   naiif_printf("D0 Test Enable: %s\r\n", sD0TestEnable);
   naiif_printf("D3 Test Enable: %s\r\n", sD3TestEnable);
   if (DisplayAsHex)
   {
      check_status(naibrd_LVDT_GetRaw(cardIndex, module, NAIBRD_LVDT_RAW_TEST_POSITION, &testPositionRaw));
      naiif_printf("Raw Test Position: 0x%08X\r\n", testPositionRaw);
      naiif_printf("Raw Test Enable Register Value: 0x%08X\r\n", testEnableRaw);
   }
   else
   {
      check_status(naibrd_LVDT_GetTestPosition(cardIndex, module, &testPosition));
      naiif_printf("Test Position: %10.4f\r\n", testPosition);
   }
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTTestMenu_LL2_displayTestTable illustrates the methods to call in the naibrd library
 * to retrieve the basic operation configuration states and test states
 * as well as the current LVDT reading for all channels.
 * </summary>
 */
/*****************************************************************************/
static void LVDTTestMenu_LL2_displayTestTable(int32_t cardIndex, int32_t module, uint32_t modId)
{
   int32_t MAX_CHANNEL = naibrd_LVDT_GetChannelCount(modId);
   int32_t channel = 0;
   uint32_t mask = 0x1u;
   uint32_t positionRaw = 0u;
   uint32_t frequencyRaw = 0u;
   uint32_t sigVoltRaw = 0u;
   uint32_t refVoltRaw = 0u;
   uint32_t testPositionRaw = 0u;
   uint32_t testEnableRaw = 0u;
   float64_t position = 0.0f;
   float64_t frequency = 0.0f;
   float64_t sigVolt = 0.0f;
   float64_t refVolt = 0.0f;
   uint32_t d0TestEnable = 0u;
   uint32_t d3TestEnable = 0u;
   float64_t testPosition = 0.0f;
   char* sD0TestEnable = "";
   char* sD3TestEnable = "";
   naiif_printf("\r\n\r\n=====================================================================\r\n");
   naiif_printf("%7s%17s%13s%10s%12s\r\n", "Chan", "Position", " Frequency", "RefVolt", " SigVolt");

   check_status(naibrd_LVDT_GetRaw(cardIndex, module, NAIBRD_LVDT_RAW_TEST_ENABLE, &testEnableRaw));
   d0TestEnable = (testEnableRaw & mask);
   if (d0TestEnable == 0u)
   {
      sD0TestEnable = "DISABLED";
   }
   else /* if (d0TestEnable != 0u) */
   {
      sD0TestEnable = "ENABLED ";
   }
   d3TestEnable = ((testEnableRaw >> 3) & mask);
   if (d3TestEnable == 0u)
   {
      sD3TestEnable = "DISABLED";
   }
   else /* if (d3TestEnable != 0u) */
   {
      sD3TestEnable = "ENABLED ";
   }
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      naiif_printf("%4d", channel);
      if (DisplayAsHex)
      {
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_POSITION, &positionRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_FREQUENCY, &frequencyRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_SIGNAL_VOLTAGE, &sigVoltRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_REF_VOLTAGE, &refVoltRaw));
         naiif_printf("           0x%08X  0x%08X  0x%08X  0x%08X\r\n", positionRaw, frequencyRaw, refVoltRaw, sigVoltRaw);
      }
      else
      {
         check_status(naibrd_LVDT_GetPosition(cardIndex, module, channel, &position));
         check_status(naibrd_LVDT_GetFrequency(cardIndex, module, channel, &frequency));
         check_status(naibrd_LVDT_GetSignalVoltage(cardIndex, module, channel, &sigVolt));
         check_status(naibrd_LVDT_GetRefVoltage(cardIndex, module, channel, &refVolt));
         naiif_printf("          %10.4f%12.4f %10.4f%12.4f\r\n", position, frequency, refVolt, sigVolt);
      }
   }
   naiif_printf("\r\n");
   naiif_printf("D0 Test Enable: %s\r\n", sD0TestEnable);
   naiif_printf("D3 Test Enable: %s\r\n", sD3TestEnable);
   if (DisplayAsHex)
   {
      check_status(naibrd_LVDT_GetRaw(cardIndex, module, NAIBRD_LVDT_RAW_TEST_POSITION, &testPositionRaw));
      naiif_printf("Raw Test Position: 0x%08X\r\n", testPositionRaw);
      naiif_printf("Raw Test Enable Register Value: 0x%08X\r\n", testEnableRaw);
   }
   else
   {
      check_status(naibrd_LVDT_GetTestPosition(cardIndex, module, &testPosition));
      naiif_printf("Test Position: %10.4f\r\n", testPosition);
   }
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTTestMenu_SetTestPosition sets the test position of the LVDT module to
 * the user-specified value.
 * </summary>
 */
/*****************************************************************************/
static nai_status_t LVDTTestMenu_SetTestPosition(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   float64_t position;
   uint32_t rawPosition = 0u;
   nai_status_t status = NAI_SUCCESS;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   p_naiapp_AppParameters_t plvdtParas = (p_naiapp_AppParameters_t)p_params;
   if (paramCount == APP_PARAM_COUNT)
   {
      if (DisplayAsHex)
      {
         naiif_printf("Type Raw Hex Test Position value to set: ");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if ((!bQuit) && (inputResponseCnt > 0))
         {
            rawPosition = (uint32_t)(strtol((const char*)inputBuffer, NULL, 16));
            status = check_status(naibrd_LVDT_SetRaw(plvdtParas->cardIndex, plvdtParas->module, NAIBRD_LVDT_RAW_TEST_POSITION,
               rawPosition));
         }
      }
      else
      {
         naiif_printf("Type Test Position floating-point value to set: ");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if ((!bQuit) && (inputResponseCnt > 0))
         {
            position = atof((const char*)inputBuffer);
            status = check_status(naibrd_LVDT_SetTestPosition(plvdtParas->cardIndex, plvdtParas->module, position));
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTTestMenu_SetD0TestEnable sets the enabled/disabled state
 * of the D0 Test to the user-specified setting.
 * </summary>
 */
/*****************************************************************************/
static nai_status_t LVDTTestMenu_SetD0TestEnable(int32_t paramCount, int32_t* p_params)
{
   uint32_t enableNum = 0u;
   nai_status_t status = NAI_SUCCESS;
   uint32_t valueToSet = 0u;
   uint32_t enableChannelMask = 0x1u;
   uint32_t disableChannelMask = ~(enableChannelMask);
   p_naiapp_AppParameters_t plvdtParas = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naibrd_LVDT_GetChannelCount(plvdtParas->modId);
      naiif_printf("Type D0 Test Enable Setting to set ('0' = DISABLE, '1' = ENABLE): ");
      naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      enableNum = atoi((const char*)inputBuffer);
      if (enableNum > 1)
      {
         naiif_printf("\r\nError! Invalid Test Enable Setting\r\n");
      }
      else
      {
         status = check_status(naibrd_LVDT_GetRaw(plvdtParas->cardIndex, plvdtParas->module, NAIBRD_LVDT_RAW_TEST_ENABLE, &valueToSet));
         if (enableNum == 0)
         {
            valueToSet &= disableChannelMask;
            status = check_status(naibrd_LVDT_SetRaw(plvdtParas->cardIndex, plvdtParas->module, NAIBRD_LVDT_RAW_TEST_ENABLE, valueToSet));
         }
         else /* if (enableNum == 1) */
         {
            valueToSet |= enableChannelMask;
            status = check_status(naibrd_LVDT_SetRaw(plvdtParas->cardIndex, plvdtParas->module, NAIBRD_LVDT_RAW_TEST_ENABLE, valueToSet));
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTTestMenu_SetD3TestEnable sets the enabled/disabled state
 * of the D3 Test to the user-specified setting.
 * </summary>
 */
/*****************************************************************************/
static nai_status_t LVDTTestMenu_SetD3TestEnable(int32_t paramCount, int32_t* p_params)
{
   uint32_t enableNum = 0u;
   nai_status_t status = NAI_SUCCESS;
   uint32_t valueToSet = 0u;
   uint32_t enableChannelMask = 0x8u;
   uint32_t disableChannelMask = ~(enableChannelMask);
   p_naiapp_AppParameters_t plvdtParas = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naibrd_LVDT_GetChannelCount(plvdtParas->modId);
      naiif_printf("Type D3 Test Enable Setting to set ('0' = DISABLE, '1' = ENABLE): ");
      naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      enableNum = atoi((const char*)inputBuffer);
      if (enableNum > 1)
      {
         naiif_printf("\r\nError! Invalid Test Enable Setting\r\n");
      }
      else
      {
         status = check_status(naibrd_LVDT_GetRaw(plvdtParas->cardIndex, plvdtParas->module, NAIBRD_LVDT_RAW_TEST_ENABLE, &valueToSet));
         if (enableNum == 0)
         {
            valueToSet &= disableChannelMask;
            status = check_status(naibrd_LVDT_SetRaw(plvdtParas->cardIndex, plvdtParas->module, NAIBRD_LVDT_RAW_TEST_ENABLE, valueToSet));
         }
         else /* if (enableNum == 1) */
         {
            valueToSet |= enableChannelMask;
            status = check_status(naibrd_LVDT_SetRaw(plvdtParas->cardIndex, plvdtParas->module, NAIBRD_LVDT_RAW_TEST_ENABLE, valueToSet));
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTTestMenu_CheckPowerOnBIT() Checks to see if the power-on BIT test
 * has been run on the module. If the PBIT test has run, it checks the result
 * of the test and reports it back.
 * </summary>
 */
/*****************************************************************************/
static nai_status_t LVDTTestMenu_CheckPowerOnBIT(int32_t paramCount, int32_t* p_params)
{
   nai_status_t status = NAI_SUCCESS;
   int32_t channelCount = 0;
   int32_t channel = 0;
   bool_t pbitComplete;
   nai_status_bit_t bitFailed;
   p_naiapp_AppParameters_t plvdtParas = (p_naiapp_AppParameters_t)p_params;
   if (paramCount == APP_PARAM_COUNT)
   {
      switch (plvdtParas->modId)
      {
         case NAIBRD_MODULE_ID_LD2:
         {
            channelCount = naibrd_LVDT_GetChannelCount(plvdtParas->modId);

            /* Check to see if PBIT ran for the module. */
            naiif_printf("Checking if the Power-On BIT test has run...\r\n");
            status = naibrd_LVDT_CheckPowerOnBITComplete(plvdtParas->cardIndex, plvdtParas->module, &pbitComplete);
            naiif_printf("PBIT Complete: %s", (pbitComplete) ? "COMPLETED\r\n" : "NOT COMPLETED\r\n");

            if (pbitComplete)
            {
               /* Read the BIT status */
               naiif_printf("Checking the result of the Power-on BIT test...\r\n");
               for (channel = 1; channel <= channelCount; channel++)
               {
                  status = naibrd_LVDT_GetChanMappedStatus(plvdtParas->cardIndex, plvdtParas->module, channel, NAIBRD_LVDT_CHAN_MAPPED_STATUS_BIT_LATCHED,
                     &bitFailed);
                  naiif_printf("Ch. %d: %s", channel, bitFailed ? "BIT FAILED\r\n" : "BIT Passed\r\n");
               }
            }

         }
         break;
         default:
            naiif_printf("\r\n\r\n*** This feature is not supported by this module.***\r\n");
            status = NAI_ERROR_NOT_SUPPORTED;
            break;
      }
   }
   return status;
}
/*END: This section is Test implementation*/

/*BEGIN: This section is for hex display implementation*/
static nai_status_t LVDTBasicMenu_Hex(int32_t paramCount, int32_t* p_params)
{
   nai_status_t status = NAI_SUCCESS;
   bool_t bQuit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   p_params = NULL;
   if (paramCount == APP_PARAM_COUNT)
   {
      naiif_printf("Display in Hex: [0 (No) or 1 (Yes)]");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         DisplayAsHex = NAI_FALSE;
         if (inputBuffer[0] == '1')
         {
            DisplayAsHex = NAI_TRUE;
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}
/*END: This section is for hex display implementation*/

/*BEGIN: This section is for Operation Function Implementation*/
static nai_status_t LVDTBasicMenu_Operation(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   int32_t MAX_CHANNELS = 0;
   int32_t cmd, CommandCount;
   int32_t channel = 0;
   nai_status_t status = NAI_SUCCESS;
   p_naiapp_AppParameters_t plvdtParas = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   MAX_CHANNELS = naibrd_LVDT_GetChannelCount(plvdtParas->modId);
   naiapp_utils_LoadParamMenuCommands(LVDT_OPERATION_CMD_COUNT, LVDT_OperationMenuCmds);
   do
   {
      LVDTBasicMenu_displayOperation(plvdtParas->cardIndex, plvdtParas->module, plvdtParas->modId);
      naiapp_display_ParamMenuCommands((int8_t*)"LVDT Operation Menu");
      naiif_printf("\r\n Type command or %c to quit : ", NAI_QUIT_CHAR);
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
         CommandCount = LVDT_OPERATION_CMD_COUNT;
         if ((cmd >= 0) && (cmd < CommandCount))
         {
            naiapp_query_ChannelNumber(MAX_CHANNELS, 1, &channel);
            plvdtParas->channel = channel;
            LVDT_OperationMenuCmds[cmd].func(paramCount, p_params);
         }
         else
            naiif_printf(" Invalid command entered\r\n");
      }
      else if (bQuit)
      {
         naiapp_utils_LoadParamMenuCommands(LVDT_BASICMENU_CMD_COUNT, LVDT_BasicOpMenuCmds);
      }
      else /* if ((inputResponseCnt < 0) && (!bQuit)) */
      {
         naiif_printf("Invalid command entered\r\n");
      }
   } while (!bQuit);
   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTBasicMenu_displayOperation illustrates the methods to call in the naibrd library
 * to retrieve the basic operation status of the lvdt reading for all channels.
 * Items:  GetPosition
 *         GetRefFreq
 *         GetRefVoltage
 *         GetSigVoltage
 *         GetLatch
 * </summary>
 */
/*****************************************************************************/
static void LVDTBasicMenu_displayOperation(int32_t cardIndex, int32_t module, uint32_t modId)
{
   uint8_t msg[MSG_LENGTH];
   int32_t channel, MAX_CHANNEL = naibrd_LVDT_GetChannelCount(modId);
   naibrd_lvdt_format_t mode;
   uint32_t positionRaw = 0u;
   uint32_t frequencyRaw = 0u;
   uint32_t sigVoltRaw = 0u;
   uint32_t refVoltRaw = 0u;
   uint32_t latchRaw = 0u;
   uint32_t latch = 0u;
   float64_t position = 0.0;
   float64_t frequency = 0.0;
   float64_t sigvolt = 0.0;
   float64_t refvolt = 0.0;
   naiif_printf("*** The latch register will be un-latched when the position is read from the board. ***");
   naiif_printf("\r\n\r\n ========================================================================================================\r\n");
   switch (modId)
   {
      case NAIBRD_MODULE_ID_LD1:
      case NAIBRD_MODULE_ID_LD2:
      case NAIBRD_MODULE_ID_LD3:
      case NAIBRD_MODULE_ID_LD4:
      case NAIBRD_MODULE_ID_LD6:
      case NAIBRD_MODULE_ID_LR2:
      {
         naiif_printf("%5s%14s%17s%17s%17s%17s%17s\r\n", " Chan", "        Mode  ", "Position", "Frequency", "RefVolt", "SigVolt", "Latch");
      }
      break;
      default:
         break;
   }

   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      naiif_printf(" %1d   ", channel);
      check_status(naibrd_LVDT_GetChanMode(cardIndex, module, channel, &mode));
      LVDTBasicMenu_displayMode(mode);
      if (DisplayAsHex)
      {

         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_FREQUENCY, &frequencyRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_SIGNAL_VOLTAGE, &sigVoltRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_REF_VOLTAGE, &refVoltRaw));
         check_status(naibrd_LVDT_GetRaw(cardIndex, module, NAIBRD_LVDT_RAW_LATCH, &latchRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_POSITION, &positionRaw));
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", positionRaw);
         naiif_printf("  %17s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%X", "0x", frequencyRaw);
         naiif_printf("%14s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%X", "0x", refVoltRaw);
         naiif_printf("%17s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%X", "0x", sigVoltRaw);
         naiif_printf("%17s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%X", "0x", latchRaw);
         naiif_printf("%17s", msg);
      }
      else
      {
         check_status(naibrd_LVDT_GetFrequency(cardIndex, module, channel, &frequency));
         check_status(naibrd_LVDT_GetSignalVoltage(cardIndex, module, channel, &sigvolt));
         check_status(naibrd_LVDT_GetRefVoltage(cardIndex, module, channel, &refvolt));
         check_status(naibrd_LVDT_GetLatch(cardIndex, module, channel, &latch));
         check_status(naibrd_LVDT_GetPosition(cardIndex, module, channel, &position));
         naiif_printf("%17.4f%17.4f%17.4f%17.4f%16d", position, frequency, refvolt, sigvolt, latch);
      }
      naiif_printf("\r\n");
   }
}

static nai_status_t LVDT_Operation_SetLatch(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_SUCCESS;
   uint32_t latchRaw = 0;
   uint32_t latch = 0;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naibrd_LVDT_GetChannelCount(plvdtPara->modId);
      if (DisplayAsHex)
      {
         naiif_printf("Set Latch in Hex [0x0 = Un-latch, 0x1 = Latch]");
      }
      else
      {
         naiif_printf("Set Latch: [0 = Un-latch, 1 = Latch]");
      }
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         if (DisplayAsHex)
         {
            latchRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
            status = check_status(naibrd_LVDT_SetRaw(plvdtPara->cardIndex, plvdtPara->module, NAIBRD_LVDT_RAW_LATCH, latchRaw));
         }
         else
         {
            latch = atoi((const char*)inputBuffer);
            if (latch > 1)
            {
               naiif_printf("\r\n Invalid Latch Entry");
            }
            else
            {
               status = check_status(naibrd_LVDT_SetLatch(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel, latch));
            }
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}
/*END: This section is for Operation Function Implementation*/

/*BEGIN: This section is for Configuration Function Implementation*/
static nai_status_t LVDTBasicMenu_Configuration(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   int32_t MAX_CHANNELS = 0;
   int32_t cmd, CommandCount;
   int32_t channel = 0;
   nai_status_t status = NAI_SUCCESS;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   MAX_CHANNELS = naibrd_LVDT_GetChannelCount(plvdtPara->modId);
   naiapp_utils_LoadParamMenuCommands(LVDT_CONFIG_CMD_COUNT, LVDT_ConfigurationMenuCmds);
   do
   {
      LVDTBasicMenu_displayConfigTable(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->modId);
      naiapp_display_ParamMenuCommands((int8_t*)"LVDT Configuration Menu");
      naiif_printf("\r\n Type command or %c to quit : ", NAI_QUIT_CHAR);
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
         CommandCount = LVDT_CONFIG_CMD_COUNT;
         if ((cmd >= 0) && (cmd < CommandCount))
         {
            naiapp_query_ChannelNumber(MAX_CHANNELS, 1, &channel);
            plvdtPara->channel = channel;
            LVDT_ConfigurationMenuCmds[cmd].func(paramCount, p_params);
         }
         else
            naiif_printf(" Invalid command entered\r\n");
      }
      else if (bQuit)
      {
         naiapp_utils_LoadParamMenuCommands(LVDT_BASICMENU_CMD_COUNT, LVDT_BasicOpMenuCmds);
      }
      else /* if ((inputResponseCnt < 0) && (!bQuit)) */
      {
         naiif_printf("Invalid command entered\r\n");
      }
   } while (!bQuit);
   return status;
}

static nai_status_t LVDTBasicMenu_LL2_Configuration(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   int32_t MAX_CHANNELS = 0;
   int32_t cmd, CommandCount;
   int32_t channel = 0;
   nai_status_t status = NAI_SUCCESS;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   MAX_CHANNELS = naibrd_LVDT_GetChannelCount(plvdtPara->modId);
   naiapp_utils_LoadParamMenuCommands(LVDT_LL2_CONFIG_CMD_COUNT, LVDT_LL2_ConfigurationMenuCmds);
   do
   {
      LVDTBasicMenu_LL2_displayConfigTable(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->modId);
      naiapp_display_ParamMenuCommands((int8_t*)"LVDT LL2 Configuration Menu");
      naiif_printf("\r\n Type command or %c to quit : ", NAI_QUIT_CHAR);
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if ((!bQuit) && (inputResponseCnt > 0))
      {
         naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
         CommandCount = LVDT_LL2_CONFIG_CMD_COUNT;
         if ((cmd >= 0) && (cmd < CommandCount))
         {
            naiapp_query_ChannelNumber(MAX_CHANNELS, 1, &channel);
            plvdtPara->channel = channel;
            LVDT_LL2_ConfigurationMenuCmds[cmd].func(paramCount, p_params);
         }
         else
            naiif_printf(" Invalid command entered\r\n");
      }
      else if (bQuit)
      {
         naiapp_utils_LoadParamMenuCommands(LVDT_LL2_BASICMENU_CMD_COUNT, LVDT_LL2_BasicOpMenuCmds);
      }
      else /* if ((inputResponseCnt <= 0) && (!bQuit)) */
      {
         naiif_printf("Invalid command entered\r\n");
      }
   } while (!bQuit);
   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTBasicMenu_displayConfigTable illustrates the methods to call in the naibrd
 * library to retrieve the configuration data of the LVDT for all channels.
 * Items:  GetChanMode
 *         GetPosition
 *         GetRefFreq
 *         GetRefVoltage
 *         GetSigVoltage
 *         GetChannelCount
 *         GetChanStatusEnable
 *         GetSigLossThreshold
 *         GetRefLossThreshold
 *         GetBandwidth
 *         GetBandwidthSelect
 *         GetLVDTScale
 * </summary>
 */
/*****************************************************************************/
static void LVDTBasicMenu_displayConfigTable(int32_t cardIndex, int32_t module, uint32_t modId)
{
   uint8_t msg[MSG_LENGTH];
   uint8_t strInvVaCtrl[MSG_LENGTH];
   uint8_t strInvVbCtrl[MSG_LENGTH];
   uint8_t strInvRefCtrl[MSG_LENGTH];
   uint8_t strInvVaVbCtrl[SIG_INV_MSG_LENGTH];
   int32_t channel = 0;
   int32_t MAX_CHANNEL = naibrd_LVDT_GetChannelCount(modId);
   naibrd_lvdt_format_t mode;
   uint32_t positionRaw = 0u;
   uint32_t frequencyRaw = 0u;
   uint32_t sigVoltRaw = 0u;
   uint32_t refVoltRaw = 0u;
   uint32_t chanStatEnabRaw = 0u;
   uint32_t refLoThresRaw = 0u;
   uint32_t sigLoThresRaw = 0u;
   uint32_t refHiThresRaw = 0u;
   uint32_t sigHiThresRaw = 0u;
   uint32_t openThresRaw = 0u;
   uint32_t shortThresRaw = 0u;
   uint32_t bandWidthRaw = 0u;
   float64_t position = 0.0;
   float64_t frequency = 0.0;
   float64_t sigVolt = 0.0;
   float64_t refVolt = 0.0;
   bool_t chanStatEnab = 0u;
   float64_t sigLoThres = 0.0;
   float64_t refLoThres = 0.0;
   float64_t sigHiThres = 0.0;
   float64_t refHiThres = 0.0;
   float64_t openThres = 0.0;
   float64_t shortThres = 0.0;
   uint32_t bandWidth = 0u;
   uint32_t lvdtScale = 0u;
   naibrd_lvdt_signal_inversion_resp_value_type_t invVaCtrl = NAIBRD_LVDT_RESP_NON_INVERTED_VA;
   naibrd_lvdt_signal_inversion_resp_value_type_t invVbCtrl = NAIBRD_LVDT_RESP_NON_INVERTED_VB;
   naibrd_lvdt_signal_inversion_resp_value_type_t invRefCtrl = NAIBRD_LVDT_RESP_NON_INVERTED_REF;
   naibrd_lvdt_signal_inversion_resp_value_type_t invVaVbCtrl = NAIBRD_LVDT_RESP_DIFF_VA_VB;
   uint32_t channelMask = 0u;
   const char* sChanStatEnab = "";
   const char* sBwSelect = "";
   naibrd_lvdt_bandwidth_select_t bwSelect;
   naiif_printf("\r\n\r\n =================================================================================================================== \r\n");
   switch (modId)
   {
      case NAIBRD_MODULE_ID_LD1:
      case NAIBRD_MODULE_ID_LD2:
      case NAIBRD_MODULE_ID_LD3:
      case NAIBRD_MODULE_ID_LD4:
      case NAIBRD_MODULE_ID_LD6:
      case NAIBRD_MODULE_ID_LR2:
      {
         naiif_printf("%5s%9s%14s%14s%10s%11s%20s%11s%11s%8s\r\n", "Chan", " Mode", "Position", "Frequency", "RefVolt", " SigVolt",
            "Chan Stat Enable", " Bandwidth", " BW Select", "Scale");
         naiif_printf(" =================================================================================================================== \r\n");
      }
      break;
      default:
         break;
   }
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      channelMask = 0x1u << (((uint32_t)(channel)) - 1u);
      naiif_printf(" %1d", channel);
      check_status(naibrd_LVDT_GetChanMode(cardIndex, module, channel, &mode));
      LVDTBasicMenu_displayMode(mode);
      if (DisplayAsHex)
      {
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_POSITION, &positionRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_FREQUENCY, &frequencyRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_SIGNAL_VOLTAGE, &sigVoltRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_REF_VOLTAGE, &refVoltRaw));
         check_status(naibrd_LVDT_GetRaw(cardIndex, module, NAIBRD_LVDT_RAW_ACTIVE_CHANNELS, &chanStatEnabRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_BANDWIDTH, &bandWidthRaw));
         check_status(naibrd_LVDT_GetBandwidthSelect(cardIndex, module, channel, &bwSelect));
         check_status(naibrd_LVDT_GetLVDTScale(cardIndex, module, channel, &lvdtScale));
         chanStatEnabRaw &= channelMask;
         chanStatEnabRaw >>= (((uint32_t)(channel)) - 1u);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", positionRaw);
         naiif_printf("%14s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", frequencyRaw);
         naiif_printf("%14s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", refVoltRaw);
         naiif_printf("%12s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", sigVoltRaw);
         naiif_printf("%11s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%01X", "0x", chanStatEnabRaw);
         naiif_printf("%10s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", bandWidthRaw);
         naiif_printf("%19s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%01X", "0x", ((uint32_t)(bwSelect)));
         naiif_printf("%7s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", lvdtScale);
         naiif_printf("%15s", msg);
      }
      else
      {
         check_status(naibrd_LVDT_GetFrequency(cardIndex, module, channel, &frequency));
         check_status(naibrd_LVDT_GetSignalVoltage(cardIndex, module, channel, &sigVolt));
         check_status(naibrd_LVDT_GetRefVoltage(cardIndex, module, channel, &refVolt));
         check_status(naibrd_LVDT_GetPosition(cardIndex, module, channel, &position));
         check_status(naibrd_LVDT_GetChanStatusEnable(cardIndex, module, channel, &chanStatEnab));
         if (chanStatEnab == NAI_FALSE)
         {
            sChanStatEnab = "DISABLED";
         }
         else
         {
            sChanStatEnab = "ENABLED ";
         }
         check_status(naibrd_LVDT_GetBandwidth(cardIndex, module, channel, &bandWidth));
         check_status(naibrd_LVDT_GetBandwidthSelect(cardIndex, module, channel, &bwSelect));
         if (((uint32_t)(bwSelect)) == 0u)
         {
            sBwSelect = " MANUAL  ";
         }
         else
         {
            sBwSelect = "AUTOMATIC";
         }
         check_status(naibrd_LVDT_GetLVDTScale(cardIndex, module, channel, &lvdtScale));
         naiif_printf("%12.4f%13.4f%12.4f %9.4f         %s      %08d   %s  %08u", position, frequency, refVolt, sigVolt,
            sChanStatEnab, bandWidth, sBwSelect, lvdtScale);
      }
      naiif_printf("\r\n");
   }
   switch (modId)
   {
      case NAIBRD_MODULE_ID_LD1:
      case NAIBRD_MODULE_ID_LD2:
      case NAIBRD_MODULE_ID_LD3:
      case NAIBRD_MODULE_ID_LD4:
      case NAIBRD_MODULE_ID_LD6:
      case NAIBRD_MODULE_ID_LR2:
      {
         naiif_printf("\r\n\r\n ============================================================================================================================= \r\n");
         naiif_printf("%5s%20s%20s%20s%20s%20s%20s\r\n", "Chan", "Ref Loss Threshold", "Sig Loss Threshold", "Ref Hi Threshold",
                      "Sig Hi Threshold", "Open Threshold", "Short Threshold");
         naiif_printf(" ============================================================================================================================= \r\n");
      }
      break;
      default:
         break;
   }
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      channelMask = 0x1u << (((uint32_t)(channel)) - 1u);
      naiif_printf(" %1d", channel);
      if (DisplayAsHex)
      {
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_SIG_FAULT_LOW_THRESHOLD, &sigLoThresRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_REF_FAULT_LOW_THRESHOLD, &refLoThresRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_SIG_FAULT_HIGH_THRESHOLD, &sigHiThresRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_REF_FAULT_HIGH_THRESHOLD, &refHiThresRaw));
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", refLoThresRaw);
         naiif_printf("      %17s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", sigLoThresRaw);
         naiif_printf("%20s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", refHiThresRaw);
         naiif_printf("%20s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", sigHiThresRaw);
         naiif_printf("%20s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", openThresRaw);
         naiif_printf("%20s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", shortThresRaw);
         naiif_printf("%20s\r\n", msg);
      }
      else
      {
         check_status(naibrd_LVDT_GetThreshold(cardIndex, module, channel, NAIBRD_LVDT_REF_FAULT_LO_THRESHOLD, &refLoThres));
         check_status(naibrd_LVDT_GetThreshold(cardIndex, module, channel, NAIBRD_LVDT_SIG_FAULT_LO_THRESHOLD, &sigLoThres));
         check_status(naibrd_LVDT_GetThreshold(cardIndex, module, channel, NAIBRD_LVDT_REF_FAULT_HI_THRESHOLD, &refHiThres));
         check_status(naibrd_LVDT_GetThreshold(cardIndex, module, channel, NAIBRD_LVDT_SIG_FAULT_HI_THRESHOLD, &sigHiThres));
         check_status(naibrd_LVDT_GetThreshold(cardIndex, module, channel, NAIBRD_LVDT_OPEN_THRESHOLD, &openThres));
         check_status(naibrd_LVDT_GetThreshold(cardIndex, module, channel, NAIBRD_LVDT_SHORT_THRESHOLD, &shortThres));
         naiif_printf("   %20.6f%20.6f%20.6f%20.6f%20.6f%20.6f\r\n", refLoThres, sigLoThres, refHiThres, sigHiThres, openThres, shortThres);
      }
   }
   switch (modId)
   {
      case NAIBRD_MODULE_ID_LD1:
      case NAIBRD_MODULE_ID_LD2:
      case NAIBRD_MODULE_ID_LD3:
      case NAIBRD_MODULE_ID_LD4:
      case NAIBRD_MODULE_ID_LD6:
      case NAIBRD_MODULE_ID_LR2:
      {
         naiif_printf("\r\n\r\n ============================================================================================ \r\n");
         naiif_printf("%7s%17s%14s%15s%15s\r\n", "Chan", "Invert Va", "Invert Vb", "Invert Ref", "Invert Va-Vb");
         naiif_printf("%7s%16s%14s%14s%14s\r\n", "", "Control", "Control", "Control", "Control");
         naiif_printf(" ============================================================================================ \r\n");
      }
      break;
      default:
         break;
   }
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      naiif_printf("%4d    ", channel);
      check_status(naibrd_LVDT_GetSignalInversion(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_INV_VA, &invVaCtrl));
      switch (invVaCtrl)
      {
         case NAIBRD_LVDT_RESP_NON_INVERTED_VA:
            memset(strInvVaCtrl, 0, sizeof(strInvVaCtrl));
            naiif_snprintf((char*)strInvVaCtrl, MSG_LENGTH + 1, "Non-Inverted");
         break;
         case NAIBRD_LVDT_RESP_INVERTED_VA:
            memset(strInvVaCtrl, 0, sizeof(strInvVaCtrl));
            naiif_snprintf((char*)strInvVaCtrl, MSG_LENGTH + 1, "  Inverted  ");
         break;
         default:
            memset(strInvVaCtrl, 0, sizeof(strInvVaCtrl));
            naiif_snprintf((char*)strInvVaCtrl, MSG_LENGTH + 1, "  Unknown   ");
         break;
      }
      check_status(naibrd_LVDT_GetSignalInversion(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_INV_VB, &invVbCtrl));
      switch (invVbCtrl)
      {
         case NAIBRD_LVDT_RESP_NON_INVERTED_VB:
            memset(strInvVbCtrl, 0, sizeof(strInvVbCtrl));
            naiif_snprintf((char*)strInvVbCtrl, MSG_LENGTH + 1, "Non-Inverted");
         break;
         case NAIBRD_LVDT_RESP_INVERTED_VB:
            memset(strInvVbCtrl, 0, sizeof(strInvVbCtrl));
            naiif_snprintf((char*)strInvVbCtrl, MSG_LENGTH + 1, "  Inverted  ");
         break;
         default:
            memset(strInvVbCtrl, 0, sizeof(strInvVbCtrl));
            naiif_snprintf((char*)strInvVbCtrl, MSG_LENGTH + 1, "  Unknown   ");
         break;
      }
      check_status(naibrd_LVDT_GetSignalInversion(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_INV_REF, &invRefCtrl));
      switch (invRefCtrl)
      {
         case NAIBRD_LVDT_RESP_NON_INVERTED_REF:
            memset(strInvRefCtrl, 0, sizeof(strInvRefCtrl));
            naiif_snprintf((char*)strInvRefCtrl, MSG_LENGTH + 1, "Non-Inverted");
         break;
         case NAIBRD_LVDT_RESP_INVERTED_REF:
            memset(strInvRefCtrl, 0, sizeof(strInvRefCtrl));
            naiif_snprintf((char*)strInvRefCtrl, MSG_LENGTH + 1, "  Inverted  ");
         break;
         default:
            memset(strInvRefCtrl, 0, sizeof(strInvRefCtrl));
            naiif_snprintf((char*)strInvRefCtrl, MSG_LENGTH + 1, "  Unknown   ");
         break;
      }
      check_status(naibrd_LVDT_GetSignalInversion(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_INV_DIFF, &invVaVbCtrl));
      switch (invVaVbCtrl)
      {
         case NAIBRD_LVDT_RESP_DIFF_VA_VB:
            memset(strInvVaVbCtrl, 0, sizeof(strInvVaVbCtrl));
            naiif_snprintf((char*)strInvVaVbCtrl, SIG_INV_MSG_LENGTH + 1, "Non-Inverted ((Va - Vb) / (Va + Vb))");
         break;
         case NAIBRD_LVDT_RESP_DIFF_VB_VA:
            memset(strInvVaVbCtrl, 0, sizeof(strInvVaVbCtrl));
            naiif_snprintf((char*)strInvVaVbCtrl, SIG_INV_MSG_LENGTH + 1, "Inverted ((Vb - Va) / (Va + Vb))    ");
         break;
         default:
            memset(strInvVaVbCtrl, 0, sizeof(strInvVaVbCtrl));
            naiif_snprintf((char*)strInvVaVbCtrl, SIG_INV_MSG_LENGTH + 1, "  Unknown                           ");
         break;
      }
      naiif_printf("      %12s  %12s  %12s  %-37s\r\n", strInvVaCtrl, strInvVbCtrl, strInvRefCtrl, strInvVaVbCtrl);
   }
   if (DisplayAsHex)
   {
      naiif_printf("Module Channel Count: 0x%02X", MAX_CHANNEL);
   }
   else
   {
      naiif_printf("Module Channel Count: %d", MAX_CHANNEL);
   }
}

/*****************************************************************************/
/**
 * <summary>
 * LVDTBasicMenu_LL2_displayConfigTable illustrates the methods to call in the naibrd
 * library to retrieve the configuration data of the LVDT for all channels.
 * Items:  GetPosition
 *         GetRefFreq
 *         GetRefVoltage
 *         GetSigVoltage
 *         GetChannelCount
 *         GetChanStatusEnable
 *         GetRefLossThreshold
 *         GetBandwidth
 *         GetBandwidthSelect
 * </summary>
 */
/*****************************************************************************/
static void LVDTBasicMenu_LL2_displayConfigTable(int32_t cardIndex, int32_t module, uint32_t modId)
{
   uint8_t msg[MSG_LENGTH];
   uint8_t strInvVaCtrl[MSG_LENGTH];
   uint8_t strInvRefCtrl[MSG_LENGTH];
   int32_t channel = 0;
   uint32_t positionRaw = 0u;
   uint32_t frequencyRaw = 0u;
   uint32_t sigVoltRaw = 0u;
   uint32_t refVoltRaw = 0u;
   uint32_t chanStatEnabRaw = 0u;
   uint32_t refLoThresRaw = 0u;
   uint32_t refHiThresRaw = 0u;
   uint32_t sigHiThresRaw = 0u;
   uint32_t bandWidthRaw = 0u;
   float64_t position = 0.0;
   float64_t frequency = 0.0;
   float64_t sigVolt = 0.0;
   float64_t refVolt = 0.0;
   uint32_t trValue = 0u;
   bool_t chanStatEnab = 0u;
   float64_t refLoThres = 0.0;
   float64_t sigHiThres = 0.0;
   float64_t refHiThres = 0.0;
   uint32_t bandWidth = 0u;
   naibrd_lvdt_signal_inversion_resp_value_type_t invVaCtrl = NAIBRD_LVDT_RESP_NON_INVERTED_VA;
   naibrd_lvdt_signal_inversion_resp_value_type_t invRefCtrl = NAIBRD_LVDT_RESP_NON_INVERTED_REF;
   uint32_t channelMask = 0u;
   const char* sChanStatEnab = "";
   const char* sBwSelect = "";
   naibrd_lvdt_bandwidth_select_t bwSelect;
   int32_t MAX_CHANNEL = naibrd_LVDT_GetChannelCount(modId);

   naiif_printf("\r\n\r\n =================================================================================================================== \r\n");
   naiif_printf("%5s%14s%14s%10s%11s%11s%20s%11s%11s\r\n", "Chan", "Position", "Frequency", "RefVolt", " SigVolt", "TR Value",
                "Chan Stat Enable", " Bandwidth", " BW Select");
   naiif_printf(" =================================================================================================================== \r\n");
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      channelMask = 0x1u << (((uint32_t)(channel)) - 1u);
      naiif_printf(" %1d   ", channel);
      if (DisplayAsHex)
      {
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_POSITION, &positionRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_FREQUENCY, &frequencyRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_SIGNAL_VOLTAGE, &sigVoltRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_REF_VOLTAGE, &refVoltRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_TR_VALUE, &trValue));
         check_status(naibrd_LVDT_GetRaw(cardIndex, module, NAIBRD_LVDT_RAW_ACTIVE_CHANNELS, &chanStatEnabRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_BANDWIDTH, &bandWidthRaw));
         check_status(naibrd_LVDT_GetBandwidthSelect(cardIndex, module, channel, &bwSelect));
         chanStatEnabRaw &= channelMask;
         chanStatEnabRaw >>= (((uint32_t)(channel)) - 1u);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", positionRaw);
         naiif_printf("%14s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", frequencyRaw);
         naiif_printf("%14s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", refVoltRaw);
         naiif_printf("%12s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", sigVoltRaw);
         naiif_printf("%11s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", trValue);
         naiif_printf("%11s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%01X", "0x", chanStatEnabRaw);
         naiif_printf("%10s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", bandWidthRaw);
         naiif_printf("%19s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%01X", "0x", ((uint32_t)(bwSelect)));
         naiif_printf("%7s", msg);
      }
      else
      {
         check_status(naibrd_LVDT_GetFrequency(cardIndex, module, channel, &frequency));
         check_status(naibrd_LVDT_GetSignalVoltage(cardIndex, module, channel, &sigVolt));
         check_status(naibrd_LVDT_GetRefVoltage(cardIndex, module, channel, &refVolt));
         check_status(naibrd_LVDT_GetPosition(cardIndex, module, channel, &position));
         check_status(naibrd_LVDT_GetTRValue(cardIndex, module, channel, &trValue));
         check_status(naibrd_LVDT_GetChanStatusEnable(cardIndex, module, channel, &chanStatEnab));
         if (chanStatEnab == NAI_FALSE)
         {
            sChanStatEnab = "DISABLED";
         }
         else
         {
            sChanStatEnab = "ENABLED ";
         }
         check_status(naibrd_LVDT_GetBandwidth(cardIndex, module, channel, &bandWidth));
         check_status(naibrd_LVDT_GetBandwidthSelect(cardIndex, module, channel, &bwSelect));
         if (((uint32_t)(bwSelect)) == 0u)
         {
            sBwSelect = " MANUAL  ";
         }
         else
         {
            sBwSelect = "AUTOMATIC";
         }
         naiif_printf(" %12.4f%13.4f%12.4f  %9.4f %10u        %s      %08d   %s", position, frequency, refVolt, sigVolt, trValue,
            sChanStatEnab, bandWidth, sBwSelect);
      }
      naiif_printf("\r\n");
   }

   naiif_printf("\r\n\r\n ============================================================================================================================= \r\n");
   naiif_printf("%5s%20s%20s%20s\r\n", "Chan", "Ref Loss Threshold", "Ref Hi Threshold", "Sig Hi Threshold");
   naiif_printf(" ============================================================================================================================= \r\n");
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      channelMask = 0x1u << (((uint32_t)(channel)) - 1u);
      naiif_printf(" %1d", channel);
      if (DisplayAsHex)
      {
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_REF_FAULT_LOW_THRESHOLD, &refLoThresRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_SIG_FAULT_HIGH_THRESHOLD, &sigHiThresRaw));
         check_status(naibrd_LVDT_GetChannelRaw(cardIndex, module, channel, NAIBRD_LVDT_CHAN_RAW_REF_FAULT_HIGH_THRESHOLD, &refHiThresRaw));
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", refLoThresRaw);
         naiif_printf("      %17s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", refHiThresRaw);
         naiif_printf("%20s", msg);
         memset(msg, 0, sizeof(msg));
         naiif_snprintf((char*)msg, MSG_LENGTH + 1, "%s%08X", "0x", sigHiThresRaw);
         naiif_printf("%20s\r\n", msg);
      }
      else
      {
         check_status(naibrd_LVDT_GetThreshold(cardIndex, module, channel, NAIBRD_LVDT_REF_FAULT_LO_THRESHOLD, &refLoThres));
         check_status(naibrd_LVDT_GetThreshold(cardIndex, module, channel, NAIBRD_LVDT_REF_FAULT_HI_THRESHOLD, &refHiThres));
         check_status(naibrd_LVDT_GetThreshold(cardIndex, module, channel, NAIBRD_LVDT_SIG_FAULT_HI_THRESHOLD, &sigHiThres));
         naiif_printf("   %20.6f%20.6f%20.6f\r\n", refLoThres, refHiThres, sigHiThres);
      }
   }

   naiif_printf("\r\n\r\n ============================================================================================ \r\n");
   naiif_printf("%7s%17s%15s\r\n", "Chan", "Invert Va", "Invert Ref");
   naiif_printf("%7s%16s%14s\r\n", "", "Control", "Control");
   naiif_printf(" ============================================================================================ \r\n");
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      naiif_printf("%4d    ", channel);
      check_status(naibrd_LVDT_GetSignalInversion(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_INV_VA, &invVaCtrl));
      switch (invVaCtrl)
      {
         case NAIBRD_LVDT_RESP_NON_INVERTED_VA:
            memset(strInvVaCtrl, 0, sizeof(strInvVaCtrl));
            naiif_snprintf((char*)strInvVaCtrl, MSG_LENGTH + 1, "Non-Inverted");
         break;
         case NAIBRD_LVDT_RESP_INVERTED_VA:
            memset(strInvVaCtrl, 0, sizeof(strInvVaCtrl));
            naiif_snprintf((char*)strInvVaCtrl, MSG_LENGTH + 1, "  Inverted  ");
         break;
         default:
            memset(strInvVaCtrl, 0, sizeof(strInvVaCtrl));
            naiif_snprintf((char*)strInvVaCtrl, MSG_LENGTH + 1, "  Unknown   ");
         break;
      }
      check_status(naibrd_LVDT_GetSignalInversion(cardIndex, module, channel, NAIBRD_LVDT_SIGNAL_INV_REF, &invRefCtrl));
      switch (invRefCtrl)
      {
         case NAIBRD_LVDT_RESP_NON_INVERTED_REF:
            memset(strInvRefCtrl, 0, sizeof(strInvRefCtrl));
            naiif_snprintf((char*)strInvRefCtrl, MSG_LENGTH + 1, "Non-Inverted");
         break;
         case NAIBRD_LVDT_RESP_INVERTED_REF:
            memset(strInvRefCtrl, 0, sizeof(strInvRefCtrl));
            naiif_snprintf((char*)strInvRefCtrl, MSG_LENGTH + 1, "  Inverted  ");
         break;
         default:
            memset(strInvRefCtrl, 0, sizeof(strInvRefCtrl));
            naiif_snprintf((char*)strInvRefCtrl, MSG_LENGTH + 1, "  Unknown   ");
         break;
      }
      naiif_printf("      %12s  %12s\r\n", strInvVaCtrl, strInvRefCtrl);
   }
   if (DisplayAsHex)
   {
      naiif_printf("Module Channel Count: 0x%02X", MAX_CHANNEL);
   }
   else
   {
      naiif_printf("Module Channel Count: %d", MAX_CHANNEL);
   }
}

static nai_status_t LVDT_Config_SetMode(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_SUCCESS;
   uint32_t  mode = 0;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naibrd_LVDT_GetChannelCount(plvdtPara->modId);
      if (DisplayAsHex)
      {
         naiif_printf("Set Mode in Hex [0x1 = 3/4-Wire, 0x2 = 2-Wire]");
      }
      else
      {
         naiif_printf("Set Mode: [1 = 3/4-Wire, 2 = 2-Wire]");
      }
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         if (DisplayAsHex)
         {
            mode = naiapp_utils_HexStrToDecUInt32(inputBuffer);
         }
         else
         {
            mode = atoi((const char*)inputBuffer);
         }
         if ((mode >= NAIBRD_LVDT_4WIRE) && (mode <= NAIBRD_LVDT_2WIRE))
         {
            status = check_status(naibrd_LVDT_SetChanMode(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
               (naibrd_lvdt_format_t)mode));
         }
         else
         {
            naiif_printf("\r\n Invalid Mode Entry");
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

static nai_status_t LVDT_Config_SetChanStatEnb(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_SUCCESS;
   uint32_t  chanStatEnb = 0;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naibrd_LVDT_GetChannelCount(plvdtPara->modId);
      if (DisplayAsHex)
      {
         naiif_printf("Set Channel Status Enable/Disable in Hex [0x0 = Disable, 0x1 = Enable]");
      }
      else
      {
         naiif_printf("Set Channel Status Enable: [0 = Disable, 1 = Enable]");
      }
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         if (DisplayAsHex)
         {
            chanStatEnb = naiapp_utils_HexStrToDecUInt32(inputBuffer);
         }
         else
         {
            chanStatEnb = atoi((const char*)inputBuffer);
         }
         if (chanStatEnb <= LVDT_CHAN_STATUS_ENABLED)
         {
            status = check_status(naibrd_LVDT_SetChanStatusEnable(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
               (uint32_t)chanStatEnb));
         }
         else
         {
            naiif_printf("\r\n Invalid Channel Status Enable/Disable Entry");
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

static nai_status_t LVDT_Config_SetSigLossThreshold(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_SUCCESS;
   uint32_t  thresholdRaw = 0;
   float64_t  threshold = 0.0;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naibrd_LVDT_GetChannelCount(plvdtPara->modId);
      if (DisplayAsHex)
      {
         naiif_printf("Set Raw Sig Loss Threshold in Hex (0x0 - 0x2328)\r\n>>");  /* 10mV/Count 90V = 9000 = 0x2328 */
      }
      else
      {
         naiif_printf("Set Sig Loss Threshold (0.0 - 90.0 Volts)\r\n>>");
      }
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         if (DisplayAsHex)
         {
            thresholdRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
            if ((thresholdRaw >= THRESHOLD_RAW_0V) && (thresholdRaw <= THRESHOLD_RAW_90V))
            {
               status = check_status(naibrd_LVDT_SetChannelRaw(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_RAW_SIG_FAULT_LOW_THRESHOLD, thresholdRaw));
            }
            else
            {
               naiif_printf("\r\n Invalid Sig Loss Threshold Entry!");
            }
         }
         else
         {
            threshold = atof((const char*)inputBuffer);
            if ((threshold >= THRESHOLD_0V) && (threshold <= THRESHOLD_90V))
            {
               status = check_status(naibrd_LVDT_SetThreshold(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_SIG_FAULT_LO_THRESHOLD, threshold));
            }
            else
            {
               naiif_printf("\r\n Invalid Sig Loss Threshold Entry!");
            }
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

static nai_status_t LVDT_Config_SetRefLossThreshold(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_SUCCESS;
   uint32_t  thresholdRaw = 0;
   float64_t  threshold = 0.0;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naibrd_LVDT_GetChannelCount(plvdtPara->modId);
      if (DisplayAsHex)
      {
         naiif_printf("Set Raw Ref Loss Threshold in Hex (0x0 - 0x2CEC) >>");  /* 10mV/Count 115V = 11500 = 0x2CEC */
      }
      else
      {
         naiif_printf("Set Ref Loss Threshold (0.0 - 115.0 Volts) >>");
      }
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         if (DisplayAsHex)
         {
            thresholdRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
            if ((thresholdRaw >= THRESHOLD_RAW_0V) && (thresholdRaw <= THRESHOLD_RAW_115V))
            {
               status = check_status(naibrd_LVDT_SetChannelRaw(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_RAW_REF_FAULT_LOW_THRESHOLD, thresholdRaw));
            }
            else
            {
               naiif_printf("\r\n Invalid Ref Loss Threshold Entry!");
            }
         }
         else
         {
            threshold = atof((const char*)inputBuffer);
            if ((threshold >= THRESHOLD_0V) && (threshold <= THRESHOLD_115V))
            {
               status = check_status(naibrd_LVDT_SetThreshold(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_REF_FAULT_LO_THRESHOLD, threshold));
            }
            else
            {
               naiif_printf("\r\n Invalid Ref Loss Threshold Entry!");
            }
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

static nai_status_t LVDT_Config_SetSigHiThreshold(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_SUCCESS;
   uint32_t  thresholdRaw = 0;
   float64_t  threshold = 0.0;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naibrd_LVDT_GetChannelCount(plvdtPara->modId);
      if (DisplayAsHex)
      {
         naiif_printf("Set Raw Sig Fault High Threshold in Hex (0x0 - 0x2328)\r\n>>");  /* 10mV/Count 90V = 9000 = 0x2328 */
      }
      else
      {
         naiif_printf("Set Sig Fault High Threshold (0.0 - 90.0 Volts)\r\n>>");
      }
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         if (DisplayAsHex)
         {
            thresholdRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
            if ((thresholdRaw >= THRESHOLD_RAW_0V) && (thresholdRaw <= THRESHOLD_RAW_90V))
            {
               status = check_status(naibrd_LVDT_SetChannelRaw(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_RAW_SIG_FAULT_HIGH_THRESHOLD, thresholdRaw));
            }
            else
            {
               naiif_printf("\r\n Invalid Sig Fault High Threshold Entry!");
            }
         }
         else
         {
            threshold = atof((const char*)inputBuffer);
            if ((threshold >= THRESHOLD_0V) && (threshold <= THRESHOLD_90V))
            {
               status = check_status(naibrd_LVDT_SetThreshold(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_SIG_FAULT_HI_THRESHOLD, threshold));
            }
            else
            {
               naiif_printf("\r\n Invalid Sig Fault High Threshold Entry!");
            }
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

static nai_status_t LVDT_Config_SetRefHiThreshold(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_SUCCESS;
   uint32_t  thresholdRaw = 0;
   float64_t  threshold = 0.0;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naibrd_LVDT_GetChannelCount(plvdtPara->modId);
      if (DisplayAsHex)
      {
         naiif_printf("Set Raw Ref Fault High Threshold in Hex (0x0 - 0x2CEC) >>");  /* 10mV/Count 115V = 11500 = 0x2CEC */
      }
      else
      {
         naiif_printf("Set Ref Fault High Threshold (0.0 - 115.0 Volts) >>");
      }
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         if (DisplayAsHex)
         {
            thresholdRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
            if ((thresholdRaw >= THRESHOLD_RAW_0V) && (thresholdRaw <= THRESHOLD_RAW_115V))
            {
               status = check_status(naibrd_LVDT_SetChannelRaw(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_CHAN_RAW_REF_FAULT_HIGH_THRESHOLD, thresholdRaw));
            }
            else
            {
               naiif_printf("\r\n Invalid Ref Fault High Threshold Entry!");
            }
         }
         else
         {
            threshold = atof((const char*)inputBuffer);
            if ((threshold >= THRESHOLD_0V) && (threshold <= THRESHOLD_115V))
            {
               status = check_status(naibrd_LVDT_SetThreshold(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
                  NAIBRD_LVDT_REF_FAULT_HI_THRESHOLD, threshold));
            }
            else
            {
               naiif_printf("\r\n Invalid Ref Fault High Threshold Entry!");
            }
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

static nai_status_t LVDT_Config_SetOpenThreshold(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_SUCCESS;
   uint32_t  thresholdRaw = 0;
   float64_t  threshold = 0.0;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naibrd_LVDT_GetChannelCount(plvdtPara->modId);
      if (DisplayAsHex)
      {
         naiif_printf("Set Raw Open Threshold in Hex\r\n>>");
      }
      else
      {
         naiif_printf("Set Open Threshold\r\n>>");
      }
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         if (DisplayAsHex)
         {
            thresholdRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
            status = check_status(naibrd_LVDT_SetChannelRaw(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
               NAIBRD_LVDT_CHAN_RAW_OPEN_THRESHOLD, thresholdRaw));
         }
         else
         {
            threshold = atof((const char*)inputBuffer);
            status = check_status(naibrd_LVDT_SetThreshold(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
               NAIBRD_LVDT_OPEN_THRESHOLD, threshold));
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

static nai_status_t LVDT_Config_SetShortThreshold(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_SUCCESS;
   uint32_t  thresholdRaw = 0;
   float64_t  threshold = 0.0;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naibrd_LVDT_GetChannelCount(plvdtPara->modId);
      if (DisplayAsHex)
      {
         naiif_printf("Set Raw Short Threshold in Hex\r\n>>");
      }
      else
      {
         naiif_printf("Set Short Threshold\r\n>>");
      }
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         if (DisplayAsHex)
         {
            thresholdRaw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
            status = check_status(naibrd_LVDT_SetChannelRaw(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
               NAIBRD_LVDT_CHAN_RAW_SHORT_THRESHOLD, thresholdRaw));
         }
         else
         {
            threshold = atof((const char*)inputBuffer);
            status = check_status(naibrd_LVDT_SetThreshold(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
               NAIBRD_LVDT_SHORT_THRESHOLD, threshold));
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

static nai_status_t LVDT_Config_SetSignalInversion(int32_t paramCount, int32_t* p_params)
{
   uint8_t strSigType[MSG_LENGTH];
   bool_t bQuit = NAI_FALSE;
   naibrd_lvdt_signal_inversion_type_t sigType = NAIBRD_LVDT_SIGNAL_INV_VA;
   p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = LVDT_params->cardIndex;
   int32_t module = LVDT_params->module;
   int32_t channel = LVDT_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   NAIBSP_UNREFERENCED_PARAMETER(paramCount);

   naiif_printf("*Note: If the signal inversion control for Va-Vb is set to non-inverted, the algorithm used for position measurement is ");
   naiif_printf("(Va - Vb) / (Va + Vb), and if the signal inversion control for Va-Vb is set to inverted, the algorithm used for position ");
   naiif_printf("measurement is (Vb - Va) / (Va + Vb).\r\n");
   naiif_printf("Select Signal Type to set signal inversion control for (0 for Va, 1 for Vb, 2 for Reference, 3 for Va-Vb, q for quit): ");
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if ((!bQuit) && (inputResponseCnt > 0))
   {
      switch (inputBuffer[0])
      {
         case '0':
            sigType = NAIBRD_LVDT_SIGNAL_INV_VA;
            memset(strSigType, 0, sizeof(strSigType));
            naiif_snprintf((char*)strSigType, MSG_LENGTH + 1, "Va");
         break;
         case '1':
            sigType = NAIBRD_LVDT_SIGNAL_INV_VB;
            memset(strSigType, 0, sizeof(strSigType));
            naiif_snprintf((char*)strSigType, MSG_LENGTH + 1, "Vb");
         break;
         case '2':
            sigType = NAIBRD_LVDT_SIGNAL_INV_REF;
            memset(strSigType, 0, sizeof(strSigType));
            naiif_snprintf((char*)strSigType, MSG_LENGTH + 1, "Reference");
         break;
         case '3':
            sigType = NAIBRD_LVDT_SIGNAL_INV_DIFF;
            memset(strSigType, 0, sizeof(strSigType));
            naiif_snprintf((char*)strSigType, MSG_LENGTH + 1, "Va-Vb");
         break;
         default:
            bQuit = NAI_TRUE;
            naiif_printf("\r\nInvalid signal type entered\r\n");
         break;
      }

      if (!bQuit)
      {
         naiif_printf("\r\nDo you want to set the signal inversion control for the %s signal to inverted or non-inverted? ", strSigType);
         naiif_printf("(1 for inverted, 0 for non-inverted): ");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if ((!bQuit) && (inputResponseCnt > 0))
         {
            switch (inputBuffer[0])
            {
               case '0':
                  switch (sigType)
                  {
                     case NAIBRD_LVDT_SIGNAL_INV_VA:
                        check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_NON_INVERTED_VA));
                     break;
                     case NAIBRD_LVDT_SIGNAL_INV_VB:
                        check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_NON_INVERTED_VB));
                     break;
                     case NAIBRD_LVDT_SIGNAL_INV_REF:
                        check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_NON_INVERTED_REF));
                     break;
                     case NAIBRD_LVDT_SIGNAL_INV_DIFF:
                        check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_DIFF_VA_VB));
                     break;
                  }
               break;
               case '1':
                  switch (sigType)
                  {
                     case NAIBRD_LVDT_SIGNAL_INV_VA:
                        check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_INVERTED_VA));
                     break;
                     case NAIBRD_LVDT_SIGNAL_INV_VB:
                        check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_INVERTED_VB));
                     break;
                     case NAIBRD_LVDT_SIGNAL_INV_REF:
                        check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_INVERTED_REF));
                     break;
                     case NAIBRD_LVDT_SIGNAL_INV_DIFF:
                        check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_DIFF_VB_VA));
                     break;
                  }
               break;
               default:
                  bQuit = NAI_TRUE;
                  naiif_printf("\r\nInvalid selection entered\r\n");
               break;
            }
         }
      }
   }

   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}

static nai_status_t LVDT_Config_LL2_SetSignalInversion(int32_t paramCount, int32_t* p_params)
{
   uint8_t strSigType[MSG_LENGTH];
   bool_t bQuit = NAI_FALSE;
   naibrd_lvdt_signal_inversion_type_t sigType = NAIBRD_LVDT_SIGNAL_INV_VA;
   p_naiapp_AppParameters_t LVDT_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = LVDT_params->cardIndex;
   int32_t module = LVDT_params->module;
   int32_t channel = LVDT_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   NAIBSP_UNREFERENCED_PARAMETER(paramCount);

   naiif_printf("Select Signal Type to set signal inversion control for (0 for Va, 1 for Reference, q for quit): ");
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if ((!bQuit) && (inputResponseCnt > 0))
   {
      switch (inputBuffer[0])
      {
         case '0':
            sigType = NAIBRD_LVDT_SIGNAL_INV_VA;
            memset(strSigType, 0, sizeof(strSigType));
            naiif_snprintf((char*)strSigType, MSG_LENGTH + 1, "Va");
         break;
         case '1':
            sigType = NAIBRD_LVDT_SIGNAL_INV_REF;
            memset(strSigType, 0, sizeof(strSigType));
            naiif_snprintf((char*)strSigType, MSG_LENGTH + 1, "Reference");
         break;
         default:
            bQuit = NAI_TRUE;
            naiif_printf("\r\nInvalid signal type entered\r\n");
         break;
      }

      if (!bQuit)
      {
         naiif_printf("\r\nDo you want to set the signal inversion control for the %s signal to inverted or non-inverted? ", strSigType);
         naiif_printf("(1 for inverted, 0 for non-inverted): ");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if ((!bQuit) && (inputResponseCnt > 0))
         {
            switch (inputBuffer[0])
            {
               case '0':
                  switch (sigType)
                  {
                     case NAIBRD_LVDT_SIGNAL_INV_VA:
                        check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_NON_INVERTED_VA));
                     break;
                     case NAIBRD_LVDT_SIGNAL_INV_REF:
                        check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_NON_INVERTED_REF));
                     break;
                  }
               break;
               case '1':
                  switch (sigType)
                  {
                     case NAIBRD_LVDT_SIGNAL_INV_VA:
                        check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_INVERTED_VA));
                     break;
                     case NAIBRD_LVDT_SIGNAL_INV_REF:
                        check_status(naibrd_LVDT_SetSignalInversion(cardIndex, module, channel, sigType, NAIBRD_LVDT_RESP_INVERTED_REF));
                     break;
                  }
               break;
               default:
                  bQuit = NAI_TRUE;
                  naiif_printf("\r\nInvalid selection entered\r\n");
               break;
            }
         }
      }
   }

   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}

static nai_status_t LVDT_Config_SetBandWidth(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_SUCCESS;
   uint32_t  bw = 0;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      if (DisplayAsHex)
      {
         naiif_printf("Set Band Width(Hz) In Hex. [0x2 - 0x500] >>");
      }
      else
      {
         naiif_printf("Set Band Width(Hz). [2 - 1280] >>");
      }
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit && inputResponseCnt > 0)
      {
         if (DisplayAsHex)
         {
            bw = naiapp_utils_HexStrToDecUInt32(inputBuffer);
         }
         else
         {
            bw = atoi((const char*)inputBuffer);
         }
         if ((bw >= BW_2HZ) && (bw <= BW_1280HZ))
         {
            status = check_status(naibrd_LVDT_SetBandwidth(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel, bw));
         }
         else
         {
            naiif_printf("\r\n Invalid Band Width Entry");
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

static nai_status_t LVDT_Config_SetBandWidthSelect(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_SUCCESS;
   uint32_t bwSelect = 0u;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naiif_printf("Please select Band Width Select Mode ['0' = MANUAL, '1' = AUTOMATIC]: ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if ((!bQuit) && (inputResponseCnt > 0))
      {
         bwSelect = (uint32_t)(atoi((const char*)inputBuffer));
         if (bwSelect == 0u)
         {
            status = check_status(naibrd_LVDT_SetBandwidthSelect(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
               NAIBRD_LVDT_BW_MANUAL));
         }
         else if (bwSelect == 1u)
         {
            status = check_status(naibrd_LVDT_SetBandwidthSelect(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel,
               NAIBRD_LVDT_BW_AUTOMATIC));
         }
         else
         {
            naiif_printf("\r\n Invalid Band Width Select Entry\r\n");
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

static nai_status_t LVDT_Config_SetLVDTScale(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   uint32_t scale = 0u;
   nai_status_t status = NAI_SUCCESS;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      if (DisplayAsHex)
      {
         naiif_printf("Type in LVDT scale raw value to set [0x0 - 0xFFFFFFFF]: >>");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         scale = (uint32_t)(naiapp_utils_HexStrToDecUInt32(inputBuffer));
      }
      else
      {
         naiif_printf("Type in LVDT scale value to set [0 - 4294967295]: >>");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         scale = (uint32_t)strtoul((const char *)inputBuffer, NULL, 10);
      }
      if ((!bQuit) && (inputResponseCnt > 0))
      {
         status = check_status(naibrd_LVDT_SetLVDTScale(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel, scale));
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

static nai_status_t LVDT_Config_SetTRValue(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   uint32_t trValue = 0u;
   nai_status_t status = NAI_SUCCESS;
   p_naiapp_AppParameters_t plvdtPara = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      if (DisplayAsHex)
      {
         naiif_printf("Type in TR raw value to set [0x0 - 0xFFFFFFFF]: >>");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         trValue = (uint32_t)(naiapp_utils_HexStrToDecUInt32(inputBuffer));
      }
      else
      {
         naiif_printf("Type in TR Value to set [0 - 4294967295]: >>");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         trValue = (uint32_t)strtoul((const char *)inputBuffer, NULL, 10);
      }

      if ((!bQuit) && (inputResponseCnt > 0))
      {
         status = check_status(naibrd_LVDT_SetTRValue(plvdtPara->cardIndex, plvdtPara->module, plvdtPara->channel, trValue));
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}
/*END: This section is for Configuration Function Implementation*/

static nai_status_t LVDTBasicMenu_FloatingPoint(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   int32_t MAX_CHANNELS = 0;
   int32_t cmd = 0;
   int32_t CommandCount = 0;
   int32_t channel = 0;
   nai_status_t status = NAI_SUCCESS;
   p_naiapp_AppParameters_t plvdtParas = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   MAX_CHANNELS = naibrd_LVDT_GetChannelCount(plvdtParas->modId);
   naiapp_utils_LoadParamMenuCommands(LVDT_FLOATINGPOINTMENU_CMD_COUNT, LVDT_FloatingPointMenuCmds);
   do
   {
      LVDT_FloatingPoint_displayFloatingPointTable(plvdtParas->cardIndex, plvdtParas->module, plvdtParas->modId);
      naiapp_display_ParamMenuCommands((int8_t*)"LVDT Floating-Point Menu");
      naiif_printf("\r\n Type command or %c to quit : ", NAI_QUIT_CHAR);
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if ((!bQuit) && (inputResponseCnt > 0))
      {
         naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
         CommandCount = LVDT_FLOATINGPOINTMENU_CMD_COUNT;
         if ((cmd >= 0) && (cmd < CommandCount))
         {
            if (cmd != LVDT_FLOATINGPOINTMENU_CMD_SET_FLOATING_POINT_MODE_ENABLE)
            {
               naiapp_query_ChannelNumber(MAX_CHANNELS, 1, &channel);
               plvdtParas->channel = channel;
            }
            LVDT_FloatingPointMenuCmds[cmd].func(paramCount, (int32_t*)plvdtParas);
         }
         else
         {
            naiif_printf(" Invalid command entered\r\n");
         }
      }
      else if (bQuit)
      {
         naiapp_utils_LoadParamMenuCommands(LVDT_BASICMENU_CMD_COUNT, LVDT_BasicOpMenuCmds);
      }
      else /* if ((inputResponseCnt <= 0) && (!bQuit)) */
      {
         naiif_printf("Invalid command entered\r\n");
      }
   } while (!bQuit);
   return status;
}

/**************************************************************************************************************/
/**
<summary>
This function enables/disables the floating-point hardware conversion mode of the module.
Applies to Gen5 modules only.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t LVDT_FloatingPoint_SetFloatingPointMode(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   p_naiapp_AppParameters_t lvdtParams = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;


   if (paramCount == APP_PARAM_COUNT)
   {
      naiif_printf("Select Floating-Point Mode to set ('0' for DISABLED, '1' for ENABLED)(default:DISABLED): ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputBuffer[0] == '0')
         {
            status = check_status(naibrd_SetFloatingPointModeEnable(lvdtParams->cardIndex, lvdtParams->module, 0x0));
         }
         else if (inputBuffer[0] == '1')
         {
            status = check_status(naibrd_SetFloatingPointModeEnable(lvdtParams->cardIndex, lvdtParams->module, 0x1));
         }
         naiif_printf("Returned status %s\r\n", naibrd_GetStatusString(status));
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the floating-point hardware conversion mode A-Side position offset of the channel specified
by the user. Applies to Gen5 modules only. Can only be set when module is in floating-point mode.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t LVDT_FloatingPoint_SetFloatingPointPositionOffsetA(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   float64_t offset = 0.0;
   p_naiapp_AppParameters_t lvdtParams = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naiif_printf("Type Floating-Point A-Side Position Offset value to set: ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            offset = atof((const char*)inputBuffer);
            status = check_status(naibrd_LVDT_SetFloatingPointAttributes(lvdtParams->cardIndex, lvdtParams->module, lvdtParams->channel,
               NAIBRD_LVDT_POSITION_OFFSET_A, offset));
         }
         else if (inputResponseCnt == 0)
         {
            naiif_printf("Invalid Offset Value.\r\n");
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the floating-point hardware conversion mode A-Side position scale factor of the channel
specified by the user. Applies to Gen5 modules only. Can only be set when module is in floating-point mode.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t LVDT_FloatingPoint_SetFloatingPointPositionScaleA(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   float64_t scaleFactor = 0.0;
   p_naiapp_AppParameters_t lvdtParams = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naiif_printf("Type Floating-Point A-Side Position Scale Factor value to set: ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            scaleFactor = atof((const char*)inputBuffer);
            status = check_status(naibrd_LVDT_SetFloatingPointAttributes(lvdtParams->cardIndex, lvdtParams->module, lvdtParams->channel,
               NAIBRD_LVDT_POSITION_SCALE_A, scaleFactor));
         }
         else if (inputResponseCnt == 0)
         {
            naiif_printf("Invalid Scale Factor Value.\r\n");
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the floating-point hardware conversion mode B-side position offset of the channel
specified by the user. Applies to Gen5 modules only. Can only be set when module is in floating-point mode.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t LVDT_FloatingPoint_SetFloatingPointPositionOffsetB(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   float64_t offset = 0.0;
   p_naiapp_AppParameters_t lvdtParams = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naiif_printf("Type Floating-Point Position B-Side Offset value to set: ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            offset = atof((const char*)inputBuffer);
            status = check_status(naibrd_LVDT_SetFloatingPointAttributes(lvdtParams->cardIndex, lvdtParams->module, lvdtParams->channel,
               NAIBRD_LVDT_POSITION_OFFSET_2WIRE_B, offset));
         }
         else if (inputResponseCnt == 0)
         {
            naiif_printf("Invalid Offset Value.\r\n");
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the floating-point hardware conversion mode B-side position scale factor of the channel
specified by the user. Applies to Gen5 modules only. Can only be set when module is in floating-point mode.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t LVDT_FloatingPoint_SetFloatingPointPositionScaleB(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   float64_t scaleFactor = 0.0;
   p_naiapp_AppParameters_t lvdtParams = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naiif_printf("Type Floating-Point Position B-Side Scale Factor value to set: ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            scaleFactor = atof((const char*)inputBuffer);
            status = check_status(naibrd_LVDT_SetFloatingPointAttributes(lvdtParams->cardIndex, lvdtParams->module, lvdtParams->channel,
               NAIBRD_LVDT_POSITION_SCALE_2WIRE_B, scaleFactor));
         }
         else if (inputResponseCnt == 0)
         {
            naiif_printf("Invalid Scale Factor Value.\r\n");
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the floating-point hardware conversion mode A-Side velocity offset of the channel specified
by the user. Applies to Gen5 modules only. Can only be set when module is in floating-point mode.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t LVDT_FloatingPoint_SetFloatingPointVelocityOffsetA(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   float64_t offset = 0.0;
   p_naiapp_AppParameters_t lvdtParams = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naiif_printf("Type Floating-Point A-Side Velocity Offset value to set: ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            offset = atof((const char*)inputBuffer);
            status = check_status(naibrd_LVDT_SetFloatingPointAttributes(lvdtParams->cardIndex, lvdtParams->module, lvdtParams->channel,
               NAIBRD_LVDT_VELOCITY_OFFSET_A, offset));
         }
         else if (inputResponseCnt == 0)
         {
            naiif_printf("Invalid Offset Value.\r\n");
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the floating-point hardware conversion mode A-Side velocity scale factor of the channel
specified by the user. Applies to Gen5 modules only. Can only be set when module is in floating-point mode.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t LVDT_FloatingPoint_SetFloatingPointVelocityScaleA(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   float64_t scaleFactor = 0.0;
   p_naiapp_AppParameters_t lvdtParams = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naiif_printf("Type Floating-Point A-Side Velocity Scale Factor value to set: ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            scaleFactor = atof((const char*)inputBuffer);
            status = check_status(naibrd_LVDT_SetFloatingPointAttributes(lvdtParams->cardIndex, lvdtParams->module, lvdtParams->channel,
               NAIBRD_LVDT_VELOCITY_SCALE_A, scaleFactor));
         }
         else if (inputResponseCnt == 0)
         {
            naiif_printf("Invalid Scale Factor Value.\r\n");
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the floating-point hardware conversion mode B-side velocity offset of the channel
specified by the user. Applies to Gen5 modules only. Can only be set when module is in floating-point mode.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t LVDT_FloatingPoint_SetFloatingPointVelocityOffsetB(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   float64_t offset = 0.0;
   p_naiapp_AppParameters_t lvdtParams = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naiif_printf("Type Floating-Point Velocity B-Side Offset value to set: ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            offset = atof((const char*)inputBuffer);
            status = check_status(naibrd_LVDT_SetFloatingPointAttributes(lvdtParams->cardIndex, lvdtParams->module, lvdtParams->channel,
               NAIBRD_LVDT_VELOCITY_OFFSET_2WIRE_B, offset));
         }
         else if (inputResponseCnt == 0)
         {
            naiif_printf("Invalid Offset Value.\r\n");
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/**************************************************************************************************************/
/**
<summary>
This function sets the floating-point hardware conversion mode B-side velocity scale factor of the channel
specified by the user. Applies to Gen5 modules only. Can only be set when module is in floating-point mode.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t LVDT_FloatingPoint_SetFloatingPointVelocityScaleB(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   float64_t scaleFactor = 0.0;
   p_naiapp_AppParameters_t lvdtParams = (p_naiapp_AppParameters_t)p_params;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      naiif_printf("Type Floating-Point Velocity B-Side Scale Factor value to set: ");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            scaleFactor = atof((const char*)inputBuffer);
            status = check_status(naibrd_LVDT_SetFloatingPointAttributes(lvdtParams->cardIndex, lvdtParams->module, lvdtParams->channel,
               NAIBRD_LVDT_VELOCITY_SCALE_2WIRE_B, scaleFactor));
         }
         else if (inputResponseCnt == 0)
         {
            naiif_printf("Invalid Scale Factor Value.\r\n");
         }
      }
   }
   else
   {
      status = NAI_ERROR_INVALID_VALUE;
   }
   return status;
}

/*****************************************************************************/
/**
 * <summary>
 * LVDT_FloatingPoint_displayFloatingPointTable illustrates the methods to
 * call in the naibrd library to retrieve the floating-point attributes data
 * of the LVDT for all channels.
 * Function: naibrd_LVDT_GetFloatingPointPositionAttributes
 * Types:  NAIBRD_LVDT_POSITION_OFFSET_A
 *         NAIBRD_LVDT_POSITION_SCALE_A
 *         NAIBRD_LVDT_POSITION_OFFSET_2WIRE_B
 *         NAIBRD_LVDT_POSITION_SCALE_2WIRE_B
 *         NAIBRD_LVDT_VELOCITY_OFFSET_A
 *         NAIBRD_LVDT_VELOCITY_SCALE_A
 *         NAIBRD_LVDT_VELOCITY_OFFSET_2WIRE_B
 *         NAIBRD_LVDT_VELOCITY_SCALE_2WIRE_B
 * </summary>
 */
/*****************************************************************************/
static void LVDT_FloatingPoint_displayFloatingPointTable(int32_t cardIndex, int32_t module, uint32_t modId)
{
   int32_t MAX_CHANNEL = naibrd_LVDT_GetChannelCount(modId);
   int32_t channel = 0;
   bool_t floatModeEnabled = NAI_FALSE;
   float64_t posOffsetA = 0.0;
   float64_t posScaleA = 0.0;
   float64_t posOffsetB = 0.0;
   float64_t posScaleB = 0.0;
   float64_t positionA = 0.0;
   float64_t positionB = 0.0;
   float64_t velOffsetA = 0.0;
   float64_t velScaleA = 0.0;
   float64_t velOffsetB = 0.0;
   float64_t velScaleB = 0.0;
   float64_t velocityA = 0.0;
   float64_t velocityB = 0.0;
   naiif_printf("\r\n\r\n=====================================================================================================\r\n");
   switch (modId)
   {
      case NAIBRD_MODULE_ID_LD1:
      case NAIBRD_MODULE_ID_LD2:
      case NAIBRD_MODULE_ID_LD3:
      case NAIBRD_MODULE_ID_LD4:
      case NAIBRD_MODULE_ID_LD6:
      case NAIBRD_MODULE_ID_LR2:
         naiif_printf("Chan    Position A     Pos A Offset     Pos A Scale     Position B     Pos B Offset    Pos B Scale\r\n");
         break;
      default:
         /* Nothing to do here; all cases already covered */
         break;
   }
   check_status(naibrd_GetRunningInFloatingPointMode(cardIndex, module, &floatModeEnabled));
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      check_status(naibrd_LVDT_GetFloatingPointAttributes(cardIndex, module, channel, NAIBRD_LVDT_POSITION_OFFSET_A, &posOffsetA));
      check_status(naibrd_LVDT_GetFloatingPointAttributes(cardIndex, module, channel, NAIBRD_LVDT_POSITION_SCALE_A, &posScaleA));
      check_status(naibrd_LVDT_GetFloatingPointAttributes(cardIndex, module, channel, NAIBRD_LVDT_POSITION_OFFSET_2WIRE_B, &posOffsetB));
      check_status(naibrd_LVDT_GetFloatingPointAttributes(cardIndex, module, channel, NAIBRD_LVDT_POSITION_SCALE_2WIRE_B, &posScaleB));
      check_status(naibrd_LVDT_GetPosition(cardIndex, module, channel, &positionA));
      check_status(naibrd_LVDT_GetTwoWirePosition(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_B, &positionB));
      naiif_printf(" %2d    %13.5f   %13.5f   %13.5f   %13.5f   %13.5f   %13.5f\r\n", channel, positionA, posOffsetA, posScaleA, positionB,
                   posOffsetB, posScaleB);
   }
   naiif_printf("\r\n\r\n=====================================================================================================\r\n");
   switch (modId)
   {
      case NAIBRD_MODULE_ID_LD1:
      case NAIBRD_MODULE_ID_LD2:
      case NAIBRD_MODULE_ID_LD3:
      case NAIBRD_MODULE_ID_LD4:
      case NAIBRD_MODULE_ID_LD6:
      case NAIBRD_MODULE_ID_LR2:
         naiif_printf("Chan    Velocity A     Vel A Offset     Vel A Scale     Velocity B     Vel B Offset    Vel B Scale\r\n");
         break;
      default:
         /* Nothing to do here; all cases already covered */
         break;
   }
   for (channel = 1; channel <= MAX_CHANNEL; channel++)
   {
      check_status(naibrd_LVDT_GetFloatingPointAttributes(cardIndex, module, channel, NAIBRD_LVDT_VELOCITY_OFFSET_A, &velOffsetA));
      check_status(naibrd_LVDT_GetFloatingPointAttributes(cardIndex, module, channel, NAIBRD_LVDT_VELOCITY_SCALE_A, &velScaleA));
      check_status(naibrd_LVDT_GetFloatingPointAttributes(cardIndex, module, channel, NAIBRD_LVDT_VELOCITY_OFFSET_2WIRE_B, &velOffsetB));
      check_status(naibrd_LVDT_GetFloatingPointAttributes(cardIndex, module, channel, NAIBRD_LVDT_VELOCITY_SCALE_2WIRE_B, &velScaleB));
      check_status(naibrd_LVDT_GetVelocity(cardIndex, module, channel, &velocityA));
      check_status(naibrd_LVDT_GetTwoWireVelocity(cardIndex, module, channel, NAIBRD_LVDT_TWO_WIRE_B, &velocityB));
      naiif_printf(" %2d    %13.5f   %13.5f   %13.5f   %13.5f   %13.5f   %13.5f\r\n", channel, velocityA, velOffsetA, velScaleA, velocityB,
                   velOffsetB, velScaleB);
   }
   if (floatModeEnabled == NAI_FALSE)
   {
      naiif_printf("\r\nFloating-Point Mode: DISABLED\r\n");
   }
   else
   {
      naiif_printf("\r\nFloating-Point Mode: ENABLED\r\n");
   }
}
/**************************************************************************************************************/
/**
<summary>
Configure_LVDT_ModulePowerResetMenu displays the menu for module power reset commands.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Configure_LVDT_ModulePowerResetMenu(int32_t paramCount, int32_t* p_params)
{
   bool_t bQuit = NAI_FALSE;
   bool_t bContinue = NAI_TRUE;
   bool_t bCmdFound = NAI_FALSE;
   int32_t cmd = 0;
   int32_t numMenuCmds = 0;
   bool_t poweredDownStatus = NAI_FALSE;
   bool_t notDetectedStatus = NAI_FALSE;
   bool_t notLinkInitStatus = NAI_FALSE;
   bool_t notFWNotStatus = NAI_FALSE;
   bool_t commErrorStatus = NAI_FALSE;
   bool_t resetRequest = NAI_FALSE;
   bool_t powerDownRequest = NAI_FALSE;
   bool_t powerUpRequest = NAI_FALSE;
   p_naiapp_AppParameters_t p_lvdt_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_lvdt_params->cardIndex;
   int32_t module = p_lvdt_params->module;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;


   numMenuCmds = LVDT_MODULE_POWER_RESET_CMD_COUNT;
   naiapp_utils_LoadParamMenuCommands(numMenuCmds, LVDT_ModulePowerResetMenuCmds);
   while (bContinue)
   {
      naiif_printf("\r\n\r\n\r\n");
      naiif_printf(" -----------------------------Status------------------------------    ----------Request----------\r\n");
      naiif_printf(" Powered Down  Not Detected  Not Link Init  Not FW Not  Comm Error    Reset  Power Down  Power Up\r\n");
      naiif_printf(" ------------  ------------  -------------  ----------  ----------    -----  ----------  --------\r\n");
      check_status(naibrd_LVDT_GetModulePowerResetStatus(cardIndex, module, NAIBRD_LVDT_MODULE_POWER_RESET_STATUS_POWERED_DOWN, &poweredDownStatus));
      check_status(naibrd_LVDT_GetModulePowerResetStatus(cardIndex, module, NAIBRD_LVDT_MODULE_POWER_RESET_STATUS_NOT_DETECTED, &notDetectedStatus));
      check_status(naibrd_LVDT_GetModulePowerResetStatus(cardIndex, module, NAIBRD_LVDT_MODULE_POWER_RESET_STATUS_NOT_LINK_INIT, &notLinkInitStatus));
      check_status(naibrd_LVDT_GetModulePowerResetStatus(cardIndex, module, NAIBRD_LVDT_MODULE_POWER_RESET_STATUS_FW_NOT_READY, &notFWNotStatus));
      check_status(naibrd_LVDT_GetModulePowerResetStatus(cardIndex, module, NAIBRD_LVDT_MODULE_POWER_RESET_STATUS_COMM_ERROR, &commErrorStatus));
      check_status(naibrd_LVDT_GetModulePowerReset(cardIndex, module, NAIBRD_LVDT_MODULE_POWER_RESET_REQUEST_RESET, &resetRequest));
      check_status(naibrd_LVDT_GetModulePowerReset(cardIndex, module, NAIBRD_LVDT_MODULE_POWER_RESET_REQUEST_POWER_DOWN, &powerDownRequest));
      check_status(naibrd_LVDT_GetModulePowerReset(cardIndex, module, NAIBRD_LVDT_MODULE_POWER_RESET_REQUEST_POWER_UP, &powerUpRequest));
      naiif_printf("      %1d             %1d              %1d            %1d           %1d           %1d        %1d          %1d\r\n",
         poweredDownStatus, notDetectedStatus, notLinkInitStatus, notFWNotStatus, commErrorStatus, resetRequest, powerDownRequest, powerUpRequest);
      naiapp_display_ParamMenuCommands((int8_t*)"DT Power Reset Operation Menu");
      naiif_printf("\r\nType LVDT Module Power Reset command or %c to quit : main > module power reset >", NAI_QUIT_CHAR);
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            if ((inputBuffer[0] == 'B') || (inputBuffer[0] == 'b'))
            {
               bContinue = NAI_FALSE;
            }
            else
            {
               bCmdFound = naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
               if (bCmdFound)
               {
                  LVDT_ModulePowerResetMenuCmds[cmd].func(paramCount, p_params);
               }
               else
               {
                  naiif_printf("\r\nInvalid command entered\r\n");
               }
            }
         }
      }
      else
         bContinue = NAI_FALSE;
   }
   numMenuCmds = LVDT_BASICMENU_CMD_COUNT;
   naiapp_utils_LoadParamMenuCommands(numMenuCmds, LVDT_BasicOpMenuCmds);
   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
Configure_LVDT_ClearModulePowerResetStatus handles the user request to clear the module power reset status
and calls the method in the naibrd library to clear the module power reset status. The user is
prompted for the module power reset status type to clear.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Configure_LVDT_ClearModulePowerResetStatus(int32_t paramCount, int32_t* p_params)
{
   uint8_t statusTypeStr[MSG_LENGTH];
   bool_t bQuit = NAI_FALSE;
   naibrd_lvdt_module_power_reset_status_type_t statusTypeToClear = (naibrd_lvdt_module_power_reset_status_type_t)0u;
   bool_t modulePowerResetStatusRead = 0u;
   p_naiapp_AppParameters_t p_lvdt_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_lvdt_params->cardIndex;
   int32_t module = p_lvdt_params->module;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   NAIBSP_UNREFERENCED_PARAMETER(paramCount);

   naiif_printf("\r\nSelect Module Power Reset Status type to clear: (0 for Powered Down, 1 for Not Detected, 2 for Not Link Init, 3 for Not FW Not, 4 for Comm Error, q for quit): ");
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if ((!bQuit) && (inputResponseCnt > 0))
   {
      switch (inputBuffer[0])
      {
      case '0':
         statusTypeToClear = NAIBRD_LVDT_MODULE_POWER_RESET_STATUS_POWERED_DOWN;
         memset(statusTypeStr, 0, sizeof(statusTypeStr));
         naiif_snprintf((char*)statusTypeStr, MSG_LENGTH + 1, "Powered Down");
         break;
      case '1':
         statusTypeToClear = NAIBRD_LVDT_MODULE_POWER_RESET_STATUS_NOT_DETECTED;
         memset(statusTypeStr, 0, sizeof(statusTypeStr));
         naiif_snprintf((char*)statusTypeStr, MSG_LENGTH + 1, "Not Detected");
         break;
      case '2':
         statusTypeToClear = NAIBRD_LVDT_MODULE_POWER_RESET_STATUS_NOT_LINK_INIT;
         memset(statusTypeStr, 0, sizeof(statusTypeStr));
         naiif_snprintf((char*)statusTypeStr, MSG_LENGTH + 1, "Not Link Init");
         break;
      case '3':
         statusTypeToClear = NAIBRD_LVDT_MODULE_POWER_RESET_STATUS_FW_NOT_READY;
         memset(statusTypeStr, 0, sizeof(statusTypeStr));
         naiif_snprintf((char*)statusTypeStr, MSG_LENGTH + 1, "Not FW Not");
         break;
      case '4':
         statusTypeToClear = NAIBRD_LVDT_MODULE_POWER_RESET_STATUS_COMM_ERROR;
         memset(statusTypeStr, 0, sizeof(statusTypeStr));
         naiif_snprintf((char*)statusTypeStr, MSG_LENGTH + 1, "Comm Error");
         break;
      case 'q':
      case 'Q':
         bQuit = NAI_TRUE;
         break;
      default:
         bQuit = NAI_TRUE;
         naiif_printf("\r\nInvalid module power reset status type entered\r\n");
         break;
      }

      if (!bQuit)
      {
         naiif_printf("\r\nAre you sure you want to clear the %s status? (Y for Yes or N for No): ", statusTypeStr);
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if ((!bQuit) && (inputResponseCnt > 0) && (toupper(inputBuffer[0]) == 'Y'))
         {
            check_status(naibrd_LVDT_GetModulePowerResetStatus(cardIndex, module, statusTypeToClear, &modulePowerResetStatusRead));
            if (modulePowerResetStatusRead == 1u)
            {
               check_status(naibrd_LVDT_ClearModulePowerResetStatus(cardIndex, module, statusTypeToClear));
            }
         }
      }
   }

   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
Configure_LVDT_SetModulePowerReset handles the user request to set the module power reset request
and calls the method in the naibrd library to set the module power reset request. The user is
prompted for the module power reset request type to set, and then the user is prompted to set
or reset the request bit.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t Configure_LVDT_SetModulePowerReset(int32_t paramCount, int32_t* p_params)
{
   uint8_t resetTypeStr[MSG_LENGTH];
   bool_t bQuit = NAI_FALSE;
   naibrd_lvdt_module_power_reset_type_t resetTypeToSet = (naibrd_lvdt_module_power_reset_type_t)0u;
   p_naiapp_AppParameters_t p_lvdt_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_lvdt_params->cardIndex;
   int32_t module = p_lvdt_params->module;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   NAIBSP_UNREFERENCED_PARAMETER(paramCount);

   naiif_printf("\r\nSelect Module Power Reset Request type to set: (0 for Reset, 1 for Power Down, 2 for Power Up, q for quit): ");
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if ((!bQuit) && (inputResponseCnt > 0))
   {
      switch (inputBuffer[0])
      {
      case '0':
         resetTypeToSet = NAIBRD_LVDT_MODULE_POWER_RESET_REQUEST_RESET;
         memset(resetTypeStr, 0, sizeof(resetTypeStr));
         naiif_snprintf((char*)resetTypeStr, MSG_LENGTH + 1, "Reset");
         break;
      case '1':
         resetTypeToSet = NAIBRD_LVDT_MODULE_POWER_RESET_REQUEST_POWER_DOWN;
         memset(resetTypeStr, 0, sizeof(resetTypeStr));
         naiif_snprintf((char*)resetTypeStr, MSG_LENGTH + 1, "Power Down");
         break;
      case '2':
         resetTypeToSet = NAIBRD_LVDT_MODULE_POWER_RESET_REQUEST_POWER_UP;
         memset(resetTypeStr, 0, sizeof(resetTypeStr));
         naiif_snprintf((char*)resetTypeStr, MSG_LENGTH + 1, "Power Up");
         break;
      case 'q':
      case 'Q':
         bQuit = NAI_TRUE;
         break;
      default:
         bQuit = NAI_TRUE;
         naiif_printf("\r\nInvalid module power reset request type entered\r\n");
         break;
      }

      if (!bQuit)
      {
         naiif_printf("\r\nDo you want to set or reset the %s request? (1 to set, 0 to reset): ", resetTypeStr);
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if ((!bQuit) && (inputResponseCnt > 0))
         {
            if (inputBuffer[0] == '0')
            {
               check_status(naibrd_LVDT_SetModulePowerReset(cardIndex, module, resetTypeToSet, (bool_t)NAI_FALSE));
            }
            else if (inputBuffer[0] == '1')
            {
               check_status(naibrd_LVDT_SetModulePowerReset(cardIndex, module, resetTypeToSet, (bool_t)NAI_TRUE));
            }
            else
            {
               naiif_printf("\r\nInvalid selection entered\r\n");
            }
         }
      }
   }

   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}

Help Bot

X