Skip to content

fix(send-receive): write a TCP address without leading zeros - #168

Merged
ssweber merged 3 commits into
mainfrom
fix/ip-canonical
Nov 20, 2026
Merged

ssweber merged 3 commits into
mainfrom
fix/ip-canonical

Conversation

@ssweber

@ssweber ssweber commented Nov 20, 2026

Copy link
Copy Markdown
Owner

ModbusTcpTarget accepted a TCP address with leading zeros, such as 010.002.003.004, and wrote it as given. v0.4.0 did the same. CLICK's Send and Receive dialog reads each part as a decimal number and saves it without leading zeros: 010 is 10, not octal 8. Sam ruled on 2026-11-20 that laddercodec writes the address the way the dialog saves it. This follows the rule for addresses: accept what CLICK accepts, and write the form that CLICK writes.

What changes:

  • ModbusTcpTarget holds each part as a decimal number without leading zeros. A part that is all zeros becomes 0. read_csv, from_csv_token, to_csv, write_csv and encode() all go through the constructor, so they agree.
  • What is refused does not change. The code, the reason and CLICK's id are the same as before.
  • CLICK keeps a pasted padded address as pasted, so a clipboard or program file can hold one. decode() and decode_program() read such an address without its leading zeros. While the Send or Receive is unchanged, encode() writes the blob that it was decoded from, with the padded address. That is the same rule as for the other fields that CLICK saves in another form. Once you change a field, the address is written without leading zeros.
  • A test pads every TCP address in tests/fixtures/scr_captures/coverage.scr. It checks that each decoded Send and Receive keeps a blob that equals the matching box in coverage.bin, with only the address changed.
  • The CHANGELOG, the CSV guide, the AGENTS.md decoding notes and one reason text in tests/test_editor_answers.py say what the code now does. No recorded CLICK answer and no golden changed.

Gate: make lint, make test (19166 passed, 139 skipped) and make docs-build passed on 097f007. The last commit changes a docstring and wraps a string. make lint and the two affected test files passed on it.

Nothing waits on Sam. No CLICK check is needed, because no golden changed and CLICK accepts an address without leading zeros.

ssweber and others added 3 commits November 20, 2026 08:50
ModbusTcpTarget kept a padded address such as 010.002.003.004 as given. Each
part is a decimal number, so the target now holds 10.2.3.4, and to_csv(),
write_csv and encode() write that form. A part of zeros is 0. The same values
are refused, with the same code, reason and CLICK id.

A clipboard or program file can hold a padded address. The decoders read it in
the written form, and the Send or Receive keeps the blob it was decoded from
while it is unchanged, so encode() writes the padded address back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rewrite the CHANGELOG entry as three sentences and a Do line. Correct the
editor-answers note that said a padded address is written as given. Say in the
_check_ip docstring that it sets target.ip. Add the TCP address to the places
that list the forms a decoder reads in another form. Test the program-file
decode against the real coverage fixture, padding each TCP address in it and
comparing the kept blob with the clipboard's blob of the same box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first line of the _check_ip docstring now says that the function sets
target.ip as well as refusing an address. The IP_PADDED reason is wrapped to
the file's line length with its text unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ssweber
ssweber merged commit 1870931 into main Nov 20, 2026
7 checks passed
@ssweber
ssweber deleted the fix/ip-canonical branch November 20, 2026 14:20
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