Skip to content

fix: accept the null acknowledgement real PLCs send for set clock and session passwords - #940

Merged
gijzelaerr merged 2 commits into
masterfrom
fix-set-clock-null-ack
Oct 7, 2026
Merged

gijzelaerr merged 2 commits into
masterfrom
fix-set-clock-null-ack

Conversation

@gijzelaerr

Copy link
Copy Markdown
Owner

Fixes #935.

A real S7-300 acknowledges a set-clock with a USER_DATA response whose parameter error code is 0 and whose data section is 0a 00 00 00 (return code 0x0A, transport size 0, length 0). check_userdata_response treated every return code other than 0xFF as a failure, so set_plc_datetime raised "Object does not exist" against such a PLC. The bundled server answered with 0xFF, which hid it.

  • check_userdata_response takes a keyword-only accept_null_ack. It is passed for set clock and the set/clear session password calls in both clients, the services that return no data. Every other service still requires 0xFF, and a nonzero parameter error code or any other return code is still a failure.
  • parse_response tolerates the null acknowledgement so the caller's stricter check decides.
  • The bundled server now acknowledges those three services in the null form.
  • A test replays the captured PDU from the Wireshark sample s7comm_reading_setting_plc_time.pcap (frame 44).

I could only verify this against the captured acknowledgement, not a physical PLC.

@gijzelaerr
gijzelaerr force-pushed the fix-set-clock-null-ack branch from 8754202 to 78576ce Compare October 7, 2026 10:09
@gijzelaerr
gijzelaerr merged commit c256137 into master Oct 7, 2026
20 checks passed
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.

set_plc_datetime fails against a real PLC: a successful set-clock acknowledgement (return code 0x0a, no data) is rejected

1 participant