Commit 70a14990f44ecf9f2417d81d541068e508a8dbee
Committed by
Stéphane Raimbault
1 parent
72de18bc
Make error_print() globally accessible
Renamed error_print() to _error_print() in order to indicate it's a private method and make it globally accessible so functions in modbus-rtu.c and modbus-tcp.c can make use of it as well. Signed-off-by: Stéphane Raimbault <stephane.raimbault@gmail.com>
Showing
2 changed files
with
8 additions
and
7 deletions
src/modbus-private.h
src/modbus.c
| ... | ... | @@ -86,7 +86,7 @@ const char *modbus_strerror(int errnum) { |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | -static void error_print(modbus_t *ctx, const char *context) | |
| 89 | +void _error_print(modbus_t *ctx, const char *context) | |
| 90 | 90 | { |
| 91 | 91 | if (ctx->debug) { |
| 92 | 92 | fprintf(stderr, "ERROR %s", modbus_strerror(errno)); |
| ... | ... | @@ -158,7 +158,7 @@ static int send_msg(modbus_t *ctx, uint8_t *req, int req_length) |
| 158 | 158 | do { |
| 159 | 159 | rc = ctx->backend->send(ctx->s, req, req_length); |
| 160 | 160 | if (rc == -1) { |
| 161 | - error_print(ctx, NULL); | |
| 161 | + _error_print(ctx, NULL); | |
| 162 | 162 | if (ctx->error_recovery && |
| 163 | 163 | (errno == EBADF || errno == ECONNRESET || errno == EPIPE)) { |
| 164 | 164 | modbus_close(ctx); |
| ... | ... | @@ -247,7 +247,7 @@ static int compute_data_length(modbus_t *ctx, uint8_t *msg) |
| 247 | 247 | FD_ZERO(&rfds); \ |
| 248 | 248 | FD_SET(ctx->s, &rfds); \ |
| 249 | 249 | } else { \ |
| 250 | - error_print(ctx, "select"); \ | |
| 250 | + _error_print(ctx, "select"); \ | |
| 251 | 251 | if (ctx->error_recovery && (errno == EBADF)) { \ |
| 252 | 252 | modbus_close(ctx); \ |
| 253 | 253 | modbus_connect(ctx); \ |
| ... | ... | @@ -270,7 +270,7 @@ static int compute_data_length(modbus_t *ctx, uint8_t *msg) |
| 270 | 270 | errno = EMBUNKEXC; \ |
| 271 | 271 | } else { \ |
| 272 | 272 | errno = ETIMEDOUT; \ |
| 273 | - error_print(ctx, "select"); \ | |
| 273 | + _error_print(ctx, "select"); \ | |
| 274 | 274 | } \ |
| 275 | 275 | return -1; \ |
| 276 | 276 | } \ |
| ... | ... | @@ -353,7 +353,7 @@ static int receive_msg(modbus_t *ctx, int msg_length_computed, |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | if (read_rc == -1) { |
| 356 | - error_print(ctx, "read"); | |
| 356 | + _error_print(ctx, "read"); | |
| 357 | 357 | if (ctx->error_recovery && (errno == ECONNRESET || |
| 358 | 358 | errno == ECONNREFUSED)) { |
| 359 | 359 | modbus_close(ctx); |
| ... | ... | @@ -396,7 +396,7 @@ static int receive_msg(modbus_t *ctx, int msg_length_computed, |
| 396 | 396 | msg_length_computed += length_to_read; |
| 397 | 397 | if (msg_length_computed > ctx->backend->max_adu_length) { |
| 398 | 398 | errno = EMBBADDATA; |
| 399 | - error_print(ctx, "too many data"); | |
| 399 | + _error_print(ctx, "too many data"); | |
| 400 | 400 | return -1; |
| 401 | 401 | } |
| 402 | 402 | state = COMPLETE; |
| ... | ... | @@ -540,7 +540,7 @@ static int receive_msg_req(modbus_t *ctx, uint8_t *req, uint8_t *rsp) |
| 540 | 540 | } else { |
| 541 | 541 | errno = EMBBADEXC; |
| 542 | 542 | } |
| 543 | - error_print(ctx, NULL); | |
| 543 | + _error_print(ctx, NULL); | |
| 544 | 544 | return -1; |
| 545 | 545 | } |
| 546 | 546 | } | ... | ... |