libgpiod  0.3.2
Macros | Enumerations | Functions
Error handling

Error handling functions and macros. More...

Macros

#define _GPIOD_ERRNO_OFFSET   10000
 Private: offset for all libgpiod error numbers.
 

Enumerations

enum  {
  GPIOD_ESUCCESS = _GPIOD_ERRNO_OFFSET, GPIOD_EREQUEST, GPIOD_EEVREQUEST, GPIOD_EBULKINCOH,
  GPIOD_ELINEBUSY, GPIOD_ELINEMAX, _GPIOD_MAX_ERR
}
 libgpiod-specific error numbers. More...
 

Functions

int gpiod_errno (void) GPIOD_API
 Return last error. More...
 
const char * gpiod_strerror (int errnum) GPIOD_API
 Convert error number to a human-readable string. More...
 
const char * gpiod_last_strerror (void) GPIOD_API
 Convert the last libgpiod error number to a human-readable string. More...
 

Detailed Description

Error handling functions and macros.

This library uses a combination of system-wide errno numbers and internal GPIO-specific errors. The routines in this section should be used to access the information about any error conditions that may occur.

With some noted exceptions, all libgpiod functions set the last error variable if an error occurs. Internally, the last_error variable has a separate instance per thread making the library thread-safe.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

libgpiod-specific error numbers.

Enumerator
GPIOD_ESUCCESS 

No error.

GPIOD_EREQUEST 

The caller has no ownership of this line.

GPIOD_EEVREQUEST 

The caller has not configured any events on this line.

GPIOD_EBULKINCOH 

Not all lines in bulk belong to the same GPIO chip.

GPIOD_ELINEBUSY 

This line is currently in use.

GPIOD_ELINEMAX 

Number of lines in the request exceeds limit.

_GPIOD_MAX_ERR 

Private: number of libgpiod-specific error numbers.

Definition at line 79 of file gpiod.h.

Function Documentation

◆ gpiod_errno()

int gpiod_errno ( void  )

Return last error.

Returns
Number of the last error inside libgpiod.

◆ gpiod_last_strerror()

const char* gpiod_last_strerror ( void  )

Convert the last libgpiod error number to a human-readable string.

Returns
Pointer to a null-terminated error description.

◆ gpiod_strerror()

const char* gpiod_strerror ( int  errnum)

Convert error number to a human-readable string.

Parameters
errnumError number to convert.
Returns
Pointer to a null-terminated error description.