EasyModbusTCP.NET icon indicating copy to clipboard operation
EasyModbusTCP.NET copied to clipboard

Type of EasyModbus.ModbusServer.HoldingRegisters.localArray is not suitable

Open aigefjk opened this issue 4 years ago • 3 comments

public short[] localArray defined in EasyModbus.ModbusServer.HoldingRegisters, which is not suitable defined as a short[] type because sometimes we need to write a value bigger than 32767 (UInt16) to a single register. I suggest we could change short[] to int[] to solve this issue.

BTW, type of EasyModbus.ModbusServer.InputRegisters.localArray has the same issue! issue

aigefjk avatar Sep 09 '21 07:09 aigefjk

You shall use ushort, not int. Int is signed 32bit, while ushort is unsigned 16bit

Padanian avatar Sep 09 '21 08:09 Padanian

You shall use ushort, not int. Int is signed 32bit, while ushort is unsigned 16bit


Maybe you don't get what problem I met. I mean if Modbus server itself wants to update the holding registers by set its localArray, localArray whose type is short[] can not receive value greater than 32767 , value of ushort type also has the same problem.

aigefjk avatar Sep 09 '21 09:09 aigefjk

Each register is 1 word = 16 bits = 2 bytes and also has data address between 0000 and 270E. (https://www.simplymodbus.ca/FAQ.htm)

CJure avatar Oct 22 '21 18:10 CJure