Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Sleep a little while reconnecting. #77

Closed
wants to merge 1 commit into from

2 participants

@karlp

As this code is called in a forever loop, it should try and be somewhat
polite to any other OS tasks. At present, with tcp connections to localhost,
and presumably rtu connections to a local serial port, this is a CPU hog if
the remote port is not listening.

@karlp karlp Sleep a little while reconnecting.
As this code is called in a forever loop, it should try and be somewhat
polite to any other OS tasks.  At present, with tcp connections to localhost,
and presumably rtu connections to a local serial port, this is a CPU hog if
the remote port is not listening.
f407c3f
@stephane
Owner

I'll test this...

@stephane stephane closed this pull request from a commit
@stephane Sleep for delay of response timeout before reconnect (closes #77)
Thanks to Karl Palsson.
a06255b
@stephane stephane closed this in a06255b
@karlp karlp deleted the karlp:cpu_hog_send_i79 branch
@mk8 mk8 referenced this pull request from a commit in mk8/libmodbus
@stephane Sleep for delay of response timeout before reconnect (closes #77)
Thanks to Karl Palsson.
110197f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 30, 2012
  1. @karlp

    Sleep a little while reconnecting.

    karlp authored
    As this code is called in a forever loop, it should try and be somewhat
    polite to any other OS tasks.  At present, with tcp connections to localhost,
    and presumably rtu connections to a local serial port, this is a CPU hog if
    the remote port is not listening.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 0 deletions.
  1. +1 −0  src/modbus.c
View
1  src/modbus.c
@@ -189,6 +189,7 @@ static int send_msg(modbus_t *ctx, uint8_t *msg, int msg_length)
if ((errno == EBADF || errno == ECONNRESET || errno == EPIPE)) {
modbus_close(ctx);
+ usleep(100 * 1000); // Be polite to other tasks
modbus_connect(ctx);
} else {
_sleep_and_flush(ctx);
Something went wrong with that request. Please try again.