src/utils.cpp
bool LibSerialCheck(enum sp_return result) {
  char* err_msg;
  switch (result)
  {
  case SP_ERR_ARG:
    throw(LibSerialPortError("Error: Invalid argument."));
    break;

  case SP_ERR_FAIL:
    err_msg = sp_last_error_message();
    throw(LibSerialPortError("Error: Failed: " + std::string(err_msg)));
    sp_free_error_message(err_msg);
    break;

  case SP_ERR_SUPP:
    throw(LibSerialPortError("Error: Not Supported."));
    break;

  case SP_ERR_MEM:
    throw(LibSerialPortError("Error: Couldn't allocate memory."));
    break;

  case SP_OK:
  default:
    return true;
  }
}
/* Helper function for error handling. */
Helper function for error handling.
Helper function for error handling .
bool LibSerialCheck(enum sp_return result) {
  char* err_msg;
  switch (result)
  {
  case SP_ERR_ARG:
    throw(LibSerialPortError("Error: Invalid argument."));
    break;
  case SP_ERR_FAIL:
    err_msg = sp_last_error_message();
    throw(LibSerialPortError("Error: Failed: " + std::string(err_msg)));
    sp_free_error_message(err_msg);
    break;
  case SP_ERR_SUPP:
    throw(LibSerialPortError("Error: Not Supported."));
    break;
  case SP_ERR_MEM:
    throw(LibSerialPortError("Error: Couldn't allocate memory."));
    break;
  case SP_OK:
  default:
    return true;
  }
}
bool LibSerialCheck ( enum sp_return result ) { char * err_msg ; switch ( result ) { case SP_ERR_ARG : throw ( LibSerialPortError ( " " ) ) ; break ; case SP_ERR_FAIL : err_msg = sp_last_error_message ( ) ; throw ( LibSerialPortError ( " " + std :: string ( err_msg ) ) ) ; sp_free_error_message ( err_msg ) ; break ; case SP_ERR_SUPP : throw ( LibSerialPortError ( " " ) ) ; break ; case SP_ERR_MEM : throw ( LibSerialPortError ( " " ) ) ; break ; case SP_OK : default : return true ; } }
Helper function for error handling.
Helper function for error handling .