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

DS MSMB Ethernet

DS MSMB Ethernet Sample Application (SSK 1.x)

Overview

The DS MSMB Ethernet sample application demonstrates multi-speed synchro/resolver operation across multiple NAI boards connected via Ethernet, using the NAI Software Support Kit (SSK 1.x). Unlike the DS_MultiSpd sample where coarse and fine channels reside on the same module, MSMB (Multi-Speed via Multi-Board) pairs a coarse channel on one board with a fine channel on a different board. The API handles the Ethernet communication and angle computation transparently — you configure the pair once, then write angles to both boards in a single API call.

This is useful in distributed systems where the coarse and fine synchro/resolver channels are physically located on different boards in different chassis or at different points in a platform. The API computes the appropriate coarse and fine angle values based on the configured speed ratio and writes them to their respective boards over Ethernet.

This sample supports all DS module types and requires Ethernet connections between the host and all target boards (see the DS1-DSN Manual for module specifications). It serves as a practical API reference for the naibrd_DS_SetMultiSpeedViaMultiBoard() API.

Prerequisites

Before running this sample, make sure you have:

  • Two or more NAI boards with DS modules installed, each connected to the host via Ethernet.

  • SSK 1.x installed on your development host.

  • The sample applications built. Refer to the SSK 1.x build instructions for your platform if you have not already compiled them.

  • The IP addresses of all target boards known and reachable from the development host.

How to Run

Launch the DS_MSMB_Ethernet executable from your build output directory. On startup the application looks for a configuration file (default_DS_MSMB.txt). On the first run, this file will not exist — the application will present an interactive board menu where you configure connections to all boards that will participate in the multi-speed pair. You must add each board as a separate connection in the board menu. You can save this configuration so that subsequent runs skip the menu and connect automatically. Once connected, the MSMB command menu lets you configure pairs and write angles to both boards.

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 DS. For details on board connection configuration, see the First Time Setup Guide.

Because this sample operates across multiple boards, you must establish connections to each board during the initial configuration. The board menu supports configuring multiple board connections — add one entry per board. After connecting, the sample queries for a card index and module to establish an initial context before entering the MSMB command loop.

#if defined (__VXWORKS__)
int32_t DS_MSMB_Ethernet(void)
#else
int32_t main(void)
#endif
{
   uint32_t cmdIdx = 0;
   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)
      {
         stop = naiapp_query_CardIndex(naiapp_GetBoardCnt(), 0, &cardIndex);
         if (stop != TRUE)
         {
            check_status(naibrd_GetModuleCount(cardIndex, &moduleCnt));
            stop = naiapp_query_ModuleNumber(moduleCnt, 1, &module);
            if (stop != TRUE)
            {
               moduleID = naibrd_GetModuleID(cardIndex, module);
               if ((moduleID != 0))
               {
                  /* Enter the MSMB command loop */
                  do
                  {
                     Show_MSMBMenuFunc_Commands();
                     /* dispatch user command */
                  } while (!gQuit);
               }
            }
         }
      }
   }
   return 0;
}
Important

Common connection errors you may encounter at this stage:

  • No board found — verify that all boards are powered on and connected via Ethernet. Each board must have its own connection entry in the board menu.

  • Connection timeout — confirm IP settings for each board. 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.

  • Second board unreachable — the MSMB feature requires Ethernet connectivity to both boards. Verify that each board’s IP address is correct and reachable from the host.

Program Structure

Entry Point

On standard platforms the entry point is main(). On VxWorks the entry point is DS_MSMB_Ethernet().

MSMB Pair Data Structure

The sample maintains an array of nai_DsMSVMB structures (up to MAX_MULTI_SPD_VIA_MULIT_BOARD_COUNT = 5 pairs), one per coarse/fine pair. Each structure stores all the information needed to identify and control a multi-speed pair across two boards:

typedef struct _naiDsMultiSpdViaMultiBd
{
   int32_t coarseCardidx;       /* Card index for the coarse channel board */
   int32_t coarseModuleNo;      /* Module slot on the coarse board */
   int32_t coarseChan;          /* Channel number on the coarse module */
   uint32_t coarseBoardAddress; /* Board address (Ethernet) */
   int32_t fineCardidx;         /* Card index for the fine channel board */
   int32_t fineModuleNo;        /* Module slot on the fine board */
   int32_t fineChan;            /* Channel number on the fine module */
   uint32_t fineBoardAddress;   /* Board address (Ethernet) */
   int32_t multiSpdRatio;       /* Speed ratio between coarse and fine */
   float64_t multiSpdAngle;     /* Desired two-speed angle */
} nai_DsMSVMB;

Your application will need to track the same values. The coarseCardidx and fineCardidx are card indices as returned by the board menu — they identify which of the connected boards holds the coarse and fine channels respectively.

Command Loop

Command Description

I

Select which MSMB pair index to work with (0 to 4)

P

Configure the pair properties (coarse/fine board, module, channel, ratio, angle)

A

Set a new angle for the current pair

W

Write the computed angle to both boards

E

Set power enable/disable for both channels of the pair

Q

Quit

The menu-driven structure is a convenience of the sample application. In your own application, you would call naibrd_DS_SetMultiSpeedViaMultiBoard() directly with the appropriate parameters.

Configuring an MSMB Pair

Select Pair Index

The sample supports up to 5 independent coarse/fine pairs (indices 0 through 4). To select which pair to configure, use the I command. In your own application, you pass the pair index directly to the API:

int32_t pairIndex = 0;  /* Use pair 0 */

Set Pair Properties

The MSMB_SetPairProperty() function prompts for all pair parameters: coarse card, module, and channel; fine card, module, and channel; the multi-speed ratio; and the initial angle. It then calls naibrd_DS_SetMultiSpeedViaMultiBoard() twice — once to configure the pair assignment, and once to set the ratio:

/* Step 1: Configure the coarse/fine pair assignment */
naibrd_DS_SetMultiSpeedViaMultiBoard(pairIndex,
   DsMultiSpdViaMultBoard[pairIndex].coarseCardidx,
   DsMultiSpdViaMultBoard[pairIndex].coarseModuleNo,
   DsMultiSpdViaMultBoard[pairIndex].coarseChan,
   DsMultiSpdViaMultBoard[pairIndex].fineCardidx,
   DsMultiSpdViaMultBoard[pairIndex].fineModuleNo,
   DsMultiSpdViaMultBoard[pairIndex].fineChan,
   NAI_DS_MSVMB_CONFIG,
   DsMultiSpdViaMultBoard[pairIndex].multiSpdAngle);

/* Step 2: Set the multi-speed ratio for the pair */
naibrd_DS_SetMultiSpeedViaMultiBoard(pairIndex,
   DsMultiSpdViaMultBoard[pairIndex].coarseCardidx,
   DsMultiSpdViaMultBoard[pairIndex].coarseModuleNo,
   DsMultiSpdViaMultBoard[pairIndex].coarseChan,
   DsMultiSpdViaMultBoard[pairIndex].fineCardidx,
   DsMultiSpdViaMultBoard[pairIndex].fineModuleNo,
   DsMultiSpdViaMultBoard[pairIndex].fineChan,
   NAI_DS_MSVMB_RATIO,
   DsMultiSpdViaMultBoard[pairIndex].multiSpdRatio);
  • pairIndex — identifies which MSMB pair (0 to 4).

  • NAI_DS_MSVMB_CONFIG — tells the API to store the coarse/fine channel assignments for this pair.

  • NAI_DS_MSVMB_RATIO — tells the API to store the multi-speed ratio for this pair.

Both calls must be made before writing an angle. The config call establishes which boards and channels belong to the pair, and the ratio call tells the API how to distribute the angle between coarse and fine.

Important

Common Errors

  • Invalid card index in pair config — The coarse and fine card indices must match boards that were configured in the board menu. If a card index does not correspond to a connected board, the write operation will fail.

  • Ratio not set before writing angle — The API uses the ratio to compute coarse/fine angles. Writing an angle without first setting the ratio produces incorrect results.

Writing Angles to Both Boards

Set Angle

To update the angle for a pair, use the A command (which calls askForTwoSpdAngle()). This updates the multiSpdAngle field in the pair structure but does not write to the boards yet.

Write Angle to Both Boards

To compute the coarse and fine angles and write them to both boards in a single coordinated operation, call naibrd_DS_SetMultiSpeedViaMultiBoard() with NAI_DS_MSVMB_ANGLE:

nai_status_t status = naibrd_DS_SetMultiSpeedViaMultiBoard(pairIndex,
   DsMultiSpdViaMultBoard[pairIndex].coarseCardidx,
   DsMultiSpdViaMultBoard[pairIndex].coarseModuleNo,
   DsMultiSpdViaMultBoard[pairIndex].coarseChan,
   DsMultiSpdViaMultBoard[pairIndex].fineCardidx,
   DsMultiSpdViaMultBoard[pairIndex].fineModuleNo,
   DsMultiSpdViaMultBoard[pairIndex].fineChan,
   NAI_DS_MSVMB_ANGLE,
   DsMultiSpdViaMultBoard[pairIndex].multiSpdAngle);

if (status == NAI_SUCCESS)
   printf("\nNew Angle written to Board Pair:%d", pairIndex);
else
   printf("\nFailed to write angle to Board Pair:%d", pairIndex);
  • NAI_DS_MSVMB_ANGLE — computes the appropriate coarse and fine angles based on the configured ratio and writes them to their respective boards over Ethernet.

  • The API returns NAI_SUCCESS if both boards were updated successfully.

This is the key MSMB operation. The API handles the angle math (splitting the requested angle into coarse and fine components) and the Ethernet communication (writing the coarse angle to the coarse board and the fine angle to the fine board).

Power Control

To enable or disable power on both channels of the pair, call naibrd_DS_SetPowerEnable() for each channel independently. The sample toggles both the coarse and fine channels together:

bool_t powerState = DS_CHANNEL_POWER_ON;  /* 1 = on, 0 = off */

/* Power on the coarse channel */
naibrd_DS_SetPowerEnable(
   DsMultiSpdViaMultBoard[pairIndex].coarseCardidx,
   DsMultiSpdViaMultBoard[pairIndex].coarseModuleNo,
   DsMultiSpdViaMultBoard[pairIndex].coarseChan,
   powerState);

/* Power on the fine channel */
naibrd_DS_SetPowerEnable(
   DsMultiSpdViaMultBoard[pairIndex].fineCardidx,
   DsMultiSpdViaMultBoard[pairIndex].fineModuleNo,
   DsMultiSpdViaMultBoard[pairIndex].fineChan,
   powerState);
  • Both channels must be powered on before the angle write will produce output signals.

  • DS_CHANNEL_POWER_ON is 1, DS_CHANNEL_POWER_OFF is 0.

Important

Common Errors

  • Write fails to one board — Verify that both boards are reachable over Ethernet and that the card indices in the pair configuration are correct.

  • Angle mismatch between boards — Ensure the ratio is configured (via NAI_DS_MSVMB_RATIO) before writing the angle. The API computes coarse/fine angles based on the configured ratio at the time of the angle write.

  • NAI_ERROR_NOT_SUPPORTED — The module does not support multi-speed via multi-board operation.

  • Power not enabled on both channels — Both the coarse and fine channels must be powered on independently. Powering only one channel will not produce a valid multi-speed output.

Troubleshooting Reference

Note
This section summarizes errors covered in the preceding sections. Consult the DS1-DSN Manual for hardware-specific diagnostics.
Error / Symptom Possible Causes Suggested Resolution

No board found or connection timeout

Board not powered or Ethernet not connected

Verify power and Ethernet connectivity for all boards. Check IP addresses in the configuration file.

Write to boards fails

Incorrect card index or module number in pair configuration

Verify pair properties match actual hardware setup. Card indices must correspond to boards configured in the board menu.

Angle not reflected on fine board

Ratio not configured before writing angle, or pair not configured with NAI_DS_MSVMB_CONFIG

Configure the pair first, set the ratio, then write the angle

Connection timeout to second board

IP misconfiguration or network issue

Verify IP addresses for both boards; check that both are on the same network or that routing is configured

NAI_ERROR_NOT_SUPPORTED

Module does not support multi-speed via multi-board

Verify that your DS module supports this feature

Only one channel producing output

Power not enabled on both coarse and fine channels

Call naibrd_DS_SetPowerEnable() for both the coarse and fine channels

Full Source

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

Full Source — DS_MSMB_Ethernet.c (SSK 1.x)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.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"
#include "nai_ar_utils.h"

/* naibrd include files */
#include "nai.h"
#include "naibrd.h"
#include "functions/naibrd_ds.h"
#include "naibrd_ether.h"
#include "advanced/nai_ether_adv.h"
#include "maps/nai_map_ds.h"
#include "DS_MSMB_Ethernet.h"

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

/* Function prototypes */
static void askForPairBoardIndex(int32_t *pairIndex);
static void askForCoarseCardNumber(int32_t pairIndex);
static void askForCoarseModuleNumber(int32_t pairIndex);
static void askForCoarseChannelNumber(int32_t pairIndex);
static void askForFineCardNumber(int32_t pairIndex);
static void askForFineModuleNumber(int32_t pairIndex);
static void askForFineChannelNumber(int32_t pairIndex);
static void askForTwoSpdRatio(int32_t pairIndex);
static void askForTwoSpdAngle(int32_t pairIndex);
static void Show_MSMBMenuFunc_Commands();
static void MSMB_SetPair();
static void MSMB_SetPairProperty();
static void MSMB_SetNewAngle();
static void MSMB_Write2Boards();
static void MSMB_PowerEnable();
static void MSMB_Quit();

static struct msmbDemofunc_cmdtbl MSMB_MenuCmds[] = {
   {"I", "Select MSMB Pair",           MSMB_FUNC_SET_BOARD_PAIR,           MSMB_SetPair},
   {"P", "Select MSMB Property",       MSMB_FUNC_SET_BOARD_PAIR_PROPERTY,  MSMB_SetPairProperty},
   {"A", "Set New Angle",              MSMB_FUNC_SET_ANGLE,                MSMB_SetNewAngle},
   {"W", "Write New Angle to boards",  MSMB_FUNC_WRITE_TO_BOARDS,          MSMB_Write2Boards},
   {"E", "Set D/S Power State",        MSMB_FUNC_POWER_ENABLE,             MSMB_PowerEnable},
   {"Q", "Quit",                       MSMB_FUNC_QUIT,                     MSMB_Quit},
};

static nai_DsMSVMB DsMultiSpdViaMultBoard[MAX_MULTI_SPD_VIA_MULIT_BOARD_COUNT];
int32_t msvmbPairIdx = DEFAULT_MSVMB_PAIR_INDEX;
bool_t gQuit = FALSE;

#define DS_CHANNEL_POWER_ON            1
#define DS_CHANNEL_POWER_OFF           0

#if defined (__VXWORKS__)
int32_t DS_MSMB_Ethernet(void)
#else
int32_t main(void)
#endif
{
   uint32_t cmdIdx=0;
   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))
               {
                  do
                  {
                     Show_MSMBMenuFunc_Commands();
                     naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
                     for(cmdIdx = 0; cmdIdx < MSMB_FUNC_LAST; cmdIdx++)
                     {
                        if( 0 == naiapp_strnicmp( (const int8_t*)inputBuffer, (const int8_t*)MSMB_MenuCmds[cmdIdx].cmdstr, inputResponseCnt) )
                           break;
                     }
                     switch( cmdIdx )
                     {
                        case MSMB_FUNC_SET_BOARD_PAIR:
                        case MSMB_FUNC_SET_BOARD_PAIR_PROPERTY:
                        case MSMB_FUNC_SET_ANGLE:
                        case MSMB_FUNC_WRITE_TO_BOARDS:
                        case MSMB_FUNC_POWER_ENABLE:
                        case MSMB_FUNC_QUIT:
                           MSMB_MenuCmds[cmdIdx].func();
                           break;
                        default:
                           printf("Invalid command entered");
                           break;
                     }
                  }while(!gQuit);
               }
            }
         }
      }
   }
   return 0;
}

static void askForPairBoardIndex(int32_t *pairIndex)
{
   bool_t bQuit = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   printf("\nPlease Enter Multi-Spd Via Multi-Board Pair Number: [default=%d]): ", DEFAULT_MSVMB_PAIR_INDEX);
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         *pairIndex = (uint16_t)atol((const char *)inputBuffer);
      }
      else
         *pairIndex = DEFAULT_MSVMB_PAIR_INDEX;
   }
}

static void askForCoarseCardNumber(int32_t pairIndex)
{
   bool_t bQuit = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   printf("\nPlease Enter Coarse Card Number for profile %d: [default=%d]): ",pairIndex,  DEFAULT_COARSE_CARD_NUMBER);
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         DsMultiSpdViaMultBoard[pairIndex].coarseCardidx = (uint16_t)atol((const char *)inputBuffer);
      }
      else
         DsMultiSpdViaMultBoard[pairIndex].coarseCardidx = DEFAULT_COARSE_CARD_NUMBER;
   }
}

static void askForCoarseModuleNumber(int32_t pairIndex)
{
   bool_t bQuit = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   printf("\nPlease Enter Coarse Module Number for profile %d: [default=%d]): ", pairIndex, DEFAULT_COARSE_MODULE_NUMBER);
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         DsMultiSpdViaMultBoard[pairIndex].coarseModuleNo = (uint16_t)atol((const char *)inputBuffer);
      }
      else
         DsMultiSpdViaMultBoard[pairIndex].coarseModuleNo = DEFAULT_COARSE_MODULE_NUMBER;
   }
}

static void askForCoarseChannelNumber(int32_t pairIndex)
{
   bool_t bQuit = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   printf("\nPlease Enter Coarse Channel Number for profile %d: [default=%d]): ", pairIndex, DEFAULT_COARSE_CHAN_NUMBER);
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         DsMultiSpdViaMultBoard[pairIndex].coarseChan = (uint16_t)atol((const char *)inputBuffer);
      }
      else
         DsMultiSpdViaMultBoard[pairIndex].coarseChan = DEFAULT_COARSE_CHAN_NUMBER;
   }
}

static void askForFineCardNumber(int32_t pairIndex)
{
   bool_t bQuit = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   printf("\nPlease Enter Fine Card Number for profile %d: [default=%d]): ",pairIndex,  DEFAULT_FINE_CARD_NUMBER);
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         DsMultiSpdViaMultBoard[pairIndex].fineCardidx = (uint16_t)atol((const char *)inputBuffer);
      }
      else
         DsMultiSpdViaMultBoard[pairIndex].fineCardidx = DEFAULT_FINE_CARD_NUMBER;
   }
}

static void askForFineModuleNumber(int32_t pairIndex)
{
   bool_t bQuit = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   printf("\nPlease Enter Fine Module Number for profile %d: [default=%d]): ", pairIndex, DEFAULT_FINE_MODULE_NUMBER);
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         DsMultiSpdViaMultBoard[pairIndex].fineModuleNo = (uint16_t)atol((const char *)inputBuffer);
      }
      else
         DsMultiSpdViaMultBoard[pairIndex].fineModuleNo = DEFAULT_FINE_MODULE_NUMBER;
   }
}

static void askForFineChannelNumber(int32_t pairIndex)
{
   bool_t bQuit = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   printf("\nPlease Enter Fine Channel Number for profile %d: [default=%d]): ", pairIndex,  DEFAULT_FINE_CHAN_NUMBER);
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         DsMultiSpdViaMultBoard[pairIndex].fineChan = (uint16_t)atol((const char *)inputBuffer);
      }
      else
         DsMultiSpdViaMultBoard[pairIndex].fineChan = DEFAULT_FINE_CHAN_NUMBER;
   }
}

static void askForTwoSpdRatio(int32_t pairIndex)
{
   bool_t bQuit = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   printf("\nPlease Enter Two Speed Ratio for profile %d: [default=%d]): ",pairIndex,  DEFAULT_TWO_SPEED_RATIO);
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         DsMultiSpdViaMultBoard[pairIndex].multiSpdRatio = atol((const char *)inputBuffer);
      }
      else
         DsMultiSpdViaMultBoard[pairIndex].multiSpdRatio = DEFAULT_TWO_SPEED_RATIO;
   }
}

static void askForTwoSpdAngle(int32_t pairIndex)
{
   bool_t bQuit = FALSE;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   printf("\nPlease Enter Two Speed Angle for profile %d [default=%d]): ", pairIndex, DEFAULT_TWO_SPEED_ANGLE);
   bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (!bQuit)
   {
      if (inputResponseCnt > 0)
      {
         DsMultiSpdViaMultBoard[pairIndex].multiSpdAngle = atof((const char *)inputBuffer);
      }
      else
         DsMultiSpdViaMultBoard[pairIndex].multiSpdAngle = DEFAULT_TWO_SPEED_ANGLE;
   }
}

static void Show_MSMBMenuFunc_Commands(void)
{
   int i;
   printf("\n\t\t MSMB User Menu.");
   printf("\n=======================================\n");
   printf("\n\nCommands");
   printf(  "\n--------");
   for (i=0; i < MSMB_FUNC_LAST && MSMB_MenuCmds[i].cmdstr != NULL; i++)
      printf ("\n%s\t%s", MSMB_MenuCmds[i].cmdstr, MSMB_MenuCmds[i].menustr);
   printf("\n");
}

static void MSMB_SetPair()
{
   askForPairBoardIndex(&msvmbPairIdx);
}

static void MSMB_SetPairProperty()
{
   printf("\nCurrent MSMB Pair: %d",msvmbPairIdx);
   askForCoarseCardNumber(msvmbPairIdx);
   askForCoarseModuleNumber(msvmbPairIdx);
   askForCoarseChannelNumber(msvmbPairIdx);
   askForFineCardNumber(msvmbPairIdx);
   askForFineModuleNumber(msvmbPairIdx);
   askForFineChannelNumber(msvmbPairIdx);
   askForTwoSpdRatio(msvmbPairIdx);
   askForTwoSpdAngle(msvmbPairIdx);

   /* Set the Card, Module and Channel information for Multi-Speed Configuration */
   naibrd_DS_SetMultiSpeedViaMultiBoard(  msvmbPairIdx,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].coarseCardidx,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].coarseModuleNo,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].coarseChan,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].fineCardidx,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].fineModuleNo,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].fineChan,
                                             NAI_DS_MSVMB_CONFIG,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].multiSpdAngle
                                             );
   /* Set the Ratio for Multi_Speed Configuration */
   naibrd_DS_SetMultiSpeedViaMultiBoard(  msvmbPairIdx,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].coarseCardidx,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].coarseModuleNo,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].coarseChan,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].fineCardidx,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].fineModuleNo,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].fineChan,
                                             NAI_DS_MSVMB_RATIO,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].multiSpdRatio
                                             );
}

static void MSMB_SetNewAngle()
{
   askForTwoSpdAngle(msvmbPairIdx);
}

static void MSMB_Write2Boards()
{
   nai_status_t success;

    /* Set the Angle for Multi_Speed Configuration */
   success = naibrd_DS_SetMultiSpeedViaMultiBoard(  msvmbPairIdx,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].coarseCardidx,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].coarseModuleNo,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].coarseChan,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].fineCardidx,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].fineModuleNo,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].fineChan,
                                             NAI_DS_MSVMB_ANGLE,
                                             DsMultiSpdViaMultBoard[msvmbPairIdx].multiSpdAngle
                                             );
      if(success == NAI_SUCCESS)
         printf("\nNew Angle:%f has been written to Board Pair:%d", DsMultiSpdViaMultBoard[msvmbPairIdx].multiSpdAngle, msvmbPairIdx);
      else
         printf("\nFailed to write New Angle:%f has been written to Board Pair:%d", DsMultiSpdViaMultBoard[msvmbPairIdx].multiSpdAngle, msvmbPairIdx);

}

static void MSMB_PowerEnable(void)
{
   bool_t bPowerEnable = DS_CHANNEL_POWER_OFF;
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   printf("\nPower setting 0(Off)/1(On) for pair index:%d (default: 0) : ", msvmbPairIdx);
   naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (inputResponseCnt == 0)
      bPowerEnable = DS_CHANNEL_POWER_OFF;
   else
   {
      if (inputBuffer[0] == '1')
         bPowerEnable = DS_CHANNEL_POWER_ON;
      else
         bPowerEnable = DS_CHANNEL_POWER_OFF;
   }

   naibrd_DS_SetPowerEnable( DsMultiSpdViaMultBoard[msvmbPairIdx].coarseCardidx,\
                             DsMultiSpdViaMultBoard[msvmbPairIdx].coarseModuleNo,\
                             DsMultiSpdViaMultBoard[msvmbPairIdx].coarseChan,\
                             bPowerEnable );
   naibrd_DS_SetPowerEnable( DsMultiSpdViaMultBoard[msvmbPairIdx].fineCardidx,\
                             DsMultiSpdViaMultBoard[msvmbPairIdx].fineModuleNo,\
                             DsMultiSpdViaMultBoard[msvmbPairIdx].fineChan,\
                             bPowerEnable );
}

static void MSMB_Quit(void)
{
   int8_t inputBuffer[80];
   int32_t inputResponseCnt;

   printf("\nPress \'Q\' to quit ");
   naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
   if (inputResponseCnt > 0)
   {
      if( inputBuffer[0] == 'q' || inputBuffer[0] == 'Q')
         gQuit = TRUE;
      else
         gQuit = FALSE;
   }
}

Help Bot

X