RC1000-PP Host:
Error Handling Functions


 

PP1000InstallErrorHandler

 
  PP1000_STATUS PP1000InstallErrorHandler(
                      PP1000_HANDLER_FUNCTION Handler);
  

 

Arguments
Handler Error handler function
Return Values
PP1000_SUCCESS Success.
Description

This function is used to install a user defined function that will be called whenever the RC1000-PP support library encounters an error condition. The prototype of the handler function should be:

void Handler(char *FnName, PP1000_STATUS Status);

When this function is called, FnName will point to a string containing the name of the calling function and Status will contain the error code. Should the handler function return, the RC1000-PP function that generated the error will return to the main program with the same error condition.

Passing NULL as the value for Handler will un-install the error handler. A suggested error handling function is as follows:

void Handler(char *FnName, PP1000_STATUS Status)
{
  unsigned char Buffer[1024];

  PP1000StatusToString(Status, Buffer, sizeof(Buffer));
  printf("\n%s - %s\n", FnName, Buffer);

  exit(1);
}

 

 

 

PP1000StatusToString

 
  PP1000_STATUS PP1000StatusToString(
                      PP1000_Status Status,
                      char * String,
                      unsigned long Length);
  

 

Arguments
Status Return code to decode.
String Pointer to buffer to receive error string.
Length Length to buffer to receive string.
Return Values
PP1000_SUCCESS Success.
PP1000_NULL_POINTER String is a NULL pointer.
PP1000_INVALID_ARGUMENT Length is zero.
Description

This function is used to obtain a text error string for a return code. The zero terminated string will be written into the buffer pointed to by String. The maximum length of the error string (including zero termination) will be Length bytes. If Status is not a recognised return code, a string of “Unknown Error” will be returned.