{"action":"created","issue":{"url":"https://api.github.com/repos/nyholku/purejavacomm/issues/106","repository_url":"https://api.github.com/repos/nyholku/purejavacomm","labels_url":"https://api.github.com/repos/nyholku/purejavacomm/issues/106/labels{/name}","comments_url":"https://api.github.com/repos/nyholku/purejavacomm/issues/106/comments","events_url":"https://api.github.com/repos/nyholku/purejavacomm/issues/106/events","html_url":"https://github.com/nyholku/purejavacomm/issues/106","id":306614032,"number":106,"title":"Non-responsive bluetooth serial port hangs application ","user":{"login":"GlennED","id":26574816,"avatar_url":"https://avatars1.githubusercontent.com/u/26574816?v=4","gravatar_id":"","url":"https://api.github.com/users/GlennED","html_url":"https://github.com/GlennED","followers_url":"https://api.github.com/users/GlennED/followers","following_url":"https://api.github.com/users/GlennED/following{/other_user}","gists_url":"https://api.github.com/users/GlennED/gists{/gist_id}","starred_url":"https://api.github.com/users/GlennED/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GlennED/subscriptions","organizations_url":"https://api.github.com/users/GlennED/orgs","repos_url":"https://api.github.com/users/GlennED/repos","events_url":"https://api.github.com/users/GlennED/events{/privacy}","received_events_url":"https://api.github.com/users/GlennED/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-19T20:04:51Z","updated_at":"2018-03-20T00:52:09Z","closed_at":null,"author_association":"NONE","body":"The following is a code snippet from the CommPortIdentifier class method open:\r\n\r\nif (info != null)\r\n\tport = info.m_Driver.getCommPort(m_PortName, info.m_PortType);\r\nelse\r\n\tport = new PureJavaSerialPort(m_PortName, timeout); // FIXME timeout here is not used\r\n\r\nThe following code snippet from the PureJavaSerialPort class:\r\n\r\n        PureJavaSerialPort(String name, int timeout) throws PortInUseException {\r\n\t\tsuper();\r\n\r\n\t\tboolean usepoll = false;\r\n\t\tif (JTermios.canPoll()) {\r\n\t\t\tString key1 = \"purejavacomm.use_poll\";\r\n\t\t\tString key2 = \"purejavacomm.usepoll\";\r\n\t\t\tif (System.getProperty(key1) != null) {\r\n\t\t\t\tusepoll = Boolean.getBoolean(key1);\r\n\t\t\t\tlog = log && log(1, \"use of '%s' is deprecated, use '%s' instead\\n\", key1, key2);\r\n\t\t\t} else if (System.getProperty(key2) != null)\r\n\t\t\t\tusepoll = Boolean.getBoolean(key2);\r\n\t\t\telse\r\n\t\t\t\tusepoll = true;\r\n\t\t}\r\n\t\tUSE_POLL = usepoll;\r\n\r\n\t\tRAW_READ_MODE = Boolean.getBoolean(\"purejavacomm.rawreadmode\");\r\n\r\n\t\tthis.name = name;\r\n\r\n\t\tint tries = (timeout + 5) / 10;\r\n\t\twhile ((m_FD = open(name, O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) {\r\n\t\t\tint errno = errno();\r\n\t\t\ttry {\r\n\t\t\t\tThread.sleep(10);\r\n\t\t\t} catch (InterruptedException e) {\r\n\t\t\t\te.printStackTrace();\r\n\t\t\t\tThread.currentThread().interrupt();\r\n\t\t\t}\r\n\t\t\tif (tries-- < 0)\r\n\t\t\t\tthrow new PortInUseException(\"Unknown Application\", errno);\r\n\t\t}\r\n\r\nIt appears that the \"timeout\" value is 3000 and this results in the \"tries\" to be 300. Since a bluetooth port does not respond when the bluetooth device is off it takes an extremely long time to return from the \"open\" method. The comment \"FIXME timeout here is not used\" suggests that the \"tries\" value can be passed as an argument instead of the \"timeout\" parameter.\r\n\r\nI will try this myself but if you know any reason why this is not a good idea please let me know. Thanks.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/nyholku/purejavacomm/issues/comments/374435138","html_url":"https://github.com/nyholku/purejavacomm/issues/106#issuecomment-374435138","issue_url":"https://api.github.com/repos/nyholku/purejavacomm/issues/106","id":374435138,"user":{"login":"johnstosh","id":1680027,"avatar_url":"https://avatars3.githubusercontent.com/u/1680027?v=4","gravatar_id":"","url":"https://api.github.com/users/johnstosh","html_url":"https://github.com/johnstosh","followers_url":"https://api.github.com/users/johnstosh/followers","following_url":"https://api.github.com/users/johnstosh/following{/other_user}","gists_url":"https://api.github.com/users/johnstosh/gists{/gist_id}","starred_url":"https://api.github.com/users/johnstosh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnstosh/subscriptions","organizations_url":"https://api.github.com/users/johnstosh/orgs","repos_url":"https://api.github.com/users/johnstosh/repos","events_url":"https://api.github.com/users/johnstosh/events{/privacy}","received_events_url":"https://api.github.com/users/johnstosh/received_events","type":"User","site_admin":false},"created_at":"2018-03-20T00:52:08Z","updated_at":"2018-03-20T00:52:08Z","author_association":"NONE","body":"FYI, the code can be changed to calculate the elapsed time instead of\nassuming that the open call takes zero time.\n\nI can write an example if that would explain better.\n\n\nOn Mon, Mar 19, 2018, 4:09 PM nyholku <notifications@github.com> wrote:\n\n> Hi,\n>\n> I think that comment is outdated as clearly 'timeout' is used in the code\n> to calculate 'tries'. I suggest you try timeout 0 this will get you timeout\n> after the first try fails which is probably what you want with bluetooth\n> devices.\n>\n> —\n> You are receiving this because you are subscribed to this thread.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/nyholku/purejavacomm/issues/106#issuecomment-374354866>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/ABmim483RiLmYrlMYDSpoIa3jiiIwXGpks5tgBCJgaJpZM4Sw0Jq>\n> .\n>\n"}}
{"actor":{"display_login":"johnstosh"}}