When using the API, errors may occur for a variety of reasons. For example, if the ETH32 device is powered off, there will be an error when trying to connect to it. As another example, if you try to read the value of a port, but specify a non-existent port number, an error will occur. All of the API functions have return values that indicate whether or not an error occurred.
The API functions return a value of zero when no error has occurred, or a negative value (one of the error codes listed below) when an error has occurred.
Note about eth32_open
The eth32_open function is different from the other functions. It returns the newly created handle to the device on success. The only invalid handle value is zero, which indicates an error if it is returned. If you need the actual error code, that can be returned through the parameter list.
The following error codes are defined in the header file:
ETH_GENERAL_ERROR - A miscellaneous or uncategorized error has occurred.
ETH_CLOSING - Function aborted because the device is being closed.
ETH_NETWORK_ERROR - Network communications error. Connection was unable to be established or existing connection was broken.
ETH_THREAD_ERROR - Internal error occurred in the threads and synchronization library.
ETH_NOT_SUPPORTED - Function not supported by this device.
ETH_PIPE_ERROR - Internal API error dealing with data pipes.
ETH_RTHREAD_ERROR - Internal API error dealing with the "Reader thread."
ETH_ETHREAD_ERROR - Internal API error dealing with the "Event thread."
ETH_MALLOC_ERROR - Error dynamically allocating memory.
ETH_WINDOWS_ERROR - Internal API error specific to the Microsoft Windows platform.
ETH_WINSOCK_ERROR - Internal API error in dealing with the Microsoft Winsock library.
ETH_NETWORK_INTR - Network read/write operation was interrupted.
ETH_WRONG_MODE - Something is not configured correctly in order to allow this functionality.
ETH_BCAST_OPT - Error setting the SO_BROADCAST option on a socket.
ETH_REUSE_OPT - Error setting the SO_REUSEADDR option on a socket.
ETH_CFG_NOACK - Warning - device did not acknowledge our attempt to store a new configuration.
ETH_CFG_REJECT - Device has rejected the new configuration data we attempted to store. Configuration switch on device may be disabled.
ETH_LOADLIB - Error loading an external DLL library.
ETH_PLUGIN - General error with the currently configured plugin/sniffer library.
ETH_BUFSIZE - A buffer provided was either invalid size or too small.
ETH_INVALID_HANDLE - Invalid device handle was given.
ETH_INVALID_PORT - The given port number does not exist on this device.
ETH_INVALID_BIT - The given bit number does not exist on this port.
ETH_INVALID_CHANNEL - The given channel number does not exist on this device.
ETH_INVALID_POINTER - The pointer passed in to an API function was invalid.
ETH_INVALID_OTHER - One of the parameters passed in to an API function was invalid.
ETH_INVALID_VALUE - The given value is out of range for this I/O port, counter, etc.
ETH_INVALID_IP - The IP address provided was invalid.
ETH_INVALID_NETMASK - The subnet mask provided was invalid.
ETH_INVALID_INDEX - Invalid index value.
ETH_TIMEOUT - Operation timed out before it could be completed.