File: 0001-Added-C-GRC-codegen-support-for-RFE-and-sink.patch

package info (click to toggle)
gr-limesdr 3.0.1.10.69-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,900 kB
  • sloc: python: 9,646; cpp: 2,091; ansic: 26; makefile: 8; sh: 5
file content (285 lines) | stat: -rw-r--r-- 8,182 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
From d68a6301d906208197671e41245b5f8102c9d90c Mon Sep 17 00:00:00 2001
From: Nicholas Corgan <n.corgan@gmail.com>
Date: Sat, 6 May 2023 08:31:46 -0500
Subject: [PATCH] Added C++ GRC codegen support for RFE and sink

---
 grc/limesdr_rfe.block.yml     | 39 +++++++++++++-
 grc/limesdr_sink.block.yml    | 95 ++++++++++++++++++++++++++++++++++-
 include/limesdr/rfe.h         | 17 ++++++-
 lib/rfe_impl.cc               | 31 +++++++++++-
 python/bindings/rfe_python.cc |  2 +-
 5 files changed, 176 insertions(+), 8 deletions(-)

diff --git a/grc/limesdr_rfe.block.yml b/grc/limesdr_rfe.block.yml
index 59c7d13..41f0b5a 100644
--- a/grc/limesdr_rfe.block.yml
+++ b/grc/limesdr_rfe.block.yml
@@ -2,7 +2,8 @@
 
 id: limesdr_rfe
 label: LimeRFE Control
-category: '[LimeSuite]'
+category: '[LimeSDR]'
+flags: [cpp, python, throttle]
 
 parameters:
 -   id: comm_type
@@ -99,6 +100,42 @@ templates:
     - set_notch(${notch})
     - set_fan(${fan})
 
+templates:
+    imports: import limesdr
+    make: |-
+        limesdr.rfe(${comm_type},
+        % if comm_type == 0:
+            ${com_port},
+        % else:
+            ${sdr_serial},
+        % endif
+        ${filename}, ${rx_channel}, ${tx_channel}, ${rx_port}, ${tx_port}, ${mode}, ${notch}, ${atten})
+    callbacks:
+    - change_mode(${mode})
+    - set_attenuation(${atten})
+    - set_notch(${notch})
+    - set_fan(${fan})
+
+cpp_templates:
+  packages: ["gnuradio-limesdr"]
+  includes: ["#include <limesdr/rfe.h>"]
+  link: ["gnuradio::gnuradio-limesdr"]
+  translations:
+    "True": "true"
+    "False": "false"
+    "''": '""'
+
+  declarations: "gr::limesdr::rfe::sptr ${id};"
+  make: |-
+    this->${id} = gr::limesdr::rfe::make(
+        ${comm_type},
+        % if comm_type == 0:
+        ${com_port},
+        % else:
+        ${sdr_serial},
+        % endif
+        ${filename}, ${rx_channel}, ${tx_channel}, ${rx_port}, ${tx_port}, ${mode}, ${notch}, ${atten});
+
 documentation: |-
     -------------------------------------------------------------------------------------------------------------------
     COMMUNICATION
diff --git a/grc/limesdr_sink.block.yml b/grc/limesdr_sink.block.yml
index d88551a..9711d3f 100644
--- a/grc/limesdr_sink.block.yml
+++ b/grc/limesdr_sink.block.yml
@@ -1,7 +1,7 @@
 id: limesdr_sink
 label: LimeSDR Sink (TX)
 category: '[LimeSDR]'
-flags: throttle
+flags: [cpp, python, throttle]
 
 parameters:
 - id: serial
@@ -169,7 +169,7 @@ templates:
     % if filename() == "":
 
     self.${id}.set_sample_rate(${samp_rate})
- 
+
     % if int(oversample()) > 0:
     self.${id}.set_oversampling(${oversample})
     % endif
@@ -244,6 +244,97 @@ templates:
   - set_gain(${gain_dB_ch1}, 1)
   - set_tcxo_dac(${dacVal})
 
+cpp_templates:
+  packages: ["gnuradio-limesdr"]
+  includes: ["#include <limesdr/sink.h>"]
+  link: ["gnuradio::gnuradio-limesdr"]
+  translations:
+    "True": "true"
+    "False": "false"
+    "''": '""'
+
+  declarations: "gr::limesdr::sink::sptr ${id};"
+  make: |-
+    this->${id} = gr::limesdr::sink::make(${serial}, ${channel_mode}, ${filename}, ${length_tag_name});
+
+    % if filename() == "":
+
+    this->${id}->set_sample_rate(${samp_rate});
+
+    % if int(oversample()) > 0:
+    this->${id}->set_oversampling(${oversample});
+    % endif
+
+    this->${id}->set_center_freq(${rf_freq}, 0);
+
+    % if analog_bandw_ch0() > 0 and (int(channel_mode()) == 0 or int(channel_mode()) == 2):
+    this->${id}->set_bandwidth(${analog_bandw_ch0}, 0);
+    % endif
+
+    % if analog_bandw_ch1() > 0 and int(channel_mode()) > 0:
+    this->${id}->set_bandwidth(${analog_bandw_ch1}, 1);
+    % endif
+
+    % if digital_bandw_ch0() > 0 and (int(channel_mode()) == 0 or int(channel_mode()) == 2):
+    this->${id}->set_digital_filter(${digital_bandw_ch0}, 0);
+    % endif
+
+    % if digital_bandw_ch1() > 0 and int(channel_mode()) > 0:
+    this->${id}->set_digital_filter(${digital_bandw_ch1}, 1);
+    % endif
+
+    % if int(channel_mode()) == 0 or int(channel_mode()) == 2:
+    this->${id}->set_gain(${gain_dB_ch0}, 0);
+    % endif
+
+    % if int(channel_mode()) > 0:
+    this->${id}->set_gain(${gain_dB_ch1}, 1);
+    % endif
+
+    % if int(channel_mode()) == 0 or int(channel_mode()) == 2:
+    this->${id}->set_antenna(${pa_path_ch0}, 0);
+    % endif
+
+    % if int(channel_mode()) > 0:
+    this->${id}->set_antenna(${pa_path_ch1}, 1);
+    % endif
+
+    % if calibr_bandw_ch0() > 0 and (int(channel_mode()) == 0 or int(channel_mode()) == 2):
+    this->${id}->calibrate(${calibr_bandw_ch0}, 0);
+    % endif
+
+    % if calibr_bandw_ch1() > 0 and int(channel_mode()) > 0:
+    this->${id}->calibrate(${calibr_bandw_ch1}, 1);
+    % endif
+
+    % if nco_freq_ch0() != 0 and (int(channel_mode()) == 0 or int(channel_mode()) == 2):
+    this->${id}->set_nco(${nco_freq_ch0},0);
+    % endif
+
+    % if nco_freq_ch1() != 0 and int(channel_mode()) > 0:
+    this->${id}->set_nco(${nco_freq_ch1}, 1);
+    % endif
+
+    % endif # if filename() == ""
+
+    % if int(allow_tcxo_dac) == 1:
+    this->${id}->set_tcxo_dac(${dacVal});
+    % endif
+
+  callbacks:
+  - set_center_freq(${rf_freq}, 0)
+  - set_antenna(${pa_path_ch0}, 0)
+  - set_antenna(${pa_path_ch1}, 1)
+  - set_nco(${nco_freq_ch0}, 0)
+  - set_nco(${nco_freq_ch1}, 1)
+  - set_bandwidth(${analog_bandw_ch0}, 0)
+  - set_bandwidth(${analog_bandw_ch1}, 1)
+  - set_digital_filter(${digital_bandw_ch0}, 0)
+  - set_digital_filter(${digital_bandw_ch1}, 1)
+  - set_gain(${gain_dB_ch0}, 0)
+  - set_gain(${gain_dB_ch1}, 1)
+  - set_tcxo_dac(${dacVal})
+
 asserts:
 - ${ int(channel_mode) >= 0 }
 - ${ 2 >= int(channel_mode) }
diff --git a/include/limesdr/rfe.h b/include/limesdr/rfe.h
index 7638577..0e1bbf4 100644
--- a/include/limesdr/rfe.h
+++ b/include/limesdr/rfe.h
@@ -37,9 +37,22 @@ namespace limesdr {
 class LIMESDR_API rfe
 {
 public:
+    typedef std::shared_ptr<rfe> sptr;
+
+    static sptr make(int comm_type,
+        const std::string &device,
+        const std::string &config_file,
+        char IDRX,
+        char IDTX,
+        char PortRX,
+        char PortTX,
+        char Mode,
+        char Notch,
+        char Atten);
+
     rfe(int comm_type,
-        std::string device,
-        std::string config_file,
+        const std::string &device,
+        const std::string &config_file,
         char IDRX,
         char IDTX,
         char PortRX,
diff --git a/lib/rfe_impl.cc b/lib/rfe_impl.cc
index 4cf3048..85b4d84 100644
--- a/lib/rfe_impl.cc
+++ b/lib/rfe_impl.cc
@@ -32,9 +32,35 @@
 
 namespace gr {
 namespace limesdr {
+
+rfe::sptr rfe::make(
+    int comm_type,
+    const std::string &device,
+    const std::string &config_file,
+    char IDRX,
+    char IDTX,
+    char PortRX,
+    char PortTX,
+    char Mode,
+    char Notch,
+    char Atten)
+{
+    return sptr(new rfe(
+        comm_type,
+        device,
+        config_file,
+        IDRX,
+        IDTX,
+        PortRX,
+        PortTX,
+        Mode,
+        Notch,
+        Atten));
+}
+
 rfe::rfe(int comm_type,
-         std::string device,
-         std::string config_file,
+         const std::string &device_,
+         const std::string &config_file,
          char IDRX,
          char IDTX,
          char PortRX,
@@ -44,6 +70,7 @@ rfe::rfe(int comm_type,
          char Atten)
 {
     set_limesuite_logger();
+    auto device = device_;
 
     gr::configure_default_loggers(
         d_logger,
diff --git a/python/bindings/rfe_python.cc b/python/bindings/rfe_python.cc
index 6c09e12..6bceb62 100644
--- a/python/bindings/rfe_python.cc
+++ b/python/bindings/rfe_python.cc
@@ -10,7 +10,7 @@
 /* BINDTOOL_GEN_AUTOMATIC(0)                                                       */
 /* BINDTOOL_USE_PYGCCXML(0)                                                        */
 /* BINDTOOL_HEADER_FILE(rfe.h)                                                     */
-/* BINDTOOL_HEADER_FILE_HASH(c8af915fcfdda460c8c0cad6f26345d6)                     */
+/* BINDTOOL_HEADER_FILE_HASH(13d9fc789d1818bc73245ab84524c8d5)                     */
 /***********************************************************************************/
 
 #include <pybind11/complex.h>
-- 
2.47.3