Skip to content

Conversation

@pieterg
Copy link

@pieterg pieterg commented Apr 20, 2023

ReadWriteMultipleRegister support is not working, because the generated frame is incomplete.
The frame is created by ModbusMessageImpl.MessageFrame, which calls ModbusMessageImpl.ProtocolDataUnit internally, instead of the overridden ReadWriteMultipleRegisterRequest.ProtocolDataUnit.
By overriding ModbusMessageImpl.MessageFrame in ReadWriteMultipleRegisterRequest (duplicating the implementation, there might be a better solution), the generated ReadWriteMultipleRegister frame will be correct.
After fixing this, I found that the response is rejected, because ReadWriteMultipleRegisters was is not in the functionCode switch.

These commits result in working ReadWriteMultipleRegister support (tested with RTU)

pieterg added 3 commits April 20, 2023 14:49
so it can be overridden by classes which need to override ProtocolDataUnit
When using the base class MessageFrame implementation, it will call the base class ProtocolDataUnit, resulting in an invalid/incomplete message frame.
By overriding MessageFrame,  our overridden ProtocolDataUnit will be called instead.
ReadWriteMultipleRegisters response is the same as a ReadHoldingRegisters response
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

Successfully merging this pull request may close these issues.

1 participant