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

TC BasicOps

TC BasicOps Sample Application (SSK 2.x)

Overview

The TC BasicOps sample application demonstrates how to configure and read thermocouple channels using the NAI Software Support Kit (SSK 2.x). It covers thermocouple type selection, sample rate configuration, cold junction compensation (CJC), temperature and voltage reading, threshold configuration, status management, offset temperature, background operation suspension, system calibration triggering, open-line checks, BIT operations, and TC/RTD configuration mode switching.

This sample supports the TC1 module type (and TR1 for combined TC/RTD operation). It provides an interactive command menu where each command maps directly to one or more naibrd_TC_*() API calls. Refer to the TC1 Manual for detailed module specifications.

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

Prerequisites

Before running this sample, make sure you have:

  • An NAI board with a TC1 (or TR1) module installed.

  • SSK 2.x installed on your development host.

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

How to Run

Launch the tc_basic_ops executable from your build output directory. On startup the application looks for a configuration file (default_TC_BasicOps.txt). On the first run, this file will not exist — the application will present an interactive board menu where you configure a board connection, card index, and module slot. You can save this configuration so that subsequent runs skip the menu and connect automatically. Once connected, the application prompts for a channel number, displays channel measurements, and presents the command menu.

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

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_TC_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().

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

   if (naiapp_RunBoardMenu(TC_CONFIG_FILE) == (bool_t)NAI_TRUE)
   {
      while (stop != NAI_TRUE)
      {
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != NAI_TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != NAI_TRUE)
            {
               check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
               g_modId = moduleID;
               if ((moduleID != 0))
               {
                  TCBasicMenu_Run(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:

  • The VxWorks preprocessor guard uses NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS (SSK 1.x uses __VXWORKS__).

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

Program Structure

Entry Point

On standard platforms (Petalinux, DEOS) the entry point is main(). On VxWorks the entry point is TC_RunBasicOps().

Command Loop

The TCBasicMenu_Run() function prompts for a channel number, displays channel measurements, loads the command table, and enters a do…​while loop that processes user commands.

Command Description

0

Set the thermocouple type (J, K, E, T, N, B, R, S)

1

Set the sample rate

2

Set the compensation temperature

3

Enable or disable Cold Junction Compensation (CJC)

4

Set the CJC type

5

Set a threshold value

6

Clear a status

7

Set the offset temperature

8

Suspend BIT/Open tests and System Cal

9

Trigger system calibration

A

Trigger open-line check

B

Trigger BIT

C

Enable/disable channel status reporting

D

Set TC/RTD configuration mode (for TR1 modules)

Display Channel Measurements

The naiapp_TCBasicMenu_DisplayMeasurements() function displays comprehensive channel information including TC/RTD configuration type, thermocouple type, temperature (Celsius and Fahrenheit), voltage, sample rate, compensation temperature, CJC enable status, CJC type, offset temperature, background operation suspension, thresholds, and all channel statuses.

Key API calls:

  • naibrd_TC_GetTemperature() — reads temperature in Celsius or Fahrenheit.

  • naibrd_TC_GetVoltage() — reads the thermocouple voltage.

  • naibrd_TC_GetSampleRate() — reads the configured sample rate.

  • naibrd_TC_GetCompTemperature() — reads the compensation temperature.

  • naibrd_TC_GetCJCEnable() — checks if CJC is enabled.

  • naibrd_TC_GetThermocoupleType() — reads the configured thermocouple type.

  • naibrd_TC_GetChanMappedStatus() — reads channel status bits.

Configuration Operations

The configuration commands allow setting the thermocouple type, sample rate, CJC parameters, thresholds, and offset temperature.

Key API calls:

  • naibrd_TC_SetThermocoupleType() — sets the thermocouple type (J, K, E, T, N, B, R, S).

  • naibrd_TC_SetSampleRate() — sets the measurement sample rate.

  • naibrd_TC_SetCompTemperature() — sets the compensation temperature.

  • naibrd_TC_SetCJCEnable() — enables or disables CJC.

  • naibrd_TC_SetCJCType() — sets the CJC type.

  • naibrd_TC_SetThreshold() — sets a threshold value.

  • naibrd_TC_SetOffsetTemperature() — sets the offset temperature.

  • naibrd_TC_SetConfiguration() — switches between TC and RTD mode (TR1 modules).

Calibration and Test Operations

The application supports triggering system calibration, open-line checks, and BIT operations.

Key API calls:

  • naibrd_TC_TriggerSystemCalibration() — initiates a system calibration cycle.

  • naibrd_TC_TriggerOpenCheck() — initiates an open-line check.

  • naibrd_TC_TriggerBIT() — initiates a Built-In Test.

  • naibrd_TC_SetBackgroundOpSuspension() — suspends or resumes background BIT/open/cal operations.

  • naibrd_TC_SetChanStatusEnable() — enables or disables channel status reporting.

  • naibrd_TC_ClearChanMappedStatus() — clears a latched status.

Troubleshooting Reference

Error / Symptom Possible Causes Suggested Resolution

No board found

Board not powered or not connected

Verify power and physical connections; check configuration file

Connection timeout

Network/bus misconfiguration

Confirm IP address, subnet, or PCI/PCIe settings

Invalid card or module index

Wrong index values entered

Cards are zero-based, modules are one-based

Temperature reads out of range

Wrong thermocouple type selected or open circuit

Verify TC type matches physical sensor; check wiring

Voltage reads zero

No thermocouple connected or channel disabled

Connect thermocouple; enable channel status reporting

CJC compensation incorrect

CJC disabled or wrong CJC type

Enable CJC and verify CJC type matches your setup

Open-line status asserted

Thermocouple disconnected or broken wire

Check thermocouple wiring and connections

BIT failure

Hardware or calibration issue

Run system calibration; check module health

Sample rate not changing

Background operations suspended

Resume background operations before changing sample rate

TC/RTD mode switch fails

Module does not support RTD (TC1 only supports TC)

RTD mode is only available on TR1 modules

Full Source

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

Full Source — tc_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_tc.h"

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

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

#define MSG_LENGTH (20)

static const int8_t *SAMPLE_PGM_NAME = (const int8_t *)"TC Module Basic Operations";
static const int8_t *TC_CONFIG_FILE = (const int8_t *)"default_TC_BasicOps.txt";

uint32_t g_modId = 0u;

/* Function prototypes */
static bool_t TCBasicMenu_Run(int32_t cardIndex, int32_t module, uint32_t moduleID);
static void naiapp_TCBasicMenu_DisplayMeasurements(int32_t cardIndex, int32_t module, int32_t chan);

/* Channel Display Helper Functions*/
static void naiapp_TC_Display_ConfigAndThermoCoupleType(int32_t cardIndex, int32_t module, int32_t chan);
static void naiapp_TC_Display_Temperature(int32_t cardIndex, int32_t module, int32_t chan);
static void naiapp_TC_Display_Voltage(int32_t cardIndex, int32_t module, int32_t chan);
static void naiapp_TC_Display_SampleRate(int32_t cardIndex, int32_t module, int32_t chan);
static void naiapp_TC_Display_CompTemp(int32_t cardIndex, int32_t module, int32_t chan);
static void naiapp_TC_Display_CJCEnable(int32_t cardIndex, int32_t module);
static void naiapp_TC_Display_Statuses(int32_t cardIndex, int32_t module, int32_t chan);
static void naiapp_TC_Display_Thresholds(int32_t cardIndex, int32_t module, int32_t chan);
static void naiapp_TC_Display_CJCType(int32_t cardIndex, int32_t module, int32_t chan);
static void naiapp_TC_Display_OffsetTemp(int32_t cardIndex, int32_t module, int32_t chan);
static void naiapp_TC_Display_BackgroundOpSuspension(int32_t cardIndex, int32_t module, int32_t chan);

/* Menu Command Helper Functions*/
static nai_status_t naiapp_TC_Set_ThermoCoupleType(int32_t paramCount, int32_t* p_params);
static nai_status_t naiapp_TC_Set_SampleRate(int32_t paramCount, int32_t* p_params);
static nai_status_t naiapp_TC_Set_CompTemp(int32_t paramCount, int32_t* p_params);
static nai_status_t naiapp_TC_Set_CJCEnable(int32_t paramCount, int32_t* p_params);
static nai_status_t naiapp_TC_Set_Thresh(int32_t paramCount, int32_t* p_params);
static nai_status_t naiapp_TC_ClearStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t naiapp_TC_Set_CJCType(int32_t paramCount, int32_t* p_params);
static nai_status_t naiapp_TC_Set_OffsetTemp(int32_t paramCount, int32_t* p_params);
static nai_status_t naiapp_TC_Set_BackgroundOpSuspension(int32_t paramCount, int32_t* p_params);
static nai_status_t naiapp_TC_Trigger_SystemCalibration(int32_t paramCount, int32_t* p_params);
static nai_status_t naiapp_TC_Trigger_OpenCheck(int32_t paramCount, int32_t* p_params);
static nai_status_t naiapp_TC_Trigger_BIT(int32_t paramCount, int32_t* p_params);
static nai_status_t naiapp_TC_ChannelStatusEnable(int32_t paramCount, int32_t* params);
static nai_status_t naiapp_TC_Configuration(int32_t paramCount, int32_t* p_params);


/****** Command Tables *******/
enum tc_basicops_commands
{
   TC_BASICMENU_CMD_SET_THERMO_COUPLE_TYPE,
   TC_BASICMENU_CMD_SET_SAMPLE_RATE,
   TC_BASICMENU_CMD_SET_COMP_TEMP,
   TC_BASICMENU_CMD_SET_CJC_ENABLE,
   TC_BASICMENU_CMD_SET_CJC_TYPE,
   TC_BASICMENU_CMD_SET_THRESH,
   TC_BASICMENU_CMD_CLEAR_STATUS,
   TC_BASICMENU_CMD_SET_OFFSET_TEMP,
   TC_BASICMENU_CMD_SET_BACKGROUND_OP_SUSPEND,
   TC_BASICMENU_CMD_TRIGGER_SYSTEM_CAL,
   TC_BASICMENU_CMD_TRIGGER_OPEN_CHECK,
   TC_BASICMENU_CMD_TRIGGER_BIT,
   TC_BASICMENU_CMD_CHANNEL_STATUS_ENABLE,
   TC_BASICMENU_CMD_TC_RTD_CONFIG,
   TC_BASICMENU_CMD_COUNT
};


naiapp_cmdtbl_params_t TC_BasicOpMenuCmds[] = {
   {"0", "Set the Thermo Couple Type", TC_BASICMENU_CMD_SET_THERMO_COUPLE_TYPE, naiapp_TC_Set_ThermoCoupleType},
   {"1", "Set the Sample Rate", TC_BASICMENU_CMD_SET_SAMPLE_RATE, naiapp_TC_Set_SampleRate},
   {"2", "Set the Compensation Temperature", TC_BASICMENU_CMD_SET_COMP_TEMP, naiapp_TC_Set_CompTemp},
   {"3", "Enable/Disable Cold Junction Compensation", TC_BASICMENU_CMD_SET_CJC_ENABLE, naiapp_TC_Set_CJCEnable},
   {"4", "Set the CJC Type", TC_BASICMENU_CMD_SET_CJC_TYPE, naiapp_TC_Set_CJCType},
   {"5", "Set a Threshold Value", TC_BASICMENU_CMD_SET_THRESH, naiapp_TC_Set_Thresh},
   {"6", "Clear a Status", TC_BASICMENU_CMD_CLEAR_STATUS, naiapp_TC_ClearStatus},
   {"7", "Set the Offset Temperature", TC_BASICMENU_CMD_SET_OFFSET_TEMP, naiapp_TC_Set_OffsetTemp},
   {"8", "Suspend BIT/Open tests and System Cal", TC_BASICMENU_CMD_SET_BACKGROUND_OP_SUSPEND, naiapp_TC_Set_BackgroundOpSuspension},
   {"9", "Trigger System Calibration", TC_BASICMENU_CMD_TRIGGER_SYSTEM_CAL, naiapp_TC_Trigger_SystemCalibration},
   {"A", "Trigger Open-Line Check", TC_BASICMENU_CMD_TRIGGER_OPEN_CHECK, naiapp_TC_Trigger_OpenCheck},
   {"B", "Trigger BIT", TC_BASICMENU_CMD_TRIGGER_BIT, naiapp_TC_Trigger_BIT},
   {"C", "Channel Status Enable/Disable", TC_BASICMENU_CMD_CHANNEL_STATUS_ENABLE, naiapp_TC_ChannelStatusEnable},
   {"D", "Set TC/RTD Configuration Mode", TC_BASICMENU_CMD_TC_RTD_CONFIG, naiapp_TC_Configuration}
};

/**************************************************************************************************************/
/**
<summary>
The purpose of the TC_BasicOps is to illustrate the methods to call in the naibrd library to perform basic
 operations with the thermal coupling module 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 TC routines.
 - ClearDeviceCfg
 - QuerySystemCfg
 - DisplayDeviceCfg
 - GetBoardSNModCfg
 - SaveDeviceCfg

</summary>
*/
/**************************************************************************************************************/

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

   if (naiapp_RunBoardMenu(TC_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));
               g_modId = moduleID;
               if ((moduleID != 0))
               {
                  TCBasicMenu_Run(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_TC_BasicOps prompts the user for the card, module and channel to use for the application and calls
Cfg_TC_Channel if the card, module, channel is valid for as a discrete module.
</summary>
*/
/**************************************************************************************************************/
static bool_t TCBasicMenu_Run(int32_t cardIndex, int32_t module, uint32_t modId)
{
   bool_t quit = NAI_FALSE;
   int32_t cmd = TC_BASICMENU_CMD_COUNT;
   naiapp_AppParameters_t refParams;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   refParams.cardIndex = cardIndex;
   refParams.module = module;
   refParams.modId = modId;
   refParams.maxChannels = naibrd_TC_GetChannelCount(modId);

   naiapp_utils_LoadParamMenuCommands(TC_BASICMENU_CMD_COUNT, TC_BasicOpMenuCmds);
   do
   {
      naiapp_query_ChannelNumber(refParams.maxChannels, 1, &(refParams.channel));
      naiapp_TCBasicMenu_DisplayMeasurements(cardIndex, module, refParams.channel);
      naiapp_display_ParamMenuCommands((int8_t*)SAMPLE_PGM_NAME);
      naiif_printf("\r\n Type command or %c to quit : ", NAI_QUIT_CHAR);
      quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!quit && inputResponseCnt > 0)
      {
         naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
         switch (cmd)
         {
            case TC_BASICMENU_CMD_SET_THERMO_COUPLE_TYPE:
            case TC_BASICMENU_CMD_SET_SAMPLE_RATE:
            case TC_BASICMENU_CMD_SET_COMP_TEMP:
            case TC_BASICMENU_CMD_SET_CJC_ENABLE:
            case TC_BASICMENU_CMD_SET_CJC_TYPE:
            case TC_BASICMENU_CMD_SET_THRESH:
            case TC_BASICMENU_CMD_CLEAR_STATUS:
            case TC_BASICMENU_CMD_SET_OFFSET_TEMP:
            case TC_BASICMENU_CMD_SET_BACKGROUND_OP_SUSPEND:
            case TC_BASICMENU_CMD_TRIGGER_SYSTEM_CAL:
            case TC_BASICMENU_CMD_TRIGGER_OPEN_CHECK:
            case TC_BASICMENU_CMD_TRIGGER_BIT:
            case TC_BASICMENU_CMD_CHANNEL_STATUS_ENABLE:
            case TC_BASICMENU_CMD_TC_RTD_CONFIG:
               TC_BasicOpMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)&refParams);
            break;

            default:
               naiif_printf("Please enter a menu selection above\r\n");
            break;
         }
      }
   } while (!quit);


   return NAI_TRUE;
}

/**************************************************************************************************************/
/**
<summary>
Display_TC_ChannelCfg illustrate the methods to call in the naibrd library to retrieve the configuration states
for basic operation.
</summary>
*/
/**************************************************************************************************************/
static void naiapp_TCBasicMenu_DisplayMeasurements(int32_t cardIndex, int32_t module, int32_t chan)
{
   naiif_printf("\r\n===============================================================\r\n");
   naiif_printf("CHANNEL %d\r\n", chan);
   naiif_printf("===============================================================\r\n");
   naiapp_TC_Display_ConfigAndThermoCoupleType(cardIndex, module, chan);
   naiapp_TC_Display_Temperature(cardIndex, module, chan);
   naiapp_TC_Display_Voltage(cardIndex, module, chan);
   naiapp_TC_Display_SampleRate(cardIndex, module, chan);
   naiapp_TC_Display_CompTemp(cardIndex, module, chan);
   naiapp_TC_Display_CJCEnable(cardIndex, module);
   naiapp_TC_Display_CJCType(cardIndex, module, chan);
   naiapp_TC_Display_OffsetTemp(cardIndex, module, chan);
   naiapp_TC_Display_BackgroundOpSuspension(cardIndex, module, chan);
   naiapp_TC_Display_Thresholds(cardIndex, module, chan);
   naiapp_TC_Display_Statuses(cardIndex, module, chan);
   naiif_printf("\r\n=========================================================================");
}

static void naiapp_TC_Display_ConfigAndThermoCoupleType(int32_t cardIndex, int32_t module, int32_t chan)
{
   naibrd_tc_config_type_t configType;
   naibrd_tc_thermocouple_type_t TcType;
   bool_t isTCConfig = NAI_FALSE;
   char type = '\0';
   uint8_t strConfig[MSG_LENGTH] = "";
   if (g_modId == NAIBRD_MODULE_ID_TR1)
   {
      check_status(naibrd_TC_GetConfiguration(cardIndex, module, chan, &configType));
   }
   else
   {
      configType = NAIBRD_TC_THERMOCOUPLE;
   }

   switch (configType)
   {
      case NAIBRD_TC_THERMOCOUPLE:
         naiif_snprintf((char*)strConfig, MSG_LENGTH + 1, "TC");
         isTCConfig = NAI_TRUE;
      break;
      case NAIBRD_TC_RTD:
         naiif_snprintf((char*)strConfig, MSG_LENGTH + 1, "RTD");
         isTCConfig = NAI_FALSE;
      break;
      default:
         naiif_printf("Invalid TC/RTD Configuration Type read from module\r\n");
         naiif_snprintf((char*)strConfig, MSG_LENGTH + 1, "Non-TC");
         isTCConfig = NAI_FALSE;
      break;
   }

   naiif_printf("\r\n%-35s %s\r\n", "TC/RTD Configuration Type:", strConfig);

   if (isTCConfig == NAI_TRUE)
   {
      check_status(naibrd_TC_GetThermocoupleType(cardIndex, module, chan, &TcType));
      switch(TcType)
      {
         case NAIBRD_TC_THERMOCOUPLE_TYPE_J:
            type = 'J';
         break;

         case NAIBRD_TC_THERMOCOUPLE_TYPE_K:
            type = 'K';
         break;

         case NAIBRD_TC_THERMOCOUPLE_TYPE_E:
            type = 'E';
         break;

         case NAIBRD_TC_THERMOCOUPLE_TYPE_T:
            type = 'T';
         break;

         case NAIBRD_TC_THERMOCOUPLE_TYPE_N:
            type = 'N';
         break;

         case NAIBRD_TC_THERMOCOUPLE_TYPE_B:
            type = 'B';
         break;

         case NAIBRD_TC_THERMOCOUPLE_TYPE_R:
            type = 'R';
         break;

         case NAIBRD_TC_THERMOCOUPLE_TYPE_S:
            type = 'S';
         break;

         default:
            naiif_printf("Invalid ThermoCouple Type\r\n");
         break;
      }

      naiif_printf("\r\n%-35s %c\r\n", "ThermoCouple Type:", type);
   }
   else
   {
      naiif_printf("\r\n%-35s RTD\r\n", "ThermoCouple Type:");
   }
}

static void naiapp_TC_Display_Temperature(int32_t cardIndex, int32_t module, int32_t chan)
{
   float64_t cTemp = 0.0;
   float64_t fTemp = 0.0;

   check_status(naibrd_TC_GetTemperature(cardIndex, module, chan, NAIBRD_TC_TEMP_TYPE_CELSIUS, &cTemp));
   check_status(naibrd_TC_GetTemperature(cardIndex, module, chan, NAIBRD_TC_TEMP_TYPE_FAHRENHEIT, &fTemp));

   naiif_printf("%-35s %f C\r\n","Temperature(Celsius):", cTemp);
   naiif_printf("%-35s %f F\r\n","Temperature(Fahrenheit):", fTemp);
}

static void naiapp_TC_Display_Voltage(int32_t cardIndex, int32_t module, int32_t chan)
{
   float64_t voltage = 0.0;
   check_status(naibrd_TC_GetVoltage(cardIndex, module, chan, &voltage));

   naiif_printf("%-35s %.3f mV\r\n", "Voltage:", voltage * 1000.0);
}

static void naiapp_TC_Display_SampleRate(int32_t cardIndex, int32_t module, int32_t chan)
{
   float64_t rate = 0.0;
   check_status(naibrd_TC_GetSampleRate(cardIndex, module, chan, &rate));

   naiif_printf("%-35s %i Hz\r\n", "Sample Rate:", (int32_t)rate);
}

static void naiapp_TC_Display_CompTemp(int32_t cardIndex, int32_t module, int32_t chan)
{
   float64_t temp = 0.0;
   check_status(naibrd_TC_GetCompTemperature(cardIndex, module, chan, &temp));

   naiif_printf("%-35s %f C\r\n", "Compensation Temperature:", temp);
}

static void naiapp_TC_Display_CJCEnable(int32_t cardIndex, int32_t module)
{
   bool_t enabled = NAI_FALSE;

   check_status(naibrd_TC_GetCJCEnable(cardIndex, module, &enabled));
   naiif_printf("%-35s %s\r\n", "CJC Enabled:", enabled? "True" : "False");
}

static void naiapp_TC_Display_Statuses(int32_t cardIndex, int32_t module, int32_t chan)
{
   int32_t statusIndex;
   bool_t chanStatusEnabled = NAI_TRUE;
   nai_status_bit_t statuses[NAIBRD_TC_STATUS_TYPE_ENUM_COUNT]; /* declare array to hold status bits */

   check_status(naibrd_TC_GetChanStatusEnable(cardIndex, module, chan, &chanStatusEnabled));

   /* get status bits for the channel*/
   for(statusIndex = 0; (uint32_t)statusIndex < NAIBRD_TC_STATUS_TYPE_ENUM_COUNT; statusIndex++)
   {
      check_status(naibrd_TC_GetChanMappedStatus( cardIndex, module, chan, (naibrd_tc_chan_mapped_status_type_t)statusIndex,
         &statuses[statusIndex]));
   }

   /* print headers (hardcoded) */
   naiif_printf("Channel Status: %s\r\n", (chanStatusEnabled == NAI_FALSE) ? "DISABLED" : "ENABLED");
   naiif_printf("\r\nStatus(latched):\r\n");
   naiif_printf("%-10s %-10s %-10s %-10s %-10s %-10s %-10s\r\n", "bit", "open", "alert_lo", "alarm_lo", "alert_hi", "alarm_hi", "summary");
   naiif_printf("-------------------------------------------------------------------------\r\n");

   /* print status bits */
   for(statusIndex = 1; (uint32_t)statusIndex < NAIBRD_TC_STATUS_TYPE_ENUM_COUNT; statusIndex+=2)
   {
      naiif_printf("%-10i ", statuses[statusIndex]);
   }
}

static void naiapp_TC_Display_Thresholds(int32_t cardIndex, int32_t module, int32_t chan)
{
   float64_t alert_lo, alarm_lo, alert_hi, alarm_hi;
   check_status(naibrd_TC_GetThreshold(cardIndex, module, chan, NAIBRD_TC_THRESH_ALERT_LO, &alert_lo));
   check_status(naibrd_TC_GetThreshold(cardIndex, module, chan, NAIBRD_TC_THRESH_ALARM_LO, &alarm_lo));
   check_status(naibrd_TC_GetThreshold(cardIndex, module, chan, NAIBRD_TC_THRESH_ALERT_HI, &alert_hi));
   check_status(naibrd_TC_GetThreshold(cardIndex, module, chan, NAIBRD_TC_THRESH_ALARM_HI, &alarm_hi));
   naiif_printf("\r\nThresholds:\r\n");
   naiif_printf("Alert Lo: %-13f C  Alarm Lo: %-13f C  \r\nAlert Hi: %-13f C  Alarm Hi: %-13f C\r\n", alert_lo, alarm_lo, alert_hi, alarm_hi);
}

static void naiapp_TC_Display_CJCType(int32_t cardIndex, int32_t module, int32_t chan)
{
   naibrd_tc_comp_type_t type;

   check_status(naibrd_TC_GetCompType(cardIndex, module, chan, &type));

   naiif_printf("%-35s ", "CJC Type:");
   switch(type)
   {
      case NAIBRD_TC_COMP_TYPE_MANUAL:
         naiif_printf("Manual\r\n");
      break;

      case NAIBRD_TC_COMP_TYPE_AUTO:
         naiif_printf("Auto\r\n");
      break;

      default:
         naiif_printf("Invalid CJC Type\r\n");
      break;
   }
}

static void naiapp_TC_Display_OffsetTemp(int32_t cardIndex, int32_t module, int32_t chan)
{
   float64_t temp = 0.0;
   nai_status_t status = check_status(naibrd_TC_GetOffsetTemperature(cardIndex, module, chan, &temp));

   if (status == NAI_SUCCESS)
   {
      naiif_printf("%-35s %f C\r\n", "Offset Temperature:", temp);
   }
   else if (status == NAI_ERROR_NOT_SUPPORTED)
   {
      naiif_printf("%-35s Not supported\r\n", "Offset Temperature:");
   }
   else
   {
      naiif_printf("%-35s Unknown\r\n", "Offset Temperature:");
   }
}

static void naiapp_TC_Display_BackgroundOpSuspension(int32_t cardIndex, int32_t module, int32_t chan)
{
   bool_t disabled = NAI_FALSE;
   nai_status_t status = check_status(naibrd_TC_GetBackgroundOpSuspend(cardIndex, module, chan, &disabled));

   if (status == NAI_SUCCESS)
   {
      naiif_printf("%-35s %s\r\n", "Background Ops Suspended:", disabled? "True" : "False");
   }
   else if (status == NAI_ERROR_NOT_SUPPORTED)
   {
      naiif_printf("%-35s Not supported\r\n", "Background Ops Suspended:");
   }
   else
   {
      naiif_printf("%-35s Unknown\r\n", "Background Ops Suspended:");
   }
}

/**************************************************************************************************************/
/**
<summary>
TC_Set_ThermoCoupleType handles the user request to configure the thermo couple type for the given channel and
calls the relevant setter method in the naibrd library.
</summary>
*/
/**************************************************************************************************************/

static nai_status_t naiapp_TC_Set_ThermoCoupleType(int32_t paramCount, int32_t* p_params)
{
   bool_t responseValid = NAI_FALSE;
   naibrd_tc_thermocouple_type_t type;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   p_naiapp_AppParameters_t p_tcParams = NULL;
   bool_t quit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      p_tcParams = (p_naiapp_AppParameters_t)p_params;

      do
      {
         naiif_printf("Enter new thermo couple type (J, K, E, T, N, B, R, or S): ");
         quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if(!quit)
         {
            responseValid = NAI_TRUE;
            switch(toupper(inputBuffer[0]))
            {
               case 'J':
                  type = NAIBRD_TC_THERMOCOUPLE_TYPE_J;
               break;

               case 'K':
                  type = NAIBRD_TC_THERMOCOUPLE_TYPE_K;
               break;

               case 'E':
                  type = NAIBRD_TC_THERMOCOUPLE_TYPE_E;
               break;

               case 'T':
                  type = NAIBRD_TC_THERMOCOUPLE_TYPE_T;
               break;

               case 'N':
                  type = NAIBRD_TC_THERMOCOUPLE_TYPE_N;
               break;

               case 'B':
                  type = NAIBRD_TC_THERMOCOUPLE_TYPE_B;
               break;

               case 'R':
                  type = NAIBRD_TC_THERMOCOUPLE_TYPE_R;
               break;

               case 'S':
                  type = NAIBRD_TC_THERMOCOUPLE_TYPE_S;
               break;

               default:
                  responseValid = NAI_FALSE;
               break;
            }
         }

         if (responseValid == NAI_FALSE)
         {
            naiif_printf("\r\n\r\n\r\nInvalid ThermoCouple Type\r\n\r\n");
         }
         else
         {
            status = check_status(naibrd_TC_SetThermocoupleType(p_tcParams->cardIndex, p_tcParams->module, p_tcParams->channel, type));
         }
      } while ((quit == NAI_FALSE) && (responseValid == NAI_FALSE));
   }

   return status;
}

/**************************************************************************************************************/
/**
<summary>
TC_Set_SampleRate handles the user request to configure the sample rate for the given channel and
calls the relevant setter method in the naibrd library.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t naiapp_TC_Set_SampleRate(int32_t paramCount, int32_t* p_params)
{
   float64_t rate = 0.0;
   bool_t responseValid = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   p_naiapp_AppParameters_t p_tcParams = NULL;
   bool_t quit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      p_tcParams = (p_naiapp_AppParameters_t)p_params;

      do
      {
         naiif_printf("Enter new sample rate: ");
         quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if(!quit)
         {
            if (strlen((const char*)inputBuffer) > 0)
            {
               rate = atof((const char*)inputBuffer);
               status = check_status(naibrd_TC_SetSampleRate(p_tcParams->cardIndex, p_tcParams->module, p_tcParams->channel, rate));
               responseValid = NAI_TRUE;
            }
            else
            {
               naiif_printf("\r\n\r\n\r\nInvalid Sample Rate Entered\r\n\r\n");
               responseValid = NAI_FALSE;
            }
         }
      } while ((quit == NAI_FALSE) && (responseValid == NAI_FALSE));
   }

   return status;
}

/**************************************************************************************************************/
/**
<summary>
TC_Set_CompTemp handles the user request to configure the compensation temperature for the given channel and
calls the relevant setter method in the naibrd library.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t naiapp_TC_Set_CompTemp(int32_t paramCount, int32_t* p_params)
{
   float64_t temp = 0.0;
   bool_t responseValid = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   p_naiapp_AppParameters_t p_tcParams = NULL;
   bool_t quit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      p_tcParams = (p_naiapp_AppParameters_t)p_params;

      do
      {
         naiif_printf("Enter new compensation temperature: ");
         quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if(!quit)
         {
            if (strlen((const char*)inputBuffer) > 0)
            {
               temp = atof((const char*)inputBuffer);
               status = check_status(naibrd_TC_SetCompTemperature(p_tcParams->cardIndex, p_tcParams->module, p_tcParams->channel, temp));
               responseValid = NAI_TRUE;
            }
            else
            {
               naiif_printf("\r\n\r\n\r\nInvalid Compensation Temperature Entered\r\n\r\n");
               responseValid = NAI_FALSE;
            }
         }
      } while ((quit == NAI_FALSE) && (responseValid == NAI_FALSE));
   }

   return status;
}

/**************************************************************************************************************/
/**
<summary>
TC_Set_CJCEnable handles the user request to configure the cold junction compensation for the TC module and
calls the relevant setter method in the naibrd library.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t naiapp_TC_Set_CJCEnable(int32_t paramCount, int32_t* p_params)
{
   bool_t enable = NAI_FALSE;
   int32_t response = 0;
   bool_t responseValid = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   p_naiapp_AppParameters_t p_tcParams = NULL;
   bool_t quit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      p_tcParams = (p_naiapp_AppParameters_t)p_params;

      do
      {
         naiif_printf("Enable cold junction compensation? (1 - Yes, 0 - No): ");
         quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if(!quit)
         {
            if (strlen((const char*)inputBuffer) > 0)
            {
               response = (int32_t)atoi((const char*)inputBuffer);
               responseValid = NAI_TRUE;
               switch(response)
               {
                  case 0:
                     enable = NAI_FALSE;
                  break;

                  case 1:
                     enable = NAI_TRUE;
                  break;

                  default:
                     responseValid = NAI_FALSE;
                  break;
               }
            }

            if (responseValid == NAI_FALSE)
            {
               naiif_printf("\r\n\r\n\r\nInvalid Response\r\n\r\n");
            }
            else
            {
               status = check_status(naibrd_TC_SetCJCEnable(p_tcParams->cardIndex, p_tcParams->module, enable));
            }
         }
      } while ((quit == NAI_FALSE) && (responseValid == NAI_FALSE));
   }

   return status;
}

/**************************************************************************************************************/
/**
<summary>
TC_Set_Thresh handles the user request to configure the threshold values for the given channel and
calls the relevant setter method in the naibrd library.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t naiapp_TC_Set_Thresh(int32_t paramCount, int32_t* p_params)
{
   naibrd_tc_thresh_type_t type;
   int32_t response = 0;
   float64_t value;
   bool_t responseValid = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   p_naiapp_AppParameters_t p_tcParams = NULL;
   bool_t quit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      p_tcParams = (p_naiapp_AppParameters_t)p_params;

      do
      {
         /* get threshold type*/
         naiif_printf("Enter threshold type to set \r\n(0 - alert lo, 1 - alarm lo, 2 - alert hi, 3 - alarm hi):");
         quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if(!quit)
         {
            if (strlen((const char*)inputBuffer) > 0)
            {
               response = (int32_t)atoi((const char*)inputBuffer);
               responseValid = NAI_TRUE;
               switch(response)
               {
                  case 0:
                     type = NAIBRD_TC_THRESH_ALERT_LO;
                  break;

                  case 1:
                     type = NAIBRD_TC_THRESH_ALARM_LO;
                  break;

                  case 2:
                     type = NAIBRD_TC_THRESH_ALERT_HI;
                  break;

                  case 3:
                     type = NAIBRD_TC_THRESH_ALARM_HI;
                  break;

                  default:
                     responseValid = NAI_FALSE;
                  break;
               }
            }
         }

         if (responseValid == NAI_FALSE)
         {
            naiif_printf("\r\n\r\n\r\nInvalid Threshold Type\r\n\r\n");
         }
      } while ((quit == NAI_FALSE) && (responseValid == NAI_FALSE));

      if(!quit)
      {
         do
         {
            /* get threshold value*/
            naiif_printf("Enter threshold value:");
            quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
            if(!quit)
            {
               if (strlen((const char*)inputBuffer) > 0)
               {
                  value = atof((const char*)inputBuffer);
                  status = check_status(naibrd_TC_SetThreshold(p_tcParams->cardIndex, p_tcParams->module, p_tcParams->channel, type, value));
                  responseValid = NAI_TRUE;
               }
               else
               {
                  naiif_printf("\r\n\r\n\r\nInvalid Threshold Value\r\n\r\n");
                  responseValid = NAI_FALSE;
               }
            }
         } while ((quit == NAI_FALSE) && (responseValid == NAI_FALSE));
      }
   }
   return status;
}

/**************************************************************************************************************/
/**
<summary>
TC_ClearStatus handles the user request to clear the status for the given status type and channel and
calls the relevant method in the naibrd library.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t naiapp_TC_ClearStatus(int32_t paramCount, int32_t* p_params)
{
   bool_t responseValid = NAI_FALSE;
   int32_t response = 0;
   naibrd_tc_chan_mapped_status_type_t type;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   p_naiapp_AppParameters_t p_tcParams = NULL;
   bool_t quit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      p_tcParams = (p_naiapp_AppParameters_t)p_params;

      do
      {
         /* get status type*/
         naiif_printf("Enter status type to clear\r\n");
         naiif_printf("(0 - bit, 1 - open, 2 - alert lo, 3 - alarm lo, 4 - alert hi, 5 - alarm hi):");
         quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if(!quit)
         {
            if (strlen((const char*)inputBuffer) > 0)
            {
               response = (int32_t)atoi((const char*)inputBuffer);
               responseValid = NAI_TRUE;
               switch(response)
               {
                  case 0:
                     type = NAIBRD_TC_STATUS_BIT_LATCHED;
                  break;

                  case 1:
                     type = NAIBRD_TC_STATUS_OPEN_LATCHED;
                  break;

                  case 2:
                     type = NAIBRD_TC_STATUS_ALERT_LO_LATCHED;
                  break;

                  case 3:
                     type = NAIBRD_TC_STATUS_ALARM_LO_LATCHED;
                  break;

                  case 4:
                     type = NAIBRD_TC_STATUS_ALERT_HI_LATCHED;
                  break;

                  case 5:
                     type = NAIBRD_TC_STATUS_ALARM_HI_LATCHED;
                  break;

                  default:
                     responseValid = NAI_FALSE;
                  break;
               }
            }

            if (responseValid == NAI_FALSE)
            {
               naiif_printf("\r\n\r\n\r\nInvalid Status Type\r\n\r\n");
            }
            else
            {
               status = check_status(naibrd_TC_ClearChanMappedStatus(p_tcParams->cardIndex, p_tcParams->module, p_tcParams->channel, type));
            }
         }
      } while ((quit == NAI_FALSE) && (responseValid == NAI_FALSE));
   }

   return status;
}

/**************************************************************************************************************/
/**
<summary>
TC_Set_CJCType handles the user request to configure the cold junction compensation type for the TC module and
calls the relevant setter method in the naibrd library.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t naiapp_TC_Set_CJCType(int32_t paramCount, int32_t* p_params)
{
   naibrd_tc_comp_type_t type;
   int32_t response = 0;
   bool_t responseValid = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   p_naiapp_AppParameters_t p_tcParams = NULL;
   bool_t quit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      p_tcParams = (p_naiapp_AppParameters_t)p_params;

      do
      {
         naiif_printf("Set CJC Type (1 - Manual, 0 - Auto): ");
         quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if(!quit)
         {
            if (strlen((const char*)inputBuffer) > 0)
            {
               response = (int32_t)atoi((const char*)inputBuffer);
               responseValid = NAI_TRUE;
               switch(response)
               {
                  case 0:
                     type = NAIBRD_TC_COMP_TYPE_AUTO;
                  break;

                  case 1:
                     type = NAIBRD_TC_COMP_TYPE_MANUAL;
                  break;

                  default:
                     responseValid = NAI_FALSE;
                  break;
               }
            }

            if (responseValid == NAI_FALSE)
            {
               naiif_printf("\r\n\r\n\r\nInvalid Response\r\n\r\n");
            }
            else
            {
               status = check_status(naibrd_TC_SetCompType(p_tcParams->cardIndex, p_tcParams->module, p_tcParams->channel, type));
            }
         }
      } while ((quit == NAI_FALSE) && (responseValid == NAI_FALSE));
   }

   return status;
}

/**************************************************************************************************************/
/**
<summary>
TC_Set_OffsetTemp handles the user request to configure the offset temperature for the given channel and
calls the relevant setter method in the naibrd library.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t naiapp_TC_Set_OffsetTemp(int32_t paramCount, int32_t* p_params)
{
   float64_t temp = 0.0;
   bool_t responseValid = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   p_naiapp_AppParameters_t p_tcParams = NULL;
   bool_t quit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      p_tcParams = (p_naiapp_AppParameters_t)p_params;

      do
      {
         naiif_printf("Enter new offset temperature: ");
         quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if (!quit)
         {
            if (strlen((const char*)inputBuffer) > 0)
            {
               temp = atof((const char*)inputBuffer);
               status = check_status(naibrd_TC_SetOffsetTemperature(p_tcParams->cardIndex, p_tcParams->module, p_tcParams->channel, temp));
               responseValid = NAI_TRUE;
            }
            else
            {
               naiif_printf("\r\n\r\n\r\nInvalid Offset Temperature Entered\r\n\r\n");
               responseValid = NAI_FALSE;
            }
         }
      } while ((quit == NAI_FALSE) && (responseValid == NAI_FALSE));
   }

   return status;
}

/**************************************************************************************************************/
/**
<summary>
TC_Set_BackgroundOpSuspension handles the user request to suspend the BIT/Open-Line tests and
System Calibration for the given channel and calls the relevant setter method in the naibrd library.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t naiapp_TC_Set_BackgroundOpSuspension(int32_t paramCount, int32_t* p_params)
{
   bool_t disable = NAI_FALSE;
   bool_t responseValid = NAI_FALSE;
   int32_t response = 0;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   p_naiapp_AppParameters_t p_tcParams = NULL;
   bool_t quit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      p_tcParams = (p_naiapp_AppParameters_t)p_params;

      do
      {
         naiif_printf("Suspend or enable BIT/Open-Line tests and System Calibration? (1 - Suspend, 0 - Enable): ");
         quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if (!quit)
         {
            if (strlen((const char*)inputBuffer) > 0)
            {
               response = (int32_t)atoi((const char*)inputBuffer);
               responseValid = NAI_TRUE;
               switch (response)
               {
                  case 0:
                     disable = NAI_FALSE;
                  break;

                  case 1:
                     disable = NAI_TRUE;
                  break;

                  default:
                     responseValid = NAI_FALSE;
                  break;
               }

               if (responseValid == NAI_FALSE)
               {
                  naiif_printf("\r\n\r\n\r\nInvalid Response\r\n\r\n");
               }
               else
               {
                  status = check_status(naibrd_TC_SetBackgroundOpSuspend(p_tcParams->cardIndex, p_tcParams->module, p_tcParams->channel, disable));
               }
            }
         }
      } while ((quit == NAI_FALSE) && (responseValid == NAI_FALSE));
   }

   return status;
}

/**************************************************************************************************************/
/**
<summary>
TC_Trigger_SystemCalibration handles the user request to trigger system calibration for the given channel and
calls the relevant setter method in the naibrd library.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t naiapp_TC_Trigger_SystemCalibration(int32_t paramCount, int32_t* p_params)
{
   bool_t responseValid = NAI_FALSE;
   int32_t response = 0;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   p_naiapp_AppParameters_t p_tcParams = NULL;
   bool_t quit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      p_tcParams = (p_naiapp_AppParameters_t)p_params;

      do
      {
         naiif_printf("Trigger System Calibration? (1 - Yes, 0 - No): ");
         quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if (!quit)
         {
            if (strlen((const char*)inputBuffer) > 0)
            {
               response = (int32_t)atoi((const char*)inputBuffer);
               responseValid = NAI_TRUE;
               switch (response)
               {
                  case 0:
                  break;

                  case 1:
                     status = check_status(naibrd_TC_TriggerBackgroundOperation(p_tcParams->cardIndex, p_tcParams->module, p_tcParams->channel,
                        NAIBRD_TC_BACKGROUND_OP_SYSTEM_CAL));
                  break;

                  default:
                     responseValid = NAI_FALSE;
                  break;
               }
            }

            if (responseValid == NAI_FALSE)
            {
               naiif_printf("\r\n\r\n\r\nInvalid Response\r\n\r\n");
            }
         }
      } while ((quit == NAI_FALSE) && (responseValid == NAI_FALSE));
   }

   return status;
}

/**************************************************************************************************************/
/**
<summary>
TC_Trigger_OpenCheck handles the user request to trigger an open-line check for the given channel and
calls the relevant setter method in the naibrd library.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t naiapp_TC_Trigger_OpenCheck(int32_t paramCount, int32_t* p_params)
{
   bool_t responseValid = NAI_FALSE;
   int32_t response = 0;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   p_naiapp_AppParameters_t p_tcParams = NULL;
   bool_t quit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      p_tcParams = (p_naiapp_AppParameters_t)p_params;

      do
      {
         naiif_printf("Trigger Open-Line Check? (1 - Yes, 0 - No): ");
         quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if (!quit)
         {
            if (strlen((const char*)inputBuffer) > 0)
            {
               response = (int32_t)atoi((const char*)inputBuffer);
               responseValid = NAI_TRUE;
               switch (response)
               {
                  case 0:
                  break;

                  case 1:
                     status = check_status(naibrd_TC_TriggerBackgroundOperation(p_tcParams->cardIndex, p_tcParams->module, p_tcParams->channel,
                        NAIBRD_TC_BACKGROUND_OP_OPEN));
                  break;

                  default:
                     responseValid = NAI_FALSE;
                  break;
               }
            }

            if (responseValid == NAI_FALSE)
            {
               naiif_printf("\r\n\r\n\r\nInvalid Response\r\n\r\n");
            }
         }
      } while ((quit == NAI_FALSE) && (responseValid == NAI_FALSE));
   }

   return status;
}

/**************************************************************************************************************/
/**
<summary>
TC_Trigger_BIT handles the user request to trigger BIT for the given channel and calls the relevant setter method
in the naibrd library.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t naiapp_TC_Trigger_BIT(int32_t paramCount, int32_t* p_params)
{
   bool_t responseValid = NAI_FALSE;
   int32_t response = 0;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   p_naiapp_AppParameters_t p_tcParams = NULL;
   bool_t quit = NAI_FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (paramCount == APP_PARAM_COUNT)
   {
      p_tcParams = (p_naiapp_AppParameters_t)p_params;

      do
      {
         naiif_printf("Trigger BIT? (1 - Yes, 0 - No): ");
         quit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if (!quit)
         {
            if (strlen((const char*)inputBuffer) > 0)
            {
               response = (int32_t)atoi((const char*)inputBuffer);
               responseValid = NAI_TRUE;
               switch (response)
               {
                  case 0:
                  break;

                  case 1:
                     status = check_status(naibrd_TC_TriggerBackgroundOperation(p_tcParams->cardIndex, p_tcParams->module, p_tcParams->channel,
                        NAIBRD_TC_BACKGROUND_OP_BIT));
                  break;

                  default:
                     responseValid = NAI_FALSE;
                  break;
               }
            }
            else
            {
               naiif_printf("\r\n\r\n\r\nInvalid Response\r\n\r\n");
            }
         }
      } while ((quit == NAI_FALSE) && (responseValid == NAI_FALSE));
   }

   return status;
}

/**************************************************************************************************************/
/**
 * <summary>
 * This function Enables\Disables the reporting of the Channel Status. When enabled, the user will get status
 * updates. When disabled, the statuses will not report and status-based interrupts will not assert.
 * </summary>
 */
/**************************************************************************************************************/
static nai_status_t naiapp_TC_ChannelStatusEnable(int32_t paramCount, int32_t* params)
{
   p_naiapp_AppParameters_t tc_params = (p_naiapp_AppParameters_t)params;
   bool_t bQuit = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   if (APP_PARAM_COUNT == paramCount)
   {
      bQuit = naiapp_query_ChannelNumber(tc_params->maxChannels, tc_params->channel, &(tc_params->channel));
      if (!bQuit)
      {
         naiif_printf("Enable Channel Status (Y = YES, [any other key] = NO: ");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if (!bQuit)
         {
            status = check_status(naibrd_TC_SetChanStatusEnable(tc_params->cardIndex, tc_params->module, tc_params->channel,
               ((inputResponseCnt > 0) && (inputBuffer[0] == 'Y' || inputBuffer[0] == 'y')) ? NAI_TRUE : NAI_FALSE));
         }
      }
   }

   return status;
}

/**************************************************************************************************************/
/**
 * <summary>
 * naiapp_TC_Configuration handles the user request to configure the given channel to TC or RTD mode
 * and calls the relevant setter method in the naibrd library.
 * </summary>
 */
/**************************************************************************************************************/
static nai_status_t naiapp_TC_Configuration(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t tc_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = NAI_FALSE;
   bool_t responseValid = NAI_FALSE;
   nai_status_t status = NAI_ERROR_UNKNOWN;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt = 0;
   int32_t response = 0;
   naibrd_tc_config_type_t configType = NAIBRD_TC_THERMOCOUPLE;

   if (APP_PARAM_COUNT == paramCount)
   {
      bQuit = naiapp_query_ChannelNumber(tc_params->maxChannels, tc_params->channel, &(tc_params->channel));
      if (!bQuit)
      {
         naiif_printf("Set TC/RTD Configuration Type (1 - RTD, 0 - TC): ");
         bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
         if (!bQuit)
         {
            if (strlen((const char*)inputBuffer) > 0)
            {
               response = (int32_t)atoi((const char*)inputBuffer);
               responseValid = NAI_TRUE;
               if ((inputBuffer[0] != '0') && (inputBuffer[0] != '1'))
               {
                  responseValid = NAI_FALSE;
               }
               else
               {
                  switch (response)
                  {
                     case 0:
                        configType = NAIBRD_TC_THERMOCOUPLE;
                     break;
                     case 1:
                        configType = NAIBRD_TC_RTD;
                     break;
                     default:
                        responseValid = NAI_FALSE;
                     break;
                  }
               }
            }

            if (responseValid == NAI_FALSE)
            {
               naiif_printf("\r\n\r\n\r\nInvalid Response\r\n\r\n");
            }
            else
            {
               status = check_status(naibrd_TC_SetConfiguration(tc_params->cardIndex, tc_params->module, tc_params->channel, configType));
            }
         }
      }
   }

   return status;
}

Help Bot

X