Note that there are some explanatory texts on larger screens.

plurals
  1. POIssues receiving in RXTX
    primarykey
    data
    text
    <p>I've been using RXTX for about a year now, without too many problems. I just started a new program to interact with a new piece of hardware, so I reused the connect() method I've used on my other projects, but I have a weird problem I've never seen before. </p> <p><strong>The Problem</strong></p> <p>The device works fine, because when I connect with HyperTerminal, I send things and receive what I expect, and <a href="http://www.serial-port-monitor.com/" rel="nofollow noreferrer">Serial Port Monitor</a>(SPM) reflects this. </p> <p>However, when I run the simple HyperTerminal-clone I wrote to diagnose the problem I'm having with my main app, bytes are sent, according to SPM, but nothing is received, and my SerialPortEventListener never fires. Even when I check for available data in the main loop, <code>reader.ready()</code> returns <code>false</code>. If I ignore this check, then I get an exception, details below.</p> <p><strong>Relevant section of connect() method</strong></p> <pre><code>// Configure and open port port = (SerialPort) CommPortIdentifier.getPortIdentifier(name) .open(owner,1000) port.setSerialPortParams(baud, databits, stopbits, parity); port.setFlowControlMode(fc_mode); final BufferedReader br = new BufferedReader( new InputStreamReader( port.getInputStream(), "US-ASCII")); // Add listener to print received characters to screen port.addEventListener(new SerialPortEventListener(){ public void serialEvent(SerialPortEvent ev) { try { System.out.println("Received: "+br.readLine()); } catch (IOException e) { e.printStackTrace(); } } }); port.notifyOnDataAvailable(); </code></pre> <p><strong>Exception</strong></p> <pre><code>java.io.IOException: Underlying input stream returned zero bytes at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:268) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158) at java.io.InputStreamReader.read(InputStreamReader.java:167) at java.io.BufferedReader.fill(BufferedReader.java:136) at java.io.BufferedReader.read(BufferedReader.java:157) at &lt;my code&gt; </code></pre> <p><strong>The big question (again)</strong></p> <p>I think I've eliminated all possible hardware problems, so what could be wrong with my code, or the RXTX library? </p> <p><strong>Edit: something interesting</strong></p> <p>When I open HyperTerminal after sending a bunch of commands from java that should have gotten responses, all of the responses appear immediately, as if they had been put in the buffer somewhere, but unavailable.</p> <p><strong>Edit 2: Tried something new, same results</strong></p> <p>I ran the code example found <a href="http://rxtx.qbang.org/wiki/index.php/Two_way_communcation_with_the_serial_port" rel="nofollow noreferrer">here</a>, with the same results. No data came in, but when I switched to a new program, it came all at once.</p> <p><strong>Edit 3</strong></p> <p>The hardware is fine, and even a different computer has the same problem. I am not using any sort of USB adapter.</p> <p>I've started using <a href="http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx" rel="nofollow noreferrer">PortMon</a>, too, and it's giving me some interesting results. HyperTerminal and RXTX are not using the same settings, and RXTX always polls the port, unlike HyperTerminal, but I still can't see what settings would affect this. As soon as I can isolate the configuration from the constant polling, I'll post my PortMon logs.</p> <p><strong>Edit 4</strong></p> <p>Is it possible that some sort of Windows update in the last 3 months could have caused this? It has screwed up one of my MATLAB mex-based programs once.</p> <p><strong>Edit 5</strong></p> <p>I've also noticed some things that are different between HyperTerminal, RXTX, and a separate program I found that communicates with the device (but doesn't do what I want, which is why I'm rolling my own program)</p> <ul> <li>HyperTerminal - set to no flow control, but Serial Port Monitor's RTS and DTR indicators are green</li> <li>Other program - not sure what settings it thinks it's using, but only SPM's RTS indicator is green</li> <li>RXTX - no matter what flow control I set, only SPM's CTS and DTR indicators are on.</li> </ul> <p>From Serial Port Monitor's help files (paraphrased): </p> <pre><code>the indicators display the state of the serial control lines RTS - Request To Send CTS - Clear To Send DTR - Data Terminal Ready </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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