Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aigefjk opened this issue Sep 9, 2021 · 3 comments

Comments

@aigefjk
Copy link

aigefjk commented Sep 9, 2021

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

@Padanian
Copy link

Padanian commented Sep 9, 2021

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

@aigefjk
Copy link
Author

aigefjk commented Sep 9, 2021

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.

@CJure
Copy link

CJure commented Oct 22, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants