feat: session password set/clear for password-protected PLCs (#792) - #799
Open
gijzelaerr wants to merge 1 commit into
Open
feat: session password set/clear for password-protected PLCs (#792)#799gijzelaerr wants to merge 1 commit into
gijzelaerr wants to merge 1 commit into
Conversation
Add set_session_password() and clear_session_password() to both the sync Client and async AsyncClient. These send real S7 USERDATA PDUs (function group 5 / Security) to unlock password-protected PLCs, replacing the old no-op stubs in ClientMixin. The password encoding matches the Sharp7/rs-snap7 wire format: XOR each byte with 0x55, then rotate left by 3 bits, padded to 8 bytes.
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
set_session_password(password)andclear_session_password()to bothsnap7.Client(sync) andsnap7.AsyncClient(async)ClientMixin0x55, rotate left by 3 bits, padded to 8 bytesChanges
encode_password(),build_set_session_password_request(),build_clear_session_password_request(), andcheck_userdata_response()toS7Protocolset_session_password/clear_session_passwordwith real protocol operations (uses_send_receive_with_reconnectfor auto-reconnect support)_send_receiveClientMixin(both concrete clients now implement the real protocol)check_userdata_responseerror handlingTest plan
uv run pytest tests/ -x -q-- all 1639 tests passuv run pre-commit run --all-files-- all hooks pass (mypy, ruff, formatting)Closes #792