I'm happy for you to 'basically own it' - consider copyright assigned or whatever.
It takes quite a while to find the empeg too.
This is because this read blocks for 5 secs or so.
A check for myIS.available() >0 speeds up discovery a lot (30s->5s for me) -- *but* I guess this may be a problem if the serial port is slow?
public int read(byte[] _buffer) throws IOException {
int pos = 0;
while (pos < _buffer.length) {
if (myIS.available() >0) {
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 {
pos += bytesRead;
}
} else {
throw new IOException("The connection had no data to read");
}
}
return pos;
}
mmmm - I'm not sure I like it