title: Writing to modbus with Jamod
body: <p>I came across with a curious situation when using jamod to write to modbus. Following read code works perfectly:</p>
  
  <pre><code>public static void main(String[] args) throws Exception {
     InetAddress address = InetAddress.getByName("host.somewhere");
     TCPMasterConnection connection = new TCPMasterConnection(address);
     connection.setPort(502);
     connection.connect();
     ReadMultipleRegistersRequest request = new ReadMultipleRegistersRequest(0, 1);
     ReadMultipleRegistersResponse response = (ReadMultipleRegistersResponse)
         executeTransaction(connection, request);
  }
  
  private static ModbusResponse executeTransaction(TCPMasterConnection connection,
           ModbusRequest request) 
           throws ModbusIOException, ModbusSlaveException, ModbusException {
     ModbusTCPTransaction transaction = new ModbusTCPTransaction(connection);
     transaction.setRequest(request);
     transaction.execute();
     return transaction.getResponse();
  }
  </code></pre>
  
  <p>But trying to write similar manner fails (Jamod tries 3 times, each times encounters SocketTimeoutException and finally throws ModbusException).</p>
  
  <pre><code>public static void main(String[] args) throws Exception {
      final InetAddress address = InetAddress.getByName("host.somewhere");
      final TCPMasterConnection connection = new TCPMasterConnection(address);
      connection.setPort(502);
      connection.connect();
      Register reg = new SimpleRegister(0);
      WriteMultipleRegistersRequest request = new WriteMultipleRegistersRequest(0,
          new Register[]{reg});
      executeTransaction(connection, request);
  }
  </code></pre>
  
  <p>Yes, I know that I am using multi-register versions of the request-objects, but device I'm working with only supports function codes 3 and 16.</p>
  
  <p>I also wrote raw-socket tester to write registers, and as far as I can see it works correctly. But it would be nice to use jamod in both situations.</p>
  
  <p>Does anyone have anyone experience using jamod and would that one be kind enough to tell what I'm doing wrong? This happens with both 1.1 and 1.2rc1 versions of jamod. Or is this possibly some vendor-specific situation?</p>