summaryrefslogtreecommitdiff
path: root/gr-uhd/examples/python
diff options
context:
space:
mode:
authorPiotr Krysik <ptrkrysik@gmail.com>2018-05-04 07:49:36 +0200
committerMarcus Müller <marcus@hostalia.de>2019-03-08 20:29:56 +0100
commitaffb5c7e4b84cde42ad3704043a11f0f7b2a0558 (patch)
tree7d51cecb9095418ffdeb26caf6508f1c49556cd2 /gr-uhd/examples/python
parentbe11e7a256e2a36096234dd3dae5e6ed731069c9 (diff)
uhd: fix freq_hopping example - missing 'time'
Freq_hopping example wasn't working correctly and symptom of it was that frequency changes were happening in random moments. The reason was that time of execution of tune commands wasn't specified and so they were executed as non-timed commands. In case of of full tuning (dsp_tuning == false) more changes were needed. 'tx_freq' tag can't be executed as a timed command at all, so I changed it to 'tx_command' with 'freq' element and also added missing 'time'. I found out about the issue but credit of fixing it by adding 'time' element to 'tx_command' tag value goes to Sylvain Munaut, as this change was suggested by him.
Diffstat (limited to 'gr-uhd/examples/python')
-rwxr-xr-xgr-uhd/examples/python/freq_hopping.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/gr-uhd/examples/python/freq_hopping.py b/gr-uhd/examples/python/freq_hopping.py
index 1d034c1862..56cedf58ab 100755
--- a/gr-uhd/examples/python/freq_hopping.py
+++ b/gr-uhd/examples/python/freq_hopping.py
@@ -128,6 +128,10 @@ class FrequencyHopperSrc(gr.hier_block2):
gain_tag.value = pmt.to_pmt({'gain': tx_gain})
tag_list = [gain_tag,]
for i in range(len(self.hop_sequence)):
+ time = pmt.cons(
+ pmt.from_uint64(int(base_time + i * hop_time+0.01)),
+ pmt.from_double((base_time + i * hop_time+0.01) % 1),
+ )
tune_tag = gr.tag_t()
tune_tag.offset = i * burst_length
# TODO dsp_tuning should also be able to do post_tuning
@@ -136,9 +140,11 @@ class FrequencyHopperSrc(gr.hier_block2):
if dsp_tuning:
tune_tag.key = pmt.string_to_symbol('tx_command')
tune_tag.value = pmt.to_pmt({'lo_freq': base_freq, 'dsp_freq': base_freq - self.hop_sequence[i]})
+ tune_tag.value = pmt.dict_add(tune_tag.value, pmt.intern("time"),time)
else:
- tune_tag.key = pmt.string_to_symbol('tx_freq')
- tune_tag.value = pmt.to_pmt(self.hop_sequence[i])
+ tune_tag.key = pmt.string_to_symbol('tx_command')
+ tune_tag.value = pmt.to_pmt({'freq': self.hop_sequence[i]})
+ tune_tag.value = pmt.dict_add(tune_tag.value, pmt.intern('time'), time)
tag_list.append(tune_tag)
length_tag = gr.tag_t()
length_tag.offset = i * burst_length
@@ -149,8 +155,8 @@ class FrequencyHopperSrc(gr.hier_block2):
time_tag.offset = i * burst_length
time_tag.key = pmt.string_to_symbol('tx_time')
time_tag.value = pmt.make_tuple(
- pmt.from_uint64(int(base_time + i * hop_time)),
- pmt.from_double((base_time + i * hop_time) % 1),
+ pmt.car(time),
+ pmt.cdr(time)
)
tag_list.append(time_tag)
tag_source = blocks.vector_source_c((1.0,) * n_samples_total, repeat=False, tags=tag_list)
@@ -239,4 +245,3 @@ if __name__ == '__main__':
main()
except KeyboardInterrupt:
pass
-