Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Cannot find anything wrong with the code, but I can suggest some starting points for debugging:</p> <ul> <li><p>Try the same code with Sun's (errr.. Oracle's) javax.comm implementation. The Windows version is no longer available for download from their site, but it can still be found in other places. Even if you don't want to use this implementation in your final setup, it might help you find the problem. There are also other alternatives such as <a href="http://serialio.com/support/jspCommAPI.php" rel="nofollow noreferrer">SerialIO</a>.</p></li> <li><p>Use <a href="http://com0com.sourceforge.net/" rel="nofollow noreferrer">com0com</a> to install a virtual com port. Enable logging (see last question in the <a href="http://com0com.cvs.sourceforge.net/viewvc/com0com/com0com/ReadMe.txt?revision=RELEASED" rel="nofollow noreferrer">README.txt file</a>). Compare the logs when you use your code with the logs you get when using HyperTerminal, and look for any differences.</p></li> <li><p>Try a different serial -> USB converter. In my experience, many of these don't implement RS232 properly, or have plenty of bugs.</p></li> </ul> <p><strong>Edit:</strong></p> <p>If you discover that this is actually a rxtx bug, but for some reason don't want to switch to another javax.comm implementation (I've seen this happen :-) here are some additional hints that may be useful (I would try the above suggestions first anyway):</p> <ul> <li><p>Are the calls to <code>setInputBufferSize</code>, <code>setOutputBufferSize</code> required? Try removing them. Does the device actually use XON/XOFF flow control? If not, try setting flow control to none. Does the device require RTS disabled? If not, remove this line as well. Also, try to set the serial port params before opening the output stream. Of course, none of this should make any difference, but you might be triggering some rxtx bug.</p></li> <li><p>Is the problem related to opening and closing the port in sequence several times? You could try to keep the port always open. On each sale, just do:</p> <pre><code>outputStream.write("k".getBytes()); outputStream.flush(); </code></pre> <p>And see if the problem still reproduces.</p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload