• Recent
    • Tags
    • Popular
    • Register
    • Login
    1. Home
    2. pfau

    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 Mango 5 Documentation Website
    P
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    pfau

    @pfau

    0
    Reputation
    429
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    pfau Unfollow Follow

    Latest posts made by pfau

    • SetValue() and getValue() methods

      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.

      posted in Modbus4J general discussion
      P
      pfau
    • RE: SetValue() and getValue() methods

      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.

      posted in Modbus4J general discussion
      P
      pfau