In 'general' a bit ago I had a problem where Emplode finds my serial port but Jemplode wont (
here)
Well, some digging later it turns out that javax.comm enumerates the serial ports on my XP box as COM3, COM4, COM1, COM2
COM3 and COM4 are USB ports.
For whatever reason the java.io.InputStream.read() returns 0 bytes (documented behaviour)
This is bad because the read() in LittleEndianInputStream loops by incrementing pos by bytesRead
Result: infinite loop and jemplode doesn't see my serial port.
Patch below fixes this and I can now see my Empeg on COM2 (from eclipse - yep it's CVS is pretty good isn't it
)
Index: src/com/inzyme/typeconv/LittleEndianInputStream.java
===================================================================
RCS file: /share/mirror/cvsstore/Jemplode/inzyme-core/src/com/inzyme/typeconv/LittleEndianInputStream.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 LittleEndianInputStream.java
--- src/com/inzyme/typeconv/LittleEndianInputStream.java 28 Oct 2003 17:16:04 -0000 1.1.1.1
+++ src/com/inzyme/typeconv/LittleEndianInputStream.java 30 Oct 2003 20:53:29 -0000
@@ -70,6 +70,8 @@
int bytesRead = read(_buffer, pos, _buffer.length - pos);
if (bytesRead == -1) {
throw new IOException("The connection to the device dropped while attemping to read data from it.");
+ } else if (bytesRead == 0) {
+ throw new IOException("The connection had no data to read");
} else {
pos += bytesRead;
}