-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeout for msg indications #95
Comments
Dear Stephane, i must add the parameter "ctx->indication_timeout.tv_usec" in the struct _modbus I don´t know if this issus has relation with my issus #233 |
Is it possible for me to get this patch now? Instead of waiting for the next milestone? I need it to kick a watchdog in my modbus server application. |
@jfieldhouse yep feel free to patch your Modbus server, the Open Source way! |
Could someone review my patch? |
Merged. |
Copied from https://answers.launchpad.net/libmodbus/+question/193271
Hi, I just bumped into the same problem. In older versions, there was a timeout in the select() call, so it was possible to properly stop a thread waiting for an indication, update watchdog, whatever. The commit that changes this is:
commit 89d0dc0
Author: Stéphane Raimbault [email protected]
Date: Fri May 6 19:06:59 2011 +0200
Fix longstanding limitation of server to wait forever
The change for serial on Windows is temporary. If you're interested of
improving the situation for this, please have a look at the FIXME.
So, in some cases (like mine: ) this limitation was not so undesirable. Now in the code we have a hardcored value of NULL if we're waiting for an idication:
if (msg_type == MSG_INDICATION) {
/* Wait for a message, we don't know when the message will be
* received */
p_tv = NULL;
} else {
tv.tv_sec = ctx->response_timeout.tv_sec;
tv.tv_usec = ctx->response_timeout.tv_usec;
p_tv = &tv;
}
I think it will be better to make this configurable, like the other timeouts. So, what do you think about changing it to somethink like:
if (msg_type == MSG_INDICATION) {
/* Wait for a message, we don't know when the message will be
* received */
if (ctx->indication_timeout.tv_usec==-1) {
p_tv=NULL;
} else {
tv.tv_sec = ctx->indication_timeout.tv_sec;
tv.tv_usec = ctx->indication_timeout.tv_usec;
p_tv = &tv;
}
} else {
tv.tv_sec = ctx->response_timeout.tv_sec;
tv.tv_usec = ctx->response_timeout.tv_usec;
p_tv = &tv;
}
And the default value for indication_timeout can be NULL, so it will wait forever. But for some of us who need a timeout there will be a way to set it.
The text was updated successfully, but these errors were encountered: