• V
    vijay chelliah

    I'm building a java modbus data acquisition system (using MODBUS4J), I've successfully communicated with the modbus device using its slave id, address, datatype.

    But is there a way to just detect slaves, by just addressing slaves from 0-255 without specific register or coil addresses? So, that slaves with matching slaveId's respond.

    posted in Modbus4J general discussion read more
  • V
    vijay chelliah

    wrapper.getInputStream is returning null.

    posted in Modbus4J general discussion read more
  • V
    vijay chelliah

    I've tested this code to detect a Modbus device ( was discovered by a discovery software) connected to my computer.
    but the code throw a null pointer Exception, can someone help me understand it.

    public class MasterTest {
    public static void main(String[] args) throws Exception {

    	String commPortId = "/dev/ttyUSB0";
    	int baudRate = 9600;
    	int flowControlIn = 0;
    	int flowControlOut = 0;
    	int dataBits = 0;
    	int stopBits = 0;
    	int parity = 1;
    	TestSerialPortWrapper wrapper = new TestSerialPortWrapper(commPortId, baudRate, flowControlIn, flowControlOut, dataBits, stopBits, parity);
        IpParameters ipParameters = new IpParameters();
        ModbusFactory modbusFactory = new ModbusFactory();
         ModbusMaster master = modbusFactory.createRtuMaster(wrapper);
        try {
            int slaveId = 2;
          BaseLocator<Number> locator = BaseLocator.holdingRegister(slaveId, 50, DataType.EIGHT_BYTE_INT_UNSIGNED);
            master.setValue(locator, 10000000);
        finally {

    posted in Modbus4J general discussion read more
  • V
    vijay chelliah

    I want to develop a JAVA code using MODBUS4J which should discover and read data from modbus controllers present in its network.

    Is there a feature like autodiscovery in modbus like that of bacnet?

    I have a doubt if my code should be a master or slave?

    if master can a network have multiple masters? for network might have a plc or a master modbus controller.

    if a slave can a slave communicate with a master to get all data?

    posted in Modbus4J general discussion read more