Skip to content

usb host bulk in support - #11479

Merged
tannewt merged 10 commits into
adafruit:mainfrom
FoamyGuy:usb_host_sdr
Oct 7, 2026
Merged

tannewt merged 10 commits into
adafruit:mainfrom
FoamyGuy:usb_host_sdr

Conversation

@FoamyGuy

Copy link
Copy Markdown
Collaborator

Adds start_bulk_in(), read_bulk_into(), stop_bulk_in(), and bulk_in_lost_packets to usb.core.Device

The "No continuous capture running" error message is the only new one added. It could use "Interface must be started" instead if we want to re-use a an existing string that isn't as close of a fit.

Only enabled and tested on the Fruit Jam with USB SDR devices.

@tannewt tannewt 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 rethink the API. Maybe look at async pyusb too.

Comment thread shared-bindings/usb/core/Device.c Outdated
@FoamyGuy FoamyGuy closed this Sep 30, 2026
@FoamyGuy FoamyGuy reopened this Sep 30, 2026
# Conflicts:
#	locale/circuitpython.pot
#	ports/raspberrypi/boards/adafruit_fruit_jam/mpconfigboard.mk
#	shared-module/usb/core/Device.c
@FoamyGuy

Copy link
Copy Markdown
Collaborator Author

This is refactored in the latest commits to a new module usb_host_bulk and InStream class which supports non-blocking reads.

@tannewt tannewt 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.

A few API questions but overall it is getting close. Thanks!

Comment thread shared-bindings/usb_host_bulk/InStream.c Outdated
Comment thread shared-bindings/usb_host_bulk/InStream.c
Comment thread shared-bindings/usb_host_bulk/InStream.c Outdated

@tannewt tannewt 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.

I think you can fold the notion of ended into deinit. It's a little tricky with moving any remaining values to a VM allocated buffer but that way it'll get cleaned up automatically after the deinit() call. You can't use a port allocated buffer because it doesn't get GCed.

Comment thread ports/raspberrypi/common-hal/usb_host_bulk/InStream.c Outdated
Comment thread shared-bindings/usb_host_bulk/InStream.h Outdated
Comment thread shared-bindings/usb_host_bulk/InStream.c Outdated
Comment thread shared-bindings/usb_host_bulk/InStream.c Outdated
Comment thread shared-bindings/usb_host_bulk/InStream.c
Comment thread ports/raspberrypi/common-hal/usb_host_bulk/InStream.c Outdated

@tannewt tannewt 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.

Thanks! I think this is close. I would simplify things by making an explicit deinit work the same as a finalizer. The only way to get deinit but maintain the buffer is implicit deinit due to losing the device.

Comment thread shared-bindings/usb_host_bulk/InStream.h Outdated
Comment thread shared-bindings/usb_host_bulk/InStream.h Outdated

@tannewt tannewt 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.

Looks good! Thanks!

@tannewt
tannewt merged commit b4a3fa3 into adafruit:main Oct 7, 2026
685 checks 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.

2 participants