Skip to content

fix: accept the ten-byte S7 clock reply and emit it from the server - #934

Merged
gijzelaerr merged 1 commit into
masterfrom
fix-get-clock-ten-byte-response
Oct 7, 2026
Merged

gijzelaerr merged 1 commit into
masterfrom
fix-get-clock-ten-byte-response

Conversation

@gijzelaerr

Copy link
Copy Markdown
Owner

Fixes #925.

parse_get_clock_response only accepted exactly eight data bytes, while the S7 clock data (native Snap7 TResDataGetTime: Rsvd, HiYear, Time[8]) is ten bytes, as is the data the library sends in build_set_clock_request. A native server or PLC reply was therefore rejected.

  • The parser accepts the ten-byte form (reserved, century, year..second, milliseconds/weekday), validates the BCD digits and milliseconds, and maps the two-digit year as 1990-2089. The eight-byte form is still tolerated.
  • The bundled server now answers with the ten-byte form.
  • New tests cover the ten-byte layout, milliseconds, and invalid milliseconds; the short-data message is updated.

This touches the same server lines as the weekday fix, so the two PRs will need a trivial rebase whichever lands second (the server here already uses Sunday=1).

@gijzelaerr
gijzelaerr force-pushed the fix-get-clock-ten-byte-response branch from 409ec92 to f5e2c15 Compare October 7, 2026 09:31
@gijzelaerr
gijzelaerr merged commit dbf2b30 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.

parse_get_clock_response requires 8 data bytes; the S7 clock reply (and set-clock request) carries 10

1 participant