{"id":5599,"date":"2014-04-03T21:36:21","date_gmt":"2014-04-03T21:36:21","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/03\/serial-comm-port-in-windows-remains-owned-after-closing-collection-of-common-programming-errors\/"},"modified":"2014-04-03T21:36:21","modified_gmt":"2014-04-03T21:36:21","slug":"serial-comm-port-in-windows-remains-owned-after-closing-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/03\/serial-comm-port-in-windows-remains-owned-after-closing-collection-of-common-programming-errors\/","title":{"rendered":"Serial COMM port in windows remains owned after closing-Collection of common programming errors"},"content":{"rendered":"<p>I have a problem with comm ports in JAVA. I&#8217;m using Java version, 1.5 because that version still have access to windows COMM ports (serials).<\/p>\n<p>The problem is that the command throws the exception:<\/p>\n<pre><code>javax.comm.PortInUseException: Port currently owned by Unknown Windows Application\n<\/code><\/pre>\n<p>The thing is that the application opens the comm port for the first time, then I close the comm when the user exits some window. But the user may return to that window, and therefore I try to open again the same port:<\/p>\n<p>I close with:<\/p>\n<pre><code>if (puertoSerie != null) {\n puertoSerie.removeEventListener();\npuertoSerie.close();\npuertoSerie = null;\n}\n<\/code><\/pre>\n<p>So I added a <code>PortOwnershipListener<\/code>:<\/p>\n<pre><code>idPuerto.addPortOwnershipListener(new MyResolver());\n<\/code><\/pre>\n<p>And the error says:<\/p>\n<pre><code>Somebody else has the port\nSomebody else has the port\n<\/code><\/pre>\n<p>That occurs when :<\/p>\n<pre><code>case PORT_OWNERSHIP_REQUESTED:\nif (owned) {\nSystem.out.println(\"Owned ... Somebody else has the port\");\n} else {\nSystem.out.println(\"Somebody else has the port\");\n}\n<\/code><\/pre>\n<p>Any Idea how to work around this?<br \/>\nBest Regards<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a problem with comm ports in JAVA. I&#8217;m using Java version, 1.5 because that version still have access to windows COMM ports (serials). The problem is that the command throws the exception: javax.comm.PortInUseException: Port currently owned by Unknown Windows Application The thing is that the application opens the comm port for the first [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5599","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5599"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5599\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}