feat: forward vendor function codes - #14
Merged
Merged
Conversation
mbproxy rejected any function code outside the eight standard ones with Illegal Function. Huawei SUN2000 installer login and optimizer file transfer use 0x41, so wlcrs/huawei_solar could not complete setup through the proxy. Unknown function codes are now forwarded as opaque PDUs. They are not cached and not retried. Read-only mode still applies only to the standard write codes. Fixes #13 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0649ac6f-b014-4168-82f9-d3e4eeeafdfc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #13. mbproxy used to reject any function code outside the eight standard ones with Illegal Function. That blocked Huawei SUN2000 installer login and optimizer file transfer, both of which use
0x41. wlcrs/huawei_solar needs that for setup.Weafdinstel confirmed the same failure after updates or configuration changes: setup has to go through another proxy first, then mbproxy can be used again.
Unknown function codes are now forwarded as opaque PDUs.
Behavior
0x0B.Read-only mode still applies only to
0x05,0x06,0x0F, and0x10.0x41is forwarded even whenMODBUS_READONLY=trueordeny, because we cannot invent a valid vendor response, and faking success would break login. If you use read-only as a safety interlock, vendor codes can still change device state.Cached
0x03/0x04values are left alone. If a vendor operation later changes register-mapped state, those values stay until TTL expiry. Huawei uses0x41as a separate channel, so I did not flush the cache.Testing
go fmt ./...go vet ./...go test -count=1 -race ./...ingolang:1.24Coverage includes Huawei
0x41parse/forward, missing PDU rejection, no cache invalidation, forward underreadonly=trueanddeny, no retry on transport failure, preserved vendor exceptions, and malformed vendor responses mapping to0x0B.