{"action":"created","issue":{"url":"https://api.github.com/repos/stephane/libmodbus/issues/95","repository_url":"https://api.github.com/repos/stephane/libmodbus","labels_url":"https://api.github.com/repos/stephane/libmodbus/issues/95/labels{/name}","comments_url":"https://api.github.com/repos/stephane/libmodbus/issues/95/comments","events_url":"https://api.github.com/repos/stephane/libmodbus/issues/95/events","html_url":"https://github.com/stephane/libmodbus/issues/95","id":11404334,"number":95,"title":"Timeout for msg indications","user":{"login":"stephane","id":1815,"avatar_url":"https://avatars.githubusercontent.com/u/1815?v=3","gravatar_id":"","url":"https://api.github.com/users/stephane","html_url":"https://github.com/stephane","followers_url":"https://api.github.com/users/stephane/followers","following_url":"https://api.github.com/users/stephane/following{/other_user}","gists_url":"https://api.github.com/users/stephane/gists{/gist_id}","starred_url":"https://api.github.com/users/stephane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephane/subscriptions","organizations_url":"https://api.github.com/users/stephane/orgs","repos_url":"https://api.github.com/users/stephane/repos","events_url":"https://api.github.com/users/stephane/events{/privacy}","received_events_url":"https://api.github.com/users/stephane/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/stephane/libmodbus/labels/valid","name":"valid","color":"009628"}],"state":"open","locked":false,"assignee":{"login":"stephane","id":1815,"avatar_url":"https://avatars.githubusercontent.com/u/1815?v=3","gravatar_id":"","url":"https://api.github.com/users/stephane","html_url":"https://github.com/stephane","followers_url":"https://api.github.com/users/stephane/followers","following_url":"https://api.github.com/users/stephane/following{/other_user}","gists_url":"https://api.github.com/users/stephane/gists{/gist_id}","starred_url":"https://api.github.com/users/stephane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephane/subscriptions","organizations_url":"https://api.github.com/users/stephane/orgs","repos_url":"https://api.github.com/users/stephane/repos","events_url":"https://api.github.com/users/stephane/events{/privacy}","received_events_url":"https://api.github.com/users/stephane/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/stephane/libmodbus/milestones/1","html_url":"https://github.com/stephane/libmodbus/milestones/v3.2.0","labels_url":"https://api.github.com/repos/stephane/libmodbus/milestones/1/labels","id":450513,"number":1,"title":"v3.2.0","description":"New major stable release.","creator":{"login":"stephane","id":1815,"avatar_url":"https://avatars.githubusercontent.com/u/1815?v=3","gravatar_id":"","url":"https://api.github.com/users/stephane","html_url":"https://github.com/stephane","followers_url":"https://api.github.com/users/stephane/followers","following_url":"https://api.github.com/users/stephane/following{/other_user}","gists_url":"https://api.github.com/users/stephane/gists{/gist_id}","starred_url":"https://api.github.com/users/stephane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephane/subscriptions","organizations_url":"https://api.github.com/users/stephane/orgs","repos_url":"https://api.github.com/users/stephane/repos","events_url":"https://api.github.com/users/stephane/events{/privacy}","received_events_url":"https://api.github.com/users/stephane/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":14,"state":"open","created_at":"2013-10-09T07:05:48Z","updated_at":"2015-12-03T14:29:09Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2013-02-26T11:30:46Z","updated_at":"2016-02-17T17:25:18Z","closed_at":null,"body":"Copied from https://answers.launchpad.net/libmodbus/+question/193271\r\n\r\nHi, 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:\r\n\r\ncommit 89d0dc01372c8648792f3d02b99d86d093755c31\r\nAuthor: Stéphane Raimbault <stephane.raimbault@gmail.com>\r\nDate: Fri May 6 19:06:59 2011 +0200\r\n\r\n    Fix longstanding limitation of server to wait forever\r\n\r\n    The change for serial on Windows is temporary. If you're interested of\r\n    improving the situation for this, please have a look at the FIXME.\r\n\r\nSo, 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:\r\n\r\n  if (msg_type == MSG_INDICATION) {\r\n         /* Wait for a message, we don't know when the message will be\r\n          * received */\r\n        p_tv = NULL;\r\n     } else {\r\n         tv.tv_sec = ctx->response_timeout.tv_sec;\r\n         tv.tv_usec = ctx->response_timeout.tv_usec;\r\n         p_tv = &tv;\r\n     }\r\n\r\nI think it will be better to make this configurable, like the other timeouts. So, what do you think about changing it to somethink like:\r\n\r\n  if (msg_type == MSG_INDICATION) {\r\n         /* Wait for a message, we don't know when the message will be\r\n          * received */\r\n         if (ctx->indication_timeout.tv_usec==-1) {\r\n         p_tv=NULL;\r\n         } else {\r\n         tv.tv_sec = ctx->indication_timeout.tv_sec;\r\n         tv.tv_usec = ctx->indication_timeout.tv_usec;\r\n         p_tv = &tv;\r\n         }\r\n     } else {\r\n         tv.tv_sec = ctx->response_timeout.tv_sec;\r\n         tv.tv_usec = ctx->response_timeout.tv_usec;\r\n         p_tv = &tv;\r\n     }\r\n\r\nAnd 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."},"comment":{"url":"https://api.github.com/repos/stephane/libmodbus/issues/comments/185312438","html_url":"https://github.com/stephane/libmodbus/issues/95#issuecomment-185312438","issue_url":"https://api.github.com/repos/stephane/libmodbus/issues/95","id":185312438,"user":{"login":"jfieldhouse","id":16947598,"avatar_url":"https://avatars.githubusercontent.com/u/16947598?v=3","gravatar_id":"","url":"https://api.github.com/users/jfieldhouse","html_url":"https://github.com/jfieldhouse","followers_url":"https://api.github.com/users/jfieldhouse/followers","following_url":"https://api.github.com/users/jfieldhouse/following{/other_user}","gists_url":"https://api.github.com/users/jfieldhouse/gists{/gist_id}","starred_url":"https://api.github.com/users/jfieldhouse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfieldhouse/subscriptions","organizations_url":"https://api.github.com/users/jfieldhouse/orgs","repos_url":"https://api.github.com/users/jfieldhouse/repos","events_url":"https://api.github.com/users/jfieldhouse/events{/privacy}","received_events_url":"https://api.github.com/users/jfieldhouse/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T17:25:18Z","updated_at":"2016-02-17T17:25:18Z","body":"Did this patch get implemented? I need the same ability so that I can kick a watchdog from my modbus server application which could be blocked indefinitely... I'm using V3.1.2 of libmodbus, and I don't see the patch mentioned above in the _modbus_receive_msg() function."}}