Apollo3zehn / FluentModbus

Lightweight and fast client and server implementation of the Modbus protocol (TCP/RTU).
MIT License
218 stars 75 forks source link

Serial I/O #129

Open SY6502 opened 2 months ago

SY6502 commented 2 months ago

I found "ReadTimeout { get; set; } = 1000;" in ModbusRtuClient.cs. Is this 1s timeout the best value? I read in some device's Modbus docs that max timeout for response is 5 seconds. I am not sure is this the Modbus standard or specific timeout for this device.

I also see that default baud rate is 9600. Is this recommended speed? If devices support 115200, is there reason not to use it?

And one recommendation - it may be good to have method like RawRW. Instead of ReadHoldingRegisters or WriteSingleCoil, its parameters include byte array of whole command (without CRC for RTU). unitIdentifier can be included in command or sent as separate parameter.

Apollo3zehn commented 1 month ago

I found "ReadTimeout { get; set; } = 1000;" in ModbusRtuClient.cs. Is this 1s timeout the best value? I read in some device's Modbus docs that max timeout for response is 5 seconds. I am not sure is this the Modbus standard or specific timeout for this device.

I am not aware of any timeout mentioned in the specs. Could you point me to the document where the 5s timeout is mentioned?

I also see that default baud rate is 9600. Is this recommended speed? If devices support 115200, is there reason not to use it?

9600 is the default value of the underlying System.IO.Ports.SerialPort, so I just copied the default from Microsoft. Also, I've found that 9600 is a pretty common value for serial communication devices. You can change to 115200 if you need more speed, but the downside is that the higher the BAUD rate, the more susceptible the signal becomes to signal interference, and the need for proper cable shielding rises.

And one recommendation - it may be good to have method like RawRW. Instead of ReadHoldingRegisters or WriteSingleCoil, its parameters include byte array of whole command (without CRC for RTU). unitIdentifier can be included in command or sent as separate parameter.

Thanks, I will put it on my v6 TODO list.