Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

  • I'm trying to read and write to a PLC via a gateway using modbus4j. I've gotten the read function to work, but I'm not getting anywhere on the setValue() method. I've tried various variations of this:

    
    IpParameters params = new IpParameters();
    params.setHost("192.168.0.100");
    params.setPort(502);
    
    //create modbus TCP master
    ModbusMaster master = new ModbusFactory().createTcpMaster(params, false);
    master.init();
    
    int regValue=0;
    regValue = regValue | 1 << 0;
    ModbusLocator loc0 = new ModbusLocator(1,RegisterRange.HOLDING_REGISTER,0,DataType.TWO_BYTE_INT_UNSIGNED);
    master.setValue(loc0,8);
    
    

    Also the getValue() method only works sporadically maybe 30% of the time I call getValue() I get the response I expect, and the other times I get all 0s out.

    System.out.println(master.getValue(33,RegisterRange.HOLDING_REGISTER,70,2));
    

    Am I misunderstanding some aspect of the get and set value methods? Thanks.