50 lines
1.3 KiB
ReStructuredText
50 lines
1.3 KiB
ReStructuredText
|
.. _rx:
|
||
|
|
||
|
Rx Example
|
||
|
==========
|
||
|
|
||
|
This example code for getting started with RIA Toolkit OSS SDR package.
|
||
|
|
||
|
.. contents::
|
||
|
:local:
|
||
|
|
||
|
Introduction
|
||
|
------------
|
||
|
|
||
|
The following examples demonstrate how to initialize an SDR, record a signal, and transmit a custom waveform.
|
||
|
These examples assume familiarity with Python and SDR concepts.
|
||
|
|
||
|
In this example, we use the [bladeRF](https://www.nuand.com/bladerf-1/). However, because
|
||
|
this package presents a common interface for all SDR devices, the same code can be used
|
||
|
to interface with additional supported radios.
|
||
|
|
||
|
Example 1: Recording a Signal
|
||
|
-----------------------------
|
||
|
|
||
|
In this example, we initialize the `Blade` SDR, configure it to record a signal for a specified duration.
|
||
|
|
||
|
.. code-block:: python
|
||
|
|
||
|
import time
|
||
|
|
||
|
from ria_toolkit_oss.datatypes.recording import Recording
|
||
|
from ria_toolkit_oss.sdr.blade import Blade
|
||
|
|
||
|
my_radio = Blade()
|
||
|
print(my_radio)
|
||
|
print(type(my_radio))
|
||
|
|
||
|
my_radio.init_rx(
|
||
|
sample_rate=1e6,
|
||
|
center_frequency=2.44e9,
|
||
|
gain=50,
|
||
|
channel=0,
|
||
|
)
|
||
|
|
||
|
rx_time = 0.01
|
||
|
start = time.time()
|
||
|
my_rec = my_radio.record(rx_time=rx_time)
|
||
|
end = time.time()
|
||
|
|
||
|
print(f"Total time: {end - start} seconds")
|
||
|
print(f"Length of the recording: {len(my_rec)} samples")
|