Hi, I used Modbus4J for many time, no problem with "old" version still on sourceforge (based on RXTX library), tested hundreds of devices at different speeds, all is ok.
Just tried to upgrade to 2.0.4 with JSSC and found some problems so I did some tests with a Seneca Z-4AI analog input module using Modbus RTU over RS485 and a Trycom TRP-C08 USB to serial converter (PL2303 chipset) with latest 1.10 prolific drivers in Windows 7 64 bit. This is a setup I used really hundreds of times.
Most of the time this device didn't answer to my requests, same with a Socomec Diris A10, so I turned on my oscilloscope and captured waveforms on serial line.
9600 bps, original code (5 ms scale), no response from device:
[url=http://postimg.org/image/cuswdaplp/]
As you can see there's a lot of space between bits, consider that scale is 5x times than following image.
9600 bps, StreamTransport insted of StreamTransportCharSpaced (1 ms scale), response OK:
[url=http://postimg.org/image/idee3p6dz/]
Spacing is ok and device answered to my request.
Now testing at higher speeds begins.
38400 bps, original code (1 ms scale), no response from device:
[url=http://postimg.org/image/rzfmkyzjt/]
Still too much space between bits.
38400 bps, StreamTransport insted of StreamTransportCharSpaced (1 ms scale), no response from device:
[url=http://postimg.org/image/75h96q8t9/]
Still too much space between bits.
Looks like there's another problem.... I investigated and found that StreamTransport use write(byte[]) method of OutputStream but JsscSerialPortOutputStream doesn't override that method, so we are using OutputStream class method. Just created this method in JsscSerialPortOutputStream to be able to write complete buffer instead of one byte at a time (like StreamTransportCharSpaced do):
@Override
public void write(byte[] b) throws IOException {
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Writing bytes: " + StreamUtils.dumpHex(b, 0, b.length));
}
if ((port != null) && (port.isOpened())) {
port.writeBytes(b);
}
} catch (jssc.SerialPortException e) {
throw new IOException(e);
}
}
and result was OK ->
38400 bps, StreamTransport insted of StreamTransportCharSpaced, buffered write (200 us scale), response OK:
[url=http://postimg.org/image/91tx95dh5/]
Spacing is ok and device answered to my request.
Maybe at higher speeds we need to use internal UART buffer and writing all data in the same request is needed instead of writing byte by byte..
What do you think about these tests? Have you found any problem communicating with devices with the new version of Modbus4J?
Edit: Same tests as above with a Moschip 7840 based USB to serial converter shows same results.