Skip to content

Add a read_only flag to Server.register_area - #992

Open
gijzelaerr wants to merge 2 commits into
masterfrom
server-read-only-areas
Open

gijzelaerr wants to merge 2 commits into
masterfrom
server-read-only-areas

Conversation

@gijzelaerr

Copy link
Copy Markdown
Owner

A real S7-1214C V4.2 answers a Write Var to a write-protected DB with item return code 0x03, "accessing the object not allowed", and no header error (capture in #976). The server can now emulate that.

Changes

  • Server.register_area() takes a keyword-only read_only argument. Registering the area again, or unregistering it, drops the flag.
  • A write to a read-only area is refused with item code 0x03 in both the single-item and the multi-item path. Nothing is written and no data-write event is emitted.
  • Reads, a block download and changes the server side makes to the buffer are not affected.

Not covered

Read-only is checked before the range. There is no capture of an out-of-range write to a protected DB, so the code a real CPU returns for that case is unknown.

Testing

New tests in tests/test_server.py cover both write paths, the unchanged read path, the event log, and dropping the flag on re-registration.

Refs #976

A real S7-1214C V4.2 answers a Write Var to a write-protected DB with
item return code 0x03, "accessing the object not allowed", and no
header error (capture in #976). The server can now emulate that.

- register_area() takes a keyword-only read_only argument. Registering
  the area again, or unregistering it, drops the flag.
- A write to a read-only area is refused with item code 0x03 in both
  the single-item and the multi-item path. Nothing is written and no
  data-write event is emitted. Read-only is checked before the range;
  there is no capture of an out-of-range write to a protected DB.
- Reads, a block download and changes the server side makes to the
  buffer are not affected.

This branch has not been deployed

No deployments
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