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

Default block unit length is two bytes why? #154

Open
hxmwr opened this issue Jul 19, 2021 · 1 comment
Open

Default block unit length is two bytes why? #154

hxmwr opened this issue Jul 19, 2021 · 1 comment

Comments

@hxmwr
Copy link

hxmwr commented Jul 19, 2021

response += struct.pack(">"+fmt, reg)

Every block unit length must be 2 bytes, is this part of protocol or just convention for this project. If I have a UINT (4 bytes) value, I have to split it to 2 WORD and then store it in two block units (if not, struct.pack would failed when reading), when reading this value I have concat these two WORD and this is not so convient.

@blotsome
Copy link

blotsome commented Oct 4, 2021

In Modbus, Holding Registers and Input Registers are 16-bit (2 bytes) per register. This is a protocol convention. It is very common for 32-bit data to be stored in 2 registers, for example floating point or as you mentioned UINT32. There is no standard on which register goes first when decoding, which is why software like modscan32 allows you to select between MSR and LSR. It is a limitation of the protocol, but I guess something you get used to when working with modbus.

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