Module: RTLSDR
- Defined in:
- lib/rtlsdr.rb,
lib/rtlsdr/dsp.rb,
lib/rtlsdr/ffi.rb,
lib/rtlsdr/device.rb,
lib/rtlsdr/errors.rb,
lib/rtlsdr/scanner.rb,
lib/rtlsdr/version.rb
Overview
Ruby bindings for RTL-SDR (Software Defined Radio) devices
RTLSDR provides a complete Ruby interface to RTL-SDR USB dongles, enabling software-defined radio applications. It offers both low-level FFI bindings that map directly to the librtlsdr C API and high-level Ruby classes with idiomatic methods and DSLs.
Features:
- Device enumeration and control
- Frequency, gain, and sample rate configuration
- Synchronous and asynchronous sample reading
- Signal processing utilities (DSP)
- Frequency scanning and spectrum analysis
- EEPROM reading/writing and bias tee control
Defined Under Namespace
Modules: DSP, FFI Classes: CallbackError, Device, DeviceNotFoundError, DeviceNotOpenError, DeviceOpenError, EEPROMError, Error, InvalidArgumentError, OperationFailedError, Scanner
Constant Summary collapse
- VERSION =
Current version of the RTL-SDR Ruby gem
This constant defines the semantic version of the Ruby bindings. The version follows semantic versioning (semver) conventions: MAJOR.MINOR.PATCH where:
- MAJOR: Backwards-incompatible API changes
- MINOR: New features, backwards-compatible
- PATCH: Bug fixes, backwards-compatible
"0.1.12"
Class Method Summary collapse
-
.device_count ⇒ Integer
Get the number of connected RTL-SDR devices.
-
.device_name(index) ⇒ String
Get the name of a device by index.
-
.device_usb_strings(index) ⇒ Hash?
Get USB device strings for a device by index.
-
.devices ⇒ Array<Hash>
List all available devices with their information.
-
.find_device_by_serial(serial) ⇒ Integer?
Find device index by serial number.
-
.open(index = 0) ⇒ RTLSDR::Device
Open a device and return a Device instance.
Class Method Details
.device_count ⇒ Integer
Get the number of connected RTL-SDR devices
46 47 48 |
# File 'lib/rtlsdr.rb', line 46 def device_count FFI.rtlsdr_get_device_count end |
.device_name(index) ⇒ String
Get the name of a device by index
57 58 59 |
# File 'lib/rtlsdr.rb', line 57 def device_name(index) FFI.rtlsdr_get_device_name(index) end |
.device_usb_strings(index) ⇒ Hash?
Get USB device strings for a device by index
Retrieves the USB manufacturer, product, and serial number strings for the specified device.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rtlsdr.rb', line 71 def device_usb_strings(index) manufact = " " * 256 product = " " * 256 serial = " " * 256 result = FFI.rtlsdr_get_device_usb_strings(index, manufact, product, serial) return nil if result != 0 { manufacturer: manufact.strip, product: product.strip, serial: serial.strip } end |
.devices ⇒ Array<Hash>
List all available devices with their information
Returns an array of hashes containing information about all connected RTL-SDR devices, including index, name, and USB strings.
130 131 132 133 134 135 136 137 138 |
# File 'lib/rtlsdr.rb', line 130 def devices (0...device_count).map do |i| { index: i, name: device_name(i), usb_strings: device_usb_strings(i) } end end |
.find_device_by_serial(serial) ⇒ Integer?
Find device index by serial number
Searches for a device with the specified serial number and returns its index if found.
96 97 98 99 100 101 |
# File 'lib/rtlsdr.rb', line 96 def find_device_by_serial(serial) result = FFI.rtlsdr_get_index_by_serial(serial) return nil if result.negative? result end |
.open(index = 0) ⇒ RTLSDR::Device
Open a device and return a Device instance
Creates and returns a new Device instance for the specified device index. The device will be automatically opened and ready for use.
115 116 117 |
# File 'lib/rtlsdr.rb', line 115 def open(index = 0) Device.new(index) end |