• M
    mdism

    Hi.
    I am trying this library, I have funded the test code in the src/Test
    I have added the code to fresh NetBeans project and import the Modbus4J library from the right side library import panel.
    but still its showing error in the code.
    I tried with alt+enter but it's not showing to import option.

    package modbustestlibrery;
    /**
     *
     * @author mdism
     */
    public class myModbus {
    
        /**
         * @param args the command line arguments
         */
            public static void main(String[] args) throws Exception {
                
         ModbusFactory factory = new ModbusFactory();
         IpParameters params = new IpParameters();
         params.setHost("localhost");
         params.setPort(12345);
         ModbusMaster master = factory.createTcpMaster(params, true, false);
         // master.setRetries(4);
         master.setRetries(0);
         try {
         master.init();
         master.getValue(1, RegisterRange.HOLDING_REGISTER, 0, DataType.TWO_BYTE_INT_UNSIGNED);
         }
         finally {
         master.destroy();
         }
         }
        
    }
    
    
    This is the error i am getting 
    
    Compiling 1 source file to D:\work\practice\Wifi\Java Test\ModbusTestLibrery\build\classes
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:19: error: cannot find symbol
         ModbusFactory factory = new ModbusFactory();
      symbol:   class ModbusFactory
      location: class myModbus
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:19: error: cannot find symbol
         ModbusFactory factory = new ModbusFactory();
      symbol:   class ModbusFactory
      location: class myModbus
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:20: error: cannot find symbol
         IpParameters params = new IpParameters();
      symbol:   class IpParameters
      location: class myModbus
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:20: error: cannot find symbol
         IpParameters params = new IpParameters();
      symbol:   class IpParameters
      location: class myModbus
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:23: error: cannot find symbol
         ModbusMaster master = factory.createTcpMaster(params, true, false);
      symbol:   class ModbusMaster
      location: class myModbus
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:28: error: cannot find symbol
         master.getValue(1, RegisterRange.HOLDING_REGISTER, 0, DataType.TWO_BYTE_INT_UNSIGNED);
      symbol:   variable RegisterRange
      location: class myModbus
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:28: error: cannot find symbol
         master.getValue(1, RegisterRange.HOLDING_REGISTER, 0, DataType.TWO_BYTE_INT_UNSIGNED);
      symbol:   variable DataType
      location: class myModbus
    7 errors
    

    1_1524135873781_Error2.png 0_1524135873775_Error1.png

    Please help.

    posted in Modbus4J general discussion read more