Closed Seba131 closed 1 month ago
Hi, you can use your self-managed SerialPort by doing the following:
var serialPort = new SerialPort("COM1")
{
DtrEnable = true,
RtsEnable = true
};
serialPort.Open();
client.Initialize(
new ModbusRtuSerialPort(serialPort),
ModbusEndianness.LittleEndian);
public ModbusRtuClient modbusRtu = new ModbusRtuClient();
modbusRtu.BaudRate = 9600;
itp...
If I already have the option modbusRtu.Connect("COM1");
then I won't select it anymore inSerialPort("COM1")
I am sorry, my example above missed the creation of the ModbusRtuClient
:
Here is a better sample now:
var serialPort = new SerialPort("COM1");
var client = new ModbusRtuClient();
client.Initialize(
new ModbusRtuSerialPort(serialPort),
ModbusEndianness.LittleEndian);
serialPort.Open();
serialPort.DtrEnable = true;
serialPort.RtsEnable = true;
As long as you have control over the instantiation of ModbusRtuClient
the code sample should work. Or do you encounter other problems I did no cover in my answer (I did not fully understand your last post so I am not sure)?
ok. It works.
Good morning, is there a chance to add support for RTS, DTR, CTS signals? They would be very helpful to me.