st_edits #6
|
|
@ -96,6 +96,7 @@ class HackRF(SDR):
|
|||
self.set_gain_amp(False)
|
||||
self.set_rx_vga_gain(45)
|
||||
self.set_rx_lna_gain(abs_gain)
|
||||
self.rx_gain = abs_gain
|
||||
|
||||
print(f"HackRF gain distribution: Amp={self.amp_enabled}, LNA={self.rx_lna_gain}dB, VGA={self.rx_vga_gain}dB")
|
||||
print("To individually modify the HackRF gains, use set_gain_amp(), set_rx_lna_gain(), and set_rx_vga_gain().")
|
||||
|
|
@ -201,6 +202,7 @@ class HackRF(SDR):
|
|||
|
||||
self.set_gain_amp(True)
|
||||
self.set_tx_vga_gain(abs_gain)
|
||||
self.tx_gain = abs_gain
|
||||
print(f"HackRF gain distribution: Amp={self.amp_enabled}, VGA={self.tx_vga_gain}dB")
|
||||
print("To individually modify the HackRF gains, use set_gain_amp() or set_tx_vga_gain().")
|
||||
|
||||
|
|
|
|||
|
|
@ -77,33 +77,6 @@ class RTLSDR(SDR):
|
|||
|
||||
return {"sample_rate": self.rx_sample_rate, "center_frequency": self.rx_center_frequency, "gain": self.rx_gain}
|
||||
|
||||
def get_rx_sample_rate(self):
|
||||
"""
|
||||
Retrieve the current sample rate of the receiver.
|
||||
|
||||
Returns:
|
||||
float: The receiver's sample rate in samples per second (Hz).
|
||||
"""
|
||||
return self.rx_sample_rate
|
||||
|
||||
def get_rx_center_frequency(self):
|
||||
"""
|
||||
Retrieve the current center frequency of the receiver.
|
||||
|
||||
Returns:
|
||||
float: The receiver's center frequency in Hertz (Hz).
|
||||
"""
|
||||
return self.rx_center_frequency
|
||||
|
||||
def get_rx_gain(self):
|
||||
"""
|
||||
Retrieve the current gain setting of the receiver.
|
||||
|
||||
Returns:
|
||||
float: The receiver's gain in decibels (dB).
|
||||
"""
|
||||
return self.rx_gain
|
||||
|
||||
def set_rx_sample_rate(self, sample_rate):
|
||||
self.radio.sample_rate = float(sample_rate)
|
||||
self.rx_sample_rate = self.radio.sample_rate
|
||||
|
|
|
|||
|
|
@ -32,6 +32,12 @@ class SDR(ABC):
|
|||
self._num_buffers_processed = 0
|
||||
self._accumulated_buffer = None
|
||||
self._last_buffer = None
|
||||
self.rx_sample_rate = None
|
||||
self.rx_center_frequency = None
|
||||
self.rx_gain = None
|
||||
self.tx_sample_rate = None
|
||||
self.tx_center_frequency = None
|
||||
self.tx_gain = None
|
||||
|
||||
def record(self, num_samples: Optional[int] = None, rx_time: Optional[int | float] = None) -> Recording:
|
||||
"""
|
||||
|
|
@ -313,6 +319,60 @@ class SDR(ABC):
|
|||
self.pause_rx()
|
||||
self.pause_tx()
|
||||
|
||||
def get_rx_sample_rate(self):
|
||||
"""
|
||||
Retrieve the current sample rate of the receiver.
|
||||
|
||||
Returns:
|
||||
float: The receiver's sample rate in samples per second (Hz).
|
||||
"""
|
||||
return self.rx_sample_rate
|
||||
|
||||
def get_rx_center_frequency(self):
|
||||
"""
|
||||
Retrieve the current center frequency of the receiver.
|
||||
|
||||
Returns:
|
||||
float: The receiver's center frequency in Hertz (Hz).
|
||||
"""
|
||||
return self.rx_center_frequency
|
||||
|
||||
def get_rx_gain(self):
|
||||
"""
|
||||
Retrieve the current gain setting of the receiver.
|
||||
|
||||
Returns:
|
||||
float: The receiver's gain in decibels (dB).
|
||||
"""
|
||||
return self.rx_gain
|
||||
|
||||
def get_tx_sample_rate(self):
|
||||
"""
|
||||
Retrieve the current sample rate of the transmitter.
|
||||
|
||||
Returns:
|
||||
float: The transmitter's sample rate in samples per second (Hz).
|
||||
"""
|
||||
return self.tx_sample_rate
|
||||
|
||||
def get_tx_center_frequency(self):
|
||||
"""
|
||||
Retrieve the current center frequency of the transmitter.
|
||||
|
||||
Returns:
|
||||
float: The transmitter's center frequency in Hertz (Hz).
|
||||
"""
|
||||
return self.tx_center_frequency
|
||||
|
||||
def get_tx_gain(self):
|
||||
"""
|
||||
Retrieve the current gain setting of the transmitter.
|
||||
|
||||
Returns:
|
||||
float: The transmitter's gain in decibels (dB).
|
||||
"""
|
||||
return self.tx_gain
|
||||
|
||||
@abstractmethod
|
||||
def close(self):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -87,33 +87,6 @@ class USRP(SDR):
|
|||
|
||||
return {"sample_rate": self.rx_sample_rate, "center_frequency": self.rx_center_frequency, "gain": self.rx_gain}
|
||||
|
||||
def get_rx_sample_rate(self):
|
||||
"""
|
||||
Retrieve the current sample rate of the receiver.
|
||||
|
||||
Returns:
|
||||
float: The receiver's sample rate in samples per second (Hz).
|
||||
"""
|
||||
return self.rx_sample_rate
|
||||
|
||||
def get_rx_center_frequency(self):
|
||||
"""
|
||||
Retrieve the current center frequency of the receiver.
|
||||
|
||||
Returns:
|
||||
float: The receiver's center frequency in Hertz (Hz).
|
||||
"""
|
||||
return self.rx_center_frequency
|
||||
|
||||
def get_rx_gain(self):
|
||||
"""
|
||||
Retrieve the current gain setting of the receiver.
|
||||
|
||||
Returns:
|
||||
float: The receiver's gain in decibels (dB).
|
||||
"""
|
||||
return self.rx_gain
|
||||
|
||||
def set_rx_sample_rate(self, sample_rate, channel=0):
|
||||
# check if sample rate arg is valid
|
||||
# Note: B200/B210 devices auto-adjust master clock rate, so get_rx_rates() returns
|
||||
|
|
@ -332,33 +305,6 @@ class USRP(SDR):
|
|||
|
||||
return {"sample_rate": self.tx_sample_rate, "center_frequency": self.tx_center_frequency, "gain": self.tx_gain}
|
||||
|
||||
def get_tx_sample_rate(self):
|
||||
"""
|
||||
Retrieve the current sample rate of the transmitter.
|
||||
|
||||
Returns:
|
||||
float: The transmitter's sample rate in samples per second (Hz).
|
||||
"""
|
||||
return self.tx_sample_rate
|
||||
|
||||
def get_tx_center_frequency(self):
|
||||
"""
|
||||
Retrieve the current center frequency of the transmitter.
|
||||
|
||||
Returns:
|
||||
float: The transmitter's center frequency in Hertz (Hz).
|
||||
"""
|
||||
return self.tx_center_frequency
|
||||
|
||||
def get_tx_gain(self):
|
||||
"""
|
||||
Retrieve the current gain setting of the transmitter.
|
||||
|
||||
Returns:
|
||||
float: The transmitter's gain in decibels (dB).
|
||||
"""
|
||||
return self.tx_gain
|
||||
|
||||
def set_tx_sample_rate(self, sample_rate, channel=0):
|
||||
# check if sample rate arg is valid
|
||||
# Note: B200/B210 devices auto-adjust master clock rate, so get_tx_rates() returns
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user