package run;
import de.re.easymodbus.modbusclient.*;

public class run {
	public static void main(String[] args)
	{
		ModbusClient modbusClient = new ModbusClient("127.0.0.1",502);
		try
		{
			modbusClient.Connect();
			modbusClient.WriteSingleCoil(0, true);
			modbusClient.WriteSingleRegister(0, 1234);
			modbusClient.WriteMultipleRegisters(11, ModbusClient.ConvertFloatToTwoRegisters((float) 123.56));
			System.out.println(modbusClient.ReadCoils(0, 1)[0]);
			System.out.println(modbusClient.ReadHoldingRegisters(0, 1)[0]);
			System.out.println(ModbusClient.ConvertRegistersToFloat(modbusClient.ReadHoldingRegisters(11, 2)));
		}
		catch (Exception e)
		{		
		}	
	}
}

相关新闻

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

cloud@modbus.cn

QQ
微信