Skip to content

Add missing data type setters and fix get_lword/get_wchar bugs#602

Open
gijzelaerr wants to merge 1 commit intomasterfrom
feat/missing-data-type-setters
Open

Add missing data type setters and fix get_lword/get_wchar bugs#602
gijzelaerr wants to merge 1 commit intomasterfrom
feat/missing-data-type-setters

Conversation

@gijzelaerr
Copy link
Owner

Summary

  • Add missing setter functions: set_wstring, set_wchar, set_tod, set_dtl, set_dt, set_lword
  • Implement previously stubbed getters: get_ltime, get_ltod, get_ldt (S7-1500 64-bit time types)
  • Fix get_lword bug (read 4 bytes instead of 8) and get_wchar bug (hardcoded index)
  • Add WSTRING, WCHAR, TOD, DTL, DATE_AND_TIME support to DB Row set_value()
  • Export all new functions from snap7.util

Test plan

  • 19 new tests covering all additions
  • All 70 util tests pass
  • Full test suite passes (217 passed, 1 skipped)
  • mypy strict mode passes
  • ruff check and format pass

🤖 Generated with Claude Code

New setter functions:
- set_wstring: S7 WSTRING write support (UTF-16-BE, max 16382 chars)
- set_wchar: single UTF-16-BE character write
- set_tod: TIME_OF_DAY write (milliseconds since midnight)
- set_dtl: DTL write (12-byte extended date/time)
- set_dt: DATE_AND_TIME write (8-byte BCD encoded)
- set_lword: 64-bit unsigned word write (was NotImplementedError)

New getter implementations:
- get_ltime: LTIME read (64-bit nanosecond duration, S7-1500)
- get_ltod: LTOD read (64-bit nanosecond time of day, S7-1500)
- get_ldt: LDT read (64-bit nanosecond datetime since epoch, S7-1500)

Bug fixes:
- get_lword: was reading 4 bytes instead of 8, now returns int
- get_wchar: used hardcoded index 1 instead of byte_index + 1

DB Row support:
- set_value now handles WSTRING, WCHAR, TOD, DTL, DATE_AND_TIME

Includes 19 new tests covering all additions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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