Skip to content

Send complete XMODEM frames over Wi-Fi#676

Draft
righteousgambit wants to merge 1 commit into
Carvera-Community:developfrom
righteousgambit:agent/use-sendall-for-xmodem
Draft

Send complete XMODEM frames over Wi-Fi#676
righteousgambit wants to merge 1 commit into
Carvera-Community:developfrom
righteousgambit:agent/use-sendall-for-xmodem

Conversation

@righteousgambit

Copy link
Copy Markdown

Closes #667

What changed

  • Replace the one-shot socket.send() in WIFIStream.putc() with socket.sendall().
  • Return len(data) after sendall() completes, preserving the XMODEM callback's integer success contract.
  • Add a deterministic regression built from a valid 8,199-byte XMODEM-8K CRC frame.
  • Document the Wi-Fi transfer reliability fix in the changelog.

Why sendall()

Python documents that socket.send() may send only part of the supplied data and leaves the remainder to the application. socket.sendall() continues until all bytes have been sent or an error occurs, which is the contract XMODEM.send() expects from this callback.

Impact and compatibility

The wire format and XMODEM CRC behavior are unchanged. This closes a reliability gap that could cause retries, timeouts, or transfer failure after a partial socket write. CRC validation prevents a truncated frame from being silently accepted, so the change does not claim to fix demonstrated undetected corruption.

Validation

Pinned develop (2ea66c10e96d88013a04441134d3d4f8e8c88510) against the new regression:

F                                                                        [100%]
E       AssertionError: assert 2048 == 8199
1 failed

Corrected implementation:

.                                                                        [100%]
1 passed

The passing test verifies all of the following:

  • the simulated wire receives all 8,199 bytes in order;
  • send() is never called;
  • sendall() is called exactly once; and
  • putc() returns 8199.

Quality checks:

ruff check carveracontroller/WIFIStream.py tests/unit/test_wifi_stream.py
ruff format --check carveracontroller/WIFIStream.py tests/unit/test_wifi_stream.py
python -m compileall -q carveracontroller/WIFIStream.py tests/unit/test_wifi_stream.py
git diff --check HEAD^ HEAD

Real branch verification

The repository's locked Poetry environment was installed from poetry.lock. The targeted suite passed on real fork commit 8c9bb6c8ba77, whose sole parent is pinned upstream develop@2ea66c10e96d88013a04441134d3d4f8e8c88510.

poetry run python -m pytest -q tests/unit/test_wifi_stream.py

Result: 1 passed.

Quality gates on the real branch:

  • Ruff check: passed
  • Ruff format --check: passed
  • git diff --check 2ea66c10e96d88013a04441134d3d4f8e8c88510..8c9bb6c8ba771e47e1101e23b2864001d15ea20d: 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.

1 participant