Board Access
Edit this on GitLab
Board Access Sample Application (SSK 2.x)
Overview
The Board Access sample application demonstrates the most fundamental operation in the NAI Software Support Kit (SSK 2.x): connecting to a board through the interactive board menu. Unlike module-specific sample applications, this program does not exercise any particular function module. Instead, it focuses exclusively on the board connection workflow — loading or creating a configuration file, selecting an interface type (Ethernet, PCI/PCIe, etc.), and establishing a connection to the hardware.
This sample is useful as a first connectivity test after installing the SSK or setting up a new board. It verifies that your host can reach the NAI hardware and that the board configuration file is valid. Because it contains no module-specific code, it also serves as a minimal starting template for new applications.
There is no SSK 1.x counterpart for this sample.
Prerequisites
-
An NAI board powered on and connected to the development host (Ethernet, PCI/PCIe, or other supported interface).
-
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 board_access executable from your build output directory. On startup the application looks for a configuration file (default_BoardAccess.txt). On the first run, this file will not exist — the application will present the interactive board menu where you configure a board connection. You can save this configuration so that subsequent runs connect automatically. Once connected, the application simply prompts you to quit or restart the board menu.
Board Connection
|
Note
|
This application demonstrates only the board connection step. There is no module selection or command loop. |
The main() function implements a minimal connection loop:
-
Call
naiapp_RunBoardMenu()to load a saved configuration file or present the interactive board menu. The configuration file (default_BoardAccess.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. -
If the board menu returns
NAI_FALSE(the user quit without connecting), exit the loop. -
Otherwise, prompt the user to quit or restart the board menu.
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t BoardAccess(void)
#else
int32_t main(void)
#endif
{
bool_t stop = NAI_FALSE;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
while (stop != NAI_TRUE)
{
if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == (bool_t)NAI_FALSE)
{
stop = NAI_TRUE;
}
else
{
naiif_printf("\r\nType Q to quit or Enter to restart menu 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: ");
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__). -
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, Windows) the entry point is main(). On VxWorks the entry point is BoardAccess() — the SSK 2.x build system selects the correct variant via a preprocessor guard:
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t BoardAccess(void)
#else
int32_t main(void)
#endif
Application Flow
This sample has no command table or command loop. The entire application flow is:
-
Enter a
whileloop that callsnaiapp_RunBoardMenu()on each iteration. -
If the board menu succeeds, prompt the user to quit or restart.
-
If the board menu fails (user quit), exit the loop.
-
Print a final exit prompt and return.
Board Menu Operation
The core of this sample is the call to naiapp_RunBoardMenu(), which encapsulates the entire board connection workflow:
static const int8_t *DEF_CONFIG_FILE = (const int8_t *)"default_BoardAccess.txt";
/* ... */
if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == (bool_t)NAI_FALSE)
{
stop = NAI_TRUE;
}
The naiapp_RunBoardMenu() function performs these steps internally:
-
Load configuration — Attempts to read the file specified by
DEF_CONFIG_FILE. If the file exists and contains valid settings, the board connection is established automatically. -
Interactive menu — If the file does not exist or is invalid, the user is presented with an interactive menu to select the interface type, enter the board address, and configure connection parameters.
-
Save configuration — After a successful connection, the user can save the settings to the configuration file so that future runs skip the interactive menu.
The function returns NAI_TRUE if a connection was established, or NAI_FALSE if the user chose to quit.
Troubleshooting Reference
| Error / Symptom | Possible Causes | Suggested Resolution |
|---|---|---|
Board menu returns NAI_FALSE |
User selected quit from the menu without connecting. |
Re-run the application and complete the connection setup. |
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 menu. |
Connection timeout |
Incorrect IP address, firewall blocking communication, or network misconfiguration. |
Confirm the board IP address. Disable or configure firewall rules. Verify the host and board are on the same subnet. |
Configuration file not loading |
File does not exist on first run, or file has been corrupted. |
This is expected on the first run. Complete the interactive menu and save settings. If the file is corrupted, delete it and re-run. |
Program exits immediately |
The configuration file contains invalid or stale settings. |
Delete |
Permission denied on configuration file |
Insufficient filesystem permissions in the build output directory. |
Ensure the application has write permission to the directory where it runs. |
Full Source
The complete source for this sample is provided below for reference. The sections above explain each part in detail.
Full Source — board_access.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"
/* naiif include files */
#include "nai_libs/naiif/include/naiif.h"
#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 *DEF_CONFIG_FILE = (const int8_t *)"default_BoardAccess.txt";
#if defined (NAIBSP_CONFIG_SOFTWARE_OS_VXWORKS)
int32_t BoardAccess(void)
#else
int32_t main(void)
#endif
{
bool_t stop = NAI_FALSE;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
/* The naiapp_access_RunBoardMenu() is the generic menu program used by
* all the sample programs in the naibrd SSK.
* The menu program handles the queries and access for all the
* NAI boards in the specified system.
*/
while (stop != NAI_TRUE)
{
if (naiapp_RunBoardMenu(DEF_CONFIG_FILE) == (bool_t)NAI_FALSE)
{
stop = NAI_TRUE;
}
else
{
naiif_printf("\r\nType Q to quit or Enter to restart menu 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: ");
return 0;
}