1 |
commit: 51b987a494bc696c6c2390f39c530ea61f6f0fcf |
2 |
Author: Zero_Chaos <zerochaos <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Sep 5 02:38:33 2018 +0000 |
4 |
Commit: Richard Farina <zerochaos <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Sep 5 02:38:44 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=51b987a4 |
7 |
|
8 |
net-wireless/gr-osmosdr: adding pluto support |
9 |
|
10 |
with no keywords for right now, just to see what happens with |
11 |
https://github.com/csete/gr-osmosdr-gqrx/issues/10 |
12 |
|
13 |
Package-Manager: Portage-2.3.48, Repoman-2.3.10 |
14 |
|
15 |
net-wireless/gr-osmosdr/files/csete-iio.patch | 640 +++++++++++++++++++++ |
16 |
.../gr-osmosdr-0.1.4_p20180626-r1.ebuild | 80 +++ |
17 |
net-wireless/gr-osmosdr/metadata.xml | 1 + |
18 |
3 files changed, 721 insertions(+) |
19 |
|
20 |
diff --git a/net-wireless/gr-osmosdr/files/csete-iio.patch b/net-wireless/gr-osmosdr/files/csete-iio.patch |
21 |
new file mode 100644 |
22 |
index 00000000000..678a8599d05 |
23 |
--- /dev/null |
24 |
+++ b/net-wireless/gr-osmosdr/files/csete-iio.patch |
25 |
@@ -0,0 +1,640 @@ |
26 |
+From 0eaf819be8a40896dfc3d810685a609a867a42e9 Mon Sep 17 00:00:00 2001 |
27 |
+From: Alexandru Csete <oz9aec@×××××.com> |
28 |
+Date: Mon, 13 Feb 2017 01:05:50 +0100 |
29 |
+Subject: [PATCH] Add PlutoSDR source through gr-iio |
30 |
+ |
31 |
+--- |
32 |
+ CMakeLists.txt | 1 + |
33 |
+ cmake/Modules/FindGnuradioIIO.cmake | 34 ++++ |
34 |
+ cmake/Modules/FindIIO.cmake | 28 +++ |
35 |
+ lib/CMakeLists.txt | 8 + |
36 |
+ lib/config.h.in | 1 + |
37 |
+ lib/device.cc | 8 + |
38 |
+ lib/plutosdr/CMakeLists.txt | 39 +++++ |
39 |
+ lib/plutosdr/plutosdr_source_c.cc | 262 ++++++++++++++++++++++++++++ |
40 |
+ lib/plutosdr/plutosdr_source_c.h | 105 +++++++++++ |
41 |
+ lib/source_impl.cc | 18 ++ |
42 |
+ 10 files changed, 504 insertions(+) |
43 |
+ create mode 100644 cmake/Modules/FindGnuradioIIO.cmake |
44 |
+ create mode 100644 cmake/Modules/FindIIO.cmake |
45 |
+ create mode 100644 lib/plutosdr/CMakeLists.txt |
46 |
+ create mode 100644 lib/plutosdr/plutosdr_source_c.cc |
47 |
+ create mode 100644 lib/plutosdr/plutosdr_source_c.h |
48 |
+ |
49 |
+diff --git a/CMakeLists.txt b/CMakeLists.txt |
50 |
+index 296456d..7871f39 100644 |
51 |
+--- a/CMakeLists.txt |
52 |
++++ b/CMakeLists.txt |
53 |
+@@ -159,6 +159,7 @@ endif() |
54 |
+ find_package(GnuradioIQBalance) |
55 |
+ find_package(UHD) |
56 |
+ find_package(GnuradioUHD) |
57 |
++find_package(GnuradioIIO) |
58 |
+ find_package(GnuradioFCD) |
59 |
+ find_package(GnuradioFCDPP) |
60 |
+ find_package(LibOsmoSDR) |
61 |
+diff --git a/cmake/Modules/FindGnuradioIIO.cmake b/cmake/Modules/FindGnuradioIIO.cmake |
62 |
+new file mode 100644 |
63 |
+index 0000000..d3c011a |
64 |
+--- /dev/null |
65 |
++++ b/cmake/Modules/FindGnuradioIIO.cmake |
66 |
+@@ -0,0 +1,34 @@ |
67 |
++INCLUDE(FindPkgConfig) |
68 |
++PKG_CHECK_MODULES(PC_GNURADIO_IIO gnuradio-iio) |
69 |
++ |
70 |
++FIND_PATH( |
71 |
++ GNURADIO_IIO_INCLUDE_DIRS |
72 |
++ NAMES gnuradio/iio/api.h |
73 |
++ HINTS $ENV{GNURADIO_IIO_DIR}/include |
74 |
++ ${PC_GNURADIO_IIO_INCLUDEDIR} |
75 |
++ PATHS /usr/local/include |
76 |
++ /usr/include |
77 |
++) |
78 |
++ |
79 |
++FIND_LIBRARY( |
80 |
++ GNURADIO_IIO_LIBRARIES |
81 |
++ NAMES gnuradio-iio |
82 |
++ HINTS $ENV{GNURADIO_IIO_DIR}/lib |
83 |
++ ${PC_GNURADIO_IIO_LIBDIR} |
84 |
++ PATHS /usr/local/lib |
85 |
++ /usr/local/lib64 |
86 |
++ /usr/lib |
87 |
++ /usr/lib64 |
88 |
++) |
89 |
++ |
90 |
++if(GNURADIO_IIO_INCLUDE_DIRS AND GNURADIO_IIO_LIBRARIES) |
91 |
++ set(GNURADIO_IIO_FOUND TRUE CACHE INTERNAL "gnuradio-iio found") |
92 |
++ message(STATUS "Found gnuradio-iio: ${GNURADIO_IIO_INCLUDE_DIRS}, ${GNURADIO_IIO_LIBRARIES}") |
93 |
++else(GNURADIO_IIO_INCLUDE_DIRS AND GNURADIO_IIO_LIBRARIES) |
94 |
++ set(GNURADIO_IIO_FOUND FALSE CACHE INTERNAL "gnuradio-iio found") |
95 |
++ message(STATUS "gnuradio-iio not found.") |
96 |
++endif(GNURADIO_IIO_INCLUDE_DIRS AND GNURADIO_IIO_LIBRARIES) |
97 |
++ |
98 |
++INCLUDE(FindPackageHandleStandardArgs) |
99 |
++FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_IIO DEFAULT_MSG GNURADIO_IIO_LIBRARIES GNURADIO_IIO_INCLUDE_DIRS) |
100 |
++MARK_AS_ADVANCED(GNURADIO_IIO_LIBRARIES GNURADIO_IIO_INCLUDE_DIRS) |
101 |
+diff --git a/cmake/Modules/FindIIO.cmake b/cmake/Modules/FindIIO.cmake |
102 |
+new file mode 100644 |
103 |
+index 0000000..bb87a4b |
104 |
+--- /dev/null |
105 |
++++ b/cmake/Modules/FindIIO.cmake |
106 |
+@@ -0,0 +1,28 @@ |
107 |
++######################################################################## |
108 |
++# Find the IIO userspace library |
109 |
++######################################################################## |
110 |
++ |
111 |
++INCLUDE(FindPkgConfig) |
112 |
++PKG_CHECK_MODULES(PC_IIO iio) |
113 |
++ |
114 |
++FIND_PATH( |
115 |
++ IIO_INCLUDE_DIRS |
116 |
++ NAMES iio.h |
117 |
++ HINTS $ENV{IIO_DIR}/include |
118 |
++ ${PC_IIO_INCLUDEDIR} |
119 |
++ PATHS /usr/local/include |
120 |
++ /usr/include |
121 |
++) |
122 |
++ |
123 |
++FIND_LIBRARY( |
124 |
++ IIO_LIBRARIES |
125 |
++ NAMES iio |
126 |
++ HINTS $ENV{IIO_DIR}/lib |
127 |
++ ${PC_IIO_LIBDIR} |
128 |
++ PATHS /usr/local/lib |
129 |
++ /usr/lib |
130 |
++) |
131 |
++ |
132 |
++INCLUDE(FindPackageHandleStandardArgs) |
133 |
++FIND_PACKAGE_HANDLE_STANDARD_ARGS(IIO DEFAULT_MSG IIO_LIBRARIES IIO_INCLUDE_DIRS) |
134 |
++MARK_AS_ADVANCED(IIO_LIBRARIES IIO_INCLUDE_DIRS) |
135 |
+diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt |
136 |
+index c05b8d9..936d84b 100644 |
137 |
+--- a/lib/CMakeLists.txt |
138 |
++++ b/lib/CMakeLists.txt |
139 |
+@@ -174,6 +174,14 @@ if(ENABLE_UHD) |
140 |
+ GR_INCLUDE_SUBDIRECTORY(uhd) |
141 |
+ endif(ENABLE_UHD) |
142 |
+ |
143 |
++######################################################################## |
144 |
++# Setup IIO component |
145 |
++######################################################################## |
146 |
++GR_REGISTER_COMPONENT("IIO Devices" ENABLE_IIO GNURADIO_IIO_FOUND) |
147 |
++if(ENABLE_IIO) |
148 |
++GR_INCLUDE_SUBDIRECTORY(plutosdr) |
149 |
++endif(ENABLE_IIO) |
150 |
++ |
151 |
+ ######################################################################## |
152 |
+ # Setup MiriSDR component |
153 |
+ ######################################################################## |
154 |
+diff --git a/lib/config.h.in b/lib/config.h.in |
155 |
+index 42e72f1..0fe2731 100644 |
156 |
+--- a/lib/config.h.in |
157 |
++++ b/lib/config.h.in |
158 |
+@@ -10,6 +10,7 @@ |
159 |
+ #cmakedefine ENABLE_RTL |
160 |
+ #cmakedefine ENABLE_RTL_TCP |
161 |
+ #cmakedefine ENABLE_UHD |
162 |
++#cmakedefine ENABLE_IIO |
163 |
+ #cmakedefine ENABLE_MIRI |
164 |
+ #cmakedefine ENABLE_SDRPLAY |
165 |
+ #cmakedefine ENABLE_HACKRF |
166 |
+diff --git a/lib/device.cc b/lib/device.cc |
167 |
+index 025a22b..77b271f 100644 |
168 |
+--- a/lib/device.cc |
169 |
++++ b/lib/device.cc |
170 |
+@@ -54,6 +54,10 @@ |
171 |
+ #include <uhd_source_c.h> |
172 |
+ #endif |
173 |
+ |
174 |
++#ifdef ENABLE_IIO |
175 |
++#include <plutosdr_source_c.h> |
176 |
++#endif |
177 |
++ |
178 |
+ #ifdef ENABLE_MIRI |
179 |
+ #include <miri_source_c.h> |
180 |
+ #endif |
181 |
+@@ -162,6 +166,10 @@ devices_t device::find(const device_t &hint) |
182 |
+ BOOST_FOREACH( std::string dev, uhd_source_c::get_devices() ) |
183 |
+ devices.push_back( device_t(dev) ); |
184 |
+ #endif |
185 |
++#ifdef ENABLE_IIO |
186 |
++ BOOST_FOREACH( std::string dev, plutosdr_source_c::get_devices() ) |
187 |
++ devices.push_back( device_t(dev) ); |
188 |
++#endif |
189 |
+ #ifdef ENABLE_MIRI |
190 |
+ BOOST_FOREACH( std::string dev, miri_source_c::get_devices() ) |
191 |
+ devices.push_back( device_t(dev) ); |
192 |
+diff --git a/lib/plutosdr/CMakeLists.txt b/lib/plutosdr/CMakeLists.txt |
193 |
+new file mode 100644 |
194 |
+index 0000000..b335885 |
195 |
+--- /dev/null |
196 |
++++ b/lib/plutosdr/CMakeLists.txt |
197 |
+@@ -0,0 +1,39 @@ |
198 |
++# Copyright 2012 Free Software Foundation, Inc. |
199 |
++# |
200 |
++# This file is part of GNU Radio |
201 |
++# |
202 |
++# GNU Radio is free software; you can redistribute it and/or modify |
203 |
++# it under the terms of the GNU General Public License as published by |
204 |
++# the Free Software Foundation; either version 3, or (at your option) |
205 |
++# any later version. |
206 |
++# |
207 |
++# GNU Radio is distributed in the hope that it will be useful, |
208 |
++# but WITHOUT ANY WARRANTY; without even the implied warranty of |
209 |
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
210 |
++# GNU General Public License for more details. |
211 |
++# |
212 |
++# You should have received a copy of the GNU General Public License |
213 |
++# along with GNU Radio; see the file COPYING. If not, write to |
214 |
++# the Free Software Foundation, Inc., 51 Franklin Street, |
215 |
++# Boston, MA 02110-1301, USA. |
216 |
++ |
217 |
++######################################################################## |
218 |
++# This file included, use CMake directory variables |
219 |
++######################################################################## |
220 |
++ |
221 |
++include_directories( |
222 |
++ ${CMAKE_CURRENT_SOURCE_DIR} |
223 |
++ ${GNURADIO_IIO_INCLUDE_DIRS} |
224 |
++ ${IIO_INCLUDE_DIRS} |
225 |
++) |
226 |
++ |
227 |
++set(iio_srcs |
228 |
++# ${CMAKE_CURRENT_SOURCE_DIR}/iio_sink_c.cc |
229 |
++ ${CMAKE_CURRENT_SOURCE_DIR}/plutosdr_source_c.cc |
230 |
++) |
231 |
++ |
232 |
++######################################################################## |
233 |
++# Append gnuradio-osmosdr library sources |
234 |
++######################################################################## |
235 |
++list(APPEND gr_osmosdr_srcs ${iio_srcs}) |
236 |
++list(APPEND gr_osmosdr_libs ${GNURADIO_IIO_LIBRARIES} ${IIO_LIBRARIES}) |
237 |
+diff --git a/lib/plutosdr/plutosdr_source_c.cc b/lib/plutosdr/plutosdr_source_c.cc |
238 |
+new file mode 100644 |
239 |
+index 0000000..009d4b2 |
240 |
+--- /dev/null |
241 |
++++ b/lib/plutosdr/plutosdr_source_c.cc |
242 |
+@@ -0,0 +1,262 @@ |
243 |
++/* -*- c++ -*- */ |
244 |
++/* |
245 |
++ * Copyright 2017 Dimitri Stolnikov <horiz0n@×××.net> |
246 |
++ * |
247 |
++ * GNU Radio is free software; you can redistribute it and/or modify |
248 |
++ * it under the terms of the GNU General Public License as published by |
249 |
++ * the Free Software Foundation; either version 3, or (at your option) |
250 |
++ * any later version. |
251 |
++ * |
252 |
++ * GNU Radio is distributed in the hope that it will be useful, |
253 |
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
254 |
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
255 |
++ * GNU General Public License for more details. |
256 |
++ * |
257 |
++ * You should have received a copy of the GNU General Public License |
258 |
++ * along with GNU Radio; see the file COPYING. If not, write to |
259 |
++ * the Free Software Foundation, Inc., 51 Franklin Street, |
260 |
++ * Boston, MA 02110-1301, USA. |
261 |
++ */ |
262 |
++#include <boost/assign.hpp> |
263 |
++#include <iostream> |
264 |
++ |
265 |
++#include "arg_helpers.h" |
266 |
++#include "osmosdr/source.h" |
267 |
++#include "plutosdr_source_c.h" |
268 |
++ |
269 |
++using namespace boost::assign; |
270 |
++ |
271 |
++plutosdr_source_c_sptr make_plutosdr_source_c(const std::string &args) |
272 |
++{ |
273 |
++ return gnuradio::get_initial_sptr(new plutosdr_source_c(args)); |
274 |
++} |
275 |
++ |
276 |
++plutosdr_source_c::plutosdr_source_c(const std::string &args) : |
277 |
++ gr::hier_block2("plutosdr_source_c", |
278 |
++ gr::io_signature::make(0, 0, 0), |
279 |
++ gr::io_signature::make(1, 1, sizeof(gr_complex))) |
280 |
++{ |
281 |
++ uri = "ip:pluto.local"; |
282 |
++ frequency = 434000000; |
283 |
++ samplerate = 2500000; |
284 |
++ decimation = 0; |
285 |
++ bandwidth = 2000000; |
286 |
++ buffer_size = 0x4000; |
287 |
++ quadrature = true; |
288 |
++ rfdc = true; |
289 |
++ bbdc = true; |
290 |
++ gain_auto = false; |
291 |
++ gain_value = 50; |
292 |
++ filter = ""; |
293 |
++ filter_auto = true; |
294 |
++ _freq_corr = 0.0; |
295 |
++ |
296 |
++ dict_t dict = params_to_dict(args); |
297 |
++ if (dict.count("uri")) |
298 |
++ uri = boost::lexical_cast< std::string >( dict["uri"] ); |
299 |
++ |
300 |
++ std::cerr << "Using PlutoSDR URI = " << uri << std::endl; |
301 |
++ |
302 |
++ _src = gr::iio::pluto_source::make(uri, frequency, samplerate, |
303 |
++ bandwidth, buffer_size, |
304 |
++ quadrature, rfdc, bbdc, |
305 |
++ "manual", gain_value, |
306 |
++ filter.c_str(), filter_auto); |
307 |
++ |
308 |
++ connect( _src, 0, self(), 0 ); |
309 |
++} |
310 |
++ |
311 |
++plutosdr_source_c::~plutosdr_source_c() |
312 |
++{ |
313 |
++} |
314 |
++ |
315 |
++std::vector< std::string > plutosdr_source_c::get_devices() |
316 |
++{ |
317 |
++ std::vector< std::string > devices; |
318 |
++ |
319 |
++ std::string args = "plutosdr,label='PlutoSDR'"; |
320 |
++ |
321 |
++ devices.push_back( args ); |
322 |
++ |
323 |
++ return devices; |
324 |
++} |
325 |
++ |
326 |
++std::string plutosdr_source_c::name() |
327 |
++{ |
328 |
++ return "PlutoSDR"; |
329 |
++} |
330 |
++ |
331 |
++size_t plutosdr_source_c::get_num_channels() |
332 |
++{ |
333 |
++ return output_signature()->max_streams(); |
334 |
++} |
335 |
++ |
336 |
++osmosdr::meta_range_t plutosdr_source_c::get_sample_rates( void ) |
337 |
++{ |
338 |
++ osmosdr::meta_range_t rates; |
339 |
++ |
340 |
++ rates += osmosdr::range_t( 2500000 ); |
341 |
++ rates += osmosdr::range_t( 5000000 ); |
342 |
++ rates += osmosdr::range_t( 10000000 ); |
343 |
++ rates += osmosdr::range_t( 20000000 ); |
344 |
++ |
345 |
++ return rates; |
346 |
++} |
347 |
++ |
348 |
++double plutosdr_source_c::set_sample_rate( double rate ) |
349 |
++{ |
350 |
++ samplerate = (unsigned long) rate; |
351 |
++ set_params(); |
352 |
++ |
353 |
++ return samplerate; |
354 |
++} |
355 |
++ |
356 |
++double plutosdr_source_c::get_sample_rate( void ) |
357 |
++{ |
358 |
++ return samplerate; |
359 |
++} |
360 |
++ |
361 |
++osmosdr::freq_range_t plutosdr_source_c::get_freq_range( size_t chan ) |
362 |
++{ |
363 |
++ osmosdr::freq_range_t range; |
364 |
++ |
365 |
++ range += osmosdr::range_t( 70.0e6, 6000.0e6, 1.0 ); |
366 |
++ |
367 |
++ return range; |
368 |
++} |
369 |
++ |
370 |
++double plutosdr_source_c::set_center_freq( double freq, size_t chan ) |
371 |
++{ |
372 |
++ frequency = (unsigned long long) freq; |
373 |
++ set_params(); |
374 |
++ |
375 |
++ return freq; |
376 |
++} |
377 |
++ |
378 |
++double plutosdr_source_c::get_center_freq( size_t chan ) |
379 |
++{ |
380 |
++ return frequency; |
381 |
++} |
382 |
++ |
383 |
++double plutosdr_source_c::set_freq_corr( double ppm, size_t chan) |
384 |
++{ |
385 |
++ _freq_corr = ppm; |
386 |
++ set_params(); |
387 |
++ |
388 |
++ return ppm; |
389 |
++} |
390 |
++ |
391 |
++double plutosdr_source_c::get_freq_corr( size_t chan) |
392 |
++{ |
393 |
++ return _freq_corr; |
394 |
++} |
395 |
++ |
396 |
++std::vector<std::string> plutosdr_source_c::get_gain_names( size_t chan ) |
397 |
++{ |
398 |
++ std::vector< std::string > gains; |
399 |
++ |
400 |
++ gains.push_back( "RF" ); |
401 |
++ |
402 |
++ return gains; |
403 |
++} |
404 |
++ |
405 |
++osmosdr::gain_range_t plutosdr_source_c::get_gain_range( size_t chan) |
406 |
++{ |
407 |
++ osmosdr::gain_range_t range; |
408 |
++ range += osmosdr::range_t( -10, 77, 1 ); // https://wiki.analog.com/resources/tools-software/linux-drivers/iio-transceiver/ad9361#rx_gain_control |
409 |
++ |
410 |
++ return range; |
411 |
++} |
412 |
++ |
413 |
++osmosdr::gain_range_t plutosdr_source_c::get_gain_range( const std::string & name, |
414 |
++ size_t chan) |
415 |
++{ |
416 |
++ osmosdr::gain_range_t range; |
417 |
++ |
418 |
++ range += osmosdr::range_t( -10, 77, 1 ); |
419 |
++ |
420 |
++ return range; |
421 |
++} |
422 |
++ |
423 |
++bool plutosdr_source_c::set_gain_mode( bool automatic, size_t chan ) |
424 |
++{ |
425 |
++ gain_auto = automatic; |
426 |
++ set_params(); |
427 |
++ |
428 |
++ return automatic; |
429 |
++} |
430 |
++ |
431 |
++bool plutosdr_source_c::get_gain_mode( size_t chan ) |
432 |
++{ |
433 |
++ return gain_auto; |
434 |
++} |
435 |
++ |
436 |
++double plutosdr_source_c::set_gain( double gain, size_t chan ) |
437 |
++{ |
438 |
++ gain_value = gain; |
439 |
++ set_params(); |
440 |
++ |
441 |
++ return gain; |
442 |
++} |
443 |
++ |
444 |
++double plutosdr_source_c::set_gain( double gain, const std::string & name, size_t chan ) |
445 |
++{ |
446 |
++ gain_value = gain; |
447 |
++ set_params(); |
448 |
++ |
449 |
++ return gain; |
450 |
++} |
451 |
++ |
452 |
++double plutosdr_source_c::get_gain( size_t chan ) |
453 |
++{ |
454 |
++ return gain_value; |
455 |
++} |
456 |
++ |
457 |
++double plutosdr_source_c::get_gain( const std::string & name, size_t chan ) |
458 |
++{ |
459 |
++ return gain_value; |
460 |
++} |
461 |
++ |
462 |
++std::vector< std::string > plutosdr_source_c::get_antennas( size_t chan ) |
463 |
++{ |
464 |
++ std::vector< std::string > antennas; |
465 |
++ |
466 |
++ antennas += get_antenna( chan ); |
467 |
++ |
468 |
++ return antennas; |
469 |
++} |
470 |
++ |
471 |
++std::string plutosdr_source_c::set_antenna( const std::string & antenna, size_t chan ) |
472 |
++{ |
473 |
++ return get_antenna( chan ); |
474 |
++} |
475 |
++ |
476 |
++std::string plutosdr_source_c::get_antenna( size_t chan ) |
477 |
++{ |
478 |
++ return "A_BALANCED"; |
479 |
++} |
480 |
++ |
481 |
++double plutosdr_source_c::set_bandwidth( double bw, size_t chan ) |
482 |
++{ |
483 |
++ if (bw == 0.0) |
484 |
++ bw = 0.8 * samplerate; // auto bandwidth |
485 |
++ |
486 |
++ bandwidth = (unsigned long)bw; |
487 |
++ set_params(); |
488 |
++ return bandwidth; |
489 |
++} |
490 |
++ |
491 |
++double plutosdr_source_c::get_bandwidth( size_t chan ) |
492 |
++{ |
493 |
++ return bandwidth; |
494 |
++} |
495 |
++ |
496 |
++void plutosdr_source_c::set_params( void ) |
497 |
++{ |
498 |
++ unsigned long long freq = ((double)frequency * (1.0 + _freq_corr * 0.000001)); |
499 |
++ |
500 |
++ // FIXME: gain_mode string can be manual / slow_attack / fast_attack / hybrid |
501 |
++ _src->set_params( freq, samplerate, bandwidth, quadrature, rfdc, bbdc, |
502 |
++ gain_auto ? "fast_attack" : "manual", gain_value, |
503 |
++ filter.c_str(), filter_auto ); |
504 |
++} |
505 |
+diff --git a/lib/plutosdr/plutosdr_source_c.h b/lib/plutosdr/plutosdr_source_c.h |
506 |
+new file mode 100644 |
507 |
+index 0000000..efac91f |
508 |
+--- /dev/null |
509 |
++++ b/lib/plutosdr/plutosdr_source_c.h |
510 |
+@@ -0,0 +1,105 @@ |
511 |
++/* -*- c++ -*- */ |
512 |
++/* |
513 |
++ * Copyright 2017 Dimitri Stolnikov <horiz0n@×××.net> |
514 |
++ * |
515 |
++ * GNU Radio is free software; you can redistribute it and/or modify |
516 |
++ * it under the terms of the GNU General Public License as published by |
517 |
++ * the Free Software Foundation; either version 3, or (at your option) |
518 |
++ * any later version. |
519 |
++ * |
520 |
++ * GNU Radio is distributed in the hope that it will be useful, |
521 |
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
522 |
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
523 |
++ * GNU General Public License for more details. |
524 |
++ * |
525 |
++ * You should have received a copy of the GNU General Public License |
526 |
++ * along with GNU Radio; see the file COPYING. If not, write to |
527 |
++ * the Free Software Foundation, Inc., 51 Franklin Street, |
528 |
++ * Boston, MA 02110-1301, USA. |
529 |
++ */ |
530 |
++#ifndef PLUTOSDR_SOURCE_C_H |
531 |
++#define PLUTOSDR_SOURCE_C_H |
532 |
++ |
533 |
++#include <gnuradio/blocks/float_to_complex.h> |
534 |
++#include <gnuradio/blocks/short_to_float.h> |
535 |
++#include <gnuradio/hier_block2.h> |
536 |
++#include <gnuradio/iio/pluto_source.h> |
537 |
++ |
538 |
++#include "source_iface.h" |
539 |
++ |
540 |
++class plutosdr_source_c; |
541 |
++ |
542 |
++typedef boost::shared_ptr< plutosdr_source_c > plutosdr_source_c_sptr; |
543 |
++ |
544 |
++plutosdr_source_c_sptr make_plutosdr_source_c(const std::string &args = ""); |
545 |
++ |
546 |
++class plutosdr_source_c : |
547 |
++ public gr::hier_block2, |
548 |
++ public source_iface |
549 |
++{ |
550 |
++private: |
551 |
++ friend plutosdr_source_c_sptr make_plutosdr_source_c(const std::string &args); |
552 |
++ |
553 |
++ plutosdr_source_c(const std::string &args); |
554 |
++ |
555 |
++public: |
556 |
++ ~plutosdr_source_c(); |
557 |
++ |
558 |
++ static std::vector< std::string > get_devices(); |
559 |
++ |
560 |
++ std::string name(); |
561 |
++ |
562 |
++ size_t get_num_channels( void ); |
563 |
++ |
564 |
++ osmosdr::meta_range_t get_sample_rates( void ); |
565 |
++ double set_sample_rate( double rate ); |
566 |
++ double get_sample_rate( void ); |
567 |
++ |
568 |
++ osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); |
569 |
++ double set_center_freq( double freq, size_t chan = 0 ); |
570 |
++ double get_center_freq( size_t chan = 0 ); |
571 |
++ |
572 |
++ double set_freq_corr( double ppm, size_t chan = 0 ); |
573 |
++ double get_freq_corr( size_t chan = 0 ); |
574 |
++ |
575 |
++ std::vector<std::string> get_gain_names( size_t chan = 0 ); |
576 |
++ osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); |
577 |
++ osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); |
578 |
++ bool set_gain_mode( bool automatic, size_t chan = 0 ); |
579 |
++ bool get_gain_mode( size_t chan = 0 ); |
580 |
++ double set_gain( double gain, size_t chan = 0 ); |
581 |
++ double set_gain( double gain, const std::string & name, size_t chan = 0 ); |
582 |
++ double get_gain( size_t chan = 0 ); |
583 |
++ double get_gain( const std::string & name, size_t chan = 0 ); |
584 |
++ |
585 |
++ std::vector< std::string > get_antennas( size_t chan = 0 ); |
586 |
++ std::string set_antenna( const std::string & antenna, size_t chan = 0 ); |
587 |
++ std::string get_antenna( size_t chan = 0 ); |
588 |
++ |
589 |
++ double set_bandwidth( double bw, size_t chan = 0 ); |
590 |
++ double get_bandwidth( size_t chan = 0 ); |
591 |
++ |
592 |
++private: |
593 |
++ |
594 |
++ void set_params(void); |
595 |
++ |
596 |
++ gr::iio::pluto_source::sptr _src; |
597 |
++ |
598 |
++ std::string uri; |
599 |
++ unsigned long long frequency; |
600 |
++ unsigned long samplerate; |
601 |
++ unsigned long decimation; |
602 |
++ unsigned long bandwidth; |
603 |
++ unsigned long buffer_size; |
604 |
++ bool quadrature; |
605 |
++ bool rfdc; |
606 |
++ bool bbdc; |
607 |
++ bool gain_auto; |
608 |
++ double gain_value; |
609 |
++ std::string filter; |
610 |
++ bool filter_auto; |
611 |
++ |
612 |
++ double _freq_corr; |
613 |
++}; |
614 |
++ |
615 |
++#endif // PLUTOSDR_SOURCE_C_H |
616 |
+diff --git a/lib/source_impl.cc b/lib/source_impl.cc |
617 |
+index a28f314..2a153bc 100644 |
618 |
+--- a/lib/source_impl.cc |
619 |
++++ b/lib/source_impl.cc |
620 |
+@@ -56,6 +56,10 @@ |
621 |
+ #include <uhd_source_c.h> |
622 |
+ #endif |
623 |
+ |
624 |
++#ifdef ENABLE_IIO |
625 |
++#include <plutosdr_source_c.h> |
626 |
++#endif |
627 |
++ |
628 |
+ #ifdef ENABLE_MIRI |
629 |
+ #include <miri_source_c.h> |
630 |
+ #endif |
631 |
+@@ -144,6 +148,9 @@ source_impl::source_impl( const std::string &args ) |
632 |
+ #ifdef ENABLE_UHD |
633 |
+ dev_types.push_back("uhd"); |
634 |
+ #endif |
635 |
++#ifdef ENABLE_IIO |
636 |
++ dev_types.push_back("plutosdr"); |
637 |
++#endif |
638 |
+ #ifdef ENABLE_MIRI |
639 |
+ dev_types.push_back("miri"); |
640 |
+ #endif |
641 |
+@@ -216,6 +223,10 @@ source_impl::source_impl( const std::string &args ) |
642 |
+ BOOST_FOREACH( std::string dev, uhd_source_c::get_devices() ) |
643 |
+ dev_list.push_back( dev ); |
644 |
+ #endif |
645 |
++#ifdef ENABLE_IIO |
646 |
++ BOOST_FOREACH( std::string dev, plutosdr_source_c::get_devices() ) |
647 |
++ dev_list.push_back( dev ); |
648 |
++#endif |
649 |
+ #ifdef ENABLE_MIRI |
650 |
+ BOOST_FOREACH( std::string dev, miri_source_c::get_devices() ) |
651 |
+ dev_list.push_back( dev ); |
652 |
+@@ -316,6 +327,13 @@ source_impl::source_impl( const std::string &args ) |
653 |
+ } |
654 |
+ #endif |
655 |
+ |
656 |
++#ifdef ENABLE_IIO |
657 |
++ if ( dict.count("plutosdr") ) { |
658 |
++ plutosdr_source_c_sptr src = make_plutosdr_source_c( arg ); |
659 |
++ block = src; iface = src.get(); |
660 |
++ } |
661 |
++#endif |
662 |
++ |
663 |
+ #ifdef ENABLE_MIRI |
664 |
+ if ( dict.count("miri") ) { |
665 |
+ miri_source_c_sptr src = make_miri_source_c( arg ); |
666 |
|
667 |
diff --git a/net-wireless/gr-osmosdr/gr-osmosdr-0.1.4_p20180626-r1.ebuild b/net-wireless/gr-osmosdr/gr-osmosdr-0.1.4_p20180626-r1.ebuild |
668 |
new file mode 100644 |
669 |
index 00000000000..3c468c6f97e |
670 |
--- /dev/null |
671 |
+++ b/net-wireless/gr-osmosdr/gr-osmosdr-0.1.4_p20180626-r1.ebuild |
672 |
@@ -0,0 +1,80 @@ |
673 |
+# Copyright 1999-2018 Gentoo Foundation |
674 |
+# Distributed under the terms of the GNU General Public License v2 |
675 |
+ |
676 |
+EAPI=6 |
677 |
+PYTHON_COMPAT=( python2_7 ) |
678 |
+ |
679 |
+inherit cmake-utils python-single-r1 |
680 |
+ |
681 |
+DESCRIPTION="GNU Radio source block for OsmoSDR and rtlsdr and hackrf" |
682 |
+HOMEPAGE="http://sdr.osmocom.org/trac/wiki/GrOsmoSDR" |
683 |
+ |
684 |
+if [[ ${PV} == 9999* ]]; then |
685 |
+ inherit git-r3 |
686 |
+ SRC_URI="" |
687 |
+ EGIT_REPO_URI="git://git.osmocom.org/${PN}.git" |
688 |
+ KEYWORDS="" |
689 |
+else |
690 |
+ #SRC_URI="http://cgit.osmocom.org/gr-osmosdr/snapshot/gr-osmosdr-${PV}.tar.xz" |
691 |
+ #git clone git://git.osmocom.org/gr-osmosdr.git |
692 |
+ #cd gr-osmosdr |
693 |
+ #git archive --format=tar --prefix=gr-osmosdr-${PV}/ v${PV} | xz > ../gr-osmosdr-${PV}.tar.xz |
694 |
+ SRC_URI="https://dev.gentoo.org/~zerochaos/distfiles/gr-osmosdr-${PV}.tar.xz" |
695 |
+ KEYWORDS="" |
696 |
+fi |
697 |
+ |
698 |
+LICENSE="GPL-3" |
699 |
+SLOT="0/${PV}" |
700 |
+IUSE="bladerf fcd hackrf iio iqbalance mirisdr python rtlsdr sdrplay soapy uhd" |
701 |
+ |
702 |
+RDEPEND="${PYTHON_DEPS} |
703 |
+ dev-libs/boost:= |
704 |
+ >=net-wireless/gnuradio-3.7_rc:0=[fcd?,${PYTHON_USEDEP}] |
705 |
+ bladerf? ( >=net-wireless/bladerf-2018.08_rc1:= ) |
706 |
+ hackrf? ( net-libs/libhackrf:= ) |
707 |
+ iio? ( net-wireless/gr-iio ) |
708 |
+ iqbalance? ( net-wireless/gr-iqbal:=[${PYTHON_USEDEP}] ) |
709 |
+ mirisdr? ( net-libs/libmirisdr:= ) |
710 |
+ rtlsdr? ( >=net-wireless/rtl-sdr-0.5.3:= ) |
711 |
+ sdrplay? ( net-wireless/sdrplay ) |
712 |
+ soapy? ( net-wireless/soapysdr ) |
713 |
+ uhd? ( net-wireless/uhd:=[${PYTHON_USEDEP}] )" |
714 |
+DEPEND="${RDEPEND} |
715 |
+ dev-python/cheetah" |
716 |
+ |
717 |
+REQUIRED_USE="${PYTHON_REQUIRED_USE}" |
718 |
+ |
719 |
+src_prepare() { |
720 |
+ eapply "${FILESDIR}/csete-iio.patch" |
721 |
+ cmake-utils_src_prepare |
722 |
+} |
723 |
+ |
724 |
+src_configure() { |
725 |
+ local mycmakeargs=( |
726 |
+ -DENABLE_DEFAULT=OFF |
727 |
+ -DPYTHON_EXECUTABLE="${PYTHON}" |
728 |
+ -DENABLE_FILE=ON |
729 |
+ -DENABLE_BLADERF="$(usex bladerf)" |
730 |
+ -DENABLE_FCD="$(usex fcd)" |
731 |
+ -DENABLE_HACKRF="$(usex hackrf)" |
732 |
+ -DENABLE_IIO="$(usex iio)" |
733 |
+ -DENABLE_IQBALANCE="$(usex iqbalance)" |
734 |
+ -DENABLE_MIRI="$(usex mirisdr)" |
735 |
+ -DENABLE_PYTHON="$(usex python)" |
736 |
+ -DENABLE_RTL="$(usex rtlsdr)" |
737 |
+ -DENABLE_RTL_TCP="$(usex rtlsdr)" |
738 |
+ -DENABLE_SOAPY="$(usex soapy)" |
739 |
+ -DENABLE_UHD="$(usex uhd)" |
740 |
+ -DENABLE_SDRPLAY="$(usex sdrplay)" |
741 |
+ -DENABLE_NONFREE="$(usex sdrplay)" |
742 |
+ ) |
743 |
+ |
744 |
+ cmake-utils_src_configure |
745 |
+} |
746 |
+ |
747 |
+src_install() { |
748 |
+ cmake-utils_src_install |
749 |
+ if use python; then |
750 |
+ python_fix_shebang "${ED}"/usr/bin |
751 |
+ fi |
752 |
+} |
753 |
|
754 |
diff --git a/net-wireless/gr-osmosdr/metadata.xml b/net-wireless/gr-osmosdr/metadata.xml |
755 |
index 2ffcfa21c90..b55e17a0636 100644 |
756 |
--- a/net-wireless/gr-osmosdr/metadata.xml |
757 |
+++ b/net-wireless/gr-osmosdr/metadata.xml |
758 |
@@ -9,6 +9,7 @@ |
759 |
<flag name="bladerf">Build with Nuand BladeRF support</flag> |
760 |
<flag name="fcd">Build with Funcube Dongle support</flag> |
761 |
<flag name="hackrf">Build with Great Scott Gadgets HackRF support</flag> |
762 |
+ <flag name="iio">Build with Industrial IO support for devices such as Analog Devices Pluto</flag> |
763 |
<flag name="iqbalance">Enable support for I/Q balancing using gr-iqbal</flag> |
764 |
<flag name="mirisdr">Build with Mirics MSi2500 + MSi001 SDR support</flag> |
765 |
<flag name="rtlsdr">Build with Realtek RTL2832U (rtlsdr) support</flag> |