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

PRNT BasicOps

PRNT BasicOps

Explanation

About the Sample Application Code

This C program demonstrates how to use North Atlantic Industries' System Software Kit (SSK) to operate and configure their various printer embedded function modules. The application interacts with these hardware modules to perform basic operations such as configuring channels, enabling or disabling devices, reading status, and handling data through FIFO (First-In-First-Out) structures.

Included Libraries and Headers The program begins by including standard libraries and specific header files tailored for hardware interaction:

  • <stdio.h>, <stdlib.h>, <string.h>, <time.h>, <ctype.h>: Standard C libraries for input/output, memory management, string handling, time functions, and character operations.

  • "nai.h", "naibrd.h": These headers contain the core definitions and declarations for interacting with NAI boards and modules.

  • NAI-specific utility and display headers:

  • "include/naiapp_boardaccess_menu.h"

  • "include/naiapp_boardaccess_query.h"

  • "include/naiapp_boardaccess_access.h"

  • "include/naiapp_boardaccess_display.h"

  • "include/naiapp_boardaccess_utils.h"

  • "functions/naibrd_prnt.h"

  • "advanced/nai_ether_adv.h"

Definitions and Enumerations - CONFIG_FILE: A constant defining the default configuration file, "default_PRNT_BasicOps.txt".

  • DEF_PRNT_CHANNEL: A predefined channel set to 1 for default operations.

  • enum prnt_basicops_commands: An enumeration defining various command identifiers (e.g., PRNT_BASICOP_CMD_RESET, PRNT_BASICOP_CMD_ENABLE, etc.).

Function Prototypes - Run_PRNT_BasicOps: Runs basic operations for a printer module. - Cfg_PRNT_Channel: Configures a specified channel of a printer module. - Display_PRNT_ChannelCfg: Displays the configuration of a specified printer module channel. - ResetPrinter, SetIOTermination, EnablePrinter, ReadFifo, ClearLatchedStatus, ClearFifoLatchedStatus: Handle specific commands related to the printer module.

Main Functionality Depending on the operating system (VXWORKS), the main function is defined differently but performs the same tasks:

  1. Configuration Menu: The program initially loads a configuration menu from the CONFIG_FILE.

  2. User Interaction Loop:

    • Query for Card Index and Module Number: It queries the user to input card and module details.

    • Run Operations: Based on user input, Run_PRNT_BasicOps is executed.

    • Exit Mechanism: Prompts user if they want to quit or restart.

  3. Run_PRNT_BasicOps: Validates the module type and, if recognized as a printer module, configures it using Cfg_PRNT_Channel.

  4. Cfg_PRNT_Channel:

    • Displays the channel configuration.

    • Handles user inputs to execute commands such as resetting the printer, reading FIFO, or clearing status.

  5. Display_PRNT_ChannelCfg: Retrieves and displays the current state and configuration of the printer channel, including control settings, termination status, runtime and latched status, and FIFO status.

  6. Command Functions: Each command function (e.g., ResetPrinter, SetIOTermination, etc.) demonstrates calling corresponding library functions to perform specific operations on the printer module:

    • ResetPrinter: Toggles the reset state.

    • SetIOTermination: Sets termination resistors.

    • EnablePrinter: Enables or disables the printer.

    • ReadFifo: Reads and displays FIFO data.

    • ClearLatchedStatus: Clears latched status bits.

    • ClearFifoLatchedStatus: Clears latched FIFO status bits.

Example Usage

Initialize and Configure the Printer Module:

int32_t cardIndex = 0;
int32_t module = 0;
uint32_t moduleID = 1234; // Example Module ID
Run_PRNT_BasicOps(cardIndex, module, moduleID);

Display Configuration:

Display_PRNT_ChannelCfg(cardIndex, module, DEF_PRNT_CHANNEL, moduleID);

Perform Reset:

ResetPrinter(0, (int32_t*)&prnt_basicops_params);

Set Termination:

SetIOTermination(0, (int32_t*)&prnt_basicops_params);

Enable the Printer:

EnablePrinter(0, (int32_t*)&prnt_basicops_params);

Read FIFO Data:

ReadFifo(0, (int32_t*)&prnt_basicops_params);

Clear Latched Status:

ClearLatchedStatus(0, (int32_t*)&prnt_basicops_params);

Clear FIFO Latched Status:

ClearFifoLatchedStatus(0, (int32_t*)&prnt_basicops_params);

This application is a comprehensive guide demonstrating how to utilize the provided library functions to manage and interact with NAI’s printer modules effectively.

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

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

/* naibrd include files */
#include "nai.h"
#include "naibrd.h"
#include "functions/naibrd_prnt.h"
#include "advanced/nai_ether_adv.h"

static const int8_t *CONFIG_FILE = (int8_t *)"default_PRNT_BasicOps.txt";

/* Function prototypes */
static int32_t Run_PRNT_BasicOps(int32_t cardIndex, int32_t module, int32_t ModuleID);
static void Cfg_PRNT_Channel(int32_t cardIndex, int32_t module, uint32_t ModuleID, int32_t MaxChannel);
static void Display_PRNT_ChannelCfg(int32_t cardIndex, int32_t module, int32_t chan, uint32_t ModuleID);
static nai_status_t ResetPrinter(int32_t paramCount, int32_t* p_params);
static nai_status_t SetIOTermination(int32_t paramCount, int32_t* p_params);
static nai_status_t EnablePrinter(int32_t paramCount, int32_t* p_params);
static nai_status_t ReadFifo(int32_t paramCount, int32_t* p_params);
static nai_status_t ClearLatchedStatus(int32_t paramCount, int32_t* p_params);
static nai_status_t ClearFifoLatchedStatus(int32_t paramCount, int32_t* p_params);

static const int32_t DEF_PRNT_CHANNEL       = 1;

/****** Command Table *******/
enum prnt_basicops_commands
{
   PRNT_BASICOP_CMD_RESET,
   PRNT_BASICOP_CMD_TERMINATION,
   PRNT_BASICOP_CMD_ENABLE,
   PRNT_BASICOP_CMD_READ_FIFO,
   PRNT_BASICOP_CMD_CLEAR_STATUS,
   PRNT_BASICOP_CMD_CLEAR_FIFO_STATUS,
   PRNT_BASICOP_CMD_COUNT
};

/****** Command Tables *******/
naiapp_cmdtbl_params_t PRNT_BasicOpMenuCmds[] = {
   {"Reset",         "Toggle printer reset",          PRNT_BASICOP_CMD_RESET,             ResetPrinter},
   {"Termination",   "Set IO Termination",            PRNT_BASICOP_CMD_TERMINATION,       SetIOTermination},
   {"Enable",        "Toggle printer Enable/Disable", PRNT_BASICOP_CMD_ENABLE,            EnablePrinter},
   {"Fifo",          "Read and display FIFO data",    PRNT_BASICOP_CMD_READ_FIFO,         ReadFifo},
   {"Clear status",  "Clears latched Status",         PRNT_BASICOP_CMD_CLEAR_STATUS,      ClearLatchedStatus},
   {"CF",            "Clears Fifo's latched status",  PRNT_BASICOP_CMD_CLEAR_FIFO_STATUS, ClearFifoLatchedStatus},
};

/**************************************************************************************************************/
/**
<summary>
The purpose of the PRNT_BasicOps is to illustrate the methods to call in the naibrd library to perform basic
 operations with the printer modules for configuration setup and reading rx data from the FIFO.

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 PRNT routines.
 - ClearDeviceCfg
 - QuerySystemCfg
 - DisplayDeviceCfg
 - GetBoardSNModCfg
 - SaveDeviceCfg
</summary>
*/
/**************************************************************************************************************/
#if defined (__VXWORKS__)
int32_t PRNT_BasicOps(void)
#else
int32_t main(void)
#endif
{
   bool_t stop = 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) == TRUE)
   {
      while (stop != TRUE)
      {
         /* Query the user for the card index */
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));

            /* Query the user for the module number */
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != TRUE)
            {
               moduleID = naibrd_GetModuleID(cardIndex, module);
               if ((moduleID != 0))
               {
                  Run_PRNT_BasicOps(cardIndex, module, moduleID);
               }
            }
         }

         printf("\nType Q to quit or Enter key to restart application:\n");
         stop = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      }
   }

   printf("\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_PRNT_BasicOps prompts the user for the card, module (channel is set to 1) to use for the application and calls
Cfg_PRNT_Channel if the card, module, channel is valid for as a printer module.
</summary>
*/
/**************************************************************************************************************/
int32_t Run_PRNT_BasicOps(int32_t cardIndex, int32_t module, int32_t ModuleID)
{
   int32_t MaxChannel;

   MaxChannel = naibrd_PRNT_GetChannelCount(ModuleID);

   if (MaxChannel == 0)
   {
      printf(" *** Module selection not recognized as PRNT module. ***\n\n");
   }
   else
   {
      Cfg_PRNT_Channel(cardIndex, module, ModuleID, MaxChannel);
   }
   return cardIndex;
}

/**************************************************************************************************************/
/**
<summary>
Cfg_PRNT_Channel handles calling the Display_PRNT_ChannelCfg routine to display the printer's channel configuration
and calling the routines associated with the user's menu commands.
</summary>
*/
/**************************************************************************************************************/
static void Cfg_PRNT_Channel(int32_t cardIndex, int32_t module, uint32_t ModuleID, int32_t MaxChannel)
{
   bool_t bQuit = FALSE;
   bool_t bContinue = TRUE;
   bool_t bCmdFound = FALSE;
   int32_t chan = DEF_PRNT_CHANNEL;
   int32_t cmd;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   naiapp_AppParameters_t  prnt_params;
   p_naiapp_AppParameters_t prnt_basicops_params = &prnt_params;
   prnt_basicops_params->cardIndex = cardIndex;
   prnt_basicops_params->module = module;
   prnt_basicops_params->channel = chan;
   prnt_basicops_params->modId = ModuleID;
   prnt_basicops_params->maxChannels = MaxChannel;

   while (bContinue)
   {
      naiapp_utils_LoadParamMenuCommands(PRNT_BASICOP_CMD_COUNT, PRNT_BasicOpMenuCmds);
      while (bContinue)
      {
         Display_PRNT_ChannelCfg(cardIndex, module, chan, ModuleID);
         naiapp_display_ParamMenuCommands((int8_t *)"PRNT Basic Operation Menu");
         printf("\nType PRNT 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)
               {
                  switch (cmd)
                  {
                  case PRNT_BASICOP_CMD_RESET:
                  case PRNT_BASICOP_CMD_TERMINATION:
                  case PRNT_BASICOP_CMD_ENABLE:
                  case PRNT_BASICOP_CMD_READ_FIFO:
                  case PRNT_BASICOP_CMD_CLEAR_STATUS:
                  case PRNT_BASICOP_CMD_CLEAR_FIFO_STATUS:
                     PRNT_BasicOpMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)prnt_basicops_params);
                     break;
                  default:
                     printf("Invalid command entered\n");
                     break;
                  }
               }
               else
                  printf("Invalid command entered\n");
            }
         }
         else
            bContinue = FALSE;
      }
   }
}

/**************************************************************************************************************/
/**
<summary>
Display_PRNT_ChannelCfg illustrate the methods to call in the naibrd library to retrieve the configuration states
for basic operation.
</summary>
*/
/**************************************************************************************************************/
static void Display_PRNT_ChannelCfg(int32_t cardIndex, int32_t module, int32_t chan, uint32_t ModuleID)
{
   nai_prnt_control_t control = (nai_prnt_control_t)0u;
   nai_prnt_termination_enable_t terminationEnable = (nai_prnt_termination_enable_t)0u;
   nai_prnt_status_t statusRT = (nai_prnt_status_t)0u, statusLT = (nai_prnt_status_t)0u;
   nai_prnt_fifo_status_t fifoStatusRT = (nai_prnt_fifo_status_t)0u, fifoStatusLT = (nai_prnt_fifo_status_t)0u;
   uint32_t fifoCount = 0u;
   uint32_t ModuleVer;
   uint32_t ModuleRev;
   uint32_t ModInfo_Special;

   check_status(naibrd_GetModuleInfo(cardIndex, module, &ModuleID, &ModuleVer, &ModuleRev, &ModInfo_Special));
   check_status(naibrd_PRNT_GetControl(cardIndex, module, chan, NAI_PRNT_CONTROL_ENABLE | NAI_PRNT_CONTROL_RESET, (uint32_t*)&control));
   check_status(naibrd_PRNT_GetTerminationEnable(cardIndex, module, chan, (nai_prnt_termination_enable_t)0xFFFFFFFFu, (uint32_t*)&terminationEnable));
   check_status(naibrd_PRNT_GetStatusRaw(cardIndex, module, chan, NAI_PRNT_STATUS_TYPE_REALTIME, &statusRT));
   check_status(naibrd_PRNT_GetStatusRaw(cardIndex, module, chan, NAI_PRNT_STATUS_TYPE_LATCHED, &statusLT));
   check_status(naibrd_PRNT_GetRxFIFOCount(cardIndex, module, chan, &fifoCount));
   check_status(naibrd_PRNT_GetFIFOStatusRaw(cardIndex, module, chan, NAI_PRNT_STATUS_TYPE_REALTIME, &fifoStatusRT));
   check_status(naibrd_PRNT_GetFIFOStatusRaw(cardIndex, module, chan, NAI_PRNT_STATUS_TYPE_LATCHED, &fifoStatusLT));

   printf("\r\n\r\n");
   printf("Channel   ===Control===  =Termination= ==Status(R/L)== =FIFO Count=  ==============FIFO Status(R/L)============\r\n");
   printf("          ENABLE  RESET                DATA_AVAILABLE                EMPTY ALMST_EMPTY ALMST_FULL FULL OVERFLOW\r\n");
   printf("---------------------------------------------------------------------------------------------------------------\r\n");
   printf(" %2i         %u       %u       0x%04X          (%u/%u)          %4u      (%u/%u)     (%u/%u)     (%u/%u)    (%u/%u)  (%u/%u)\r\n",
      chan, 0 != (control & NAI_PRNT_CONTROL_ENABLE), 0 != (control & NAI_PRNT_CONTROL_RESET), terminationEnable,
      0 != (statusRT & NAI_PRNT_STATUS_DATA_AVAILABLE), 0 != (statusLT & NAI_PRNT_STATUS_DATA_AVAILABLE), fifoCount,
      0 != (fifoStatusRT & NAI_PRNT_FIFO_STATUS_EMPTY), 0 != (fifoStatusLT & NAI_PRNT_FIFO_STATUS_EMPTY),
      0 != (fifoStatusRT & NAI_PRNT_FIFO_STATUS_ALMOST_EMPTY), 0 != (fifoStatusLT & NAI_PRNT_FIFO_STATUS_ALMOST_EMPTY),
      0 != (fifoStatusRT & NAI_PRNT_FIFO_STATUS_ALMOST_FULL), 0 != (fifoStatusLT & NAI_PRNT_FIFO_STATUS_ALMOST_FULL),
      0 != (fifoStatusRT & NAI_PRNT_FIFO_STATUS_FULL), 0 != (fifoStatusLT & NAI_PRNT_FIFO_STATUS_FULL),
      0 != (fifoStatusRT & NAI_PRNT_FIFO_STATUS_OVERFLOW), 0 != (fifoStatusLT & NAI_PRNT_FIFO_STATUS_OVERFLOW) );
}

/**************************************************************************************************************/
/**
<summary>
ResetPrinter illustrate the methods to call in the naibrd library to reset the printer.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t ResetPrinter(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_prnt_params = (p_naiapp_AppParameters_t)p_params;
   uint32_t controlData = 0;
   nai_status_t status = NAI_ERROR_UNKNOWN;

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

   status = check_status(naibrd_PRNT_GetControl(p_prnt_params->cardIndex, p_prnt_params->module, p_prnt_params->channel,
      NAI_PRNT_CONTROL_RESET, &controlData));
   if (status == NAI_SUCCESS)
   {
      status = check_status(naibrd_PRNT_SetControl(p_prnt_params->cardIndex, p_prnt_params->module, p_prnt_params->channel,
      NAI_PRNT_CONTROL_RESET, ~controlData));
   }

   return status;
}

/**************************************************************************************************************/
/**
<summary>
SetIOTermination illustrate the methods to call in the naibrd library to set the termination resistors on the
printer's I/O lines.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t SetIOTermination(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_prnt_params = (p_naiapp_AppParameters_t)p_params;
   nai_prnt_termination_enable_t terminationBits = (nai_prnt_termination_enable_t)0u;
   uint32_t terminationBitValuesSet = 0;
   bool_t bQuit = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

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

   printf("\r\n\r\nTermination Bit values:\r\n");
   printf("NAI_PRNT_TERM_ENABLE_D0     = 0x00000001\r\n");
   printf("NAI_PRNT_TERM_ENABLE_D1     = 0x00000002\r\n");
   printf("NAI_PRNT_TERM_ENABLE_D2     = 0x00000004\r\n");
   printf("NAI_PRNT_TERM_ENABLE_D3     = 0x00000008\r\n");
   printf("NAI_PRNT_TERM_ENABLE_D4     = 0x00000010\r\n");
   printf("NAI_PRNT_TERM_ENABLE_D5     = 0x00000020\r\n");
   printf("NAI_PRNT_TERM_ENABLE_D6     = 0x00000040\r\n");
   printf("NAI_PRNT_TERM_ENABLE_PARITY = 0x00000080\r\n");
   printf("NAI_PRNT_TERM_ENABLE_STROBE = 0x00000100\r\n");
   printf("NAI_PRNT_TERM_ENABLE_DEMAND = 0x00000200\r\n");
   printf("NAI_PRNT_TERM_ENABLE_READY  = 0x00000400\r\n");
   printf("NAI_PRNT_TERM_ENABLE_STATUS = 0x00000800\r\n");

   do
   {
      printf("\r\nEnter Termination bit(s) to modify in Hex (0x0001..0x0FFF): 0x");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            terminationBits = naiapp_utils_HexStrToDecUInt32(inputBuffer);
         }
      }
   } while (!bQuit && inputResponseCnt == 0);

   do
   {
      printf("\r\nEnter Termination bit value(s) in Hex (0x0000..0x0FFF): 0x");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            terminationBitValuesSet = naiapp_utils_HexStrToDecUInt32(inputBuffer);
         }
      }
   } while (!bQuit && inputResponseCnt == 0);

   printf("Setting Termination bit(s) 0x%08X to 0x%08X\r\n", terminationBits, terminationBitValuesSet);
   check_status(naibrd_PRNT_SetTerminationEnable(p_prnt_params->cardIndex, p_prnt_params->module, p_prnt_params->channel,
      terminationBits, terminationBitValuesSet));

   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
EnablePrinter handles the user request to enable/disable the printer.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t EnablePrinter(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_prnt_params = (p_naiapp_AppParameters_t)p_params;
   uint32_t controlData;

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

   check_status(naibrd_PRNT_GetControl(p_prnt_params->cardIndex, p_prnt_params->module, p_prnt_params->channel,
      NAI_PRNT_CONTROL_ENABLE, &controlData));

   return check_status(naibrd_PRNT_SetControl(p_prnt_params->cardIndex, p_prnt_params->module, p_prnt_params->channel,
      NAI_PRNT_CONTROL_ENABLE, ~controlData));
}

/**************************************************************************************************************/
/**
<summary>
ReadFifo handles the user request to read the rx data from the fifo and display it.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t ReadFifo(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_prnt_params = (p_naiapp_AppParameters_t)p_params;
   int32_t bufferIndex = 0;
   uint32_t rxFifoData[NAI_PRNT_FIFO_SIZE];
   uint32_t countRemaining = 0;
   uint32_t readCount = 0;

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

  for (bufferIndex = 0; bufferIndex < NAI_PRNT_FIFO_SIZE; bufferIndex++)
      rxFifoData[bufferIndex] = 0;

  check_status(naibrd_PRNT_ReadRxFIFO(p_prnt_params->cardIndex, p_prnt_params->module, p_prnt_params->channel, NAI_PRNT_FIFO_SIZE,
     &countRemaining, rxFifoData, &readCount));

  printf("%u items read from the FIFO, %u items remain\r\n", readCount, countRemaining);
   for (bufferIndex = 0; bufferIndex < (int32_t)readCount; bufferIndex++)
   {
      printf("%2u) 0x%08X\r\n", bufferIndex + 1, rxFifoData[bufferIndex]);
   }

   return NAI_SUCCESS;
}

/**************************************************************************************************************/
/**
<summary>
ClearLatchedStatus illustrate the methods to call in the naibrd library to clear the latched status states.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t ClearLatchedStatus(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_prnt_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   nai_prnt_status_t prntStatusBits = (nai_prnt_status_t)0;
   nai_status_t status = NAI_ERROR_INVALID_VALUE;

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

   printf("\r\n\r\nStatus Bit values:\r\n");
   printf("NAI_PRNT_STATUS_DATA_AVAILABLE     = 0x00000001\r\n");

   do
   {
      printf("\r\nEnter Status bit(s) to clear in Hex (0x0001..0x0001): 0x");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            prntStatusBits = (nai_prnt_status_t)naiapp_utils_HexStrToDecUInt32(inputBuffer);
         }
      }
   } while (!bQuit && (inputResponseCnt == 0));

   if (!bQuit && (inputResponseCnt > 0))
   {
      status = check_status(naibrd_PRNT_ClearStatus(p_prnt_params->cardIndex, p_prnt_params->module, p_prnt_params->channel,
         prntStatusBits));
   }

   return status;
}

/**************************************************************************************************************/
/**
<summary>
ClearFifoLatchedStatus illustrate the methods to call in the naibrd library to clear the fifo latched status states.
</summary>
*/
/**************************************************************************************************************/
static nai_status_t ClearFifoLatchedStatus(int32_t paramCount, int32_t* p_params)
{
   p_naiapp_AppParameters_t p_prnt_params = (p_naiapp_AppParameters_t)p_params;
   bool_t bQuit = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;
   nai_prnt_fifo_status_t fifoStatusBits = (nai_prnt_fifo_status_t)0u;
   nai_status_t status = NAI_ERROR_INVALID_VALUE;

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

   printf("\r\n\r\nFIFO Status Bit values:\r\n");
   printf("NAI_PRNT_FIFO_STATUS_EMPTY           = 0x00000001\r\n");
   printf("NAI_PRNT_FIFO_STATUS_ALMOST_EMPTY    = 0x00000002\r\n");
   printf("NAI_PRNT_FIFO_STATUS_ALMOST_FULL     = 0x00000004\r\n");
   printf("NAI_PRNT_FIFO_STATUS_FULL            = 0x00000008\r\n");
   printf("NAI_PRNT_FIFO_STATUS_OVERFLOW        = 0x00000010\r\n");

   do
   {
      printf("\r\nEnter FIFO Status bit(s) to clear in Hex (0x0001..0x001F): 0x");
      bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
      if (!bQuit)
      {
         if (inputResponseCnt > 0)
         {
            fifoStatusBits = (nai_prnt_fifo_status_t)naiapp_utils_HexStrToDecUInt32(inputBuffer);
         }
      }
   } while (!bQuit && (inputResponseCnt == 0));

   if (!bQuit && (inputResponseCnt == 0))
   {
      status = check_status(naibrd_PRNT_ClearFIFOStatus(p_prnt_params->cardIndex, p_prnt_params->module, p_prnt_params->channel,
      fifoStatusBits));
   }

   return status;
}

Help Bot

X