Module: RTLSDR
- Defined in:
- lib/rtlsdr.rb,
lib/rtlsdr/dsp.rb,
lib/rtlsdr/ffi.rb,
lib/rtlsdr/fftw.rb,
lib/rtlsdr/demod.rb,
lib/rtlsdr/device.rb,
lib/rtlsdr/errors.rb,
lib/rtlsdr/scanner.rb,
lib/rtlsdr/version.rb,
lib/rtlsdr/dsp/filter.rb,
lib/rtlsdr/tcp_client.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, Demod, FFI, FFTW Classes: CallbackError, ConnectionError, Device, DeviceNotFoundError, DeviceNotOpenError, DeviceOpenError, EEPROMError, Error, InvalidArgumentError, OperationFailedError, Scanner, TcpClient
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.3.0"
Class Method Summary collapse
-
.connect(host, port = TcpClient::DEFAULT_PORT, timeout: 10) ⇒ RTLSDR::TcpClient
Connect to a remote rtl_tcp server.
-
.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
.connect(host, port = TcpClient::DEFAULT_PORT, timeout: 10) ⇒ RTLSDR::TcpClient
Connect to a remote rtl_tcp server
Creates and returns a TcpClient instance connected to the specified rtl_tcp server. The client implements the same interface as Device, allowing seamless switching between local and remote devices.
147 148 149 |
# File 'lib/rtlsdr.rb', line 147 def connect(host, port = TcpClient::DEFAULT_PORT, timeout: 10) TcpClient.new(host, port, timeout: timeout) end |
.device_count ⇒ Integer
Get the number of connected RTL-SDR devices
57 58 59 |
# File 'lib/rtlsdr.rb', line 57 def device_count FFI.rtlsdr_get_device_count end |
.device_name(index) ⇒ String
Get the name of a device by index
68 69 70 |
# File 'lib/rtlsdr.rb', line 68 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.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/rtlsdr.rb', line 82 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.
162 163 164 165 166 167 168 169 170 |
# File 'lib/rtlsdr.rb', line 162 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.
107 108 109 110 111 112 |
# File 'lib/rtlsdr.rb', line 107 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.
126 127 128 |
# File 'lib/rtlsdr.rb', line 126 def open(index = 0) Device.new(index) end |