Skip to content

DebugPort: multi-endpoint support + flush()/DebugDataCommand fixes - #78

Closed
dccote wants to merge 1 commit into
masterfrom
debugport-multi-endpoint
Closed

dccote wants to merge 1 commit into
masterfrom
debugport-multi-endpoint

Conversation

@dccote

@dccote dccote commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Recovers an unpushed commit (e9e4faf, authored 2026-03-01) that was sitting on a stale local hamamatsu branch. Cherry-picked onto a fresh branch off master, with the one conflict resolved (PR #74 fixed the endPointIndex unbound bug differently — kept that style since it's already on master).

What this changes in DebugPort

  • numberOfEndPoints=1 parameter on __init__ — inputBuffers/outputBuffers are now sized to the requested endpoint count rather than hard-coded to 2. Lets USB-style multi-endpoint devices use DebugPort directly.
  • Fixed flush() — was writing to a nonexistent self.buffers attribute. Now properly resets each inputBuffers[i] and outputBuffers[i] to empty bytearrays.
  • defaultTimeout = 500 attribute added.
  • readData error message — now reports \"Unable to read N bytes, only M available\" rather than a generic timeout, which is much more useful when debugging stuck reads.
  • writeToOutputBuffer — endPointIndex parameter is now keyword-defaulted to 0 (was required positional).
  • Removed DebugDataCommand — the broken skeleton class that referenced unassigned attributes (self.data, self.replyDataLength, self.replyHexRegex). One of the items flagged in the earlier code review.

Relationship to PR #74

PR #74 (latent-bug fixes, merged) included a fix for readData/writeData leaving endPointIndex unbound when an explicit endPoint was passed. This commit had the same fix with slightly different ternary phrasing. The cherry-pick conflict was resolved in favor of PR #74's style (since it's already on master); behavior is identical.

Test plan

  • python3 -m pytest hardwarelibrary/tests/testCommunicationPorts.py -v — should report 84 passed, 29 skipped (hardware-gated). Already verified locally.
  • Spot-check: instantiate DebugPort(numberOfEndPoints=3) and confirm flush() and bytesAvailable(endPoint=2) work.

History note

The commit was authored on a local-only branch on 2026-03-01 and never pushed. Surfaced during a session refresh today and rescued before deletion. Original author: Daniel Côté (preserved via cherry-pick).

🤖 Generated with Claude Code

Fix flush() writing to nonexistent attribute, fix endPointIndex unbound
when endPoint is not None, add numberOfEndPoints parameter for USB
devices, add defaultTimeout attribute, remove broken DebugDataCommand.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dccote

dccote commented May 18, 2026

Copy link
Copy Markdown
Collaborator Author

Closing as redundant — PR #73 (table-driven-debug-port) already includes these DebugPort fixes (endpoint indexing, multi-endpoint support, removal of broken DebugDataCommand) as part of a larger refactor. The rescued commit e9e4faf was a 2026-03-01 stepping stone toward PR #73, not separate work to merge. Original commit remains preserved on origin/hamamatsu for history.

@dccote dccote closed this May 18, 2026
@dccote
dccote deleted the debugport-multi-endpoint branch May 18, 2026 16:02
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