Skip to content

Commit

Permalink
tx/rx/rec: Fix int sample rate casting on PlutoSDR
Browse files Browse the repository at this point in the history
Closes #38, closes #39, and closes #41.
  • Loading branch information
igorauad committed Jul 28, 2024
1 parent c22b350 commit 740a61c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 27 deletions.
15 changes: 6 additions & 9 deletions apps/dvbs2-rec
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,6 @@ class DVBS2RecTopBlock(gr.top_block, Qt.QWidget):
self.flowgraph_connected = False
self.gui_setup_complete = False

# Adjust the sample rate to an integer if necessary
if self.source == 'plutosdr' and not self.samp_rate.is_integer():
self.samp_rate = int(round(self.samp_rate))
gr.log.warn("An integer sample rate is required by the PlutoSDR. "
"Setting rate to {:d} samples/sec.".format(
self.samp_rate))
self.sym_rate = self.samp_rate / self.sps

##################################################
# Flowgraph
##################################################
Expand Down Expand Up @@ -372,7 +364,7 @@ class DVBS2RecTopBlock(gr.top_block, Qt.QWidget):

iio_pluto_source.set_len_tag_key('packet_len')
iio_pluto_source.set_frequency(self.freq)
iio_pluto_source.set_samplerate(self.samp_rate)
iio_pluto_source.set_samplerate(int(self.samp_rate))
iio_pluto_source.set_gain_mode(0, self.plutosdr['gain_mode'])
iio_pluto_source.set_gain(0, self.plutosdr['manual_gain'])
iio_pluto_source.set_quadrature(True)
Expand Down Expand Up @@ -828,6 +820,11 @@ def argument_parser():
"argument --bladerf-bw should be greater than {} Hz".format(
min_bw))

samp_rate = (options.samp_rate if options.samp_rate is not None else
options.sps * options.sym_rate)
if (options.source == "plutosdr" and not samp_rate.is_integer()):
parser.error("An integer sample rate is required by the PlutoSDR")

return options


Expand Down
15 changes: 6 additions & 9 deletions apps/dvbs2-rx
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,6 @@ class DVBS2RxTopBlock(gr.top_block, Qt.QWidget):
self.flowgraph_connected = False
self.gui_setup_complete = False

# Adjust the sample rate to an integer if necessary
if self.source == 'plutosdr' and not self.samp_rate.is_integer():
self.samp_rate = int(round(self.samp_rate))
gr.log.warn("An integer sample rate is required by the PlutoSDR. "
"Setting rate to {:d} samples/sec.".format(
self.samp_rate))
self.sym_rate = self.samp_rate / self.sps

##################################################
# Flowgraph
##################################################
Expand Down Expand Up @@ -662,7 +654,7 @@ class DVBS2RxTopBlock(gr.top_block, Qt.QWidget):

iio_pluto_source.set_len_tag_key('packet_len')
iio_pluto_source.set_frequency(self.freq)
iio_pluto_source.set_samplerate(self.samp_rate)
iio_pluto_source.set_samplerate(int(self.samp_rate))
iio_pluto_source.set_gain_mode(0, self.plutosdr['gain_mode'])
iio_pluto_source.set_gain(0, self.plutosdr['manual_gain'])
iio_pluto_source.set_quadrature(True)
Expand Down Expand Up @@ -1561,6 +1553,11 @@ def argument_parser():
"argument --bladerf-bw should be greater than {} Hz".format(
min_bw))

samp_rate = (options.samp_rate if options.samp_rate is not None else
options.sps * options.sym_rate)
if (options.source == "plutosdr" and not samp_rate.is_integer()):
parser.error("An integer sample rate is required by the PlutoSDR")

return options


Expand Down
15 changes: 6 additions & 9 deletions apps/dvbs2-tx
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,6 @@ class dvbs2_tx(gr.top_block, Qt.QWidget):
self.start_time = datetime.now()
self.uptime = datetime.now() - self.start_time

# Adjust the sample rate to an integer if necessary
if self.sink == 'plutosdr' and not self.samp_rate.is_integer():
self.samp_rate = int(round(self.samp_rate))
gr.log.warn("An integer sample rate is required by the PlutoSDR. "
"Setting rate to {:d} samples/sec.".format(
self.samp_rate))
self.sym_rate = self.samp_rate / self.sps

##################################################
# Flowgraph
##################################################
Expand Down Expand Up @@ -498,7 +490,7 @@ class dvbs2_tx(gr.top_block, Qt.QWidget):
iio_pluto_sink.set_bandwidth(
20000000) # TODO confirm if required in auto mode
iio_pluto_sink.set_frequency(self.freq)
iio_pluto_sink.set_samplerate(self.samp_rate)
iio_pluto_sink.set_samplerate(int(self.samp_rate))
iio_pluto_sink.set_attenuation(0, self.plutosdr['attenuation'])
iio_pluto_sink.set_filter_params('Auto', '', 0, 0)

Expand Down Expand Up @@ -1003,6 +995,11 @@ def argument_parser():
"argument --bladerf-bw should be greater than {} Hz".format(
min_bw))

samp_rate = (options.samp_rate if options.samp_rate is not None else
options.sps * options.sym_rate)
if (options.sink == "plutosdr" and not samp_rate.is_integer()):
parser.error("An integer sample rate is required by the PlutoSDR")

return options


Expand Down

0 comments on commit 740a61c

Please sign in to comment.