Skip to content

fix: Support interrupt endpoints in nativeTransferIn/nativeTransferOut/clearHalt#4

Merged
thegecko merged 2 commits into
node-usb:mainfrom
dressedinblack5:fix/interrupt-endpoint-support
Jun 22, 2026
Merged

fix: Support interrupt endpoints in nativeTransferIn/nativeTransferOut/clearHalt#4
thegecko merged 2 commits into
node-usb:mainfrom
dressedinblack5:fix/interrupt-endpoint-support

Conversation

@dressedinblack5

Copy link
Copy Markdown
Contributor

Problem

nativeTransferIn, nativeTransferOut, and clearHalt fail with "endpoint not found" for interrupt endpoints. The get_endpoint() method hardcodes Endpoint<Bulk, DIR>, but nusb::Interface::endpoint::<Bulk, DIR>() validates the descriptor's transfer type at runtime and returns an error when the endpoint is interrupt type.

Root Cause

The nusb crate's EndpointType trait has Bulk and Interrupt as separate types. Interface::endpoint::<EpType, Dir>() checks ep_desc.transfer_type() != EpType::TYPE and rejects mismatches.

Fix

Added an AnyEndpoint<DIR> enum that wraps either Endpoint<Bulk, DIR> or Endpoint<Interrupt, DIR>, implementing the shared methods (max_packet_size, transfer_blocking, clear_halt) by delegation. get_endpoint() now inspects ep_desc.transfer_type() at runtime and creates the correctly-typed endpoint.

Closes #2

Testing

  • Build: npm run build succeeds on Linux x64
  • Device test: Successfully read battery data (03 55 40 01 25 = 37%) from interrupt endpoint 3 on an Attack Shark X11 gaming mouse (0x1d57:0xfa60)

…t/clearHalt

Adds AnyEndpoint enum wrapping both Bulk and Interrupt endpoint types.
get_endpoint now inspects the endpoint descriptor's transfer type at
runtime and creates the appropriately typed Endpoint (Bulk or Interrupt).

Previously, get_endpoint hardcoded Endpoint<Bulk, DIR>, causing
interrupt endpoints to silently fail with 'endpoint not found'.
@thegecko

Copy link
Copy Markdown
Member

@dressedinblack5 Thanks for this PR, this was an oversight on my part.

Apologies I only just saw it, now tested it works as expected.

There's a minor formatting issue, would you mind running npm run format and updating the PR?

@thegecko thegecko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run npm run format

@thegecko thegecko merged commit bb59c02 into node-usb:main Jun 22, 2026
12 checks passed
@thegecko

Copy link
Copy Markdown
Member

Woot! thank you @dressedinblack5

@dressedinblack5

dressedinblack5 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Exciting time in the world, right now!

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.

Lack of interrupt endpoint support

2 participants