After a quick test, looks like Modbus4J is better maintained than Jamod, but they look very similar. Can someone list the benefits of using Modbus4j over the Jamod library?
A
Posts made by adaf
-
How does Modbus4J compare with Jamod library?
-
Modbus4J - Getting started
Hello,
I've evaluated Jamod and would like to evaluate and compare Modbus4J. Is there a "Getting Started" page? Some usage examples? I'm looking for a simple TCP/IP master code that runs function '2' to retrieve the value of a single bit from a given ip:port.
In Jamod, this looks something like (and I'm new to it):private void qTest() throws Exception { // Build a connection TCPMasterConnection con = new TCPMasterConnection(InetAddress.getByName(slaveIPAddr)); try { con.setPort(slavePort); con.connect(); // may throw an exception // Prepare a request final int bitIndex2read = 3; final int numBits2Read = 6; ReadInputDiscretesRequest request = new ReadInputDiscretesRequest(/*refRegister=*/0, numBits2Read); // Run a transaction (you can run as many as you like until you close the connection) ModbusTCPTransaction transaction = new ModbusTCPTransaction(con); transaction.setRequest(request); try { transaction.execute(); } catch (ModbusSlaveException e) { System.out.println("Got a Modbus error response with code "+e.getType()); e.printStackTrace(); } // Parse response ReadInputDiscretesResponse response = (ReadInputDiscretesResponse)transaction.getResponse(); boolean isOn = response.getDiscreteStatus(bitIndex2read); System.out.println("Digital Input @" + bitIndex2read + " is " + (isOn ? "On." : "Off.")); } finally { //6. Close the connection con.close(); } }
thanks,
-adaf.