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

PT BasicOps

PT BasicOps Sample Application (SSK 2.x)

Overview

The PT BasicOps sample application demonstrates how to configure and control printer/parallel port channels using the NAI Software Support Kit (SSK 2.x). It covers the core PT operations you will need in your own application: setting clock output mode, enabling output voltage (5V/12V), configuring input format and termination, and setting the crossing threshold voltage.

This sample supports the PT1 module. It serves as a practical API reference — each menu command maps directly to one or more naibrd_PT_*() API calls that you can lift into your own code.

For the SSK 1.x version, see PRNT BasicOps (SSK 1.x). For detailed module specifications, refer to the PT1 Manual.

Prerequisites

Before running this sample, make sure you have:

  • An NAI board with a PT module installed (PT1).

  • 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 pt_basic_ops executable from your build output directory. On startup the application looks for a configuration file (default_PT_BasicOp.txt). On the first run, this file will not exist — the application will present an interactive board menu where you configure a board connection, card index, and module slot. Once connected, the application prompts for a channel number and presents a command menu for configuring PT operations.

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

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_PT_BasicOp.txt) is not included with the SSK — it is created when the user saves their connection settings from the board menu. On the first run, the menu will always appear.

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

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

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

#if defined (__VXWORKS__)
int32_t PT_BasicOps(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(CONFIG_FILE) == NAI_TRUE)
   {
      while (stop != NAI_TRUE)
      {
         /* Query the user for the card index */
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != NAI_TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));

            /* Query the user for the module number */
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != NAI_TRUE)
            {
               check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
               if ((moduleID != 0))
               {
                  Run_PT_BasicOps(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 __VXWORKS__ in this particular sample (most SSK 2.x samples use NAIBSP_CONFIG_SOFTWARE_OS_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 a PT module. Use the board menu to verify which slots are populated.

Program Structure

Entry Point

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

#if defined (__VXWORKS__)
int32_t PT_BasicOps(void)
#else
int32_t main(void)
#endif

Command Loop

After connecting to the board and selecting a module, the application calls Run_PT_BasicOps(), which validates the module and delegates to Cfg_PT_Channel(). The command loop prompts for a channel number, then displays the current channel status and presents the command menu. The user selects a command by typing its short name, and the corresponding handler function is called through a dispatch table.

The command table defines the following operations:

Command Description

Clock

Set clock output mode (Disabled, Single-Ended, Differential).

Output

Enable output voltage (Disabled, 5V, 12V, or 5V+12V).

Input

Set input format (Disabled, Single-Ended, Differential, SMA, Single-Ended with Crossing Threshold).

Term

Set input termination impedance (Disabled, 50 Ohm, 75 Ohm, 100 Ohm).

Cross

Set crossing threshold voltage.

S

Switch to a different channel.

Displaying Channel Status

Before each command prompt, the application displays the current configuration for all channels. The Display_PT_Status() function reads and formats each channel’s settings:

static bool_t Display_PT_Status(int32_t cardIndex, int32_t module, int32_t chan, uint32_t ModuleID)
{
   naibrd_pt_clock_out_enable_t pt_Setting1;
   naibrd_pt_output_type_t pt_Setting2;
   int32_t MaxChannel;
   uint8_t i = 0;
   naibrd_pt_input_format_t input_setting;
   naibrd_pt_input_termination_t term;
   float64_t thresh;

   MaxChannel = naibrd_PT_GetChannelCount(ModuleID);

   for (i = 0; i < MaxChannel; i++)
   {
      check_status(naibrd_PT_GetClockOutEnable(cardIndex, module, i + 1, &pt_Setting1));
      check_status(naibrd_PT_GetOutputEnable(cardIndex, module, i + 1, &pt_Setting2));
      check_status(naibrd_PT_GetInputFormat(cardIndex, module, i + 1, &input_setting));
      check_status(naibrd_PT_GetInputTermination(cardIndex, module, i + 1, &term));
      check_status(naibrd_PT_GetCrossingThreshold(cardIndex, module, i + 1, &thresh));
      /* ... display formatted values ... */
   }
   return NAI_FALSE;
}

Key API calls:

  • naibrd_PT_GetChannelCount(moduleID) — Returns the number of channels for the PT module.

  • naibrd_PT_GetClockOutEnable() — Reads the clock output enable state.

  • naibrd_PT_GetOutputEnable() — Reads the output voltage enable state.

  • naibrd_PT_GetInputFormat() — Reads the input format configuration.

  • naibrd_PT_GetInputTermination() — Reads the input termination impedance.

  • naibrd_PT_GetCrossingThreshold() — Reads the crossing threshold voltage.

Configuring Clock Output

The Configure_PT_Clock() function sets the clock output mode for the selected channel:

static nai_status_t Configure_PT_Clock(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_pt_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_pt_params->cardIndex;
   int32_t module = p_pt_params->module;
   int32_t channel = p_pt_params->channel;
   naibrd_pt_clock_out_enable_t outstate;

   /* User selects: 1=Disabled, 2=SingleEnded, 3=Differential */
   if (bUpdateOutput)
      check_status(naibrd_PT_SetClockOutEnable(cardIndex, module, channel, outstate));

   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
  • naibrd_PT_SetClockOutEnable(cardIndex, module, channel, mode) — Sets the clock output mode. Valid modes are NAIBRD_PT_CLOCK_DISABLE, NAIBRD_PT_CLOCK_SINGLEENDED, and NAIBRD_PT_CLOCK_DIFF.

Configuring Output Enable

The Configure_PT_Output() function enables or disables the output voltage:

static nai_status_t Configure_PT_Output(int32_t paramCount, int32_t* p_params)
{
   /* User selects: 1=Disabled, 2=5V, 3=12V, 4=5V+12V */
   if (bUpdateOutput)
      check_status(naibrd_PT_SetOutputEnable(cardIndex, module, channel, outstate));

   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
  • naibrd_PT_SetOutputEnable(cardIndex, module, channel, mode) — Sets the output voltage mode. Valid modes are NAIBRD_PT_OUTPUT_DISABLE, NAIBRD_PT_OUTPUT_5V, NAIBRD_PT_OUTPUT_12V, and NAIBRD_PT_OUTPUT_5V_AND_12V.

Configuring Input Format and Termination

The Configure_PT_InputFormat() and Configure_PT_InputTermination() functions configure the input side of the PT channel:

  • naibrd_PT_SetInputFormat(cardIndex, module, channel, format) — Sets the input format. Options include NAIBRD_PT_INPUTFORMAT_DISABLED, NAIBRD_PT_INPUTFORMAT_SINGLEENDED_ENABLED, NAIBRD_PT_INPUTFORMAT_DIFFERENTIAL_ENABLED, NAIBRD_PT_INPUTFORMAT_SMA_ENABLED, and NAIBRD_PT_INPUTFORMAT_SINGLEENDED_CROSS_THRESH_ENABLED.

  • naibrd_PT_SetInputTermination(cardIndex, module, channel, termination) — Sets the input termination impedance. Options include NAIBRD_PT_INPUT_DISABLED, NAIBRD_PT_INPUT_50_OHM, NAIBRD_PT_INPUT_75_OHM, and NAIBRD_PT_INPUT_100_OHM.

Setting Crossing Threshold

The Configure_PT_Threshold() function sets the crossing threshold voltage for the selected channel:

static nai_status_t Configure_PT_Threshold(int32_t paramCnt, int32_t* p_params)
{
   float64_t threshold = 0.0;
   /* ... prompt user for voltage value ... */
   threshold = atof((const char *)inputBuffer);
   status = check_status(naibrd_PT_SetCrossingThreshold(cardIndex, module, chan, threshold));
   return status;
}
  • naibrd_PT_SetCrossingThreshold(cardIndex, module, channel, voltage) — Sets the crossing threshold voltage as a float64_t value.

Troubleshooting Reference

Error / Symptom Possible Causes Suggested Resolution

Module selection not recognized as PT module

The selected slot does not contain a PT module, or the module ID is not recognized.

Verify that a PT1 module is installed in the selected slot. Use the board menu to check module types.

No board found

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

Verify power, cables, and that the correct interface type is chosen in the board menu.

Connection timeout

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

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

Invalid card or module index

Indices are zero-based for cards and one-based for modules.

Ensure the values you enter match your hardware setup.

Clock output setting not taking effect

The channel may need to be in a specific state before clock output can be configured.

Verify the channel is properly initialized. Check the PT1 Manual for configuration dependencies.

Output enable returns error

Attempting to set an unsupported output mode for the installed module variant.

Verify the module supports the selected output mode. Not all PT1 variants support all voltage options.

Crossing threshold out of range

The entered voltage exceeds the supported range for the module.

Consult the PT1 Manual for valid threshold ranges.

Input format or termination not applying

The channel may need output to be disabled before input configuration changes take effect.

Disable output first, then configure input format and termination.

Full Source

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

Full Source — pt_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_pt.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 *CONFIG_FILE = (const int8_t *)"default_PT_BasicOp.txt";

#define K6_VER_4 0x3420u /* "4 " */

/* Function prototypes */
static void Run_PT_BasicOps(int32_t cardIndex, int32_t module, uint32_t modid);
static void Cfg_PT_Channel(int32_t cardIndex, int32_t module, uint32_t ModuleID, int32_t MaxChannel);
static bool_t Display_PT_Status(int32_t cardIndex, int32_t module, int32_t chan, uint32_t ModuleID);
static nai_status_t Configure_PT_Clock(int32_t paramCount, int32_t* p_params);
static nai_status_t Configure_PT_Output(int32_t paramCount, int32_t* p_params);
static nai_status_t Configure_PT_InputFormat(int32_t paramCount, int32_t* p_params);
static nai_status_t Configure_PT_InputTermination(int32_t paramCount, int32_t* p_params);
static nai_status_t Configure_PT_Threshold(int32_t paramCount, int32_t* p_params);
static nai_status_t Configure_PT_SelectChan(int32_t paramCount, int32_t* p_params);

static const int32_t DEF_PT_CHANNEL = 1;

/****** Command Table *******/
enum pt_basicops_commands
{
   PT_BASICOP_CMD_CLOCK_OUT,
   PT_BASICOP_CMD_OUTPUT,
   PT_BASICOP_CMD_IOFORMAT,
   PT_BASICOP_CMD_INTERM,
   PT_BASICOP_CMD_CROSS,
   PT_BASICOP_CMD_CHAN,
   PT_BASICOP_CMD_COUNT
};

/****** Command Tables *******/
naiapp_cmdtbl_params_t PT_BasicOpMenuCmds[] = {
   {"Clock",    "PT Set Clock Out",             PT_BASICOP_CMD_CLOCK_OUT,                 Configure_PT_Clock},
   {"Output",   "PT Enable Output (5V/12V)",    PT_BASICOP_CMD_OUTPUT,                    Configure_PT_Output},
   {"Input",    "PT Set Input format",          PT_BASICOP_CMD_IOFORMAT,                  Configure_PT_InputFormat},
   {"Term",     "PT Set InputTermination",      PT_BASICOP_CMD_INTERM,                    Configure_PT_InputTermination},
   {"Cross",    "PT Crossing Thresh",           PT_BASICOP_CMD_CROSS,                     Configure_PT_Threshold},
   {"S",        "PT Switch Selected Channel",   PT_BASICOP_CMD_CHAN,                      Configure_PT_SelectChan},
};

/**************************************************************************************************************/
/**
<summary>
The purpose of the pt_basic_ops is to illustrate the methods to call in the naibrd library to perform basic
operations with the relay modules for configuration setup, controlling the drive outputs, and reading
the channels.
</summary>
*/
/**************************************************************************************************************/
#if defined (__VXWORKS__)
int32_t PT_BasicOps(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(CONFIG_FILE) == NAI_TRUE)
   {
      while (stop != NAI_TRUE)
      {
         /* Query the user for the card index */
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != NAI_TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));

            /* Query the user for the module number */
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != NAI_TRUE)
            {
               check_status(naibrd_GetModuleName(cardIndex, module, &moduleID));
               if ((moduleID != 0))
               {
                  Run_PT_BasicOps(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;
}

static void Run_PT_BasicOps(int32_t cardIndex, int32_t module, uint32_t modid)
{
   int32_t MaxChannel;

   MaxChannel = naibrd_PT_GetChannelCount(modid);

   if (MaxChannel == 0)
      naiif_printf(" *** Module selection not recognized as PT module. ***\r\n\r\n");
   else
      Cfg_PT_Channel(cardIndex, module, modid, MaxChannel);
}

static void Cfg_PT_Channel(int32_t cardIndex, int32_t module, uint32_t ModuleID, int32_t MaxChannel)
{
   bool_t bQuit = NAI_FALSE;
   bool_t bContinue = NAI_TRUE;
   bool_t bCmdFound = NAI_FALSE;
   int32_t chan, defaultchan = 1;
   int32_t cmd;
   naiapp_cmdtbl_params_t menuCmds[PT_BASICOP_CMD_COUNT];
   int32_t menuCnt, totalMenuCnt;
   int32_t i;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   naiapp_AppParameters_t  pt_basicops_params;
   p_naiapp_AppParameters_t pt_basicOps_params = &pt_basicops_params;
   pt_basicOps_params->cardIndex = cardIndex;
   pt_basicOps_params->module = module;
   pt_basicOps_params->channel = 1;
   pt_basicOps_params->maxChannels = naibrd_PT_GetChannelCount(ModuleID);
   pt_basicOps_params->modId = ModuleID;
   pt_basicOps_params->displayHex = NAI_FALSE;

   /* Basic operation sample for relay modules.
   - User selection of channel
   - Set relay state, open or closed
   - read status information (BIT)
   */
   while (bContinue)
   {
      naiif_printf("    \r\n\r\n");
      naiif_printf("Channel selection \r\n");
      naiif_printf("================= \r\n");
      defaultchan = DEF_PT_CHANNEL;
      bQuit = naiapp_query_ChannelNumber(MaxChannel, defaultchan, &chan);
      pt_basicOps_params->cardIndex = cardIndex;
      pt_basicOps_params->module = module;
      pt_basicOps_params->channel = chan;
      pt_basicOps_params->modId = ModuleID;

      /* Update Menu Cmds based on Module ID */
      totalMenuCnt = 0;
      menuCnt = sizeof(PT_BasicOpMenuCmds) / sizeof(naiapp_cmdtbl_params_t);
      for (i = 0; i < menuCnt; i++)
         menuCmds[totalMenuCnt++] = PT_BasicOpMenuCmds[i];

      naiapp_utils_LoadParamMenuCommands(totalMenuCnt, menuCmds);
      while (bContinue)
      {
         Display_PT_Status(cardIndex, module, chan, ModuleID);

         naiapp_display_ParamMenuCommands((int8_t *)"PT Basic Operation Menu");
         naiif_printf("\r\n Type PT command or %c to quit : ", 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)
               {
                  naiif_printf("  <%s>", menuCmds[cmd].cmdstr); /*Echo back acknowledgment of command selection*/
                  switch (cmd)
                  {
                     case PT_BASICOP_CMD_CLOCK_OUT:
                     case PT_BASICOP_CMD_OUTPUT:
                     case PT_BASICOP_CMD_IOFORMAT:
                     case PT_BASICOP_CMD_INTERM:
                     case PT_BASICOP_CMD_CROSS:
                     case PT_BASICOP_CMD_COUNT:
                     case PT_BASICOP_CMD_CHAN:
                        PT_BasicOpMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)pt_basicOps_params);
                        break;
                     default:
                        naiif_printf("Invalid command entered\r\n");
                        break;
                  }
               }
               else
                  naiif_printf("Invalid command entered\r\n");
            }
         }
         else
            bContinue = NAI_FALSE;
      }
   }
}
static nai_status_t Configure_PT_SelectChan(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_pt_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_pt_params->cardIndex;
   int32_t module = p_pt_params->module;
   uint32_t modid = p_pt_params->modId;

   NAIBSP_UNREFERENCED_PARAMETER(paramCount);

   Run_PT_BasicOps(cardIndex, module, modid);

   return NAI_SUCCESS;
}
static bool_t Display_PT_Status(int32_t cardIndex, int32_t module, int32_t chan, uint32_t ModuleID)
{
   naibrd_pt_clock_out_enable_t pt_Setting1;
   naibrd_pt_output_type_t pt_Setting2;
   int32_t MaxChannel;
   uint8_t i = 0;
   uint8_t displaychan = 0;
   naibrd_pt_input_format_t input_setting;
   naibrd_pt_input_termination_t term;
   float64_t thresh;

   naiif_printf("\r\n\r\n");
   naiif_printf("\r\n === Settings Channel %d ===\r\n\r\n", chan);
   MaxChannel = naibrd_PT_GetChannelCount(ModuleID);

   naiif_printf("Chan   Clock Out Enable       Output Enable            Input Format             Input Termination        Cross Thresh\r\n");
   naiif_printf("---- --------------------- --------------------  ------------------------   ------------------------    --------------\r\n");

   for (i = 0; i < MaxChannel; i++)
   {
      displaychan = i + 1;
      naiif_printf(" %2d ", displaychan);

      check_status(naibrd_PT_GetClockOutEnable(cardIndex, module, displaychan, &pt_Setting1));
      switch(pt_Setting1)
      {
         case NAIBRD_PT_CLOCK_DISABLE:

            naiif_printf("      Disabled          ");
         break;
         case NAIBRD_PT_CLOCK_SINGLEENDED:
            naiif_printf("     SingleEnded        ");
         break;
         case NAIBRD_PT_CLOCK_DIFF:
            naiif_printf("     Differential       ");
            break;
         default:
            naiif_printf("        Unknown         ");
         break;
      }


      check_status(naibrd_PT_GetOutputEnable(cardIndex, module, displaychan, &pt_Setting2));
      switch (pt_Setting2)
      {
         case NAIBRD_PT_OUTPUT_DISABLE:

            naiif_printf("    Disabled       ");
         break;
         case NAIBRD_PT_OUTPUT_5V:
            naiif_printf("      5V           ");
            break;
         case NAIBRD_PT_OUTPUT_12V:
            naiif_printf("     12V           ");
            break;
         case NAIBRD_PT_OUTPUT_5V_AND_12V:
            naiif_printf("    5V + 12V       ");
            break;
         default:
            naiif_printf("    Unknown        ");
         break;
      }


      check_status(naibrd_PT_GetInputFormat(cardIndex, module, displaychan, &input_setting));
      switch (input_setting)
      {
      case NAIBRD_PT_INPUTFORMAT_DISABLED:
         naiif_printf("           Disabled           ");
         break;
      case NAIBRD_PT_INPUTFORMAT_SINGLEENDED_ENABLED:
         naiif_printf("    Single Ended, Enabled     ");
         break;
      case NAIBRD_PT_INPUTFORMAT_DIFFERENTIAL_ENABLED:
         naiif_printf("    Differential, Enabled     ");
         break;
      case NAIBRD_PT_INPUTFORMAT_SMA_ENABLED:
         naiif_printf("       SMA, Enabled           ");
         break;
      case NAIBRD_PT_INPUTFORMAT_SINGLEENDED_CROSS_THRESH_ENABLED:
         naiif_printf(" Single Ended Cross Enabled   ");
         break;
      default:
         naiif_printf("          Unknown             ");
         break;
      }
      check_status(naibrd_PT_GetInputTermination(cardIndex, module, displaychan, &term));
      switch (term)
      {
      case NAIBRD_PT_INPUT_DISABLED:
         naiif_printf("       Disabled        ");
         break;
      case NAIBRD_PT_INPUT_50_OHM:
         naiif_printf("       50 Ohms         ");
         break;
      case NAIBRD_PT_INPUT_75_OHM:
         naiif_printf("       75 Ohms         ");
         break;
      case NAIBRD_PT_INPUT_100_OHM:
         naiif_printf("       100 Ohms        ");
         break;
      default:
         naiif_printf("       Unknown         ");
         break;
      }

      check_status(naibrd_PT_GetCrossingThreshold(cardIndex, module, displaychan, &thresh));
      naiif_printf("     %+6.3f     ", thresh);


      naiif_printf("\r\n");
   }
   return NAI_FALSE;
}

static nai_status_t Configure_PT_Output(int32_t paramCount, int32_t* p_params)
{
   /*Set word for relay to change all relay settings concurrently*/
   bool_t bQuit = NAI_FALSE;
   bool_t bUpdateOutput = NAI_FALSE;
   p_naiapp_AppParameters_t p_pt_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_pt_params->cardIndex;
   int32_t module = p_pt_params->module;
   int32_t channel = p_pt_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   naibrd_pt_output_type_t outstate;

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

   naiif_printf("\r\n1 = disabled\r\n2 = 5V Enable\r\n3 = 12V Enable\r\n4 = 5V and 12V Enable");
   naiif_printf("\r\nEnter the Output Enable desired setting:  \r\n > ");
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         switch (toupper(inputBuffer[0]))
         {
            case '1':
               outstate = NAIBRD_PT_OUTPUT_DISABLE;
               bUpdateOutput = NAI_TRUE;
            break;
            case '2':
               outstate = NAIBRD_PT_OUTPUT_5V;
               bUpdateOutput = NAI_TRUE;
            break;
            case '3':
               outstate = NAIBRD_PT_OUTPUT_12V;
               bUpdateOutput = NAI_TRUE;
            break;
            case '4':
               outstate = NAIBRD_PT_OUTPUT_5V_AND_12V;
               bUpdateOutput = NAI_TRUE;
            break;
            default:
               naiif_printf("ERROR: Invalid Output State Format Entry\r\n");
               bUpdateOutput = NAI_FALSE;
            break;
         }
      }
   }
   if (!bQuit)
   {
      if (bUpdateOutput)
         check_status(naibrd_PT_SetOutputEnable(cardIndex, module, channel, outstate));
   }
   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t Configure_PT_Clock(int32_t paramCount, int32_t* p_params)
{
   /*Set word for relay to change all relay settings concurrently*/
   bool_t bQuit = NAI_FALSE;
   bool_t bUpdateOutput = NAI_FALSE;
   p_naiapp_AppParameters_t p_pt_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_pt_params->cardIndex;
   int32_t module = p_pt_params->module;
   int32_t channel = p_pt_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   naibrd_pt_clock_out_enable_t outstate;

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

   naiif_printf("\r\n1 = disabled\r\n2 = SingleEnded\r\n3 = Differential\r\n");
   naiif_printf("\r\nEnter the desired Clock output setting:  \r\n > ");
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         switch (toupper(inputBuffer[0]))
         {
         case '1':
            outstate = NAIBRD_PT_CLOCK_DISABLE;
            bUpdateOutput = NAI_TRUE;
            break;
         case '2':
            outstate = NAIBRD_PT_CLOCK_SINGLEENDED;
            bUpdateOutput = NAI_TRUE;
            break;
         case '3':
            outstate = NAIBRD_PT_CLOCK_DIFF;
            bUpdateOutput = NAI_TRUE;
            break;
         default:
            naiif_printf("ERROR: Invalid Clock State Format Entry\r\n");
            bUpdateOutput = NAI_FALSE;
            break;
         }
      }
   }
   if (!bQuit)
   {
      if (bUpdateOutput)
         check_status(naibrd_PT_SetClockOutEnable(cardIndex, module, channel, outstate));
   }
   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t Configure_PT_InputFormat(int32_t paramCount, int32_t* p_params)
{
   /*Set word for relay to change all relay settings concurrently*/
   bool_t bQuit = NAI_FALSE;
   bool_t bUpdateOutput = NAI_FALSE;
   p_naiapp_AppParameters_t p_pt_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_pt_params->cardIndex;
   int32_t module = p_pt_params->module;
   int32_t channel = p_pt_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   naibrd_pt_input_format_t outstate;

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

   naiif_printf("\r\n1 = disabled\r\n2 = SingleEnded, Enable\r\n3 = Differential, Enable\r\n4 = SMA Enable\r\n5 = Single Ended With Crossing Thresh Enable\r\n");
   naiif_printf("\r\nEnter the desired Input Format setting:  \r\n > ");
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         switch (toupper(inputBuffer[0]))
         {
         case '1':
            outstate = NAIBRD_PT_INPUTFORMAT_DISABLED;
            bUpdateOutput = NAI_TRUE;
            break;
         case '2':
            outstate = NAIBRD_PT_INPUTFORMAT_SINGLEENDED_ENABLED;
            bUpdateOutput = NAI_TRUE;
            break;
         case '3':
            outstate = NAIBRD_PT_INPUTFORMAT_DIFFERENTIAL_ENABLED;
            bUpdateOutput = NAI_TRUE;
            break;
          case '4':
            outstate = NAIBRD_PT_INPUTFORMAT_SMA_ENABLED;
            bUpdateOutput = NAI_TRUE;
            break;
          case '5':
            outstate = NAIBRD_PT_INPUTFORMAT_SINGLEENDED_CROSS_THRESH_ENABLED;
            bUpdateOutput = NAI_TRUE;
            break;
         default:
            naiif_printf("ERROR: Invalid Clock State Format Entry\r\n");
            bUpdateOutput = NAI_FALSE;
            break;
         }
      }
   }
   if (!bQuit)
   {
      if (bUpdateOutput)
         check_status(naibrd_PT_SetInputFormat(cardIndex, module, channel, outstate));
   }
   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
static nai_status_t Configure_PT_InputTermination(int32_t paramCount, int32_t* p_params)
{
   /*Set word for relay to change all relay settings concurrently*/
   bool_t bQuit = NAI_FALSE;
   bool_t bUpdateOutput = NAI_FALSE;
   p_naiapp_AppParameters_t p_pt_params = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = p_pt_params->cardIndex;
   int32_t module = p_pt_params->module;
   int32_t channel = p_pt_params->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   naibrd_pt_input_termination_t outstate;

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

   naiif_printf("\r\n1 = disabled\r\n2 = 50 Ohms\r\n3 = 75 Ohms\r\n4 = 100 Ohms\r\n");
   naiif_printf("\r\nEnter the desired input termination setting:  \r\n > ");
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         switch (toupper(inputBuffer[0]))
         {
         case '1':
            outstate = NAIBRD_PT_INPUT_DISABLED;
            bUpdateOutput = NAI_TRUE;
            break;
         case '2':
            outstate = NAIBRD_PT_INPUT_50_OHM;
            bUpdateOutput = NAI_TRUE;
            break;
         case '3':
            outstate = NAIBRD_PT_INPUT_75_OHM;
            bUpdateOutput = NAI_TRUE;
            break;
         case '4':
            outstate = NAIBRD_PT_INPUT_100_OHM;
            bUpdateOutput = NAI_TRUE;
            break;
         default:
            naiif_printf("ERROR: Invalid Clock State Format Entry\r\n");
            bUpdateOutput = NAI_FALSE;
            break;
         }
      }
   }
   if (!bQuit)
   {
      if (bUpdateOutput)
         check_status(naibrd_PT_SetInputTermination(cardIndex, module, channel, outstate));
   }
   return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}


static nai_status_t Configure_PT_Threshold(int32_t paramCnt, int32_t* p_params)
{
   nai_status_t status = NAI_ERROR_NOT_SUPPORTED;
   bool_t bQuit = NAI_FALSE;
   float64_t threshold = 0.0;
   p_naiapp_AppParameters_t dtParams = (p_naiapp_AppParameters_t)p_params;
   int32_t cardIndex = dtParams->cardIndex;
   int32_t module = dtParams->module;
   int32_t chan = dtParams->channel;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

#if defined (WIN32)
   UNREFERENCED_PARAMETER(paramCnt);
#endif

   naiif_printf("\r\nEnter the desired threshold voltage : ");
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         threshold = atof((const char *)inputBuffer);
         status = check_status(naibrd_PT_SetCrossingThreshold(cardIndex, module, chan, threshold));
      }
   }
   return status;
}

Help Bot

X