Applies to: All NAI boards — SSK 1.x and 2.x (the status codes are identical across both)


NAI Status, BIT & Error Codes

Nearly every naibrd_* function returns an NAI_STATUS value. NAI_SUCCESS (0) means the call worked; any negative value is an error. This page explains the codes you’re most likely to see, how to handle them, and gives a complete reference. It also covers a separate but easily-confused topic — the channel & BIT status bits you read back from the hardware (see Channel and BIT status below).

Note

The status codes are defined identically in SSK 1.x (nai.h) and SSK 2.x (naibsp_sys_defs.h) — the same names and the same values. Everything on this page applies to both.

The basic pattern

Check the return of every call against NAI_SUCCESS and stop on the first failure — continuing after an error usually just produces more errors that hide the real one:

NAI_STATUS status;
 
status = naibrd_OpenDevice(cardIndex, /* ... */);
if (status != NAI_SUCCESS)
{
    printf("naibrd_OpenDevice failed with status %d\n", status);
    return status;   /* bail out — later calls will fail too */
}
 
status = naibrd_AD_SetChannelData(cardIndex, module, channel, value);
if (status != NAI_SUCCESS)
{
    printf("SetChannelData failed with status %d\n", status);
    /* clean up (e.g. naibrd_Close) before returning */
    return status;
}

The sample applications follow this same if (status != NAI_SUCCESS) pattern throughout — they’re a good place to see it in context.

Looking up a specific code

The names in the reference below describe the general condition each code represents. What a specific code indicates for a particular function — and which codes a given function can return — is documented per function in the SSK API reference (Doxygen): each function’s page lists its possible return values. For the parameters and valid ranges a function accepts, see that function’s entry there and the relevant module’s manual.

Complete reference

All general status codes
ValueCodeMeaning
0NAI_SUCCESSOperation succeeded.
-1NAI_ERROR_INVALID_VALUEA parameter was outside its allowed range.
-2NAI_ERROR_INVALID_MODEThe requested mode is not valid for this operation.
-3NAI_ERROR_INVALID_SIZEA size argument is invalid.
-4NAI_ERROR_INVALID_TYPECODEThe type code is not recognized.
-5NAI_ERROR_INVALID_ADDRESSThe address is invalid.
-6NAI_ERROR_INVALID_ADDRBOUNDThe address is outside the allowed bounds.
-7NAI_ERROR_INVALID_COMMANDThe command is not valid.
-8NAI_ERROR_NOT_FOUNDThe requested item was not found.
-9NAI_ERROR_TIMEOUTThe operation timed out.
-10NAI_ERROR_COMM_ERRORA communication error occurred.
-11NAI_ERROR_LOCK_FAILEDFailed to acquire a lock.
-12NAI_ERROR_INVALID_WIDTHThe data width is invalid.
-13NAI_ERROR_INVALID_CARDThe card/board index is invalid.
-14NAI_ERROR_INVALID_MODULEThe module/slot number is invalid.
-15NAI_ERROR_INVALID_CHANNELThe channel number is invalid.
-16NAI_ERROR_OPEN_FAILEDThe device could not be opened.
-17NAI_ERROR_INVALID_MESSAGEThe message is invalid.
-18NAI_ERROR_MESSAGE_MISMATCHThe message did not match what was expected.
-19NAI_ERROR_OVERFLOWAn overflow occurred.
-20NAI_ERROR_NOT_MASTERThe operation requires the master, but this device is not the master.
-21NAI_ERROR_DISCONNECTEDThe device is disconnected.
-22NAI_ERROR_IN_USEThe resource is already in use.
-23NAI_ERROR_FULLThe buffer/queue is full.
-24NAI_ERROR_EMPTYThe buffer/queue is empty.
-25NAI_ERROR_NOT_READYThe device or function is not ready.
-26NAI_ERROR_CONNECTION_LOSTThe connection was lost.
-27NAI_ERROR_NOT_OPENThe handle is not open.
-28NAI_ERROR_PARITYA parity error occurred (serial).
-29NAI_ERROR_FRAMINGA framing error occurred (serial).
-30NAI_ERROR_FRAMING_PARITYA combined framing and parity error occurred (serial).
-31NAI_ERROR_NO_MESSAGENo message was available.
-32NAI_ERROR_WATCHDOGA watchdog condition occurred.
-33NAI_ERROR_BUS_TIMEOUTA bus access timed out.
-34NAI_ERROR_INVALID_RANGEThe range is invalid.
-35NAI_ERROR_WRONG_DEVICEThe operation was directed at the wrong device.
-36NAI_ERROR_BUS_READ_ERRA bus read error occurred.
-37NAI_ERROR_BUS_WRITE_ERRA bus write error occurred.
-38NAI_ERROR_MORE_DATAMore data is available than was returned.
-39NAI_ERROR_INVALID_ENCODER_RESThe encoder resolution is invalid.
-40NAI_ERROR_INVALID_COMMUTATION_POLESThe number of commutation poles is invalid.
-41NAI_ERROR_INVALID_RATIOThe ratio is invalid.
-42NAI_ERROR_INVALID_IO_PARAMAn I/O parameter is invalid.
-43NAI_ERROR_BIT_FAILEDA Built-In Test failed.
-44NAI_ERROR_VME_ADDR_TRANSLATIONA VME address translation error occurred.
-45NAI_ERROR_BSP_VME_TABLEA BSP VME table error occurred.
-46NAI_ERROR_INT_CONNECT_FAILEDFailed to connect an interrupt.
-47NAI_ERROR_INT_DISCONNECT_FAILEDFailed to disconnect an interrupt.
-48NAI_ERROR_1553_MESSAGE_ERRORA MIL-STD-1553 message error occurred.
-49NAI_ERROR_1553_DATA_WRAPAROUND_ERRORA MIL-STD-1553 data wraparound error occurred.
-50NAI_ERROR_PERMISSION_DENIEDPermission was denied for the operation.
-51NAI_ERROR_UNLOCK_FAILEDFailed to release a lock.
-52NAI_ERROR_PROTOCOL_FUNCTION_MISMATCHThe protocol and function do not match.
-53NAI_ERROR_FUNCTION_SPECIFIC_ERRORA function-specific error occurred (see the function’s own documentation).
-100NAI_ERROR_NOT_SUPPORTEDThe operation is not supported by this module/board.
-1000NAI_ERROR_UNKNOWNAn unknown error occurred.
-1001NAI_ERROR_UNKNOWN_VALUEAn unknown value was encountered.
Gen4 Ethernet protocol error codes (-0x8000 and below)

Boards using the Gen4 Ethernet protocol can also return a block of protocol-level error codes starting at -0x8000 (NAI_ERROR_ETHER_GENERAL_GEN4). These are low-level messaging errors — invalid preamble/postamble, sequence number, payload size, EEPROM read/write failures, etc. — that most application code will not encounter directly during normal register read/write operations.

If you receive a code at or below -0x8000, it points to a problem in the Ethernet message exchange itself (malformed or mismatched packets) rather than in your API call arguments. See the NAI Ethernet Protocol APIs page and the SSK header (nai.h) for the full enumerated list.

Channel and BIT status

This is a different thing from the return codes above. The codes above are what a function call hands back — whether the call itself succeeded. Separately, NAI modules continuously report the health and condition of each channel as status bits you read from the hardware — BIT, open/overvoltage, signal loss, termination fault, and a summary. A call can return NAI_SUCCESS (it worked) and still report back a status bit telling you a channel has a fault.

Important

Don’t confuse NAI_ERROR_BIT_FAILED (a return code — the call itself could not complete) with a BIT status bit being set (the call succeeded and told you the channel failed its self-test). Same word, different layer.

You read these bits with the module family’s status getter — for example naibrd_AD_GetStatus() or naibrd_VR_GetChanMappedStatus() — passing a status-type selector. The available conditions and their exact selector names are per module family; see that function’s entry in the SSK API reference and the module’s manual.

Real-time vs latched — the R/L convention

Every status condition has two forms, and the sample applications display them side by side as R/L:

FormMeaning
Real-time (R)The condition right now. Clears itself as soon as the condition goes away.
Latched (L)Records that the condition occurred. Stays set until you explicitly clear it — even after the condition itself is gone.

Each form is a separate selector (e.g. ..._BIT_REALTIME vs ..._BIT_LATCHED). In the R/L display, the first digit is real-time, the second is latched, and 0 = normal/pass, 1 = fail/detected. A latched 1 with a real-time 0 means “this fault happened earlier and has since cleared” — clear the latch to reset it.

Common conditions

  • BIT — the channel failed its built-in self-test.
  • Open / overvoltage — the input is disconnected or exceeds the configured range (analog input modules).
  • Signal loss — the input fell below the configured minimum amplitude or frequency (e.g. VR).
  • Termination fault — a fault in the channel’s input termination.
  • Summary — an aggregate: set if any individual condition on the channel is set. Check the summary first, then drill down to find which condition tripped it.

Enabling and clearing

  • Per-channel status reporting must be enabled with naibrd_XX_SetChanStatusEnable(). When it’s disabled, the module reports no status for that channel — and status-driven interrupts won’t assert either.
  • Latched status stays set until you clear it, using the module’s clear-status function (e.g. naibrd_VR_ClearChanMappedStatus()) with the latched selector. Real-time status needs no clearing — it follows the live condition.
  • PBIT (power-on BIT) runs only once, at power-on; check whether it completed with naibrd_GetModulePBITComplete(). On a board that hasn’t been power-cycled since install, PBIT may simply not have run yet — that’s not a fault.

What to check when a bit is set

Status bit setLook at
BITOpen input, hardware fault, or a wrong range setting — consult the module manual’s diagnostics.
Open / overvoltageInput wiring and the configured range/polarity.
Signal lossExcitation/power supply, thresholds, and minimum amplitude/frequency vs. the actual input.
Latched set, real-time clearA past event that has cleared — clear the latch to reset it.