Skip to content

Conversation

@abc8747
Copy link
Contributor

@abc8747 abc8747 commented Nov 3, 2025

Previously, opening a device by index was unreliable.

  • added a new DeviceDescriptors struct that provides an iterator over only supported RTL-SDR devices, ensuring that DeviceId::Index(n) reliably refers to the nth known RTL-SDR
  • a new Sensor API is introduced to provide an interface for querying device state like tuner type and gain
  • the rtl_test example has also been updated to use the new enumeration logic, supporting device selection by either filtered index or serial number

Tested with blog V4:

$ cargo run --example rtl_test
Found 1 device(s):
  0:  RTLSDRBlog, Blog V4, SN: 00000001

Using device 0: RTLSDRBlog, Blog V4, SN: 00000001
Found r828d tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
Sampling at 2048000 S/s.
Reading samples in sync mode...

Addresses xoolive/jet1090#264 (comment), xoolive/jet1090#294 (impl Send for Tuner and Error will be in a separate PR)
cc: @xoolive

abc8747 and others added 2 commits November 3, 2025 11:11
Previously, opening a device by index was unreliable.

- added a new `DeviceDescriptors` struct that provides an iterator over
  *only* supported RTL-SDR devices, ensuring that `DeviceId::Index(n)` reliably
  refers to the nth *known* RTL-SDR
- a new `Sensor` API is introduced to provide an interface for querying device
  state like tuner type and gain
- the `rtl_test` example has also been updated to use the new enumeration logic,
  supporting device selection by either filtered index or serial number
@xoolive
Copy link
Contributor

xoolive commented Nov 3, 2025

I just added some logic in the rtl_test example program to use a -f flag and select devices based on manufacturer/product/serial.
rust-soapysdr offers something similar and I find it very convenient as far as I am concerned.

@tkj666
Copy link
Contributor

tkj666 commented Nov 18, 2025

I think it is better to add serial as another variant of DeviceId and move the filtering and opening to DeviceHandle like index and fd. It also avoids duplicate device enumeration.

@xoolive
Copy link
Contributor

xoolive commented Dec 5, 2025

@tkj666 sorry for the delayed reply

There is actually more than serial (there is manufacturer, product, and serial), but I can try to add one more item in the enum to try to cover it all if that's ok with you.

avoids opening all devices to find serial only to opened again in enumerate,
stops exactly when target is found and returns that live handle.
see: ccostes#26 (comment)

also removed `rusb::Context` since `rusb::DeviceList` holds `Arc<ContextInner>`
@abc8747
Copy link
Contributor Author

abc8747 commented Dec 25, 2025

I think it is better to add serial as another variant of DeviceId and move the filtering and opening to DeviceHandle like index and fd. It also avoids duplicate device enumeration.

@tkj666 I've just implemented this, do you mind taking a look?

cc @xoolive

@tkj666
Copy link
Contributor

tkj666 commented Dec 26, 2025

I think it is better to add serial as another variant of DeviceId and move the filtering and opening to DeviceHandle like index and fd. It also avoids duplicate device enumeration.

@tkj666 I've just implemented this, do you mind taking a look?

cc @xoolive

Fantastic job! That should solve the problem.

@ccostes ccostes merged commit 4ef2f73 into ccostes:main Jan 28, 2026
4 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.

4 participants