EtherZBlockCommands
Edit this on GitLab
EtherZBlockCommands Sample Application (SSK 1.x)
Overview
The EtherZBlockCommands sample application demonstrates how to use Ethernet Z-Block Commands on NAI boards using the NAI Software Support Kit (SSK 1.x). Z-Blocks extend the standard Block Commands by adding a per-register address flag that specifies whether each register should be accessed via the onboard path (local to the Ethernet-connected board) or via an offboard path (through the VME or PCI backplane to a different board in the chassis). This makes Z-Blocks essential in multi-board systems where a single grouped read or write needs to span registers across multiple boards.
With standard Block Commands, all registers in a block share the same interface type. Z-Blocks remove that limitation — within a single Z-Block, some registers can target the local board while others target remote boards, and the board’s Ethernet interface handles routing each access to the correct destination.
This is a board-level sample — it is not specific to any module type. It works with any NAI board that supports Generation 4 (or later) Ethernet commands.
Prerequisites
Before running this sample, make sure you have:
-
An NAI board connected via Ethernet that supports Gen4 Ethernet commands.
-
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.
-
For multi-board Z-Blocks: additional boards accessible via VME or PCI from the primary (Ethernet-connected) board.
How to Run
Launch the EtherZBlockCommands executable from your build output directory. On startup the application looks for a configuration file (default_Ether_ZBlock.txt). On the first run, this file will not exist — the application will present an interactive board menu where you configure a board connection and card index. You can save this configuration so that subsequent runs skip the menu and connect automatically. Once connected, a command menu lets you exercise each Z-Block operation.
Board Connection
|
Note
|
This startup sequence is common to all NAI sample applications. The board connection code shown here is not specific to any module type. For details on board connection configuration, see the First Time Setup Guide. |
The main() function follows the standard SSK 1.x startup flow. No module selection is needed because Z-Block commands operate at the board level.
-
Call
naiapp_RunBoardMenu()to load a saved configuration file (if one exists) or present the interactive board menu. The configuration file (default_Ether_ZBlock.txt) is not included with the SSK — it is created when you save your connection settings from the board menu. On the first run, the menu will always appear. -
Query the user for a card index with
naiapp_query_CardIndex(). -
Check Gen4 support with
SupportsGen4Ether()and enter the command loop.
#if defined (__VXWORKS__)
int32_t EtherZBlockCommands(void)
#else
int32_t main(void)
#endif
{
bool_t stop = FALSE;
int32_t cardIndex;
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)
{
Run_EtherZBlockCommands(cardIndex);
}
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;
}
|
Important
|
Common connection errors you may encounter at this stage:
|
Program Structure
Entry Point
On standard platforms the entry point is main(). On VxWorks the entry point is EtherZBlockCommands() — the SSK 1.x build system selects the correct variant via a preprocessor guard:
#if defined (__VXWORKS__)
int32_t EtherZBlockCommands(void)
#else
int32_t main(void)
#endif
The startup flow is the same in both cases:
-
Attempt to load the saved configuration file via
naiapp_RunBoardMenu(CONFIG_FILE). If the file does not yet exist, the interactive board menu is presented instead. -
Enter a loop that queries for card index.
-
Call
Run_EtherZBlockCommands()to enter the interactive command loop. -
On exit, close all open board connections with
naiapp_access_CloseAllOpenCards().
Application Parameters
The Run_EtherZBlockCommands() function populates an naiapp_AppParameters_t struct that is passed to every command handler. For Z-Block commands, only the card index is needed:
naiapp_AppParameters_t zblock_params;
p_naiapp_AppParameters_t p_eth_zblock_params = &zblock_params;
p_eth_zblock_params->cardIndex = cardIndex;
g_bGen4ZBlockCommands = SupportsGen4Ether(cardIndex);
The sample also maintains a global array g_zblockRegCnt[] that tracks the register count for each Z-Block ID. This count is updated when a Z-Block is configured (Set) or retrieved (Get), and is used by the Write command to know how many data values to send.
Command Loop
Run_EtherZBlockCommands() drives the interactive command loop. On each iteration it displays the command menu and dispatches the user’s selection to the matching handler function:
| Command | Description |
|---|---|
Set |
Define a Z-Block configuration (register addresses with per-register onboard/offboard flags) |
Get |
Retrieve the register addresses and flags for a Z-Block ID |
Clear |
Remove a Z-Block configuration |
Read |
Read the current values of all registers in a Z-Block |
Write |
Write data to all registers in a Z-Block |
The menu-driven structure is a convenience of the sample application. In your own application, you would call the same underlying naibrd_Ether_*ZBlock() API functions directly.
Z-Block Configuration
This section covers defining, retrieving, and clearing Z-Block configurations. A Z-Block is similar to a standard Block, but each register in the Z-Block carries an address flag that tells the board whether to access the register via the onboard or offboard path.
Set Z-Block Configuration
To define a Z-Block in your own application, call naibrd_Ether_SetZBlock() with arrays of register addresses and corresponding address flags:
uint16_t addrflag[MAX_ETHER_BLOCK_REG_CNT];
uint32_t address[MAX_ETHER_BLOCK_REG_CNT];
uint32_t regCount;
/* Populate address[] and addrflag[] */
InitZBlockRegisters(®Count, addrflag, address);
nai_status_t status = naibrd_Ether_SetZBlock(cardIndex, (uint16_t)blockid,
(uint32_t)regwidth, regCount, addrflag, address);
-
blockid— a numeric ID (1 toMAX_ETHER_BLOCK_ID) that identifies this Z-Block. -
regwidth— register width in bytes. The sample usesDEF_REGISTER_SIZE(4 for 32-bit registers). -
regCount— the number of registers in the Z-Block. -
addrflag[]— per-register flag:ETHER_GEN4_ONBOARD(0) for onboard registers,ETHER_GEN4_OFFBOARD(1) for offboard registers accessible through the VME or PCI backplane. -
address[]— register addresses. For offboard registers, the address must include the remote board’s base address.
The sample’s InitZBlockRegisters() function demonstrates the multi-board pattern. It iterates over all connected boards and adds scratchpad registers from each:
for (boardindex = 0; boardindex < naiapp_GetBoardCnt(); boardindex++)
{
if (boardindex == 0)
{
inf = ETHER_GEN4_ONBOARD; /* Local board */
baseaddr = 0;
}
else
{
inf = ETHER_GEN4_OFFBOARD; /* Remote board via VME/PCI */
if (g_NAISysCfgAccess[boardindex].comm == NAIBRD_COMM_VME)
baseaddr = g_NAISysCfgAccess[boardindex].vmeCfg.boardAddress;
else if (g_NAISysCfgAccess[boardindex].comm == NAIBRD_COMM_PCI)
baseaddr = g_NAISysCfgAccess[boardindex].pciCfg.boardAddress;
else
baseaddr = 0;
}
/* Add scratchpad registers from this board */
address[index++] = baseaddr + MB_SCRATCHPAD_START_ADDRESS + 0x0000;
addrflag[flgindex++] = inf;
address[index++] = baseaddr + MB_SCRATCHPAD_START_ADDRESS + 0x0010;
addrflag[flgindex++] = inf;
/* ... additional registers ... */
}
The first board (index 0) is always onboard — its registers are accessed directly. Additional boards are offboard — their register addresses are calculated as baseaddr + registerOffset, where baseaddr is the remote board’s VME or PCI base address from the system configuration. The sample uses the motherboard scratchpad area (0x00003800 - 0x00003BFF) for testing, but in your own application you would use whatever register addresses you need to access.
Get Z-Block Configuration
To retrieve the register addresses and address flags currently assigned to a Z-Block, call naibrd_Ether_GetZBlock():
uint32_t arraysize = MAX_ETHER_BLOCK_REG_CNT;
uint16_t addrflag[MAX_ETHER_BLOCK_REG_CNT];
uint32_t address[MAX_ETHER_BLOCK_REG_CNT];
nai_status_t status = naibrd_Ether_GetZBlock(cardIndex, (uint16_t)blockid,
arraysize, addrflag, address, &g_zblockRegCnt[blockid-1]);
-
arraysize— the size of theaddrflag[]andaddress[]buffers. -
addrflag[]— on return, the per-register onboard/offboard flags. -
address[]— on return, the register addresses. -
g_zblockRegCnt[blockid-1]— on return, the number of registers in the Z-Block.
The sample displays each register’s address along with its onboard/offboard designation.
Clear Z-Block Configuration
To remove a Z-Block configuration from the board and free the Z-Block ID for reuse, call naibrd_Ether_ClearZBlock():
nai_status_t status = naibrd_Ether_ClearZBlock(cardIndex, (uint16_t)blockid);
|
Important
|
Common Errors
|
Z-Block Read and Write
Once a Z-Block is configured, you can read all of its registers or write data to all of them in a single transaction. The board’s Ethernet interface handles routing each register access to the correct board (onboard or offboard) based on the address flags configured in the Z-Block.
Read Z-Block Registers
To read the current values of all registers in a Z-Block in your own application, call naibrd_Ether_ReadZBlock():
uint32_t arraysize = MAX_ETHER_BLOCK_REG_CNT;
uint32_t data[MAX_ETHER_BLOCK_REG_CNT];
uint32_t datacount = 0;
nai_status_t status = naibrd_Ether_ReadZBlock(cardIndex, (uint16_t)blockid,
(uint32_t)regwidth, arraysize, data, &datacount);
-
regwidth— register width in bytes (4 for 32-bit). -
arraysize— the size of thedata[]buffer. -
data[]— on return, contains the values read from each register in the Z-Block, in the same order as the addresses were configured. -
datacount— on return, the number of values actually read.
The board reads each register in the Z-Block, routing onboard accesses locally and offboard accesses through the VME/PCI backplane, and returns all values in a single response.
Write Z-Block Registers
To write data to all registers in a Z-Block in your own application, call naibrd_Ether_WriteZBlock():
uint32_t data[MAX_ETHER_BLOCK_REG_CNT];
/* Populate data[] with values to write */
InitZBlockRegistersData(g_zblockRegCnt[blockid-1], &data[0]);
nai_status_t status = naibrd_Ether_WriteZBlock(cardIndex, (uint16_t)blockid,
(uint32_t)regwidth, g_zblockRegCnt[blockid-1], data);
-
data[]— an array of values to write. The order must match the order of addresses in the Z-Block configuration. -
The count must match the number of registers configured in the Z-Block.
The sample’s InitZBlockRegistersData() function fills the data array with incrementing test values using a global counter (g_writeDataCnt), so each write produces different values. This makes it easy to verify that writes and reads are working correctly by comparing the data across successive operations.
|
Important
|
Common Errors
|
Troubleshooting Reference
This table summarizes common errors and symptoms covered in the sections above. For detailed context on each entry, refer to the relevant section.
| Error / Symptom | Possible Causes | Suggested Resolution |
|---|---|---|
No board found or connection timeout |
Board not powered, incorrect or missing configuration file, network issue |
Verify hardware is powered and connected via Ethernet. If |
Gen4 not supported |
Board uses pre-Generation 4 Ethernet protocol |
Z-Block commands require Gen4 or later. Verify your board’s firmware version. |
Z-Block read returns no data |
Z-Block ID not configured |
Call |
Offboard registers return errors or unexpected values |
Remote board not accessible via VME/PCI, incorrect base address |
Verify backplane connectivity. Confirm the remote board’s base address matches the system configuration. |
Invalid Z-Block ID error |
Z-Block ID outside valid range (1 to |
Use a Z-Block ID between 1 and 16. |
Write fails or produces unexpected values |
Data count does not match Z-Block register count, or offboard board not responding |
Ensure the data array length matches the Z-Block’s register count. Check backplane connectivity for offboard registers. |
"Ethernet Z-Block Command Support Prior to Generation 4 Ethernet commands currently not supported" |
Board does not support Gen4 Ethernet |
Use a board with Gen4+ Ethernet support. |
Only onboard registers work, offboard registers fail |
Multi-board system not configured, or only one board connected |
Verify that additional boards are configured in the system and accessible via VME/PCI from the Ethernet-connected board. |
Full Source
The complete source for this sample is provided below for reference. The sections above explain each part in detail.
Full Source — EtherZBlockCommands.c (SSK 1.x)
#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 "naibrd_ether.h"
#include "advanced/nai_ether_adv.h"
#include "boards/naibrd_gen5.h"
/* Extern Functions or Variables*/
extern NAIAPPFUNC naiapp_syscfg_access_t g_NAISysCfgAccess[NAI_MAX_CARDS];
static const int8_t *CONFIG_FILE = (const int8_t *)"default_Ether_ZBlock.txt";
/* Function prototypes */
static bool_t Run_EtherZBlockCommands(int32_t cardIndex);
static bool_t QueryEthZBlockID(int32_t* p_outblockid);
static void InitZBlockRegisters(uint32_t* p_outcount, uint16_t addrflag[], uint32_t address[]);
static void InitZBlockRegistersData(uint32_t count, uint32_t data[]);
static nai_status_t SetEthZBlockConfig(int32_t paramCount, int32_t* p_params);
static nai_status_t GetEthZBlockConfig(int32_t paramCount, int32_t* p_params);
static nai_status_t ClearEthZBlockConfig(int32_t paramCount, int32_t* p_params);
static nai_status_t ReadEthZBlockRegisters(int32_t paramCount, int32_t* p_params);
static nai_status_t WriteEthZBlockRegisters(int32_t paramCount, int32_t* p_params);
/****** Command Table *******/
enum eth_zblock_commands
{
ETH_ZBLOCK_CMD_SET,
ETH_ZBLOCK_CMD_GET,
ETH_ZBLOCK_CMD_CLEAR,
ETH_ZBLOCK_CMD_READ,
ETH_ZBLOCK_CMD_WRITE,
ETH_ZBLOCK_CMD_COUNT
};
naiapp_cmdtbl_params_t ETH_ZBlockcmdMenuCmds[] = {
{"Set", "Set Z-Block Configuration", ETH_ZBLOCK_CMD_SET, SetEthZBlockConfig},
{"Get", "Get Z-Block Configuration", ETH_ZBLOCK_CMD_GET, GetEthZBlockConfig},
{"Clear", "Clear Z-Block Configuration", ETH_ZBLOCK_CMD_CLEAR, ClearEthZBlockConfig},
{"Read", "Read Z-Block Registers", ETH_ZBLOCK_CMD_READ, ReadEthZBlockRegisters},
{"Write", "Write to Z-Block Registers", ETH_ZBLOCK_CMD_WRITE, WriteEthZBlockRegisters},
};
#define MB_SCRATCHPAD_START_ADDRESS 0x00003800
#define DEF_REGISTER_SIZE 4
static bool_t g_bGen4ZBlockCommands = FALSE;
static uint32_t g_zblockRegCnt[MAX_ETHER_BLOCK_ID] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
static int32_t g_writeDataCnt = 0;
/**************************************************************************************************************/
#if defined (__VXWORKS__)
int32_t EtherZBlockCommands(void)
#else
int32_t main(void)
#endif
{
bool_t stop = FALSE;
int32_t cardIndex;
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)
{
Run_EtherZBlockCommands(cardIndex);
}
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;
}
/**************************************************************************************************************/
static bool_t Run_EtherZBlockCommands(int32_t cardIndex)
{
bool_t bQuit = FALSE;
bool_t bContinue = TRUE;
bool_t bCmdFound = FALSE;
int32_t cmd;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
naiapp_AppParameters_t zblock_params;
p_naiapp_AppParameters_t p_eth_zblock_params = &zblock_params;
p_eth_zblock_params->cardIndex = cardIndex;
g_bGen4ZBlockCommands = SupportsGen4Ether(cardIndex);
while (bContinue)
{
naiapp_utils_LoadParamMenuCommands(ETH_ZBLOCK_CMD_COUNT, ETH_ZBlockcmdMenuCmds);
naiapp_display_ParamMenuCommands((int8_t *)"Ethernet Z-Block Command Menu");
printf("\nType Ethernet Z-Block 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 ETH_ZBLOCK_CMD_SET:
case ETH_ZBLOCK_CMD_GET:
case ETH_ZBLOCK_CMD_CLEAR:
case ETH_ZBLOCK_CMD_READ:
case ETH_ZBLOCK_CMD_WRITE:
ETH_ZBlockcmdMenuCmds[cmd].func(APP_PARAM_COUNT, (int32_t*)p_eth_zblock_params);
break;
default:
printf("Invalid command entered\n");
break;
}
}
else
printf("Invalid command entered\n");
}
}
else
bContinue = FALSE;
}
return bQuit;
}
/**************************************************************************************************************/
static bool_t QueryEthZBlockID(int32_t* p_outblockid)
{
bool_t bQuit = FALSE;
int32_t valueread = 0;
int8_t inputBuffer[80];
int32_t inputResponseCnt;
printf("Enter the Z-Block ID: (default: 1) > ");
bQuit = naiapp_query_ForQuitResponse(sizeof(inputBuffer), NAI_QUIT_CHAR, inputBuffer, &inputResponseCnt);
if (!bQuit)
{
if (inputResponseCnt == 0)
valueread = 1;
else
{
valueread = atol((const char *)inputBuffer);
if ((valueread < 0) || (valueread > MAX_ETHER_BLOCK_ID))
{
printf("Error: Z-BlockID is invalid\n");
bQuit = TRUE;
}
}
*p_outblockid = valueread;
}
return bQuit;
}
/**************************************************************************************************************/
static void InitZBlockRegisters(uint32_t* p_outcount, uint16_t addrflag[], uint32_t address[])
{
int32_t index = 0;
int32_t flgindex = 0;
int32_t boardindex;
uint16_t inf;
uint32_t baseaddr;
if (g_bGen4ZBlockCommands)
{
for (boardindex = 0; boardindex < naiapp_GetBoardCnt(); boardindex++)
{
if (boardindex == 0)
{
inf = ETHER_GEN4_ONBOARD;
baseaddr = 0;
}
else
{
inf = ETHER_GEN4_OFFBOARD;
if (g_NAISysCfgAccess[boardindex].comm == NAIBRD_COMM_VME)
baseaddr = g_NAISysCfgAccess[boardindex].vmeCfg.boardAddress;
else if (g_NAISysCfgAccess[boardindex].comm == NAIBRD_COMM_PCI)
baseaddr = g_NAISysCfgAccess[boardindex].pciCfg.boardAddress;
else
baseaddr = 0;
}
address[index++] = baseaddr + MB_SCRATCHPAD_START_ADDRESS + 0x0000;
addrflag[flgindex++] = inf;
address[index++] = baseaddr + MB_SCRATCHPAD_START_ADDRESS + 0x0010;
addrflag[flgindex++] = inf;
address[index++] = baseaddr + MB_SCRATCHPAD_START_ADDRESS + 0x0050;
addrflag[flgindex++] = inf;
address[index++] = baseaddr + MB_SCRATCHPAD_START_ADDRESS + 0x0100;
addrflag[flgindex++] = inf;
address[index++] = baseaddr + MB_SCRATCHPAD_START_ADDRESS + 0x0110;
addrflag[flgindex++] = inf;
}
*p_outcount = index;
}
else
{
printf("Ethernet Z-Block Command Support Prior to Generation 4 Ethernet commands currently not supported\n");
}
}
/**************************************************************************************************************/
static void InitZBlockRegistersData(uint32_t count, uint32_t data[])
{
uint32_t index = 0;
for (index = 0; index < count; index++)
{
if (g_bGen4ZBlockCommands)
{
data[index] = g_writeDataCnt++;
}
}
}
/**************************************************************************************************************/
static nai_status_t SetEthZBlockConfig(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_status_t status;
uint16_t addrflag[MAX_ETHER_BLOCK_REG_CNT];
uint32_t address[MAX_ETHER_BLOCK_REG_CNT];
p_naiapp_AppParameters_t p_ether_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ether_params->cardIndex;
int32_t blockid = 0;
int32_t regwidth = DEF_REGISTER_SIZE;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
bQuit = QueryEthZBlockID(&blockid);
if (!bQuit)
{
InitZBlockRegisters(&g_zblockRegCnt[blockid-1], &addrflag[0], &address[0]);
status = check_status(naibrd_Ether_SetZBlock(cardIndex, (uint16_t)blockid, (uint32_t)regwidth, g_zblockRegCnt[blockid-1], addrflag, address));
if (status == NAI_SUCCESS)
{
printf("Block ID = %d configured.\n", blockid);
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
/**************************************************************************************************************/
static nai_status_t GetEthZBlockConfig(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_status_t status;
uint32_t arraysize = MAX_ETHER_BLOCK_REG_CNT;
uint16_t addrflag[MAX_ETHER_BLOCK_REG_CNT];
uint32_t address[MAX_ETHER_BLOCK_REG_CNT];
int32_t i;
p_naiapp_AppParameters_t p_ether_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ether_params->cardIndex;
int32_t blockid = 0;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
bQuit = QueryEthZBlockID(&blockid);
if (!bQuit)
{
status = check_status(naibrd_Ether_GetZBlock(cardIndex, (uint16_t)blockid, arraysize, addrflag, address, &g_zblockRegCnt[blockid-1]));
if (status == NAI_SUCCESS)
{
if (g_zblockRegCnt[blockid-1] > 0)
{
printf("\n\nBlock ID = %d - %d Registers with Addresses:\n", blockid, g_zblockRegCnt[blockid-1]);
for (i = 0; i < (int32_t)g_zblockRegCnt[blockid-1]; i++)
{
printf("%3d: 0x%08X", i+1, address[i]);
if (addrflag[i] == 0)
printf(" Onboard\n");
else
printf(" Offboard\n");
}
}
else
printf("\n\nNo Registers configured for Block ID = %d\n", blockid);
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
/**************************************************************************************************************/
static nai_status_t ClearEthZBlockConfig(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_status_t status;
p_naiapp_AppParameters_t p_ether_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ether_params->cardIndex;
int32_t blockid = 0;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
bQuit = QueryEthZBlockID(&blockid);
if (!bQuit)
{
status = check_status(naibrd_Ether_ClearZBlock(cardIndex, (uint16_t)blockid));
if (status == NAI_SUCCESS)
{
printf("Block ID = %d cleared\n", blockid);
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
/**************************************************************************************************************/
static nai_status_t ReadEthZBlockRegisters(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_status_t status;
uint32_t arraysize = MAX_ETHER_BLOCK_REG_CNT;
uint32_t data[MAX_ETHER_BLOCK_REG_CNT];
uint32_t datacount = 0;
int32_t i;
p_naiapp_AppParameters_t p_ether_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ether_params->cardIndex;
int32_t blockid = 0;
int32_t regwidth = DEF_REGISTER_SIZE;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
bQuit = QueryEthZBlockID(&blockid);
if (!bQuit)
{
status = check_status(naibrd_Ether_ReadZBlock(cardIndex, (uint16_t)blockid, (uint32_t)regwidth, arraysize, data, &datacount));
if (status == NAI_SUCCESS)
{
if (datacount > 0)
{
printf("\n\nBlock ID = %d - %d Register Values:\n", blockid, datacount);
for (i = 0; i < (int32_t)datacount; i++)
{
printf("%3d: 0x%08X\n", i+1, data[i]);
}
}
else
printf("\n\nNo Registers read for Block ID = %d\n", blockid);
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}
/**************************************************************************************************************/
static nai_status_t WriteEthZBlockRegisters(int32_t paramCount, int32_t* p_params)
{
bool_t bQuit = FALSE;
nai_status_t status;
uint32_t data[MAX_ETHER_BLOCK_REG_CNT];
p_naiapp_AppParameters_t p_ether_params = (p_naiapp_AppParameters_t)p_params;
int32_t cardIndex = p_ether_params->cardIndex;
int32_t blockid = 0;
int32_t regwidth = DEF_REGISTER_SIZE;
#if defined (WIN32)
UNREFERENCED_PARAMETER(paramCount);
#endif
bQuit = QueryEthZBlockID(&blockid);
if (!bQuit)
{
InitZBlockRegistersData(g_zblockRegCnt[blockid-1], &data[0]);
status = check_status(naibrd_Ether_WriteZBlock(cardIndex, (uint16_t)blockid, (uint32_t)regwidth, g_zblockRegCnt[blockid-1], data));
if (status == NAI_SUCCESS)
{
printf("Block ID = %d Data written.\n", blockid);
}
}
return (bQuit) ? NAI_ERROR_UNKNOWN : NAI_SUCCESS;
}