3 error codes, 4 open/close functions, 1 s826_systemopen – Sensoray 826 User Manual
Page 11: 2 s826_systemclose, Error codes, Open/close functions, S826_systemopen, S826_systemclose
3.3 Error Codes
Most of the API functions return an error code. These functions return zero if no errors are detected, otherwise a negative
value will be returned that indicates the type of error that occurred.
Error Code
Value
Description
S826_ERR_OK
0
No errors.
S826_ERR_BOARD
-1
Invalid board number.
S826_ERR_VALUE
-2
Illegal argument value.
S826_ERR_NOTREADY
-3
Device was busy or unavailable, or wait timed out.
S826_ERR_CANCELLED
-4
Blocking function was canceled.
S826_ERR_DRIVER
-5
Driver call failed.
S826_ERR_MISSEDTRIG
-6
ADC trigger occurred while previous conversion burst was in progress.
S826_ERR_DUPADDR
-9
Two 826 boards are set to the same board number. Change DIP switch settings.
S826_ERR_BOARDCLOSED
-10
Addressed board is not open.
S826_ERR_CREATEMUTEX
-11
Failed to create internal mutex.
S826_ERR_MEMORYMAP
-12
Failed to map board into memory space.
S826_ERR_MALLOC
-13
Failed to allocate memory.
S826_ERR_FIFOOVERFLOW
-15
Counter channel's snapshot FIFO overflowed.
S826_ERR_OSSPECIFIC
-1xx
Error specific to the operating system. Contact Sensoray.
3.4 Open/Close Functions
3.4.1 S826_SystemOpen
The S826_SystemOpen function detects all Model 826 boards and enables communication with the boards.
int S826_SystemOpen(void);
Return Values
If the function succeeds, the return value is a set of bit flags indicating all detected 826 boards. Each bit position
corresponds to the board number programmed onto a board's switches (see “Hardware Configuration“). For example,
bit 0 will be set if an 826 with board number 0 is detected. The return value will be zero if no boards are detected, or
positive if one or more boards are detected without error.
If the function fails, the return value is an error code (always a negative value). S826_ERR_DUPADDR will be
returned if two boards are detected that have the same board number.
Remarks
This function must be called by a process before interacting with any 826 boards. The function allocates system
resources that are used internally by other API functions. S826_SystemClose must be called once, for each call to
S826_SystemOpen, to free the resources when they are no longer needed (e.g., when the 826 application program
terminates). The board's circuitry is not reset by this function; all registers and I/O states are preserved.
S826_SystemOpen should be called once by every process that will use the 826 API. In a multi-threaded process, call
the function once before any other API functions are called; all threads belonging to the process will then have access
to all 826 boards in the system.
3.4.2 S826_SystemClose
The S826_SystemClose function frees all of the system resources that were allocated by S826_SystemOpen and
disables communication with all 826 boards.
int S826_SystemClose();
826 Instruction Manual
6
Programming