rossmann-engineering / EasyModbusTCP.NET

Modbus TCP, Modbus UDP and Modbus RTU client/server library for .NET implementations
922 stars 396 forks source link

Writing 32 bit value #78

Closed AlekseyHS closed 2 years ago

AlekseyHS commented 2 years ago

Is it possible to have write function like "Write Single Registry" but in int32 format? At the moment by analysing the code i notice even if there is a value type int, it is not an int32 but it is int16.

Padanian commented 2 years ago

No, there are no 32bit registers in modbus. If you need to write a 32bit int, it will be stored in two adjacent registers. For that, use public static int[] ConvertIntToRegisters(Int32 intValue). It will return an array of two 4-bytes arrays, the lowest two bytes of which contains your two 16bits register.

AlekseyHS commented 2 years ago

Ok thanks for the explanation