introduced result_t, added RESULT_ERR_EOF
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
namespace libebus
|
||||
{
|
||||
|
||||
const char* getResultCodeCStr(int resultCode) {
|
||||
const char* getResultCodeCStr(result_t resultCode) {
|
||||
switch (resultCode) {
|
||||
case RESULT_ERR_SEND: return "ERR_SEND: send error";
|
||||
case RESULT_ERR_EXTRA_DATA: return "ERR_EXTRA_DATA: received bytes > sent bytes";
|
||||
@@ -35,7 +35,11 @@ const char* getResultCodeCStr(int resultCode) {
|
||||
case RESULT_ERR_ESC: return "ERR_ESC: invalid escape sequence received";
|
||||
case RESULT_ERR_INVALID_ARG: return "ERR_INVALID_ARG: invalid argument specified";
|
||||
case RESULT_ERR_DEVICE: return "ERR_DEVICE: generic device error";
|
||||
default: return "success";
|
||||
case RESULT_ERR_EOF: return "ERR_EOF: end of input reached";
|
||||
default:
|
||||
if (resultCode >= 0)
|
||||
return "success";
|
||||
return "ERR: unknown error code";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,14 +44,17 @@ static const int RESULT_ERR_BUS_LOST = -8; // arbitration lost
|
||||
static const int RESULT_ERR_ESC = -9; // invalid escape sequence received
|
||||
static const int RESULT_ERR_INVALID_ARG = -10; // invalid argument
|
||||
static const int RESULT_ERR_DEVICE = -11; // generic device error (usually fatal)
|
||||
static const int RESULT_ERR_EOF = -12; // end of input reached
|
||||
|
||||
/** type for result code. */
|
||||
typedef int result_t;
|
||||
|
||||
/**
|
||||
* @brief Return the string corresponding to the result code.
|
||||
* @param resultCode the result code (see RESULT_ constants).
|
||||
* @return the string corresponding to the result code.
|
||||
*/
|
||||
const char* getResultCodeCStr(int resultCode);
|
||||
const char* getResultCodeCStr(result_t resultCode);
|
||||
|
||||
|
||||
} //namespace
|
||||
|
||||
Reference in New Issue
Block a user