{"action":"created","comment":{"url":"https://api.github.com/repos/stephane/libmodbus/pulls/comments/206522824","pull_request_review_id":141948683,"id":206522824,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNjUyMjgyNA==","diff_hunk":"@@ -1399,6 +1408,35 @@ int modbus_write_registers(modbus_t *ctx, int addr, int nb, const uint16_t *src)\n     return rc;\n }\n \n+int modbus_read_device_information_object(modbus_t *ctx, unsigned char object_id, char* dest)\n+{\n+    uint8_t req[_MIN_REQ_LENGTH];\n+    uint8_t rsp[MAX_MESSAGE_LENGTH];\n+    int rc;\n+    int req_length;\n+    int offset;\n+    int i;\n+    req_length = ctx->backend->build_request_basis(ctx, MODBUS_FC_READ_DEVICE_INFORMATION, 0x0E04, (object_id<<8), req) - 1;\n+    rc = send_msg(ctx, req, req_length);\n+    if (rc > 0) {\n+        rc = _modbus_receive_msg(ctx, rsp, MSG_CONFIRMATION);\n+        if (rc == -1)\n+            return -1;\n+\n+        rc = check_confirmation(ctx, req, rsp, rc);\n+        if (rc == -1)\n+            return -1;\n+\n+        offset = ctx->backend->header_length + 9;\n+\n+        for (i = 0; i < rc; i++) {\n+            dest[i] = rsp[offset + i];\n+        }\n+        dest[i] = '\\0';","path":"src/modbus.c","position":65,"original_position":65,"commit_id":"4c4abd63c1f32ca0f6bfca3021531febc7c9c28b","original_commit_id":"4c4abd63c1f32ca0f6bfca3021531febc7c9c28b","user":{"login":"karlp","id":127907,"node_id":"MDQ6VXNlcjEyNzkwNw==","avatar_url":"https://avatars1.githubusercontent.com/u/127907?v=4","gravatar_id":"","url":"https://api.github.com/users/karlp","html_url":"https://github.com/karlp","followers_url":"https://api.github.com/users/karlp/followers","following_url":"https://api.github.com/users/karlp/following{/other_user}","gists_url":"https://api.github.com/users/karlp/gists{/gist_id}","starred_url":"https://api.github.com/users/karlp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karlp/subscriptions","organizations_url":"https://api.github.com/users/karlp/orgs","repos_url":"https://api.github.com/users/karlp/repos","events_url":"https://api.github.com/users/karlp/events{/privacy}","received_events_url":"https://api.github.com/users/karlp/received_events","type":"User","site_admin":false},"body":"this looks dubious.  While objects 1..6 are ascii per spec, the rest are all user defined.  Should this function not just return the length as is done in many other libmodbus functions?","created_at":"2018-07-31T13:17:55Z","updated_at":"2018-07-31T13:17:55Z","html_url":"https://github.com/stephane/libmodbus/pull/443#discussion_r206522824","pull_request_url":"https://api.github.com/repos/stephane/libmodbus/pulls/443","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/stephane/libmodbus/pulls/comments/206522824"},"html":{"href":"https://github.com/stephane/libmodbus/pull/443#discussion_r206522824"},"pull_request":{"href":"https://api.github.com/repos/stephane/libmodbus/pulls/443"}}},"pull_request":{"url":"https://api.github.com/repos/stephane/libmodbus/pulls/443","id":205103030,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1MTAzMDMw","html_url":"https://github.com/stephane/libmodbus/pull/443","diff_url":"https://github.com/stephane/libmodbus/pull/443.diff","patch_url":"https://github.com/stephane/libmodbus/pull/443.patch","issue_url":"https://api.github.com/repos/stephane/libmodbus/issues/443","number":443,"state":"open","locked":false,"title":"Added function \"modbus_read_device_information_object\"","user":{"login":"Schwaneberg","id":35252661,"node_id":"MDQ6VXNlcjM1MjUyNjYx","avatar_url":"https://avatars2.githubusercontent.com/u/35252661?v=4","gravatar_id":"","url":"https://api.github.com/users/Schwaneberg","html_url":"https://github.com/Schwaneberg","followers_url":"https://api.github.com/users/Schwaneberg/followers","following_url":"https://api.github.com/users/Schwaneberg/following{/other_user}","gists_url":"https://api.github.com/users/Schwaneberg/gists{/gist_id}","starred_url":"https://api.github.com/users/Schwaneberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Schwaneberg/subscriptions","organizations_url":"https://api.github.com/users/Schwaneberg/orgs","repos_url":"https://api.github.com/users/Schwaneberg/repos","events_url":"https://api.github.com/users/Schwaneberg/events{/privacy}","received_events_url":"https://api.github.com/users/Schwaneberg/received_events","type":"User","site_admin":false},"body":"This PR adds a new function to access the built in device information from Modbus devices.\r\n\r\nChanges:\r\n- A new function code \"MODBUS_FC_READ_DEVICE_INFORMATION\" was added.\r\n- Device information object codes were added, e.g. MODBUS_OBJID_VENDORNAME.\r\n- Function \"modbus_read_device_information_object(modbus_t *ctx, unsigned char object_id, char* dest);\" was added.\r\n- Several internal functions were extended to handle the new function code.\r\n\r\nNotes:\r\nI successfully tested to code with a server that uses big endian word and byte order. Therefore, the mapping in modbus.c:1432 might be wrong for clients with little endian word order, depending on how strings are handled.\r\n\r\nSigned-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>","created_at":"2018-07-31T12:56:11Z","updated_at":"2018-07-31T13:17:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb8a4292efa7565b65fb7ae96ebe4a3755e4ab30","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/stephane/libmodbus/pulls/443/commits","review_comments_url":"https://api.github.com/repos/stephane/libmodbus/pulls/443/comments","review_comment_url":"https://api.github.com/repos/stephane/libmodbus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stephane/libmodbus/issues/443/comments","statuses_url":"https://api.github.com/repos/stephane/libmodbus/statuses/4c4abd63c1f32ca0f6bfca3021531febc7c9c28b","head":{"label":"Schwaneberg:read-device-info","ref":"read-device-info","sha":"4c4abd63c1f32ca0f6bfca3021531febc7c9c28b","user":{"login":"Schwaneberg","id":35252661,"node_id":"MDQ6VXNlcjM1MjUyNjYx","avatar_url":"https://avatars2.githubusercontent.com/u/35252661?v=4","gravatar_id":"","url":"https://api.github.com/users/Schwaneberg","html_url":"https://github.com/Schwaneberg","followers_url":"https://api.github.com/users/Schwaneberg/followers","following_url":"https://api.github.com/users/Schwaneberg/following{/other_user}","gists_url":"https://api.github.com/users/Schwaneberg/gists{/gist_id}","starred_url":"https://api.github.com/users/Schwaneberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Schwaneberg/subscriptions","organizations_url":"https://api.github.com/users/Schwaneberg/orgs","repos_url":"https://api.github.com/users/Schwaneberg/repos","events_url":"https://api.github.com/users/Schwaneberg/events{/privacy}","received_events_url":"https://api.github.com/users/Schwaneberg/received_events","type":"User","site_admin":false},"repo":{"id":143007498,"node_id":"MDEwOlJlcG9zaXRvcnkxNDMwMDc0OTg=","name":"libmodbus","full_name":"Schwaneberg/libmodbus","owner":{"login":"Schwaneberg","id":35252661,"node_id":"MDQ6VXNlcjM1MjUyNjYx","avatar_url":"https://avatars2.githubusercontent.com/u/35252661?v=4","gravatar_id":"","url":"https://api.github.com/users/Schwaneberg","html_url":"https://github.com/Schwaneberg","followers_url":"https://api.github.com/users/Schwaneberg/followers","following_url":"https://api.github.com/users/Schwaneberg/following{/other_user}","gists_url":"https://api.github.com/users/Schwaneberg/gists{/gist_id}","starred_url":"https://api.github.com/users/Schwaneberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Schwaneberg/subscriptions","organizations_url":"https://api.github.com/users/Schwaneberg/orgs","repos_url":"https://api.github.com/users/Schwaneberg/repos","events_url":"https://api.github.com/users/Schwaneberg/events{/privacy}","received_events_url":"https://api.github.com/users/Schwaneberg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Schwaneberg/libmodbus","description":"A Modbus library for Linux, Mac OS X, FreeBSD, QNX and Windows","fork":true,"url":"https://api.github.com/repos/Schwaneberg/libmodbus","forks_url":"https://api.github.com/repos/Schwaneberg/libmodbus/forks","keys_url":"https://api.github.com/repos/Schwaneberg/libmodbus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Schwaneberg/libmodbus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Schwaneberg/libmodbus/teams","hooks_url":"https://api.github.com/repos/Schwaneberg/libmodbus/hooks","issue_events_url":"https://api.github.com/repos/Schwaneberg/libmodbus/issues/events{/number}","events_url":"https://api.github.com/repos/Schwaneberg/libmodbus/events","assignees_url":"https://api.github.com/repos/Schwaneberg/libmodbus/assignees{/user}","branches_url":"https://api.github.com/repos/Schwaneberg/libmodbus/branches{/branch}","tags_url":"https://api.github.com/repos/Schwaneberg/libmodbus/tags","blobs_url":"https://api.github.com/repos/Schwaneberg/libmodbus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Schwaneberg/libmodbus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Schwaneberg/libmodbus/git/refs{/sha}","trees_url":"https://api.github.com/repos/Schwaneberg/libmodbus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Schwaneberg/libmodbus/statuses/{sha}","languages_url":"https://api.github.com/repos/Schwaneberg/libmodbus/languages","stargazers_url":"https://api.github.com/repos/Schwaneberg/libmodbus/stargazers","contributors_url":"https://api.github.com/repos/Schwaneberg/libmodbus/contributors","subscribers_url":"https://api.github.com/repos/Schwaneberg/libmodbus/subscribers","subscription_url":"https://api.github.com/repos/Schwaneberg/libmodbus/subscription","commits_url":"https://api.github.com/repos/Schwaneberg/libmodbus/commits{/sha}","git_commits_url":"https://api.github.com/repos/Schwaneberg/libmodbus/git/commits{/sha}","comments_url":"https://api.github.com/repos/Schwaneberg/libmodbus/comments{/number}","issue_comment_url":"https://api.github.com/repos/Schwaneberg/libmodbus/issues/comments{/number}","contents_url":"https://api.github.com/repos/Schwaneberg/libmodbus/contents/{+path}","compare_url":"https://api.github.com/repos/Schwaneberg/libmodbus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Schwaneberg/libmodbus/merges","archive_url":"https://api.github.com/repos/Schwaneberg/libmodbus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Schwaneberg/libmodbus/downloads","issues_url":"https://api.github.com/repos/Schwaneberg/libmodbus/issues{/number}","pulls_url":"https://api.github.com/repos/Schwaneberg/libmodbus/pulls{/number}","milestones_url":"https://api.github.com/repos/Schwaneberg/libmodbus/milestones{/number}","notifications_url":"https://api.github.com/repos/Schwaneberg/libmodbus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Schwaneberg/libmodbus/labels{/name}","releases_url":"https://api.github.com/repos/Schwaneberg/libmodbus/releases{/id}","deployments_url":"https://api.github.com/repos/Schwaneberg/libmodbus/deployments","created_at":"2018-07-31T11:51:48Z","updated_at":"2018-07-31T11:51:50Z","pushed_at":"2018-07-31T12:39:45Z","git_url":"git://github.com/Schwaneberg/libmodbus.git","ssh_url":"git@github.com:Schwaneberg/libmodbus.git","clone_url":"https://github.com/Schwaneberg/libmodbus.git","svn_url":"https://github.com/Schwaneberg/libmodbus","homepage":"http://libmodbus.org","size":1515,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"lgpl-2.1","name":"GNU Lesser General Public License v2.1","spdx_id":"LGPL-2.1","url":"https://api.github.com/licenses/lgpl-2.1","node_id":"MDc6TGljZW5zZTEx"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"stephane:master","ref":"master","sha":"ddac0cf909d9ab05423df7b9a66e6e60e8bb0fbb","user":{"login":"stephane","id":1815,"node_id":"MDQ6VXNlcjE4MTU=","avatar_url":"https://avatars1.githubusercontent.com/u/1815?v=4","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},"repo":{"id":481977,"node_id":"MDEwOlJlcG9zaXRvcnk0ODE5Nzc=","name":"libmodbus","full_name":"stephane/libmodbus","owner":{"login":"stephane","id":1815,"node_id":"MDQ6VXNlcjE4MTU=","avatar_url":"https://avatars1.githubusercontent.com/u/1815?v=4","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},"private":false,"html_url":"https://github.com/stephane/libmodbus","description":"A Modbus library for Linux, Mac OS X, FreeBSD, QNX and Windows","fork":false,"url":"https://api.github.com/repos/stephane/libmodbus","forks_url":"https://api.github.com/repos/stephane/libmodbus/forks","keys_url":"https://api.github.com/repos/stephane/libmodbus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stephane/libmodbus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stephane/libmodbus/teams","hooks_url":"https://api.github.com/repos/stephane/libmodbus/hooks","issue_events_url":"https://api.github.com/repos/stephane/libmodbus/issues/events{/number}","events_url":"https://api.github.com/repos/stephane/libmodbus/events","assignees_url":"https://api.github.com/repos/stephane/libmodbus/assignees{/user}","branches_url":"https://api.github.com/repos/stephane/libmodbus/branches{/branch}","tags_url":"https://api.github.com/repos/stephane/libmodbus/tags","blobs_url":"https://api.github.com/repos/stephane/libmodbus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stephane/libmodbus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stephane/libmodbus/git/refs{/sha}","trees_url":"https://api.github.com/repos/stephane/libmodbus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stephane/libmodbus/statuses/{sha}","languages_url":"https://api.github.com/repos/stephane/libmodbus/languages","stargazers_url":"https://api.github.com/repos/stephane/libmodbus/stargazers","contributors_url":"https://api.github.com/repos/stephane/libmodbus/contributors","subscribers_url":"https://api.github.com/repos/stephane/libmodbus/subscribers","subscription_url":"https://api.github.com/repos/stephane/libmodbus/subscription","commits_url":"https://api.github.com/repos/stephane/libmodbus/commits{/sha}","git_commits_url":"https://api.github.com/repos/stephane/libmodbus/git/commits{/sha}","comments_url":"https://api.github.com/repos/stephane/libmodbus/comments{/number}","issue_comment_url":"https://api.github.com/repos/stephane/libmodbus/issues/comments{/number}","contents_url":"https://api.github.com/repos/stephane/libmodbus/contents/{+path}","compare_url":"https://api.github.com/repos/stephane/libmodbus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stephane/libmodbus/merges","archive_url":"https://api.github.com/repos/stephane/libmodbus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stephane/libmodbus/downloads","issues_url":"https://api.github.com/repos/stephane/libmodbus/issues{/number}","pulls_url":"https://api.github.com/repos/stephane/libmodbus/pulls{/number}","milestones_url":"https://api.github.com/repos/stephane/libmodbus/milestones{/number}","notifications_url":"https://api.github.com/repos/stephane/libmodbus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stephane/libmodbus/labels{/name}","releases_url":"https://api.github.com/repos/stephane/libmodbus/releases{/id}","deployments_url":"https://api.github.com/repos/stephane/libmodbus/deployments","created_at":"2010-01-21T10:42:06Z","updated_at":"2018-07-31T05:03:36Z","pushed_at":"2018-07-31T12:56:12Z","git_url":"git://github.com/stephane/libmodbus.git","ssh_url":"git@github.com:stephane/libmodbus.git","clone_url":"https://github.com/stephane/libmodbus.git","svn_url":"https://github.com/stephane/libmodbus","homepage":"http://libmodbus.org","size":1515,"stargazers_count":814,"watchers_count":814,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":614,"mirror_url":null,"archived":false,"open_issues_count":82,"license":{"key":"lgpl-2.1","name":"GNU Lesser General Public License v2.1","spdx_id":"LGPL-2.1","url":"https://api.github.com/licenses/lgpl-2.1","node_id":"MDc6TGljZW5zZTEx"},"forks":614,"open_issues":82,"watchers":814,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/stephane/libmodbus/pulls/443"},"html":{"href":"https://github.com/stephane/libmodbus/pull/443"},"issue":{"href":"https://api.github.com/repos/stephane/libmodbus/issues/443"},"comments":{"href":"https://api.github.com/repos/stephane/libmodbus/issues/443/comments"},"review_comments":{"href":"https://api.github.com/repos/stephane/libmodbus/pulls/443/comments"},"review_comment":{"href":"https://api.github.com/repos/stephane/libmodbus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stephane/libmodbus/pulls/443/commits"},"statuses":{"href":"https://api.github.com/repos/stephane/libmodbus/statuses/4c4abd63c1f32ca0f6bfca3021531febc7c9c28b"}},"author_association":"NONE"}}
{"actor":{"display_login":"karlp"}}