{"action":"created","comment":{"url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/pulls/comments/64453346","id":64453346,"diff_hunk":"@@ -77,7 +77,14 @@ void EIO_Open(uv_work_t* req) {\n   }\n \n   DCB dcb = { 0 };\n+  SecureZeroMemory(&dcb, sizeof(DCB));\n   dcb.DCBlength = sizeof(DCB);\n+  \n+  if (!GetCommState(file, &dcb)) {\n+\tprintf(\"error getting comm state\");","path":"src/serialport_win.cpp","position":8,"original_position":8,"commit_id":"0360db7360cd88fa1b945452e4e0032cf7f1f097","original_commit_id":"0360db7360cd88fa1b945452e4e0032cf7f1f097","user":{"login":"reconbot","id":25966,"avatar_url":"https://avatars.githubusercontent.com/u/25966?v=3","gravatar_id":"","url":"https://api.github.com/users/reconbot","html_url":"https://github.com/reconbot","followers_url":"https://api.github.com/users/reconbot/followers","following_url":"https://api.github.com/users/reconbot/following{/other_user}","gists_url":"https://api.github.com/users/reconbot/gists{/gist_id}","starred_url":"https://api.github.com/users/reconbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reconbot/subscriptions","organizations_url":"https://api.github.com/users/reconbot/orgs","repos_url":"https://api.github.com/users/reconbot/repos","events_url":"https://api.github.com/users/reconbot/events{/privacy}","received_events_url":"https://api.github.com/users/reconbot/received_events","type":"User","site_admin":false},"body":"Line 129 has a good example.","created_at":"2016-05-24T18:56:21Z","updated_at":"2016-05-24T18:56:21Z","html_url":"https://github.com/EmergingTechnologyAdvisors/node-serialport/pull/824#discussion_r64453346","pull_request_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/pulls/824","_links":{"self":{"href":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/pulls/comments/64453346"},"html":{"href":"https://github.com/EmergingTechnologyAdvisors/node-serialport/pull/824#discussion_r64453346"},"pull_request":{"href":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/pulls/824"}}},"pull_request":{"url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/pulls/824","id":71268574,"html_url":"https://github.com/EmergingTechnologyAdvisors/node-serialport/pull/824","diff_url":"https://github.com/EmergingTechnologyAdvisors/node-serialport/pull/824.diff","patch_url":"https://github.com/EmergingTechnologyAdvisors/node-serialport/pull/824.patch","issue_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/issues/824","number":824,"state":"open","locked":false,"title":"Add GetCommState to fix Error 87 on a Virtual Comm Port","user":{"login":"RogerHardiman","id":10171169,"avatar_url":"https://avatars.githubusercontent.com/u/10171169?v=3","gravatar_id":"","url":"https://api.github.com/users/RogerHardiman","html_url":"https://github.com/RogerHardiman","followers_url":"https://api.github.com/users/RogerHardiman/followers","following_url":"https://api.github.com/users/RogerHardiman/following{/other_user}","gists_url":"https://api.github.com/users/RogerHardiman/gists{/gist_id}","starred_url":"https://api.github.com/users/RogerHardiman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RogerHardiman/subscriptions","organizations_url":"https://api.github.com/users/RogerHardiman/orgs","repos_url":"https://api.github.com/users/RogerHardiman/repos","events_url":"https://api.github.com/users/RogerHardiman/events{/privacy}","received_events_url":"https://api.github.com/users/RogerHardiman/received_events","type":"User","site_admin":false},"body":"I was getting Error Code 87 in SetCommState when using node-serialport on a Windows 10 laptop with a Virtual Comm Port but other Windows code I had would use the serial port correctly.\r\n\r\nOn checking the C++ code I noticed you were not reading the current DCB data structure from the serial port. This is a requirement of the Windows API and is shown in the example (taken from MSDN) below\r\n\r\nI added the GetCommState and this fixed my problem.\r\n\r\nRoger\r\n\r\n\r\nSample code from MSDN\r\n```\r\n#include <windows.h>\r\n#include <tchar.h>\r\n#include <stdio.h>\r\n\r\nvoid PrintCommState(DCB dcb)\r\n{\r\n    //  Print some of the DCB structure values\r\n    _tprintf( TEXT(\"\\nBaudRate = %d, ByteSize = %d, Parity = %d, StopBits = %d\\n\"), \r\n              dcb.BaudRate, \r\n              dcb.ByteSize, \r\n              dcb.Parity,\r\n              dcb.StopBits );\r\n}\r\n\r\n\r\nint _tmain( int argc, TCHAR *argv[] )\r\n{\r\n   DCB dcb;\r\n   HANDLE hCom;\r\n   BOOL fSuccess;\r\n   TCHAR *pcCommPort = TEXT(\"COM1\"); //  Most systems have a COM1 port\r\n\r\n   //  Open a handle to the specified com port.\r\n   hCom = CreateFile( pcCommPort,\r\n                      GENERIC_READ | GENERIC_WRITE,\r\n                      0,      //  must be opened with exclusive-access\r\n                      NULL,   //  default security attributes\r\n                      OPEN_EXISTING, //  must use OPEN_EXISTING\r\n                      0,      //  not overlapped I/O\r\n                      NULL ); //  hTemplate must be NULL for comm devices\r\n\r\n   if (hCom == INVALID_HANDLE_VALUE) \r\n   {\r\n       //  Handle the error.\r\n       printf (\"CreateFile failed with error %d.\\n\", GetLastError());\r\n       return (1);\r\n   }\r\n\r\n   //  Initialize the DCB structure.\r\n   SecureZeroMemory(&dcb, sizeof(DCB));\r\n   dcb.DCBlength = sizeof(DCB);\r\n\r\n   //  Build on the current configuration by first retrieving all current\r\n   //  settings.\r\n   fSuccess = GetCommState(hCom, &dcb);\r\n\r\n   if (!fSuccess) \r\n   {\r\n      //  Handle the error.\r\n      printf (\"GetCommState failed with error %d.\\n\", GetLastError());\r\n      return (2);\r\n   }\r\n\r\n   PrintCommState(dcb);       //  Output to console\r\n\r\n   //  Fill in some DCB values and set the com state: \r\n   //  57,600 bps, 8 data bits, no parity, and 1 stop bit.\r\n   dcb.BaudRate = CBR_57600;     //  baud rate\r\n   dcb.ByteSize = 8;             //  data size, xmit and rcv\r\n   dcb.Parity   = NOPARITY;      //  parity bit\r\n   dcb.StopBits = ONESTOPBIT;    //  stop bit\r\n\r\n   fSuccess = SetCommState(hCom, &dcb);\r\n\r\n   if (!fSuccess) \r\n   {\r\n      //  Handle the error.\r\n      printf (\"SetCommState failed with error %d.\\n\", GetLastError());\r\n      return (3);\r\n   }\r\n\r\n   //  Get the comm config again.\r\n   fSuccess = GetCommState(hCom, &dcb);\r\n\r\n   if (!fSuccess) \r\n   {\r\n      //  Handle the error.\r\n      printf (\"GetCommState failed with error %d.\\n\", GetLastError());\r\n      return (2);\r\n   }\r\n\r\n   PrintCommState(dcb);       //  Output to console\r\n\r\n   _tprintf (TEXT(\"Serial port %s successfully reconfigured.\\n\"), pcCommPort);\r\n   return (0);\r\n}\r\n\r\n```","created_at":"2016-05-24T18:22:18Z","updated_at":"2016-05-24T18:56:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3fd95f9caf75525bb964a878417ba1a1c0ed9df4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/pulls/824/commits","review_comments_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/pulls/824/comments","review_comment_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/pulls/comments{/number}","comments_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/issues/824/comments","statuses_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/statuses/0360db7360cd88fa1b945452e4e0032cf7f1f097","head":{"label":"RogerHardiman:master","ref":"master","sha":"0360db7360cd88fa1b945452e4e0032cf7f1f097","user":{"login":"RogerHardiman","id":10171169,"avatar_url":"https://avatars.githubusercontent.com/u/10171169?v=3","gravatar_id":"","url":"https://api.github.com/users/RogerHardiman","html_url":"https://github.com/RogerHardiman","followers_url":"https://api.github.com/users/RogerHardiman/followers","following_url":"https://api.github.com/users/RogerHardiman/following{/other_user}","gists_url":"https://api.github.com/users/RogerHardiman/gists{/gist_id}","starred_url":"https://api.github.com/users/RogerHardiman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RogerHardiman/subscriptions","organizations_url":"https://api.github.com/users/RogerHardiman/orgs","repos_url":"https://api.github.com/users/RogerHardiman/repos","events_url":"https://api.github.com/users/RogerHardiman/events{/privacy}","received_events_url":"https://api.github.com/users/RogerHardiman/received_events","type":"User","site_admin":false},"repo":{"id":59596890,"name":"node-serialport","full_name":"RogerHardiman/node-serialport","owner":{"login":"RogerHardiman","id":10171169,"avatar_url":"https://avatars.githubusercontent.com/u/10171169?v=3","gravatar_id":"","url":"https://api.github.com/users/RogerHardiman","html_url":"https://github.com/RogerHardiman","followers_url":"https://api.github.com/users/RogerHardiman/followers","following_url":"https://api.github.com/users/RogerHardiman/following{/other_user}","gists_url":"https://api.github.com/users/RogerHardiman/gists{/gist_id}","starred_url":"https://api.github.com/users/RogerHardiman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RogerHardiman/subscriptions","organizations_url":"https://api.github.com/users/RogerHardiman/orgs","repos_url":"https://api.github.com/users/RogerHardiman/repos","events_url":"https://api.github.com/users/RogerHardiman/events{/privacy}","received_events_url":"https://api.github.com/users/RogerHardiman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RogerHardiman/node-serialport","description":"Node.js package to access serial ports for reading and writing OR Welcome your robotic JavaScript overlords. Better yet, program them!","fork":true,"url":"https://api.github.com/repos/RogerHardiman/node-serialport","forks_url":"https://api.github.com/repos/RogerHardiman/node-serialport/forks","keys_url":"https://api.github.com/repos/RogerHardiman/node-serialport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RogerHardiman/node-serialport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RogerHardiman/node-serialport/teams","hooks_url":"https://api.github.com/repos/RogerHardiman/node-serialport/hooks","issue_events_url":"https://api.github.com/repos/RogerHardiman/node-serialport/issues/events{/number}","events_url":"https://api.github.com/repos/RogerHardiman/node-serialport/events","assignees_url":"https://api.github.com/repos/RogerHardiman/node-serialport/assignees{/user}","branches_url":"https://api.github.com/repos/RogerHardiman/node-serialport/branches{/branch}","tags_url":"https://api.github.com/repos/RogerHardiman/node-serialport/tags","blobs_url":"https://api.github.com/repos/RogerHardiman/node-serialport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RogerHardiman/node-serialport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RogerHardiman/node-serialport/git/refs{/sha}","trees_url":"https://api.github.com/repos/RogerHardiman/node-serialport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RogerHardiman/node-serialport/statuses/{sha}","languages_url":"https://api.github.com/repos/RogerHardiman/node-serialport/languages","stargazers_url":"https://api.github.com/repos/RogerHardiman/node-serialport/stargazers","contributors_url":"https://api.github.com/repos/RogerHardiman/node-serialport/contributors","subscribers_url":"https://api.github.com/repos/RogerHardiman/node-serialport/subscribers","subscription_url":"https://api.github.com/repos/RogerHardiman/node-serialport/subscription","commits_url":"https://api.github.com/repos/RogerHardiman/node-serialport/commits{/sha}","git_commits_url":"https://api.github.com/repos/RogerHardiman/node-serialport/git/commits{/sha}","comments_url":"https://api.github.com/repos/RogerHardiman/node-serialport/comments{/number}","issue_comment_url":"https://api.github.com/repos/RogerHardiman/node-serialport/issues/comments{/number}","contents_url":"https://api.github.com/repos/RogerHardiman/node-serialport/contents/{+path}","compare_url":"https://api.github.com/repos/RogerHardiman/node-serialport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RogerHardiman/node-serialport/merges","archive_url":"https://api.github.com/repos/RogerHardiman/node-serialport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RogerHardiman/node-serialport/downloads","issues_url":"https://api.github.com/repos/RogerHardiman/node-serialport/issues{/number}","pulls_url":"https://api.github.com/repos/RogerHardiman/node-serialport/pulls{/number}","milestones_url":"https://api.github.com/repos/RogerHardiman/node-serialport/milestones{/number}","notifications_url":"https://api.github.com/repos/RogerHardiman/node-serialport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RogerHardiman/node-serialport/labels{/name}","releases_url":"https://api.github.com/repos/RogerHardiman/node-serialport/releases{/id}","deployments_url":"https://api.github.com/repos/RogerHardiman/node-serialport/deployments","created_at":"2016-05-24T18:08:30Z","updated_at":"2016-05-24T18:08:32Z","pushed_at":"2016-05-24T18:15:35Z","git_url":"git://github.com/RogerHardiman/node-serialport.git","ssh_url":"git@github.com:RogerHardiman/node-serialport.git","clone_url":"https://github.com/RogerHardiman/node-serialport.git","svn_url":"https://github.com/RogerHardiman/node-serialport","homepage":"","size":1067,"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":"EmergingTechnologyAdvisors:master","ref":"master","sha":"079777b694a12a94d86e87d2ed4aa8ac7abdf126","user":{"login":"EmergingTechnologyAdvisors","id":8947774,"avatar_url":"https://avatars.githubusercontent.com/u/8947774?v=3","gravatar_id":"","url":"https://api.github.com/users/EmergingTechnologyAdvisors","html_url":"https://github.com/EmergingTechnologyAdvisors","followers_url":"https://api.github.com/users/EmergingTechnologyAdvisors/followers","following_url":"https://api.github.com/users/EmergingTechnologyAdvisors/following{/other_user}","gists_url":"https://api.github.com/users/EmergingTechnologyAdvisors/gists{/gist_id}","starred_url":"https://api.github.com/users/EmergingTechnologyAdvisors/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EmergingTechnologyAdvisors/subscriptions","organizations_url":"https://api.github.com/users/EmergingTechnologyAdvisors/orgs","repos_url":"https://api.github.com/users/EmergingTechnologyAdvisors/repos","events_url":"https://api.github.com/users/EmergingTechnologyAdvisors/events{/privacy}","received_events_url":"https://api.github.com/users/EmergingTechnologyAdvisors/received_events","type":"Organization","site_admin":false},"repo":{"id":893522,"name":"node-serialport","full_name":"EmergingTechnologyAdvisors/node-serialport","owner":{"login":"EmergingTechnologyAdvisors","id":8947774,"avatar_url":"https://avatars.githubusercontent.com/u/8947774?v=3","gravatar_id":"","url":"https://api.github.com/users/EmergingTechnologyAdvisors","html_url":"https://github.com/EmergingTechnologyAdvisors","followers_url":"https://api.github.com/users/EmergingTechnologyAdvisors/followers","following_url":"https://api.github.com/users/EmergingTechnologyAdvisors/following{/other_user}","gists_url":"https://api.github.com/users/EmergingTechnologyAdvisors/gists{/gist_id}","starred_url":"https://api.github.com/users/EmergingTechnologyAdvisors/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EmergingTechnologyAdvisors/subscriptions","organizations_url":"https://api.github.com/users/EmergingTechnologyAdvisors/orgs","repos_url":"https://api.github.com/users/EmergingTechnologyAdvisors/repos","events_url":"https://api.github.com/users/EmergingTechnologyAdvisors/events{/privacy}","received_events_url":"https://api.github.com/users/EmergingTechnologyAdvisors/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/EmergingTechnologyAdvisors/node-serialport","description":"Node.js package to access serial ports for reading and writing OR Welcome your robotic JavaScript overlords. Better yet, program them!","fork":false,"url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport","forks_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/forks","keys_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/teams","hooks_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/hooks","issue_events_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/issues/events{/number}","events_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/events","assignees_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/assignees{/user}","branches_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/branches{/branch}","tags_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/tags","blobs_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/git/refs{/sha}","trees_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/statuses/{sha}","languages_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/languages","stargazers_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/stargazers","contributors_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/contributors","subscribers_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/subscribers","subscription_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/subscription","commits_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/commits{/sha}","git_commits_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/git/commits{/sha}","comments_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/comments{/number}","issue_comment_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/issues/comments{/number}","contents_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/contents/{+path}","compare_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/merges","archive_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/downloads","issues_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/issues{/number}","pulls_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/pulls{/number}","milestones_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/milestones{/number}","notifications_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/labels{/name}","releases_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/releases{/id}","deployments_url":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/deployments","created_at":"2010-09-07T12:24:28Z","updated_at":"2016-05-24T06:35:24Z","pushed_at":"2016-05-24T18:22:18Z","git_url":"git://github.com/EmergingTechnologyAdvisors/node-serialport.git","ssh_url":"git@github.com:EmergingTechnologyAdvisors/node-serialport.git","clone_url":"https://github.com/EmergingTechnologyAdvisors/node-serialport.git","svn_url":"https://github.com/EmergingTechnologyAdvisors/node-serialport","homepage":"","size":1716,"stargazers_count":2188,"watchers_count":2188,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":484,"mirror_url":null,"open_issues_count":35,"forks":484,"open_issues":35,"watchers":2188,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/pulls/824"},"html":{"href":"https://github.com/EmergingTechnologyAdvisors/node-serialport/pull/824"},"issue":{"href":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/issues/824"},"comments":{"href":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/issues/824/comments"},"review_comments":{"href":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/pulls/824/comments"},"review_comment":{"href":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/pulls/824/commits"},"statuses":{"href":"https://api.github.com/repos/EmergingTechnologyAdvisors/node-serialport/statuses/0360db7360cd88fa1b945452e4e0032cf7f1f097"}}}}
{"actor":{"display_login":"reconbot"}}