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

There are differences between index of modbus server register array and index of modbus client register array #69

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

Comments

@aigefjk
Copy link

aigefjk commented Sep 9, 2021

When I test V5.5 library,I found there are differences between Modbus server register index and Modbus client register index.

Index of registers Modbus client class used is from 0 , while index of registers Modbus server class used is from 1.

e.g:

If you want to get value in holding register 0, you need pass index 0 to modbus client method but in modbus server method you must pass index 1 to the method.

public void WriteSingleRegister(int Addr, short Value)
{
MyServer.holdingRegisters.localArray[Addr + 1] = Value;
}

@Padanian
Copy link

Padanian commented Sep 9, 2021

For historical reasons, user reference numbers were expressed as decimal numbers with a starting offset of 1. However MODBUS uses the more natural software interpretation of an unsigned integer index starting at zero.

So a MODBUS message requesting the read of a register at offset 0 would return the value known to the application programmer as found in register 4:00001 (memory type 4 = output register, reference 00001).

@aigefjk
Copy link
Author

aigefjk commented Sep 9, 2021

For historical reasons, user reference numbers were expressed as decimal numbers with a starting offset of 1. However MODBUS uses the more natural software interpretation of an unsigned integer index starting at zero.

So a MODBUS message requesting the read of a register at offset 0 would return the value known to the application programmer as found in register 4:00001 (memory type 4 = output register, reference 00001).


Modbus client myClient.WriteSingleRegister(0, Value) update value in register 4:00001, but in modbus server localArray[1] presents 4:00001 , that not keep the same style.

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

2 participants