{"action":"created","comment":{"url":"https://api.github.com/repos/Samsung/iotjs/pulls/comments/87352036","pull_request_review_id":7966688,"id":87352036,"diff_hunk":"@@ -458,129 +406,54 @@ void SetPinWorker(uv_work_t* work_req) {\n }\n \n \n-void WritePinWorker(uv_work_t* work_req) {\n+void WriteGpioWorker(uv_work_t* work_req) {\n   GpioLinuxGeneral* gpio = GpioLinuxGeneral::GetInstance();\n   IOTJS_ASSERT(gpio->_initialized == true);\n \n   GpioReqWrap* gpio_req = reinterpret_cast<GpioReqWrap*>(work_req->data);\n   GpioReqData* req_data = gpio_req->req();\n \n-  DDDLOG(\"GPIO WritePinWorker() - pin: %d, value: %d\",\n-         req_data->pin, req_data->value);\n-\n-  if (WritePin(req_data->pin, req_data->value)) {\n-    req_data->result = kGpioErrOk;\n-  } else {\n-    req_data->result = kGpioErrSys;\n-  }\n-}\n+  uint32_t pin = req_data->pin;\n+  uint32_t value = req_data->value;\n \n+  DDDLOG(\"GPIO WriteGpioWorker() - pin: %d, value: %d\",\n+         pin, value);\n \n-void ReadPinWorker(uv_work_t* work_req) {\n-  GpioLinuxGeneral* gpio = GpioLinuxGeneral::GetInstance();\n-  IOTJS_ASSERT(gpio->_initialized == true);\n-\n-  GpioReqWrap* gpio_req = reinterpret_cast<GpioReqWrap*>(work_req->data);\n-  GpioReqData* req_data = gpio_req->req();\n+  char value_path[64] = {0};\n+  snprintf(value_path, 63, GPIO_PIN_FORMAT_VALUE, pin);\n \n-  DDDLOG(\"GPIO ReadPinWorker() - pin: %d\" ,req_data->pin);\n+  char buffer[2] = {0};\n+  buffer[0] = value ? '1' : '0';\n \n-  if (ReadPin(req_data->pin, &req_data->value)) {\n+  if (GpioOpenWriteClose(value_path, buffer)) {\n     req_data->result = kGpioErrOk;\n   } else {\n     req_data->result = kGpioErrSys;\n   }\n }\n \n \n-void SetPortWorker(uv_work_t* work_req) {\n-  GpioLinuxGeneral* gpio = GpioLinuxGeneral::GetInstance();\n-  IOTJS_ASSERT(gpio->_initialized == true);\n-\n-  GpioReqWrap* gpio_req = reinterpret_cast<GpioReqWrap*>(work_req->data);\n-  GpioReqData* req_data = gpio_req->req();\n-\n-  DDDLOG(\"GPIO SetPortWorker() - port: %d, dir: %d, mode: %d\",\n-         req_data->pin, req_data->dir, req_data->mode);\n-\n-  int32_t pin = req_data->pin * 8;\n-\n-  if (req_data->dir == kGpioDirectionNone) {\n-    for (int offset = 0; offset < 8; offset++) {\n-      // Unexport GPIO pin.\n-      if (!UnexportPin(pin + offset)) {\n-        req_data->result = kGpioErrSys;\n-        return;\n-      }\n-    }\n-  } else {\n-    for (int offset = 0; offset < 8; offset++) {\n-      // Export GPIO pin.\n-      if (!ExportPin(pin + offset)) {\n-        req_data->result = kGpioErrSys;\n-        return;\n-      }\n-      // Set direction.\n-      if (!SetPinDirection(pin + offset, req_data->dir)) {\n-        req_data->result = kGpioErrSys;\n-        return;\n-      }\n-      // Set mode.\n-      if (!SetPinMode(pin + offset, req_data->mode)) {\n-        req_data->result = kGpioErrSys;\n-        return;\n-      }\n-    }\n-  }\n-\n-  req_data->result = kGpioErrOk;\n-}\n-\n-\n-void WritePortWorker(uv_work_t* work_req) {\n+void ReadGpioWorker(uv_work_t* work_req) {\n   GpioLinuxGeneral* gpio = GpioLinuxGeneral::GetInstance();\n   IOTJS_ASSERT(gpio->_initialized == true);\n \n   GpioReqWrap* gpio_req = reinterpret_cast<GpioReqWrap*>(work_req->data);\n   GpioReqData* req_data = gpio_req->req();\n \n-  DDDLOG(\"GPIO WritePortWorker() - pin: %d, value: %d\",\n-         req_data->pin, req_data->value);\n-\n-  int32_t pin = req_data->pin * 8;\n+  uint32_t pin = req_data->pin;\n \n-  for (int offset = 0; offset < 8; offset++) {\n-    if (!WritePin(pin + offset, req_data->value & (1 << offset))) {\n-      req_data->result = kGpioErrSys;\n-      return;\n-    }\n-  }\n+  DDDLOG(\"GPIO ReadGpioWorker() - pin: %d\" ,pin);\n \n-  req_data->result = kGpioErrOk;\n-}\n-\n-\n-void ReadPortWorker(uv_work_t* work_req) {\n-  GpioLinuxGeneral* gpio = GpioLinuxGeneral::GetInstance();\n-  IOTJS_ASSERT(gpio->_initialized == true);\n-\n-  GpioReqWrap* gpio_req = reinterpret_cast<GpioReqWrap*>(work_req->data);\n-  GpioReqData* req_data = gpio_req->req();\n-\n-  DDDLOG(\"GPIO ReadPortWorker() - port: %d\" ,req_data->pin);\n-\n-  req_data->value = 0x00;\n-  int32_t pin = req_data->pin * 8;\n-  int32_t value = 0;\n+  char value_path[64] = {0};\n+  snprintf(value_path, 63, GPIO_PIN_FORMAT_VALUE, pin);\n \n-  for (int offset = 0; offset < 8; offset++) {\n-    if (!ReadPin(pin + offset, &value)) {\n-      req_data->result = kGpioErrSys;\n-      return;\n-    }\n-    if (value) req_data->value |= (1 << offset);\n+  char buffer[10] = {0};","path":"src/platform/iotjs_module_gpio-linux-general.inl.h","position":null,"original_position":390,"commit_id":"116a1d75c5cf4eb0d78179165bd17158d1d30ec0","original_commit_id":"801878d410278528a36de7e02d7d39fc5f43e1ff","user":{"login":"hs0225","id":18204719,"avatar_url":"https://avatars.githubusercontent.com/u/18204719?v=3","gravatar_id":"","url":"https://api.github.com/users/hs0225","html_url":"https://github.com/hs0225","followers_url":"https://api.github.com/users/hs0225/followers","following_url":"https://api.github.com/users/hs0225/following{/other_user}","gists_url":"https://api.github.com/users/hs0225/gists{/gist_id}","starred_url":"https://api.github.com/users/hs0225/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hs0225/subscriptions","organizations_url":"https://api.github.com/users/hs0225/orgs","repos_url":"https://api.github.com/users/hs0225/repos","events_url":"https://api.github.com/users/hs0225/events{/privacy}","received_events_url":"https://api.github.com/users/hs0225/received_events","type":"User","site_admin":false},"body":"I fixed it.","created_at":"2016-11-10T09:00:18Z","updated_at":"2016-11-10T09:00:18Z","html_url":"https://github.com/Samsung/iotjs/pull/519#discussion_r87352036","pull_request_url":"https://api.github.com/repos/Samsung/iotjs/pulls/519","_links":{"self":{"href":"https://api.github.com/repos/Samsung/iotjs/pulls/comments/87352036"},"html":{"href":"https://github.com/Samsung/iotjs/pull/519#discussion_r87352036"},"pull_request":{"href":"https://api.github.com/repos/Samsung/iotjs/pulls/519"}}},"pull_request":{"url":"https://api.github.com/repos/Samsung/iotjs/pulls/519","id":92929921,"html_url":"https://github.com/Samsung/iotjs/pull/519","diff_url":"https://github.com/Samsung/iotjs/pull/519.diff","patch_url":"https://github.com/Samsung/iotjs/pull/519.patch","issue_url":"https://api.github.com/repos/Samsung/iotjs/issues/519","number":519,"state":"open","locked":false,"title":"Rearrange GPIO API","user":{"login":"hs0225","id":18204719,"avatar_url":"https://avatars.githubusercontent.com/u/18204719?v=3","gravatar_id":"","url":"https://api.github.com/users/hs0225","html_url":"https://github.com/hs0225","followers_url":"https://api.github.com/users/hs0225/followers","following_url":"https://api.github.com/users/hs0225/following{/other_user}","gists_url":"https://api.github.com/users/hs0225/gists{/gist_id}","starred_url":"https://api.github.com/users/hs0225/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hs0225/subscriptions","organizations_url":"https://api.github.com/users/hs0225/orgs","repos_url":"https://api.github.com/users/hs0225/repos","events_url":"https://api.github.com/users/hs0225/events{/privacy}","received_events_url":"https://api.github.com/users/hs0225/received_events","type":"User","site_admin":false},"body":"- rename Gpio API\r\n  setPin -> open, writePin -> write, readPin -> read\r\n- delete port API\r\n- delete pin limit (related issues : https://github.com/Samsung/iotjs/issues/341)\r\n\r\nIoT.js-DCO-1.0-Signed-off-by: Hosung Kim hs852.kim@samsung.com","created_at":"2016-11-09T09:35:39Z","updated_at":"2016-11-10T09:00:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e60c750047036381ad6397e4126e0d6e622664f6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Samsung/iotjs/pulls/519/commits","review_comments_url":"https://api.github.com/repos/Samsung/iotjs/pulls/519/comments","review_comment_url":"https://api.github.com/repos/Samsung/iotjs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Samsung/iotjs/issues/519/comments","statuses_url":"https://api.github.com/repos/Samsung/iotjs/statuses/116a1d75c5cf4eb0d78179165bd17158d1d30ec0","head":{"label":"hs0225:GpioApiArrangement","ref":"GpioApiArrangement","sha":"116a1d75c5cf4eb0d78179165bd17158d1d30ec0","user":{"login":"hs0225","id":18204719,"avatar_url":"https://avatars.githubusercontent.com/u/18204719?v=3","gravatar_id":"","url":"https://api.github.com/users/hs0225","html_url":"https://github.com/hs0225","followers_url":"https://api.github.com/users/hs0225/followers","following_url":"https://api.github.com/users/hs0225/following{/other_user}","gists_url":"https://api.github.com/users/hs0225/gists{/gist_id}","starred_url":"https://api.github.com/users/hs0225/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hs0225/subscriptions","organizations_url":"https://api.github.com/users/hs0225/orgs","repos_url":"https://api.github.com/users/hs0225/repos","events_url":"https://api.github.com/users/hs0225/events{/privacy}","received_events_url":"https://api.github.com/users/hs0225/received_events","type":"User","site_admin":false},"repo":{"id":67200789,"name":"iotjs","full_name":"hs0225/iotjs","owner":{"login":"hs0225","id":18204719,"avatar_url":"https://avatars.githubusercontent.com/u/18204719?v=3","gravatar_id":"","url":"https://api.github.com/users/hs0225","html_url":"https://github.com/hs0225","followers_url":"https://api.github.com/users/hs0225/followers","following_url":"https://api.github.com/users/hs0225/following{/other_user}","gists_url":"https://api.github.com/users/hs0225/gists{/gist_id}","starred_url":"https://api.github.com/users/hs0225/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hs0225/subscriptions","organizations_url":"https://api.github.com/users/hs0225/orgs","repos_url":"https://api.github.com/users/hs0225/repos","events_url":"https://api.github.com/users/hs0225/events{/privacy}","received_events_url":"https://api.github.com/users/hs0225/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hs0225/iotjs","description":"Platform for Internet of Things with JavaScript http://www.iotjs.net ","fork":true,"url":"https://api.github.com/repos/hs0225/iotjs","forks_url":"https://api.github.com/repos/hs0225/iotjs/forks","keys_url":"https://api.github.com/repos/hs0225/iotjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hs0225/iotjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hs0225/iotjs/teams","hooks_url":"https://api.github.com/repos/hs0225/iotjs/hooks","issue_events_url":"https://api.github.com/repos/hs0225/iotjs/issues/events{/number}","events_url":"https://api.github.com/repos/hs0225/iotjs/events","assignees_url":"https://api.github.com/repos/hs0225/iotjs/assignees{/user}","branches_url":"https://api.github.com/repos/hs0225/iotjs/branches{/branch}","tags_url":"https://api.github.com/repos/hs0225/iotjs/tags","blobs_url":"https://api.github.com/repos/hs0225/iotjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hs0225/iotjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hs0225/iotjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/hs0225/iotjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hs0225/iotjs/statuses/{sha}","languages_url":"https://api.github.com/repos/hs0225/iotjs/languages","stargazers_url":"https://api.github.com/repos/hs0225/iotjs/stargazers","contributors_url":"https://api.github.com/repos/hs0225/iotjs/contributors","subscribers_url":"https://api.github.com/repos/hs0225/iotjs/subscribers","subscription_url":"https://api.github.com/repos/hs0225/iotjs/subscription","commits_url":"https://api.github.com/repos/hs0225/iotjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/hs0225/iotjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/hs0225/iotjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/hs0225/iotjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/hs0225/iotjs/contents/{+path}","compare_url":"https://api.github.com/repos/hs0225/iotjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hs0225/iotjs/merges","archive_url":"https://api.github.com/repos/hs0225/iotjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hs0225/iotjs/downloads","issues_url":"https://api.github.com/repos/hs0225/iotjs/issues{/number}","pulls_url":"https://api.github.com/repos/hs0225/iotjs/pulls{/number}","milestones_url":"https://api.github.com/repos/hs0225/iotjs/milestones{/number}","notifications_url":"https://api.github.com/repos/hs0225/iotjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hs0225/iotjs/labels{/name}","releases_url":"https://api.github.com/repos/hs0225/iotjs/releases{/id}","deployments_url":"https://api.github.com/repos/hs0225/iotjs/deployments","created_at":"2016-09-02T07:29:57Z","updated_at":"2016-09-02T07:30:00Z","pushed_at":"2016-11-10T08:55:36Z","git_url":"git://github.com/hs0225/iotjs.git","ssh_url":"git@github.com:hs0225/iotjs.git","clone_url":"https://github.com/hs0225/iotjs.git","svn_url":"https://github.com/hs0225/iotjs","homepage":"","size":2073,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Samsung:master","ref":"master","sha":"d629a3edf21ed476df3527a977be13350bd69b93","user":{"login":"Samsung","id":6210390,"avatar_url":"https://avatars.githubusercontent.com/u/6210390?v=3","gravatar_id":"","url":"https://api.github.com/users/Samsung","html_url":"https://github.com/Samsung","followers_url":"https://api.github.com/users/Samsung/followers","following_url":"https://api.github.com/users/Samsung/following{/other_user}","gists_url":"https://api.github.com/users/Samsung/gists{/gist_id}","starred_url":"https://api.github.com/users/Samsung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Samsung/subscriptions","organizations_url":"https://api.github.com/users/Samsung/orgs","repos_url":"https://api.github.com/users/Samsung/repos","events_url":"https://api.github.com/users/Samsung/events{/privacy}","received_events_url":"https://api.github.com/users/Samsung/received_events","type":"Organization","site_admin":false},"repo":{"id":33589470,"name":"iotjs","full_name":"Samsung/iotjs","owner":{"login":"Samsung","id":6210390,"avatar_url":"https://avatars.githubusercontent.com/u/6210390?v=3","gravatar_id":"","url":"https://api.github.com/users/Samsung","html_url":"https://github.com/Samsung","followers_url":"https://api.github.com/users/Samsung/followers","following_url":"https://api.github.com/users/Samsung/following{/other_user}","gists_url":"https://api.github.com/users/Samsung/gists{/gist_id}","starred_url":"https://api.github.com/users/Samsung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Samsung/subscriptions","organizations_url":"https://api.github.com/users/Samsung/orgs","repos_url":"https://api.github.com/users/Samsung/repos","events_url":"https://api.github.com/users/Samsung/events{/privacy}","received_events_url":"https://api.github.com/users/Samsung/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Samsung/iotjs","description":"Platform for Internet of Things with JavaScript http://www.iotjs.net ","fork":false,"url":"https://api.github.com/repos/Samsung/iotjs","forks_url":"https://api.github.com/repos/Samsung/iotjs/forks","keys_url":"https://api.github.com/repos/Samsung/iotjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Samsung/iotjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Samsung/iotjs/teams","hooks_url":"https://api.github.com/repos/Samsung/iotjs/hooks","issue_events_url":"https://api.github.com/repos/Samsung/iotjs/issues/events{/number}","events_url":"https://api.github.com/repos/Samsung/iotjs/events","assignees_url":"https://api.github.com/repos/Samsung/iotjs/assignees{/user}","branches_url":"https://api.github.com/repos/Samsung/iotjs/branches{/branch}","tags_url":"https://api.github.com/repos/Samsung/iotjs/tags","blobs_url":"https://api.github.com/repos/Samsung/iotjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Samsung/iotjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Samsung/iotjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/Samsung/iotjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Samsung/iotjs/statuses/{sha}","languages_url":"https://api.github.com/repos/Samsung/iotjs/languages","stargazers_url":"https://api.github.com/repos/Samsung/iotjs/stargazers","contributors_url":"https://api.github.com/repos/Samsung/iotjs/contributors","subscribers_url":"https://api.github.com/repos/Samsung/iotjs/subscribers","subscription_url":"https://api.github.com/repos/Samsung/iotjs/subscription","commits_url":"https://api.github.com/repos/Samsung/iotjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/Samsung/iotjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/Samsung/iotjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/Samsung/iotjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/Samsung/iotjs/contents/{+path}","compare_url":"https://api.github.com/repos/Samsung/iotjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Samsung/iotjs/merges","archive_url":"https://api.github.com/repos/Samsung/iotjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Samsung/iotjs/downloads","issues_url":"https://api.github.com/repos/Samsung/iotjs/issues{/number}","pulls_url":"https://api.github.com/repos/Samsung/iotjs/pulls{/number}","milestones_url":"https://api.github.com/repos/Samsung/iotjs/milestones{/number}","notifications_url":"https://api.github.com/repos/Samsung/iotjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Samsung/iotjs/labels{/name}","releases_url":"https://api.github.com/repos/Samsung/iotjs/releases{/id}","deployments_url":"https://api.github.com/repos/Samsung/iotjs/deployments","created_at":"2015-04-08T06:41:39Z","updated_at":"2016-11-10T08:52:31Z","pushed_at":"2016-11-10T08:55:37Z","git_url":"git://github.com/Samsung/iotjs.git","ssh_url":"git@github.com:Samsung/iotjs.git","clone_url":"https://github.com/Samsung/iotjs.git","svn_url":"https://github.com/Samsung/iotjs","homepage":"","size":2343,"stargazers_count":1099,"watchers_count":1099,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":165,"mirror_url":null,"open_issues_count":28,"forks":165,"open_issues":28,"watchers":1099,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Samsung/iotjs/pulls/519"},"html":{"href":"https://github.com/Samsung/iotjs/pull/519"},"issue":{"href":"https://api.github.com/repos/Samsung/iotjs/issues/519"},"comments":{"href":"https://api.github.com/repos/Samsung/iotjs/issues/519/comments"},"review_comments":{"href":"https://api.github.com/repos/Samsung/iotjs/pulls/519/comments"},"review_comment":{"href":"https://api.github.com/repos/Samsung/iotjs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Samsung/iotjs/pulls/519/commits"},"statuses":{"href":"https://api.github.com/repos/Samsung/iotjs/statuses/116a1d75c5cf4eb0d78179165bd17158d1d30ec0"}}}}
{"actor":{"display_login":"hs0225"}}