libserialport  unreleased development snapshot
cross-platform library for accessing serial ports
 All Data Structures Files Functions Variables Enumerations Enumerator Modules Pages
Functions
Errors

Obtaining error information. More...

Functions

int sp_last_error_code (void)
 Get the error code for a failed operation. More...
 
char * sp_last_error_message (void)
 Get the error message for a failed operation. More...
 
void sp_free_error_message (char *message)
 Free an error message returned by sp_last_error_message(). More...
 
void sp_set_debug_handler (void(*handler)(const char *format,...))
 Set the handler function for library debugging messages. More...
 
void sp_default_debug_handler (const char *format,...)
 Default handler function for library debugging messages. More...
 

Detailed Description

Obtaining error information.

Function Documentation

void sp_default_debug_handler ( const char *  format,
  ... 
)

Default handler function for library debugging messages.

This function prints debug messages to the standard error stream if the environment variable LIBSERIALPORT_DEBUG is set. Otherwise, they are ignored.

Parameters
[in]formatThe format string to use. Must not be NULL.
[in]...The variable length argument list to use.
Since
0.1.0
void sp_free_error_message ( char *  message)

Free an error message returned by sp_last_error_message().

Parameters
[in]messageThe error message string to free. Must not be NULL.
Since
0.1.0
int sp_last_error_code ( void  )

Get the error code for a failed operation.

In order to obtain the correct result, this function should be called straight after the failure, before executing any other system operations. The result is thread-specific, and only valid when called immediately after a previous call returning SP_ERR_FAIL.

Returns
The system's numeric code for the error that caused the last operation to fail.
Since
0.1.0
char* sp_last_error_message ( void  )

Get the error message for a failed operation.

In order to obtain the correct result, this function should be called straight after the failure, before executing other system operations. The result is thread-specific, and only valid when called immediately after a previous call returning SP_ERR_FAIL.

Returns
The system's message for the error that caused the last operation to fail. This string may be allocated by the function, and should be freed after use by calling sp_free_error_message().
Since
0.1.0
void sp_set_debug_handler ( void(*)(const char *format,...)  handler)

Set the handler function for library debugging messages.

Debugging messages are generated by the library during each operation, to help in diagnosing problems. The handler will be called for each message. The handler can be set to NULL to ignore all debug messages.

The handler function should accept a format string and variable length argument list, in the same manner as e.g. printf().

The default handler is sp_default_debug_handler().

Parameters
[in]handlerThe handler function to use. Can be NULL (in that case all debug messages will be ignored).
Since
0.1.0