CD BasicOps
Edit this on GitLab
CD BasicOps Sample Application (SSK 2.x)
Overview
The CD BasicOps sample application demonstrates how to perform basic chip-detect (CD) operations using the NAI Software Support Kit (SSK 2.x). It covers channel enable/disable, manual and automatic burn operations, energy settings, resistance measurements, fault and warning resistance thresholds, open resistance thresholds, and BIT (Built-In Test) management. This sample provides a practical reference for integrating CD module control into your own applications.
This sample supports the CD1 module type. The CD module is used for explosively-actuated device (EAD) and chip-detect applications, providing safe and controlled initiation with resistance monitoring capabilities. Refer to the CD1 Manual for detailed module specifications.
|
Note
|
This sample is new to SSK 2.x and does not have a direct SSK 1.x counterpart. |
Prerequisites
Before running this sample, make sure you have:
-
An NAI board with a CD1 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 cd_basic_ops executable from your build output directory. On startup the application looks for a configuration file (default_CD_BasicOps.txt). On the first run, this file will not exist — the application will present an interactive board menu where you configure a board connection, card index, and module slot. You can save this configuration so that subsequent runs skip the menu and connect automatically. Once connected, a numbered command menu lets you exercise each CD operation.
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 CD. |
The main() function follows a standard SSK 2.x startup flow:
-
Call
naiapp_RunBoardMenu()to load a saved configuration file (if one exists) or present the interactive board menu. The configuration file (default_CD_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. -
Query the user for a card index with
naiapp_query_CardIndex(). -
Query for a module slot with
naiapp_query_ModuleNumber(). -
Retrieve the module ID with
naibrd_GetModuleName().
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t CD_BasicOps(void)
#else
int32_t main(void)
#endif
{
bool_t bQuit = NAI_FALSE;
int32_t cardIndex = -1;
int32_t module = 0;
int32_t moduleCount = 0;
uint32_t modId = 0u;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == NAI_TRUE)
{
while (!bQuit)
{
naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
naibrd_GetModuleCount(cardIndex, &moduleCount);
naiapp_query_ModuleNumber(moduleCount, 1, &module);
naibrd_GetModuleName(cardIndex, module, &modId);
bQuit = Run_CD_BasicOps(cardIndex, module, modId);
}
naiif_printf("Type 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 usesnaibrd_GetModuleID()). -
Boolean constants are
NAI_TRUE/NAI_FALSE(SSK 1.x usesTRUE/FALSE). -
Console output uses
naiif_printf()from the platform abstraction layer (SSK 1.x usesprintf()directly).
|
Important
|
Common connection errors you may encounter at this stage:
|
Program Structure
Entry Point
On standard platforms (Petalinux, DEOS) the entry point is main(). On VxWorks the entry point is CD_BasicOps().
Command Loop
The Run_CD_BasicOps() function loads the command table and enters a while loop that displays the menu and processes user commands.
| Command | Description |
|---|---|
1 |
Enable channels (bitmapped hex value) |
2 |
Get enabled channels |
3 |
Initiate manual burn on channels |
4 |
Get manual burn channels |
5 |
Set auto burn max count |
6 |
Get auto burn max count |
7 |
Initiate auto burn channels |
8 |
Get auto burn channels |
9 |
Get auto burn count |
10 |
Set channel energy setting |
11 |
Get channel energy setting |
12 |
Get channel resistance |
13 |
Set channel fault resistance threshold |
14 |
Get channel fault resistance threshold |
15 |
Set channel warning resistance threshold |
16 |
Get channel warning resistance threshold |
17 |
Set channel open resistance threshold |
18 |
Get channel open resistance threshold |
19 |
Set module BIT enable |
20 |
Get module BIT enable |
21 |
Check module PBIT complete |
22 |
Manipulate BIT error thresholds |
Channel Enable and Burn Operations
Channel enable uses a bitmapped hex value where each bit corresponds to a channel (e.g., 0x01 = channel 1, 0x3F = all 6 channels). Manual and auto burn operations use the same bitmapped channel selection.
Key API calls:
-
naibrd_CD_SetEnabledChannels()— enables the specified channels. -
naibrd_CD_GetEnabledChannels()— reads which channels are enabled. -
naibrd_CD_InitiateManualBurnChannels()— initiates a manual burn on selected channels. -
naibrd_CD_InitiateAutoBurnChannels()— initiates auto burn on selected channels. -
naibrd_CD_SetAutoBurnMaxCount()/naibrd_CD_GetAutoBurnMaxCount()— configure and read the auto burn count limit. -
naibrd_CD_GetAutoBurnCount()— reads the current auto burn count.
Energy and Resistance Configuration
Each channel has configurable energy settings and resistance thresholds for fault detection.
Key API calls:
-
naibrd_CD_SetChannelEnergySetting()/naibrd_CD_GetChannelEnergySetting()— configure channel energy level. -
naibrd_CD_GetChannelResistance()— reads the measured resistance. -
naibrd_CD_SetChannelFaultResistance()/naibrd_CD_GetChannelFaultResistance()— set/get the fault resistance threshold. -
naibrd_CD_SetChannelWarningResistance()/naibrd_CD_GetChannelWarningResistance()— set/get the warning resistance threshold. -
naibrd_CD_SetChannelOpenResistance()/naibrd_CD_GetChannelOpenResistance()— set/get the open-circuit resistance threshold.
BIT Operations
The BIT functions allow enabling module-level BIT, checking PBIT completion, and configuring BIT error thresholds.
Key API calls:
-
naibrd_CD_SetModuleBITEnable()/naibrd_CD_GetModuleBITEnable()— enable/disable and query module BIT. -
naibrd_CD_CheckModulePBITComplete()— checks whether Power-On BIT has completed.
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 |
Module not present at selected slot |
Slot is empty or contains a different module type |
Use the board menu to verify slot population |
Channel enable fails |
Invalid bitmapped value |
Use hex values 0x01 through 0x3F for up to 6 channels |
Resistance reads zero |
Channel not enabled or no device connected |
Enable the channel first; verify device wiring |
Burn initiation fails |
Channel not enabled or energy not configured |
Enable the channel and set energy settings before initiating burn |
PBIT not complete |
Module still performing self-test |
Wait for PBIT to complete before proceeding |
Fault resistance threshold triggered |
Measured resistance exceeds threshold |
Check device wiring; adjust threshold if appropriate |
Auto burn count exceeded |
Auto burn max count reached |
Reset or increase the auto burn max count |
Full Source
The complete source for this sample is provided below for reference. The sections above explain each part in detail.
Full Source — cd_basic_ops.c (SSK 2.x)
#if defined (LINUX)
#include <pthread.h>
#endif
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
#include <taskLib.h>
#endif
/* 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_cd.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"
static const int8_t *SAMPLE_PGM_NAME = (const int8_t*)"CD Basic Operations";
static const int8_t *DEF_CONFIG_FILE = (const int8_t*)"default_CD_BasicOps.txt";
/* Function prototypes */
static bool_t Run_CD_BasicOps(int32_t cardIndex, int32_t module, uint32_t modId);
static nai_status_t Handle_CD_EnableChannels(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_GetEnableChannels(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_InitiateManualBurnChannels(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_GetManualBurnChannels(int32_t paramCount, int32_t* params);
static nai_status_t HANDLE_CD_SetAutoBurnMaxCount(int32_t paramCount, int32_t* params);
static nai_status_t HANDLE_CD_GetAutoBurnMaxCount(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_InitiateAutoBurnChannels(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_GetAutoBurnChannels(int32_t paramCount, int32_t* params);
static nai_status_t HANDLE_CD_GetAutoBurnCount(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_SetChanEnergySetting(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_GetChanEnergySetting(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_GetChanResistance(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_SetChanFaultResistance(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_GetChanFaultResistance(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_SetChanWarningResistance(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_GetChanWarningResistance(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_SetChanOpenResistance(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_GetChanOpenResistance(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_SetModuleBITEnable(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_GetModuleBITEnable(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_CheckModulePBITComplete(int32_t paramCount, int32_t* params);
static nai_status_t Handle_CD_BITErrorThresholds(int32_t paramCount, int32_t* params);
static const int32_t DEF_CD_CHANNEL = 1;
/********************/
/* Global Variables */
/********************/
/****** Command Tables *******/
enum cd_gen5_cd_common_commands
{
CD_COMMON_CMD_ENABLE_CHANNELS,
CD_COMMON_CMD_GET_ENABLED_CHANNELS,
CD_COMMON_CMD_INITIATE_MANUAL_BURN_CHANNELS,
CD_COMMON_CMD_GET_MANUAL_BURN_CHANNELS,
CD_COMMON_CMD_SET_AUTO_BURN_MAX_COUNT,
CD_COMMON_CMD_GET_AUTO_BURN_MAX_COUNT,
CD_COMMON_CMD_INITIATE_AUTO_BURN_CHANNELS,
CD_COMMON_CMD_GET_AUTO_BURN_CHANNELS,
CD_COMMON_CMD_GET_AUTO_BURN_COUNT,
CD_COMMON_CMD_SET_CHAN_ENERGY_SETTING,
CD_COMMON_CMD_GET_CHAN_ENERGY_SETTING,
CD_COMMON_CMD_GET_CHAN_RESISTANCE,
CD_COMMON_CMD_SET_CHAN_FAULT_RESISTANCE,
CD_COMMON_CMD_GET_CHAN_FAULT_RESISTANCE,
CD_COMMON_CMD_SET_CHAN_WARNING_RESISTANCE,
CD_COMMON_CMD_GET_CHAN_WARNING_RESISTANCE,
CD_COMMON_CMD_SET_CHAN_OPEN_RESISTANCE,
CD_COMMON_CMD_GET_CHAN_OPEN_RESISTANCE,
CD_COMMON_CMD_SET_MODULE_BIT_ENABLE,
CD_COMMON_CMD_GET_MODULE_BIT_ENABLE,
CD_COMMON_CMD_CHECK_MODULE_PBIT_COMPLETE,
CD_COMMON_CMD_BIT_ERROR_THRESHOLDS,
CD_COMMON_CMD_COUNT
};
naiapp_cmdtbl_params_t CD_StandardOpMenuCmds[CD_COMMON_CMD_COUNT] =
{
{"1", "Enable Channels", CD_COMMON_CMD_ENABLE_CHANNELS, Handle_CD_EnableChannels},
{"2", "Get Enabled Channels", CD_COMMON_CMD_GET_ENABLED_CHANNELS, Handle_CD_GetEnableChannels},
{"3", "Initiate Manual Burn on Channels", CD_COMMON_CMD_INITIATE_MANUAL_BURN_CHANNELS, Handle_CD_InitiateManualBurnChannels},
{"4", "Get Manual Burn Channels", CD_COMMON_CMD_GET_MANUAL_BURN_CHANNELS, Handle_CD_GetManualBurnChannels},
{"5", "Set Auto Burn Max Count", CD_COMMON_CMD_SET_AUTO_BURN_MAX_COUNT, HANDLE_CD_SetAutoBurnMaxCount },
{"6", "Get Auto Burn Max Count", CD_COMMON_CMD_GET_AUTO_BURN_MAX_COUNT, HANDLE_CD_GetAutoBurnMaxCount },
{"7", "Initiate Auto Burn Channels", CD_COMMON_CMD_INITIATE_AUTO_BURN_CHANNELS, Handle_CD_InitiateAutoBurnChannels },
{"8", "Get Auto Burn Channels", CD_COMMON_CMD_GET_AUTO_BURN_CHANNELS, Handle_CD_GetAutoBurnChannels },
{"9", "Get Auto Burn Count", CD_COMMON_CMD_GET_AUTO_BURN_COUNT, HANDLE_CD_GetAutoBurnCount },
{"10", "Set Channel Energy Setting", CD_COMMON_CMD_SET_CHAN_ENERGY_SETTING, Handle_CD_SetChanEnergySetting},
{"11", "Get Channel Energy Setting", CD_COMMON_CMD_GET_CHAN_ENERGY_SETTING, Handle_CD_GetChanEnergySetting},
{"12", "Get Channel Resistance", CD_COMMON_CMD_GET_CHAN_RESISTANCE, Handle_CD_GetChanResistance},
{"13", "Set Channel Fault Resistance", CD_COMMON_CMD_SET_CHAN_FAULT_RESISTANCE, Handle_CD_SetChanFaultResistance},
{"14", "Get Channel Fault Resistance", CD_COMMON_CMD_GET_CHAN_FAULT_RESISTANCE, Handle_CD_GetChanFaultResistance},
{"15", "Set Channel Warning Resistance", CD_COMMON_CMD_SET_CHAN_WARNING_RESISTANCE, Handle_CD_SetChanWarningResistance},
{"16", "Get Channel Warning Resistance", CD_COMMON_CMD_GET_CHAN_WARNING_RESISTANCE, Handle_CD_GetChanWarningResistance},
{"17", "Set Channel Open Resistance", CD_COMMON_CMD_SET_CHAN_OPEN_RESISTANCE, Handle_CD_SetChanOpenResistance},
{"18", "Get Channel Open Resistance", CD_COMMON_CMD_GET_CHAN_OPEN_RESISTANCE, Handle_CD_GetChanOpenResistance},
{"19", "Set Module BIT Enable", CD_COMMON_CMD_SET_MODULE_BIT_ENABLE, Handle_CD_SetModuleBITEnable },
{"20", "Get Module BIT Enable", CD_COMMON_CMD_GET_MODULE_BIT_ENABLE, Handle_CD_GetModuleBITEnable },
{"21", "Check Module PBIT Complete", CD_COMMON_CMD_CHECK_MODULE_PBIT_COMPLETE, Handle_CD_CheckModulePBITComplete },
{"22", "Manipulate BIT Error Thresholds", CD_COMMON_CMD_BIT_ERROR_THRESHOLDS, Handle_CD_BITErrorThresholds }
};
/**************************************************************************************************************/
/**
* <summary>
* The purpose of the CD_BasicOps is to illustrate the methods to call in the naibrd library to perform basic
* operations with the CD modules for configuration setup and basic chip-detect operation.
*
* 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 DA routines.
* - ConfigDevice
* - DisplayDeviceCfg
* - GetBoardSNModCfg
* - CheckModule
* </summary>
*/
/**************************************************************************************************************/
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t CD_BasicOps(void)
#else
int32_t main(void)
#endif
{
bool_t bQuit = NAI_FALSE;
int32_t cardIndex = -1;
int32_t module = 0;
int32_t moduleCount = 0;
uint32_t modId = 0u;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == NAI_TRUE)
{
while (!bQuit)
{
naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
naibrd_GetModuleCount(cardIndex, &moduleCount);
naiapp_query_ModuleNumber(moduleCount, 1, &module);
naibrd_GetModuleName(cardIndex, module, &modId);
bQuit = Run_CD_BasicOps(cardIndex, module, modId);
}
naiif_printf("Type the Enter key to exit the program: ");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
}
naiapp_access_CloseAllOpenCards();
return 0;
}
/**************************************************************************************************************/
/**
* <summary>
* This function runs the basic operations CD program. It controls the top level menu of the CD_BasicOps
* program and calls Handle_CD_Configuration or Handle_CD_StandardOps, depending on what the user specifies.
* </summary>
*/
/**************************************************************************************************************/
static bool_t Run_CD_BasicOps(int32_t cardIndex, int32_t module, uint32_t modId)
{
bool_t bQuit = NAI_FALSE;
bool_t bContinue = NAI_TRUE;
bool_t bCmdFound = NAI_FALSE;
int32_t cmd = 0;
int32_t numMenuCmds = 0;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
naiapp_AppParameters_t cd_params;
cd_params.cardIndex = cardIndex;
cd_params.module = module;
cd_params.channel = DEF_CD_CHANNEL;
cd_params.modId = modId;
numMenuCmds = CD_COMMON_CMD_COUNT;
/* Get the Maximum CD Channels */
cd_params.maxChannels = naibrd_CD_GetChannelCount(cd_params.modId);
naiapp_utils_LoadParamMenuCommands(numMenuCmds, CD_StandardOpMenuCmds);
while (bContinue)
{
naiapp_display_ParamMenuCommands((int8_t*)SAMPLE_PGM_NAME);
naiif_printf("\r\nType CD command or %c to quit : main >", NAI_QUIT_CHAR);
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt > 0)
{
bCmdFound = naiapp_utils_GetParamMenuCmdNum(inputResponseCnt, inputBuffer, &cmd);
if (bCmdFound)
{
CD_StandardOpMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)&cd_params);
}
else
{
naiif_printf("Invalid command entered\r\n");
}
}
else
naiif_printf("Invalid command entered\r\n");
}
else
bContinue = NAI_FALSE;
}
return bQuit;
}
/**************************************************************************************************************/
/**
* <summary>
* This function is responsible for enabling the desired channels. User is prompted to enter which channels
* are to be enabled.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_EnableChannels(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_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)
{
uint32_t channelsToEnable = 0;
memset(inputBuffer, 0x00, sizeof(inputBuffer));
naiif_printf("Enter Hex value (0x01 - 0x3F) indicating which channels to enable. Chan 1 = 0x01 All channels = 0x3F: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
channelsToEnable = (uint32_t)strtol((char*)inputBuffer, NULL, 16);
status = naibrd_CD_SetEnabledChannels(cd_params->cardIndex, cd_params->module, channelsToEnable);
if (status == NAI_SUCCESS)
{
naiif_printf("Specified channels have been enabled!");
}
else
{
naiif_printf("Problem detected enabling channels! - Status = %d", status);
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function retrieves a bitmapped 32 bit value of channels that are currently enabled.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_GetEnableChannels(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_params = (p_naiapp_AppParameters_t)params;
nai_status_t status = NAI_ERROR_UNKNOWN;
if (APP_PARAM_COUNT == paramCount)
{
uint32_t enabledChannels = 0;
status = naibrd_CD_GetEnabledChannels(cd_params->cardIndex, cd_params->module, &enabledChannels);
if (status == NAI_SUCCESS)
{
naiif_printf("Enabled channels = 0x%x", enabledChannels);
}
else
{
naiif_printf("Problem retrieving enabled channels! - Status = %d", status);
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function initiates a manual burn on the desired channels.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_InitiateManualBurnChannels(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_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)
{
uint32_t channelsForManualBurn = 0;
memset(inputBuffer, 0x00, sizeof(inputBuffer));
naiif_printf("Enter Hex value (0x01 - 0x3F) indicating which channels to initiate a manual-burn on. Chan 1 = 0x01 All channels = 0x3F: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
channelsForManualBurn = (uint32_t)strtol((char*)inputBuffer, NULL, 16);
status = naibrd_CD_InitiateManualBurnChannels(cd_params->cardIndex, cd_params->module, channelsForManualBurn);
if (status == NAI_SUCCESS)
{
naiif_printf("Specified channels have initiated a manual burn!");
}
else
{
naiif_printf("Problem detected initiating desired channels for a manual burn! - Status = %d", status);
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function returns a bitmapped 32 bit value of channels that have been configured for manual-burn.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_GetManualBurnChannels(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_params = (p_naiapp_AppParameters_t)params;
nai_status_t status = NAI_ERROR_UNKNOWN;
if (APP_PARAM_COUNT == paramCount)
{
uint32_t manualBurnChannels = 0;
status = naibrd_CD_GetManualBurnChannels(cd_params->cardIndex, cd_params->module, &manualBurnChannels);
if (status == NAI_SUCCESS)
{
naiif_printf("Manual-burn channels = 0x%x", manualBurnChannels);
}
else
{
naiif_printf("Problem retrieving manual-burn channels! - Status = %d", status);
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function assigns the Auto Burn Max count value for the given channel.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t HANDLE_CD_SetAutoBurnMaxCount(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_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(cd_params->maxChannels, cd_params->channel, &(cd_params->channel));
if (!bQuit)
{
int32_t autoBurnMaxCount;
memset(inputBuffer, 0x00, sizeof(inputBuffer));
naiif_printf("Enter desired auto burn max count for specified channel. Valid values: (0 - 10): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
naiapp_query_NumberFromResponse(&autoBurnMaxCount, inputBuffer, inputResponseCnt);
status = naibrd_CD_SetAutoBurnMaxCount(cd_params->cardIndex, cd_params->module, cd_params->channel, autoBurnMaxCount);
if (status == NAI_SUCCESS)
{
naiif_printf("Success in setting channel %d auto burn max count to %d", cd_params->channel, autoBurnMaxCount);
}
else
{
naiif_printf("Problem setting auto burn max count of %d for channel %d! - Status = %d", autoBurnMaxCount, cd_params->channel, status);
}
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function returns what a given channel's auto burn max count is currently configured to.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t HANDLE_CD_GetAutoBurnMaxCount(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_params = (p_naiapp_AppParameters_t)params;
bool_t bQuit = NAI_FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(cd_params->maxChannels, cd_params->channel, &(cd_params->channel));
if (!bQuit)
{
uint32_t autoBurnMaxCount;
status = naibrd_CD_GetAutoBurnMaxCount(cd_params->cardIndex, cd_params->module, cd_params->channel, (uint32_t*)&autoBurnMaxCount);
if (status == NAI_SUCCESS)
{
naiif_printf("Success - auto burn max count for channel %d = %d", cd_params->channel, autoBurnMaxCount);
}
else
{
naiif_printf("Problem retrieving auto burn max count for channel %d! - Status = %d", cd_params->channel, status);
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function initiates an auto burn on the desired channels.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_InitiateAutoBurnChannels(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_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)
{
uint32_t channelsForAutoBurn = 0;
memset(inputBuffer, 0x00, sizeof(inputBuffer));
naiif_printf("Enter Hex value (0x01 - 0x3F) indicating which channels to initiate a auto-burn on. Chan 1 = 0x01 All channels = 0x3F: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
channelsForAutoBurn = (uint32_t)strtol((char*)inputBuffer, NULL, 16);
status = naibrd_CD_InitiateAutoBurnChannels(cd_params->cardIndex, cd_params->module, channelsForAutoBurn);
if (status == NAI_SUCCESS)
{
naiif_printf("Specified channels have initiated an auto burn!");
}
else
{
naiif_printf("Problem detected initiating desired channels for an auto burn! - Status = %d", status);
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function Gets auto burn channels.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_GetAutoBurnChannels(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_params = (p_naiapp_AppParameters_t)params;
nai_status_t status = NAI_ERROR_UNKNOWN;
if (APP_PARAM_COUNT == paramCount)
{
uint32_t outAutoBurnChannels;
status = naibrd_CD_GetAutoBurnChannels(cd_params->cardIndex, cd_params->module, &outAutoBurnChannels);
if (status == NAI_SUCCESS)
{
naiif_printf("Success - auto burn channels = %02X", outAutoBurnChannels);
}
else
{
naiif_printf("Problem retrieving auto burn channels! - Status = %d", status);
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function returns what a given channel's auto burn count is currently configured to.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t HANDLE_CD_GetAutoBurnCount(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_params = (p_naiapp_AppParameters_t)params;
bool_t bQuit = NAI_FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(cd_params->maxChannels, cd_params->channel, &(cd_params->channel));
if (!bQuit)
{
int32_t autoBurnCount;
status = naibrd_CD_GetAutoBurnCount(cd_params->cardIndex, cd_params->module, cd_params->channel, (uint32_t*)&autoBurnCount);
if (status == NAI_SUCCESS)
{
naiif_printf("Success - auto burn count for channel %d = %d", cd_params->channel, autoBurnCount);
}
else
{
naiif_printf("Problem retrieving auto burn count for channel %d! - Status = %d", cd_params->channel, status);
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function is responsible for assigning what amount of energy (in joules) a channel will be charged.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_SetChanEnergySetting(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_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(cd_params->maxChannels, cd_params->channel, &(cd_params->channel));
if (!bQuit)
{
float32_t energySetting;
memset(inputBuffer, 0x00, sizeof(inputBuffer));
naiif_printf("Enter desired energy setting for specified channel. Valid values: (.25 - 2.25): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
naiapp_query_FloatNumberFromResponse(&energySetting, (char*)inputBuffer);
status = naibrd_CD_SetChanEnergySetting(cd_params->cardIndex, cd_params->module, cd_params->channel, energySetting);
if (status == NAI_SUCCESS)
{
naiif_printf("Success in setting channel %d energy setting to %f", cd_params->channel, energySetting);
}
else
{
naiif_printf("Problem setting energy setting of %f for channel %d! - Status = %d", energySetting, cd_params->channel, status);
}
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function returns what a given channel's energy setting is currently configured to.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_GetChanEnergySetting(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_params = (p_naiapp_AppParameters_t)params;
bool_t bQuit = NAI_FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(cd_params->maxChannels, cd_params->channel, &(cd_params->channel));
if (!bQuit)
{
float32_t energySetting;
status = naibrd_CD_GetChanEnergySetting(cd_params->cardIndex, cd_params->module, cd_params->channel, &energySetting);
if (status == NAI_SUCCESS)
{
naiif_printf("Success - Energy setting for channel %d = %f", cd_params->channel, energySetting);
}
else
{
naiif_printf("Problem retrieving energy setting for channel %d! - Status = %d", cd_params->channel, status);
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function retrieves the resistance level for the given channel.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_GetChanResistance(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_params = (p_naiapp_AppParameters_t)params;
bool_t bQuit = NAI_FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(cd_params->maxChannels, cd_params->channel, &(cd_params->channel));
if (!bQuit)
{
int32_t resistance = 0;
status = naibrd_CD_GetChanResistance(cd_params->cardIndex, cd_params->module, cd_params->channel, &resistance);
if (status == NAI_SUCCESS)
{
naiif_printf("Success - Resistance for channel %d = %d", cd_params->channel, resistance);
}
else
{
naiif_printf("Problem retrieving Resistance for channel %d! - Status = %d", cd_params->channel, status);
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function assigns the fault resistance threshold value for the given channel.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_SetChanFaultResistance(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_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(cd_params->maxChannels, cd_params->channel, &(cd_params->channel));
if (!bQuit)
{
int32_t faultResistanceThreshold = 0;
memset(inputBuffer, 0x00, sizeof(inputBuffer));
naiif_printf("Enter Fault Resistance Threshold value for specified channel in ohms. Valid values: (0 - 100000): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
naiapp_query_NumberFromResponse(&faultResistanceThreshold, inputBuffer, inputResponseCnt);
status = naibrd_CD_SetChanFaultResistanceThreshold(cd_params->cardIndex, cd_params->module, cd_params->channel,
faultResistanceThreshold);
if (status == NAI_SUCCESS)
{
naiif_printf("Success in setting channel %d Fault resistance threshold to %d", cd_params->channel, faultResistanceThreshold);
}
else
{
naiif_printf("Problem setting Fault resistance threshold of %d for channel %d! - Status = %d", faultResistanceThreshold,
cd_params->channel, status);
}
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function retrieves the fault resistance threshold for the given channel.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_GetChanFaultResistance(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_params = (p_naiapp_AppParameters_t)params;
bool_t bQuit = NAI_FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(cd_params->maxChannels, cd_params->channel, &(cd_params->channel));
if (!bQuit)
{
int32_t faultResistanceThreshold = 0;
status = naibrd_CD_GetChanFaultResistanceThreshold(cd_params->cardIndex, cd_params->module, cd_params->channel,
&faultResistanceThreshold);
if (status == NAI_SUCCESS)
{
naiif_printf("Success - Fault resistance threshold for channel %d = %d", cd_params->channel, faultResistanceThreshold);
}
else
{
naiif_printf("Problem retrieving Fault resistance threshold for channel %d! - Status = %d", cd_params->channel, status);
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function assigns the warning resistance threshold value for the given channel.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_SetChanWarningResistance(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_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(cd_params->maxChannels, cd_params->channel, &(cd_params->channel));
if (!bQuit)
{
int32_t warningResistanceThreshold = 0;
memset(inputBuffer, 0x00, sizeof(inputBuffer));
naiif_printf("Enter Warning Resistance Threshold value for specified channel in ohms. Valid values: (0 - 100000): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
naiapp_query_NumberFromResponse(&warningResistanceThreshold, inputBuffer, inputResponseCnt);
status = naibrd_CD_SetChanWarningResistanceThreshold(cd_params->cardIndex, cd_params->module, cd_params->channel,
warningResistanceThreshold);
if (status == NAI_SUCCESS)
{
naiif_printf("Success in setting channel %d Warning resistance threshold to %d", cd_params->channel, warningResistanceThreshold);
}
else
{
naiif_printf("Problem setting Warning resistance threshold of %d for channel %d! - Status = %d", warningResistanceThreshold,
cd_params->channel, status);
}
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function retrieves the warning resistance threshold for the given channel.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_GetChanWarningResistance(int32_t paramCount, int32_t* params)
{
bool_t bQuit = NAI_FALSE;
p_naiapp_AppParameters_t cd_params = (p_naiapp_AppParameters_t)params;
nai_status_t status = NAI_ERROR_UNKNOWN;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(cd_params->maxChannels, cd_params->channel, &(cd_params->channel));
if (!bQuit)
{
int32_t warningResistanceThreshold = 0;
status = naibrd_CD_GetChanWarningResistanceThreshold(cd_params->cardIndex, cd_params->module, cd_params->channel,
&warningResistanceThreshold);
if (status == NAI_SUCCESS)
{
naiif_printf("Success - Warning resistance threshold for channel %d = %d", cd_params->channel, warningResistanceThreshold);
}
else
{
naiif_printf("Problem retrieving Warning resistance threshold for channel %d! - Status = %d", cd_params->channel, status);
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function assigns the open resistance threshold value for the given channel.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_SetChanOpenResistance(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_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(cd_params->maxChannels, cd_params->channel, &(cd_params->channel));
if (!bQuit)
{
int32_t openResistanceThreshold = 0;
memset(inputBuffer, 0x00, sizeof(inputBuffer));
naiif_printf("Enter Open Resistance Threshold value for specified channel in ohms. Valid values: (0 - 100000): ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
naiapp_query_NumberFromResponse(&openResistanceThreshold, inputBuffer, inputResponseCnt);
status = naibrd_CD_SetChanOpenResistanceThreshold(cd_params->cardIndex, cd_params->module, cd_params->channel,
openResistanceThreshold);
if (status == NAI_SUCCESS)
{
naiif_printf("Success in setting channel %d Open resistance threshold to %d", cd_params->channel, openResistanceThreshold);
}
else
{
naiif_printf("Problem setting Open resistance threshold of %d for channel %d! - Status = %d", openResistanceThreshold,
cd_params->channel, status);
}
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function retrieves the open resistance threshold for the given channel.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_GetChanOpenResistance(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_params = (p_naiapp_AppParameters_t)params;
bool_t bQuit = NAI_FALSE;
nai_status_t status = NAI_ERROR_UNKNOWN;
if (APP_PARAM_COUNT == paramCount)
{
bQuit = naiapp_query_ChannelNumber(cd_params->maxChannels, cd_params->channel, &(cd_params->channel));
if (!bQuit)
{
int32_t openResistanceThreshold = 0;
status = naibrd_CD_GetChanOpenResistanceThreshold(cd_params->cardIndex, cd_params->module, cd_params->channel,
&openResistanceThreshold);
if (status == NAI_SUCCESS)
{
naiif_printf("Success - Open resistance threshold for channel %d = %d", cd_params->channel, openResistanceThreshold);
}
else
{
naiif_printf("Problem retrieving Open resistance threshold for channel %d! - Status = %d", cd_params->channel, status);
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function Enables/Disables the BIT test specified by the type parameter.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_SetModuleBITEnable(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_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)
{
naibrd_cd_test_type_t testType = NAIBRD_CD_D0_TEST;
bool_t enable = NAI_FALSE;
do
{
memset(inputBuffer, 0x00, sizeof(inputBuffer));
naiif_printf("Which Test would you like to Enable/Disable? Type '0' for D0 or '3' for D3: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputBuffer[0] == '0')
{
testType = NAIBRD_CD_D0_TEST;
}
else if (inputBuffer[0] == '3')
{
testType = NAIBRD_CD_D3_TEST;
}
}
} while (!bQuit && (inputBuffer[0] != '0') && (inputBuffer[0] != '3'));
if (!bQuit)
{
while (!bQuit && (toupper(inputBuffer[0]) != 'E') && (toupper(inputBuffer[0]) != 'D'))
{
memset(inputBuffer, 0x00, sizeof(inputBuffer));
naiif_printf("Would you like to Enable or Disable? Type 'E' for Enable or 'D' for Disable: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (toupper(inputBuffer[0]) == 'E')
{
enable = NAI_TRUE;
}
else if (toupper(inputBuffer[0]) == 'D')
{
enable = NAI_FALSE;
}
}
}
}
if (!bQuit)
{
status = naibrd_CD_SetModuleBITEnable(cd_params->cardIndex, cd_params->module, testType, enable);
if (status == NAI_SUCCESS)
{
if (testType == NAIBRD_CD_D0_TEST)
{
if (enable == NAI_TRUE)
{
naiif_printf("Success - D0 Test was enabled");
}
else
{
naiif_printf("Success - D0 Test was disabled");
}
}
else
{
if (enable == NAI_TRUE)
{
naiif_printf("Success - D3 Test was enabled");
}
else
{
naiif_printf("Success - D3 Test was disabled");
}
}
}
else
{
if (testType == NAIBRD_CD_D0_TEST)
{
if (enable == NAI_TRUE)
{
naiif_printf("Problem - with enabling D0 Test");
}
else
{
naiif_printf("Problem - with disabling D0 Test");
}
}
else
{
if (enable == NAI_TRUE)
{
naiif_printf("Problem - with enabling D3 Test");
}
else
{
naiif_printf("Problem - with disabling D3 Test");
}
}
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function retrieves the state(Enabled or Disabled) of the BIT test specified by the type parameter.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_GetModuleBITEnable(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_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)
{
naibrd_cd_test_type_t testType = NAIBRD_CD_D0_TEST;
bool_t enabled;
do
{
memset(inputBuffer, 0x00, sizeof(inputBuffer));
naiif_printf("Which BIT Test would you like to retrieve the state of?\r\nType '0' for D0 or '3' for D3: ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (!bQuit)
{
if (inputBuffer[0] == '0')
{
testType = NAIBRD_CD_D0_TEST;
}
else if (inputBuffer[0] == '3')
{
testType = NAIBRD_CD_D3_TEST;
}
}
}
} while (!bQuit && (inputBuffer[0] != '0') && (inputBuffer[0] != '3'));
if (!bQuit)
{
status = naibrd_CD_GetModuleBITEnable(cd_params->cardIndex, cd_params->module, testType, &enabled);
if (status == NAI_SUCCESS)
{
if (testType == NAIBRD_CD_D0_TEST)
{
if (enabled)
{
naiif_printf("Success - The state of D0 test is enabled");
}
else
{
naiif_printf("Success - The state of D0 test is disabled");
}
}
else
{
if (enabled)
{
naiif_printf("Success - The state of D3 test is enabled");
}
else
{
naiif_printf("Success - The state of D3 test is disabled");
}
}
}
else
{
if (testType == NAIBRD_CD_D0_TEST)
{
naiif_printf("Problem - retrieving the state of the D0 test");
}
else
{
naiif_printf("Problem - retrieving the state of the D3 test");
}
}
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function 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 Handle_CD_CheckModulePBITComplete(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_params = (p_naiapp_AppParameters_t)params;
nai_status_t status = NAI_ERROR_UNKNOWN;
if (APP_PARAM_COUNT == paramCount)
{
bool_t pbitComplete;
nai_status_bit_t bitFailed;
/* Check to see if PBIT ran for the module. */
naiif_printf("Checking if the Power-On BIT test has run...\r\n");
status = naibrd_CD_CheckPowerOnBITComplete(cd_params->cardIndex, cd_params->module, &pbitComplete);
if (status == NAI_SUCCESS)
{
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");
/* The channel parameter is irrelevant for the CD module. If one channel fails BIT, all channels will fail */
status = naibrd_CD_GetChanMappedStatus(cd_params->cardIndex, cd_params->module, cd_params->channel, NAIBRD_CD_STATUS_BIT_LATCHED,
&bitFailed);
if (status == NAI_SUCCESS)
{
naiif_printf("%s", (bitFailed) ? "BIT FAILED\r\n" : "BIT Passed\r\n");
}
else
{
naiif_printf("Problem - retrieving Power-On BIT test");
}
}
}
else
{
naiif_printf("Problem - retrieving Power-On BIT test result");
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}
/**************************************************************************************************************/
/**
* <summary>
* This function callows the user to set and get the BIT error thresholds.
* This is an advanced feature.
* </summary>
*/
/**************************************************************************************************************/
static nai_status_t Handle_CD_BITErrorThresholds(int32_t paramCount, int32_t* params)
{
p_naiapp_AppParameters_t cd_params = (p_naiapp_AppParameters_t)params;
nai_status_t status = NAI_ERROR_UNKNOWN;
uint32_t bitThreshold = 0u;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
if (APP_PARAM_COUNT == paramCount)
{
naiif_printf("Set or Get BIT Error Threshold? ('S' = Set, 'G' = Get, 'C' = Clear BIT Counter): ");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (toupper(inputBuffer[0]) == 'S')
{
naiif_printf("\r\nType the desired BIT Error Threshold (Default = 5): ");
naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
naiif_printf("\r\n");
bitThreshold = atoi((const char*)inputBuffer);
status = naibrd_CD_SetModuleBITErrorThreshold(cd_params->cardIndex, cd_params->module, bitThreshold);
if (status == NAI_SUCCESS)
{
naiif_printf("Success - setting BIT Error threshold to %d", bitThreshold);
}
else
{
naiif_printf("Problem - setting BIT Error threshold");
}
}
else if (toupper(inputBuffer[0]) == 'G')
{
status = naibrd_CD_GetModuleBITErrorThreshold(cd_params->cardIndex, cd_params->module, &bitThreshold);
if (status == NAI_SUCCESS)
{
naiif_printf("Success - BIT Error threshold: %d", bitThreshold);
}
else
{
naiif_printf("Problem - retrieving BIT Error threshold");
}
}
else if (toupper(inputBuffer[0]) == 'C')
{
naiif_printf("\r\nClearing BIT counter.\r\n");
status = naibrd_CD_ClearModuleBITLogic(cd_params->cardIndex, cd_params->module);
if (status == NAI_SUCCESS)
{
naiif_printf("Success - BIT Error threshold cleared");
}
else
{
naiif_printf("Problem - clearing BIT Error threshold");
}
}
else
{
naiif_printf("\r\nSelection not recognized.\r\n");
}
}
else
{
status = NAI_ERROR_INVALID_VALUE;
}
return status;
}