Re: [PATCH] gr-osmosdr Microtelecom Perseus HF receiver support (II)

2018-08-21 Thread Andrea Montefusco IW0HDV
Hi Dimitri,

>> could you please provide a signed-off patch with your latest changes 
>> ongithub and a proper commit message?
>> Feel free to add information to AUTHORS, README and the 
>> grc/gen_osmosdr_blocks.py files just like we did for other radios and 
>> ideally include a link where libperseus is hosted (I understand this is 
>> https://github.com/Microtelecom/libperseus-sdr ?).

I added the infor requested and even tested the module under GRC (non only 
under GQRX that is the reason I developed the patch at start).

Below you find the patch as per git command.

  *am* IW0HDV

---
 CMakeLists.txt |   1 +
 cmake/Modules/FindLibPERSEUS.cmake |  24 ++
 lib/CMakeLists.txt |   8 +
 lib/airspy/airspy_source_c.cc  |   5 +-
 lib/config.h.in|   1 +
 lib/device.cc  |   8 +
 lib/perseus/CMakeLists.txt |  37 +++
 lib/perseus/perseus_source_c.cc| 507 +
 lib/perseus/perseus_source_c.h | 120 +
 lib/rtl/rtl_source_c.cc|   2 +-
 lib/source_impl.cc |  18 +-
 11 files changed, 727 insertions(+), 4 deletions(-)
 create mode 100644 cmake/Modules/FindLibPERSEUS.cmake
 create mode 100644 lib/perseus/CMakeLists.txt
 create mode 100644 lib/perseus/perseus_source_c.cc
 create mode 100644 lib/perseus/perseus_source_c.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 296456d..94acd4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -173,6 +173,7 @@ find_package(Volk)
 find_package(LibbladeRF)
 find_package(SoapySDR NO_MODULE)
 find_package(LibFreeSRP)
+find_package(LibPERSEUS)
 find_package(Doxygen)
 
 if(NOT GNURADIO_RUNTIME_FOUND)
diff --git a/cmake/Modules/FindLibPERSEUS.cmake 
b/cmake/Modules/FindLibPERSEUS.cmake
new file mode 100644
index 000..5477327
--- /dev/null
+++ b/cmake/Modules/FindLibPERSEUS.cmake
@@ -0,0 +1,24 @@
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PC_LIBPERSEUS libperseus-sdr)
+
+FIND_PATH(
+LIBPERSEUS_INCLUDE_DIRS
+NAMES perseus-sdr.h
+HINTS $ENV{LIBPERSEUS_DIR}/include
+${PC_LIBPERSEUS_INCLUDEDIR}
+PATHS /usr/local/include
+  /usr/include
+)
+
+FIND_LIBRARY(
+LIBPERSEUS_LIBRARIES
+NAMES perseus-sdr
+HINTS $ENV{LIBPERSEUS_DIR}/lib
+${PC_LIBPERSEUS_LIBDIR}
+PATHS /usr/local/lib
+  /usr/lib
+)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPERSEUS DEFAULT_MSG LIBPERSEUS_LIBRARIES 
LIBPERSEUS_INCLUDE_DIRS)
+MARK_AS_ADVANCED(LIBPERSEUS_LIBRARIES LIBPERSEUS_INCLUDE_DIRS)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index c05b8d9..f555816 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -249,6 +249,14 @@ GR_INCLUDE_SUBDIRECTORY(freesrp)
 endif(ENABLE_FREESRP)
 
 
+# Setup PERSEUS component
+
+GR_REGISTER_COMPONENT("Microtelecom Perseus Receiver" ENABLE_PERSEUS 
LIBPERSEUS_FOUND)
+if(ENABLE_PERSEUS)
+GR_INCLUDE_SUBDIRECTORY(perseus)
+endif(ENABLE_PERSEUS)
+
+
 # Setup configuration file
 
 ADD_DEFINITIONS(-DHAVE_CONFIG_H=1)
diff --git a/lib/airspy/airspy_source_c.cc b/lib/airspy/airspy_source_c.cc
index 50150e5..02fc6ab 100644
--- a/lib/airspy/airspy_source_c.cc
+++ b/lib/airspy/airspy_source_c.cc
@@ -350,9 +350,10 @@ osmosdr::meta_range_t airspy_source_c::get_sample_rates()
 {
   osmosdr::meta_range_t range;
 
-  for (size_t i = 0; i < _sample_rates.size(); i++)
+  for (size_t i = 0; i < _sample_rates.size(); i++) {
+   std::cerr << "SR: [" << i << "]: " << _sample_rates[i].first << 
std::endl;
 range += osmosdr::range_t( _sample_rates[i].first );
-
+  }
   return range;
 }
 
diff --git a/lib/config.h.in b/lib/config.h.in
index 42e72f1..dac7e39 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -19,6 +19,7 @@
 #cmakedefine ENABLE_SOAPY
 #cmakedefine ENABLE_REDPITAYA
 #cmakedefine ENABLE_FREESRP
+#cmakedefine ENABLE_PERSEUS
 
 //provide NAN define for MSVC older than VC12
 #if defined(_MSC_VER) && (_MSC_VER < 1800)
diff --git a/lib/device.cc b/lib/device.cc
index 025a22b..df0d734 100644
--- a/lib/device.cc
+++ b/lib/device.cc
@@ -90,6 +90,10 @@
 #include 
 #endif
 
+#ifdef ENABLE_PERSEUS
+#include 
+#endif
+
 #include "arg_helpers.h"
 
 using namespace osmosdr;
@@ -194,6 +198,10 @@ devices_t device::find(const device_t &hint)
   BOOST_FOREACH( std::string dev, soapy_source_c::get_devices() )
 devices.push_back( device_t(dev) );
 #endif
+#ifdef ENABLE_PERSEUS
+  BOOST_FOREACH( std::string dev, perseus_source_c::get_devices() )
+devices.push_back( device_t(dev) );
+#endif
 
   /* software-only sources should be appended at the very end,
* hopefully resulting in hardware sources to be shown first
diff --git a/lib/pers

Re: [PATCH] gr-osmosdr Microtelecom Perseus HF receiver support (II)

2018-08-16 Thread andrea montefusco
Ok, just give me few days, currently I'm on vacation far away from
computers and radios.

Andrea Montefusco IW0HDV

On Wed, Aug 15, 2018, 20:30 horizon  wrote:

> Hi Andrea,
>
> could you please provide a signed-off patch with your latest changes
> ongithub and a proper commit message?
>
> Feel free to add information to AUTHORS, README and the
> grc/gen_osmosdr_blocks.py files just like we did for other radios and
> ideally include a link where libperseus is hosted (I understand this is
> https://github.com/Microtelecom/libperseus-sdr ?).
>
> Best regards,
>
> Dimitri
>
>
> On 02/03/2018 10:38 AM, andrea.montefu...@gmail.com wrote:
> > Second attempt: I removed all the changes not related to Perseus.
> >
> > @Sylvain: thanks for take time to review.
> >
> >
> > ---
> >   CMakeLists.txt |   1 +
> >   cmake/Modules/FindLibPERSEUS.cmake |  24 ++
> >   lib/CMakeLists.txt |   8 +
> >   lib/config.h.in|   1 +
> >   lib/device.cc  |   8 +
> >   lib/perseus/CMakeLists.txt |  37 +++
> >   lib/perseus/perseus_source_c.cc| 613
> +
> >   lib/perseus/perseus_source_c.h | 135 
> >   lib/source_impl.cc |  18 +-
> >   9 files changed, 844 insertions(+), 1 deletion(-)
> >   create mode 100644 cmake/Modules/FindLibPERSEUS.cmake
> >   create mode 100644 lib/perseus/CMakeLists.txt
> >   create mode 100644 lib/perseus/perseus_source_c.cc
> >   create mode 100644 lib/perseus/perseus_source_c.h
> >
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > index 296456d..94acd4c 100644
> > --- a/CMakeLists.txt
> > +++ b/CMakeLists.txt
> > @@ -173,6 +173,7 @@ find_package(Volk)
> >   find_package(LibbladeRF)
> >   find_package(SoapySDR NO_MODULE)
> >   find_package(LibFreeSRP)
> > +find_package(LibPERSEUS)
> >   find_package(Doxygen)
> >
> >   if(NOT GNURADIO_RUNTIME_FOUND)
> > diff --git a/cmake/Modules/FindLibPERSEUS.cmake
> b/cmake/Modules/FindLibPERSEUS.cmake
> > new file mode 100644
> > index 000..5477327
> > --- /dev/null
> > +++ b/cmake/Modules/FindLibPERSEUS.cmake
> > @@ -0,0 +1,24 @@
> > +INCLUDE(FindPkgConfig)
> > +PKG_CHECK_MODULES(PC_LIBPERSEUS libperseus-sdr)
> > +
> > +FIND_PATH(
> > +LIBPERSEUS_INCLUDE_DIRS
> > +NAMES perseus-sdr.h
> > +HINTS $ENV{LIBPERSEUS_DIR}/include
> > +${PC_LIBPERSEUS_INCLUDEDIR}
> > +PATHS /usr/local/include
> > +  /usr/include
> > +)
> > +
> > +FIND_LIBRARY(
> > +LIBPERSEUS_LIBRARIES
> > +NAMES perseus-sdr
> > +HINTS $ENV{LIBPERSEUS_DIR}/lib
> > +${PC_LIBPERSEUS_LIBDIR}
> > +PATHS /usr/local/lib
> > +  /usr/lib
> > +)
> > +
> > +INCLUDE(FindPackageHandleStandardArgs)
> > +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPERSEUS DEFAULT_MSG
> LIBPERSEUS_LIBRARIES LIBPERSEUS_INCLUDE_DIRS)
> > +MARK_AS_ADVANCED(LIBPERSEUS_LIBRARIES LIBPERSEUS_INCLUDE_DIRS)
> > diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
> > index c05b8d9..f555816 100644
> > --- a/lib/CMakeLists.txt
> > +++ b/lib/CMakeLists.txt
> > @@ -249,6 +249,14 @@ GR_INCLUDE_SUBDIRECTORY(freesrp)
> >   endif(ENABLE_FREESRP)
> >
> >
>  
> > +# Setup PERSEUS component
> > +
> > +GR_REGISTER_COMPONENT("Microtelecom Perseus Receiver" ENABLE_PERSEUS
> LIBPERSEUS_FOUND)
> > +if(ENABLE_PERSEUS)
> > +GR_INCLUDE_SUBDIRECTORY(perseus)
> > +endif(ENABLE_PERSEUS)
> > +
> > +
> >   # Setup configuration file
> >
>  
> >   ADD_DEFINITIONS(-DHAVE_CONFIG_H=1)
> > diff --git a/lib/config.h.in b/lib/config.h.in
> > index 42e72f1..dac7e39 100644
> > --- a/lib/config.h.in
> > +++ b/lib/config.h.in
> > @@ -19,6 +19,7 @@
> >   #cmakedefine ENABLE_SOAPY
> >   #cmakedefine ENABLE_REDPITAYA
> >   #cmakedefine ENABLE_FREESRP
> > +#cmakedefine ENABLE_PERSEUS
> >
> >   //provide NAN define for MSVC older than VC12
> >   #if defined(_MSC_VER) && (_MSC_VER < 1800)
> > diff --git a/lib/device.cc b/lib/device.cc
> > index 025a22b..df0d734 100644
> > --- a/lib/device.cc
> > +++ b/lib/device.cc
> > @@ -90,6 +90,10 @@
> >   #include 
> >   #endif
> >
> > +#ifdef ENABLE_PERSEUS
> > +#include 
> > +#endif
> > +
> >   #include "arg_helpers.h"
> >
> >   using namespace osmosdr;
> > @@ -194,6 +198,10 @@ devices_t device::find(const device_t &hint)
> > BOOST_FOREACH( std::string dev, soapy_source_c::get_devices() )
> >   devices.push_back( device_t(dev) );
> >   #endif
> > +#ifdef ENABLE_PERSEUS
> > +  BOOST_FOREACH( std::string dev, perseus_source_c::get_devices() )
> > +devices.push_back( device_t(dev) );
> > +#endif
> >
> > /* software-only sources should be appended at the very end,
> >  * hopefully resulting in hardware sources to be shown first
> > diff --git a/l

Re: [PATCH] gr-osmosdr Microtelecom Perseus HF receiver support (II)

2018-08-15 Thread horizon

Hi Andrea,

could you please provide a signed-off patch with your latest changes 
ongithub and a proper commit message?


Feel free to add information to AUTHORS, README and the 
grc/gen_osmosdr_blocks.py files just like we did for other radios and 
ideally include a link where libperseus is hosted (I understand this is 
https://github.com/Microtelecom/libperseus-sdr ?).


Best regards,

Dimitri


On 02/03/2018 10:38 AM, andrea.montefu...@gmail.com wrote:

Second attempt: I removed all the changes not related to Perseus.

@Sylvain: thanks for take time to review.


---
  CMakeLists.txt |   1 +
  cmake/Modules/FindLibPERSEUS.cmake |  24 ++
  lib/CMakeLists.txt |   8 +
  lib/config.h.in|   1 +
  lib/device.cc  |   8 +
  lib/perseus/CMakeLists.txt |  37 +++
  lib/perseus/perseus_source_c.cc| 613 +
  lib/perseus/perseus_source_c.h | 135 
  lib/source_impl.cc |  18 +-
  9 files changed, 844 insertions(+), 1 deletion(-)
  create mode 100644 cmake/Modules/FindLibPERSEUS.cmake
  create mode 100644 lib/perseus/CMakeLists.txt
  create mode 100644 lib/perseus/perseus_source_c.cc
  create mode 100644 lib/perseus/perseus_source_c.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 296456d..94acd4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -173,6 +173,7 @@ find_package(Volk)
  find_package(LibbladeRF)
  find_package(SoapySDR NO_MODULE)
  find_package(LibFreeSRP)
+find_package(LibPERSEUS)
  find_package(Doxygen)
  
  if(NOT GNURADIO_RUNTIME_FOUND)

diff --git a/cmake/Modules/FindLibPERSEUS.cmake 
b/cmake/Modules/FindLibPERSEUS.cmake
new file mode 100644
index 000..5477327
--- /dev/null
+++ b/cmake/Modules/FindLibPERSEUS.cmake
@@ -0,0 +1,24 @@
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PC_LIBPERSEUS libperseus-sdr)
+
+FIND_PATH(
+LIBPERSEUS_INCLUDE_DIRS
+NAMES perseus-sdr.h
+HINTS $ENV{LIBPERSEUS_DIR}/include
+${PC_LIBPERSEUS_INCLUDEDIR}
+PATHS /usr/local/include
+  /usr/include
+)
+
+FIND_LIBRARY(
+LIBPERSEUS_LIBRARIES
+NAMES perseus-sdr
+HINTS $ENV{LIBPERSEUS_DIR}/lib
+${PC_LIBPERSEUS_LIBDIR}
+PATHS /usr/local/lib
+  /usr/lib
+)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPERSEUS DEFAULT_MSG LIBPERSEUS_LIBRARIES 
LIBPERSEUS_INCLUDE_DIRS)
+MARK_AS_ADVANCED(LIBPERSEUS_LIBRARIES LIBPERSEUS_INCLUDE_DIRS)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index c05b8d9..f555816 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -249,6 +249,14 @@ GR_INCLUDE_SUBDIRECTORY(freesrp)
  endif(ENABLE_FREESRP)
  
  

+# Setup PERSEUS component
+
+GR_REGISTER_COMPONENT("Microtelecom Perseus Receiver" ENABLE_PERSEUS 
LIBPERSEUS_FOUND)
+if(ENABLE_PERSEUS)
+GR_INCLUDE_SUBDIRECTORY(perseus)
+endif(ENABLE_PERSEUS)
+
+
  # Setup configuration file
  
  ADD_DEFINITIONS(-DHAVE_CONFIG_H=1)
diff --git a/lib/config.h.in b/lib/config.h.in
index 42e72f1..dac7e39 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -19,6 +19,7 @@
  #cmakedefine ENABLE_SOAPY
  #cmakedefine ENABLE_REDPITAYA
  #cmakedefine ENABLE_FREESRP
+#cmakedefine ENABLE_PERSEUS
  
  //provide NAN define for MSVC older than VC12

  #if defined(_MSC_VER) && (_MSC_VER < 1800)
diff --git a/lib/device.cc b/lib/device.cc
index 025a22b..df0d734 100644
--- a/lib/device.cc
+++ b/lib/device.cc
@@ -90,6 +90,10 @@
  #include 
  #endif
  
+#ifdef ENABLE_PERSEUS

+#include 
+#endif
+
  #include "arg_helpers.h"
  
  using namespace osmosdr;

@@ -194,6 +198,10 @@ devices_t device::find(const device_t &hint)
BOOST_FOREACH( std::string dev, soapy_source_c::get_devices() )
  devices.push_back( device_t(dev) );
  #endif
+#ifdef ENABLE_PERSEUS
+  BOOST_FOREACH( std::string dev, perseus_source_c::get_devices() )
+devices.push_back( device_t(dev) );
+#endif
  
/* software-only sources should be appended at the very end,

 * hopefully resulting in hardware sources to be shown first
diff --git a/lib/perseus/CMakeLists.txt b/lib/perseus/CMakeLists.txt
new file mode 100644
index 000..f45a10d
--- /dev/null
+++ b/lib/perseus/CMakeLists.txt
@@ -0,0 +1,37 @@
+# Copyright 2017 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or F

[PATCH] gr-osmosdr Microtelecom Perseus HF receiver support (II)

2018-02-03 Thread andrea . montefusco
Second attempt: I removed all the changes not related to Perseus.

@Sylvain: thanks for take time to review.


---
 CMakeLists.txt |   1 +
 cmake/Modules/FindLibPERSEUS.cmake |  24 ++
 lib/CMakeLists.txt |   8 +
 lib/config.h.in|   1 +
 lib/device.cc  |   8 +
 lib/perseus/CMakeLists.txt |  37 +++
 lib/perseus/perseus_source_c.cc| 613 +
 lib/perseus/perseus_source_c.h | 135 
 lib/source_impl.cc |  18 +-
 9 files changed, 844 insertions(+), 1 deletion(-)
 create mode 100644 cmake/Modules/FindLibPERSEUS.cmake
 create mode 100644 lib/perseus/CMakeLists.txt
 create mode 100644 lib/perseus/perseus_source_c.cc
 create mode 100644 lib/perseus/perseus_source_c.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 296456d..94acd4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -173,6 +173,7 @@ find_package(Volk)
 find_package(LibbladeRF)
 find_package(SoapySDR NO_MODULE)
 find_package(LibFreeSRP)
+find_package(LibPERSEUS)
 find_package(Doxygen)
 
 if(NOT GNURADIO_RUNTIME_FOUND)
diff --git a/cmake/Modules/FindLibPERSEUS.cmake 
b/cmake/Modules/FindLibPERSEUS.cmake
new file mode 100644
index 000..5477327
--- /dev/null
+++ b/cmake/Modules/FindLibPERSEUS.cmake
@@ -0,0 +1,24 @@
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PC_LIBPERSEUS libperseus-sdr)
+
+FIND_PATH(
+LIBPERSEUS_INCLUDE_DIRS
+NAMES perseus-sdr.h
+HINTS $ENV{LIBPERSEUS_DIR}/include
+${PC_LIBPERSEUS_INCLUDEDIR}
+PATHS /usr/local/include
+  /usr/include
+)
+
+FIND_LIBRARY(
+LIBPERSEUS_LIBRARIES
+NAMES perseus-sdr
+HINTS $ENV{LIBPERSEUS_DIR}/lib
+${PC_LIBPERSEUS_LIBDIR}
+PATHS /usr/local/lib
+  /usr/lib
+)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPERSEUS DEFAULT_MSG LIBPERSEUS_LIBRARIES 
LIBPERSEUS_INCLUDE_DIRS)
+MARK_AS_ADVANCED(LIBPERSEUS_LIBRARIES LIBPERSEUS_INCLUDE_DIRS)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index c05b8d9..f555816 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -249,6 +249,14 @@ GR_INCLUDE_SUBDIRECTORY(freesrp)
 endif(ENABLE_FREESRP)
 
 
+# Setup PERSEUS component
+
+GR_REGISTER_COMPONENT("Microtelecom Perseus Receiver" ENABLE_PERSEUS 
LIBPERSEUS_FOUND)
+if(ENABLE_PERSEUS)
+GR_INCLUDE_SUBDIRECTORY(perseus)
+endif(ENABLE_PERSEUS)
+
+
 # Setup configuration file
 
 ADD_DEFINITIONS(-DHAVE_CONFIG_H=1)
diff --git a/lib/config.h.in b/lib/config.h.in
index 42e72f1..dac7e39 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -19,6 +19,7 @@
 #cmakedefine ENABLE_SOAPY
 #cmakedefine ENABLE_REDPITAYA
 #cmakedefine ENABLE_FREESRP
+#cmakedefine ENABLE_PERSEUS
 
 //provide NAN define for MSVC older than VC12
 #if defined(_MSC_VER) && (_MSC_VER < 1800)
diff --git a/lib/device.cc b/lib/device.cc
index 025a22b..df0d734 100644
--- a/lib/device.cc
+++ b/lib/device.cc
@@ -90,6 +90,10 @@
 #include 
 #endif
 
+#ifdef ENABLE_PERSEUS
+#include 
+#endif
+
 #include "arg_helpers.h"
 
 using namespace osmosdr;
@@ -194,6 +198,10 @@ devices_t device::find(const device_t &hint)
   BOOST_FOREACH( std::string dev, soapy_source_c::get_devices() )
 devices.push_back( device_t(dev) );
 #endif
+#ifdef ENABLE_PERSEUS
+  BOOST_FOREACH( std::string dev, perseus_source_c::get_devices() )
+devices.push_back( device_t(dev) );
+#endif
 
   /* software-only sources should be appended at the very end,
* hopefully resulting in hardware sources to be shown first
diff --git a/lib/perseus/CMakeLists.txt b/lib/perseus/CMakeLists.txt
new file mode 100644
index 000..f45a10d
--- /dev/null
+++ b/lib/perseus/CMakeLists.txt
@@ -0,0 +1,37 @@
+# Copyright 2017 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+
+# This file included, use CMake directory variables
+#

Re: [PATCH] gr-osmosdr: Microtelecom Perseus HF receiver support

2018-02-03 Thread andrea montefusco
On Fri, Feb 2, 2018 at 11:33 PM, Sylvain Munaut <246...@gmail.com> wrote:

> Hi,
>
> Can't comment about the patch it self but :
> >  lib/airspy/airspy_source_c.cc  |   5 +-
> >  lib/rtl/rtl_source_c.cc|   2 +-
>
> Those looks like mistakes that have nothing to do in this patch 
>
>
​Yes, I forgot to remove that.
Going to send another email with the fixed patch (cannot send it from here
as GMAIL is breaking lines at column 70 or so).​


-- 
Andrea Montefusco IW0HDV
--
As my old boss, an Apollo veteran, would often remind us “It’s good to be
smart, but it’s better to be lucky.”
   Wayne Hale, Space Shuttle Flight Director


Re: [PATCH] gr-osmosdr: Microtelecom Perseus HF receiver support

2018-02-02 Thread Sylvain Munaut
Hi,

Can't comment about the patch it self but :
>  lib/airspy/airspy_source_c.cc  |   5 +-
>  lib/rtl/rtl_source_c.cc|   2 +-

Those looks like mistakes that have nothing to do in this patch 


Cheers,

   Sylvain


[PATCH] gr-osmosdr Microtelecom Perseus HF receiver support

2018-02-02 Thread andrea . montefusco
Hi maintainer and all,

Below you find a patch that implements Microtelecom Perseus support .
I have testes it using gqrx SDR software.


---
 CMakeLists.txt |   1 +
 cmake/Modules/FindLibPERSEUS.cmake |  24 ++
 lib/CMakeLists.txt |   8 +
 lib/airspy/airspy_source_c.cc  |   5 +-
 lib/config.h.in|   1 +
 lib/device.cc  |   8 +
 lib/perseus/CMakeLists.txt |  37 +++
 lib/perseus/perseus_source_c.cc| 507 +
 lib/perseus/perseus_source_c.h | 120 +
 lib/rtl/rtl_source_c.cc|   2 +-
 lib/source_impl.cc |  18 +-
 11 files changed, 727 insertions(+), 4 deletions(-)
 create mode 100644 cmake/Modules/FindLibPERSEUS.cmake
 create mode 100644 lib/perseus/CMakeLists.txt
 create mode 100644 lib/perseus/perseus_source_c.cc
 create mode 100644 lib/perseus/perseus_source_c.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 296456d..94acd4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -173,6 +173,7 @@ find_package(Volk)
 find_package(LibbladeRF)
 find_package(SoapySDR NO_MODULE)
 find_package(LibFreeSRP)
+find_package(LibPERSEUS)
 find_package(Doxygen)
 
 if(NOT GNURADIO_RUNTIME_FOUND)
diff --git a/cmake/Modules/FindLibPERSEUS.cmake 
b/cmake/Modules/FindLibPERSEUS.cmake
new file mode 100644
index 000..5477327
--- /dev/null
+++ b/cmake/Modules/FindLibPERSEUS.cmake
@@ -0,0 +1,24 @@
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PC_LIBPERSEUS libperseus-sdr)
+
+FIND_PATH(
+LIBPERSEUS_INCLUDE_DIRS
+NAMES perseus-sdr.h
+HINTS $ENV{LIBPERSEUS_DIR}/include
+${PC_LIBPERSEUS_INCLUDEDIR}
+PATHS /usr/local/include
+  /usr/include
+)
+
+FIND_LIBRARY(
+LIBPERSEUS_LIBRARIES
+NAMES perseus-sdr
+HINTS $ENV{LIBPERSEUS_DIR}/lib
+${PC_LIBPERSEUS_LIBDIR}
+PATHS /usr/local/lib
+  /usr/lib
+)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPERSEUS DEFAULT_MSG LIBPERSEUS_LIBRARIES 
LIBPERSEUS_INCLUDE_DIRS)
+MARK_AS_ADVANCED(LIBPERSEUS_LIBRARIES LIBPERSEUS_INCLUDE_DIRS)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index c05b8d9..f555816 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -249,6 +249,14 @@ GR_INCLUDE_SUBDIRECTORY(freesrp)
 endif(ENABLE_FREESRP)
 
 
+# Setup PERSEUS component
+
+GR_REGISTER_COMPONENT("Microtelecom Perseus Receiver" ENABLE_PERSEUS 
LIBPERSEUS_FOUND)
+if(ENABLE_PERSEUS)
+GR_INCLUDE_SUBDIRECTORY(perseus)
+endif(ENABLE_PERSEUS)
+
+
 # Setup configuration file
 
 ADD_DEFINITIONS(-DHAVE_CONFIG_H=1)
diff --git a/lib/airspy/airspy_source_c.cc b/lib/airspy/airspy_source_c.cc
index 50150e5..02fc6ab 100644
--- a/lib/airspy/airspy_source_c.cc
+++ b/lib/airspy/airspy_source_c.cc
@@ -350,9 +350,10 @@ osmosdr::meta_range_t airspy_source_c::get_sample_rates()
 {
   osmosdr::meta_range_t range;
 
-  for (size_t i = 0; i < _sample_rates.size(); i++)
+  for (size_t i = 0; i < _sample_rates.size(); i++) {
+   std::cerr << "SR: [" << i << "]: " << _sample_rates[i].first << 
std::endl;
 range += osmosdr::range_t( _sample_rates[i].first );
-
+  }
   return range;
 }
 
diff --git a/lib/config.h.in b/lib/config.h.in
index 42e72f1..dac7e39 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -19,6 +19,7 @@
 #cmakedefine ENABLE_SOAPY
 #cmakedefine ENABLE_REDPITAYA
 #cmakedefine ENABLE_FREESRP
+#cmakedefine ENABLE_PERSEUS
 
 //provide NAN define for MSVC older than VC12
 #if defined(_MSC_VER) && (_MSC_VER < 1800)
diff --git a/lib/device.cc b/lib/device.cc
index 025a22b..df0d734 100644
--- a/lib/device.cc
+++ b/lib/device.cc
@@ -90,6 +90,10 @@
 #include 
 #endif
 
+#ifdef ENABLE_PERSEUS
+#include 
+#endif
+
 #include "arg_helpers.h"
 
 using namespace osmosdr;
@@ -194,6 +198,10 @@ devices_t device::find(const device_t &hint)
   BOOST_FOREACH( std::string dev, soapy_source_c::get_devices() )
 devices.push_back( device_t(dev) );
 #endif
+#ifdef ENABLE_PERSEUS
+  BOOST_FOREACH( std::string dev, perseus_source_c::get_devices() )
+devices.push_back( device_t(dev) );
+#endif
 
   /* software-only sources should be appended at the very end,
* hopefully resulting in hardware sources to be shown first
diff --git a/lib/perseus/CMakeLists.txt b/lib/perseus/CMakeLists.txt
new file mode 100644
index 000..f45a10d
--- /dev/null
+++ b/lib/perseus/CMakeLists.txt
@@ -0,0 +1,37 @@
+# Copyright 2017 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option

[PATCH] gr-osmosdr Microtelecom Perseus HF receiver support

2018-02-02 Thread andrea . montefusco
Hi maintainer and all,

Below you find a patch that implements Microtelecom Perseus support .
I have testes it using gqrx SDR software.


---
 CMakeLists.txt |   1 +
 cmake/Modules/FindLibPERSEUS.cmake |  24 ++
 lib/CMakeLists.txt |   8 +
 lib/airspy/airspy_source_c.cc  |   5 +-
 lib/config.h.in|   1 +
 lib/device.cc  |   8 +
 lib/perseus/CMakeLists.txt |  37 +++
 lib/perseus/perseus_source_c.cc| 507 +
 lib/perseus/perseus_source_c.h | 120 +
 lib/rtl/rtl_source_c.cc|   2 +-
 lib/source_impl.cc |  18 +-
 11 files changed, 727 insertions(+), 4 deletions(-)
 create mode 100644 cmake/Modules/FindLibPERSEUS.cmake
 create mode 100644 lib/perseus/CMakeLists.txt
 create mode 100644 lib/perseus/perseus_source_c.cc
 create mode 100644 lib/perseus/perseus_source_c.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 296456d..94acd4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -173,6 +173,7 @@ find_package(Volk)
 find_package(LibbladeRF)
 find_package(SoapySDR NO_MODULE)
 find_package(LibFreeSRP)
+find_package(LibPERSEUS)
 find_package(Doxygen)
 
 if(NOT GNURADIO_RUNTIME_FOUND)
diff --git a/cmake/Modules/FindLibPERSEUS.cmake 
b/cmake/Modules/FindLibPERSEUS.cmake
new file mode 100644
index 000..5477327
--- /dev/null
+++ b/cmake/Modules/FindLibPERSEUS.cmake
@@ -0,0 +1,24 @@
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PC_LIBPERSEUS libperseus-sdr)
+
+FIND_PATH(
+LIBPERSEUS_INCLUDE_DIRS
+NAMES perseus-sdr.h
+HINTS $ENV{LIBPERSEUS_DIR}/include
+${PC_LIBPERSEUS_INCLUDEDIR}
+PATHS /usr/local/include
+  /usr/include
+)
+
+FIND_LIBRARY(
+LIBPERSEUS_LIBRARIES
+NAMES perseus-sdr
+HINTS $ENV{LIBPERSEUS_DIR}/lib
+${PC_LIBPERSEUS_LIBDIR}
+PATHS /usr/local/lib
+  /usr/lib
+)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPERSEUS DEFAULT_MSG LIBPERSEUS_LIBRARIES 
LIBPERSEUS_INCLUDE_DIRS)
+MARK_AS_ADVANCED(LIBPERSEUS_LIBRARIES LIBPERSEUS_INCLUDE_DIRS)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index c05b8d9..f555816 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -249,6 +249,14 @@ GR_INCLUDE_SUBDIRECTORY(freesrp)
 endif(ENABLE_FREESRP)
 
 
+# Setup PERSEUS component
+
+GR_REGISTER_COMPONENT("Microtelecom Perseus Receiver" ENABLE_PERSEUS 
LIBPERSEUS_FOUND)
+if(ENABLE_PERSEUS)
+GR_INCLUDE_SUBDIRECTORY(perseus)
+endif(ENABLE_PERSEUS)
+
+
 # Setup configuration file
 
 ADD_DEFINITIONS(-DHAVE_CONFIG_H=1)
diff --git a/lib/airspy/airspy_source_c.cc b/lib/airspy/airspy_source_c.cc
index 50150e5..02fc6ab 100644
--- a/lib/airspy/airspy_source_c.cc
+++ b/lib/airspy/airspy_source_c.cc
@@ -350,9 +350,10 @@ osmosdr::meta_range_t airspy_source_c::get_sample_rates()
 {
   osmosdr::meta_range_t range;
 
-  for (size_t i = 0; i < _sample_rates.size(); i++)
+  for (size_t i = 0; i < _sample_rates.size(); i++) {
+   std::cerr << "SR: [" << i << "]: " << _sample_rates[i].first << 
std::endl;
 range += osmosdr::range_t( _sample_rates[i].first );
-
+  }
   return range;
 }
 
diff --git a/lib/config.h.in b/lib/config.h.in
index 42e72f1..dac7e39 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -19,6 +19,7 @@
 #cmakedefine ENABLE_SOAPY
 #cmakedefine ENABLE_REDPITAYA
 #cmakedefine ENABLE_FREESRP
+#cmakedefine ENABLE_PERSEUS
 
 //provide NAN define for MSVC older than VC12
 #if defined(_MSC_VER) && (_MSC_VER < 1800)
diff --git a/lib/device.cc b/lib/device.cc
index 025a22b..df0d734 100644
--- a/lib/device.cc
+++ b/lib/device.cc
@@ -90,6 +90,10 @@
 #include 
 #endif
 
+#ifdef ENABLE_PERSEUS
+#include 
+#endif
+
 #include "arg_helpers.h"
 
 using namespace osmosdr;
@@ -194,6 +198,10 @@ devices_t device::find(const device_t &hint)
   BOOST_FOREACH( std::string dev, soapy_source_c::get_devices() )
 devices.push_back( device_t(dev) );
 #endif
+#ifdef ENABLE_PERSEUS
+  BOOST_FOREACH( std::string dev, perseus_source_c::get_devices() )
+devices.push_back( device_t(dev) );
+#endif
 
   /* software-only sources should be appended at the very end,
* hopefully resulting in hardware sources to be shown first
diff --git a/lib/perseus/CMakeLists.txt b/lib/perseus/CMakeLists.txt
new file mode 100644
index 000..f45a10d
--- /dev/null
+++ b/lib/perseus/CMakeLists.txt
@@ -0,0 +1,37 @@
+# Copyright 2017 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option

Fwd: [PATCH] gr-osmosdr Microtelecom Perseus HF receiver support

2018-02-02 Thread andrea montefusco
-- Forwarded message --
From: 
Date: Fri, Feb 2, 2018 at 8:25 PM
Subject: [PATCH] gr-osmosdr Microtelecom Perseus HF receiver support
To: andrea.montefu...@gmail.com


Hi maintainer and all,

Below you find a patch that implements Microtelecom Perseus support .
I have testes it using gqrx SDR software.


---
 CMakeLists.txt |   1 +
 cmake/Modules/FindLibPERSEUS.cmake |  24 ++
 lib/CMakeLists.txt |   8 +
 lib/airspy/airspy_source_c.cc  |   5 +-
 lib/config.h.in|   1 +
 lib/device.cc  |   8 +
 lib/perseus/CMakeLists.txt |  37 +++
 lib/perseus/perseus_source_c.cc| 507 ++
+++
 lib/perseus/perseus_source_c.h | 120 +
 lib/rtl/rtl_source_c.cc|   2 +-
 lib/source_impl.cc |  18 +-
 11 files changed, 727 insertions(+), 4 deletions(-)
 create mode 100644 cmake/Modules/FindLibPERSEUS.cmake
 create mode 100644 lib/perseus/CMakeLists.txt
 create mode 100644 lib/perseus/perseus_source_c.cc
 create mode 100644 lib/perseus/perseus_source_c.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 296456d..94acd4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -173,6 +173,7 @@ find_package(Volk)
 find_package(LibbladeRF)
 find_package(SoapySDR NO_MODULE)
 find_package(LibFreeSRP)
+find_package(LibPERSEUS)
 find_package(Doxygen)

 if(NOT GNURADIO_RUNTIME_FOUND)
diff --git a/cmake/Modules/FindLibPERSEUS.cmake b/cmake/Modules/
FindLibPERSEUS.cmake
new file mode 100644
index 000..5477327
--- /dev/null
+++ b/cmake/Modules/FindLibPERSEUS.cmake
@@ -0,0 +1,24 @@
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PC_LIBPERSEUS libperseus-sdr)
+
+FIND_PATH(
+LIBPERSEUS_INCLUDE_DIRS
+NAMES perseus-sdr.h
+HINTS $ENV{LIBPERSEUS_DIR}/include
+${PC_LIBPERSEUS_INCLUDEDIR}
+PATHS /usr/local/include
+  /usr/include
+)
+
+FIND_LIBRARY(
+LIBPERSEUS_LIBRARIES
+NAMES perseus-sdr
+HINTS $ENV{LIBPERSEUS_DIR}/lib
+${PC_LIBPERSEUS_LIBDIR}
+PATHS /usr/local/lib
+  /usr/lib
+)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPERSEUS DEFAULT_MSG
LIBPERSEUS_LIBRARIES LIBPERSEUS_INCLUDE_DIRS)
+MARK_AS_ADVANCED(LIBPERSEUS_LIBRARIES LIBPERSEUS_INCLUDE_DIRS)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index c05b8d9..f555816 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -249,6 +249,14 @@ GR_INCLUDE_SUBDIRECTORY(freesrp)
 endif(ENABLE_FREESRP)

 
+# Setup PERSEUS component
+
+GR_REGISTER_COMPONENT("Microtelecom Perseus Receiver" ENABLE_PERSEUS
LIBPERSEUS_FOUND)
+if(ENABLE_PERSEUS)
+GR_INCLUDE_SUBDIRECTORY(perseus)
+endif(ENABLE_PERSEUS)
+
+
 # Setup configuration file
 
 ADD_DEFINITIONS(-DHAVE_CONFIG_H=1)
diff --git a/lib/airspy/airspy_source_c.cc b/lib/airspy/airspy_source_c.cc
index 50150e5..02fc6ab 100644
--- a/lib/airspy/airspy_source_c.cc
+++ b/lib/airspy/airspy_source_c.cc
@@ -350,9 +350,10 @@ osmosdr::meta_range_t airspy_source_c::get_sample_
rates()
 {
   osmosdr::meta_range_t range;

-  for (size_t i = 0; i < _sample_rates.size(); i++)
+  for (size_t i = 0; i < _sample_rates.size(); i++) {
+   std::cerr << "SR: [" << i << "]: " << _sample_rates[i].first <<
std::endl;
 range += osmosdr::range_t( _sample_rates[i].first );
-
+  }
   return range;
 }

diff --git a/lib/config.h.in b/lib/config.h.in
index 42e72f1..dac7e39 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -19,6 +19,7 @@
 #cmakedefine ENABLE_SOAPY
 #cmakedefine ENABLE_REDPITAYA
 #cmakedefine ENABLE_FREESRP
+#cmakedefine ENABLE_PERSEUS

 //provide NAN define for MSVC older than VC12
 #if defined(_MSC_VER) && (_MSC_VER < 1800)
diff --git a/lib/device.cc b/lib/device.cc
index 025a22b..df0d734 100644
--- a/lib/device.cc
+++ b/lib/device.cc
@@ -90,6 +90,10 @@
 #include 
 #endif

+#ifdef ENABLE_PERSEUS
+#include 
+#endif
+
 #include "arg_helpers.h"

 using namespace osmosdr;
@@ -194,6 +198,10 @@ devices_t device::find(const device_t &hint)
   BOOST_FOREACH( std::string dev, soapy_source_c::get_devices() )
 devices.push_back( device_t(dev) );
 #endif
+#ifdef ENABLE_PERSEUS
+  BOOST_FOREACH( std::string dev, perseus_source_c::get_devices() )
+devices.push_back( device_t(dev) );
+#endif

   /* software-only sources should be appended at the very end,
* hopefully resulting in hardware sources to be shown first
diff --git a/lib/perseus/CMakeLists.txt b/lib/perseus/CMakeLists.txt
new file mode 100644
index 000..f45a10d
--- /dev/null
+++ b/lib/perseus/CMakeLists.txt
@@ -0,0 +1,37 @@
+# Copyright 2017 Free Software 

[PATCH] gr-osmosdr: Microtelecom Perseus HF receiver support

2018-02-02 Thread andrea montefusco
Hi maintainer and all,

Below you find a patch that implements Microtelecom Perseus support in
gr-osmosdr.
I have tested it in gqrx SDR software.
(second attempt as the first one got corrupted)



---
 CMakeLists.txt |   1 +
 cmake/Modules/FindLibPERSEUS.cmake |  24 ++
 lib/CMakeLists.txt |   8 +
 lib/airspy/airspy_source_c.cc  |   5 +-
 lib/config.h.in|   1 +
 lib/device.cc  |   8 +
 lib/perseus/CMakeLists.txt |  37 +++
 lib/perseus/perseus_source_c.cc| 507
+
 lib/perseus/perseus_source_c.h | 120 +
 lib/rtl/rtl_source_c.cc|   2 +-
 lib/source_impl.cc |  18 +-
 11 files changed, 727 insertions(+), 4 deletions(-)
 create mode 100644 cmake/Modules/FindLibPERSEUS.cmake
 create mode 100644 lib/perseus/CMakeLists.txt
 create mode 100644 lib/perseus/perseus_source_c.cc
 create mode 100644 lib/perseus/perseus_source_c.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 296456d..94acd4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -173,6 +173,7 @@ find_package(Volk)
 find_package(LibbladeRF)
 find_package(SoapySDR NO_MODULE)
 find_package(LibFreeSRP)
+find_package(LibPERSEUS)
 find_package(Doxygen)

 if(NOT GNURADIO_RUNTIME_FOUND)
diff --git a/cmake/Modules/FindLibPERSEUS.cmake
b/cmake/Modules/FindLibPERSEUS.cmake
new file mode 100644
index 000..5477327
--- /dev/null
+++ b/cmake/Modules/FindLibPERSEUS.cmake
@@ -0,0 +1,24 @@
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PC_LIBPERSEUS libperseus-sdr)
+
+FIND_PATH(
+LIBPERSEUS_INCLUDE_DIRS
+NAMES perseus-sdr.h
+HINTS $ENV{LIBPERSEUS_DIR}/include
+${PC_LIBPERSEUS_INCLUDEDIR}
+PATHS /usr/local/include
+  /usr/include
+)
+
+FIND_LIBRARY(
+LIBPERSEUS_LIBRARIES
+NAMES perseus-sdr
+HINTS $ENV{LIBPERSEUS_DIR}/lib
+${PC_LIBPERSEUS_LIBDIR}
+PATHS /usr/local/lib
+  /usr/lib
+)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPERSEUS DEFAULT_MSG
LIBPERSEUS_LIBRARIES LIBPERSEUS_INCLUDE_DIRS)
+MARK_AS_ADVANCED(LIBPERSEUS_LIBRARIES LIBPERSEUS_INCLUDE_DIRS)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index c05b8d9..f555816 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -249,6 +249,14 @@ GR_INCLUDE_SUBDIRECTORY(freesrp)
 endif(ENABLE_FREESRP)

 
+# Setup PERSEUS component
+
+GR_REGISTER_COMPONENT("Microtelecom Perseus Receiver" ENABLE_PERSEUS
LIBPERSEUS_FOUND)
+if(ENABLE_PERSEUS)
+GR_INCLUDE_SUBDIRECTORY(perseus)
+endif(ENABLE_PERSEUS)
+
+
 # Setup configuration file
 
 ADD_DEFINITIONS(-DHAVE_CONFIG_H=1)
diff --git a/lib/airspy/airspy_source_c.cc b/lib/airspy/airspy_source_c.cc
index 50150e5..02fc6ab 100644
--- a/lib/airspy/airspy_source_c.cc
+++ b/lib/airspy/airspy_source_c.cc
@@ -350,9 +350,10 @@ osmosdr::meta_range_t
airspy_source_c::get_sample_rates()
 {
   osmosdr::meta_range_t range;

-  for (size_t i = 0; i < _sample_rates.size(); i++)
+  for (size_t i = 0; i < _sample_rates.size(); i++) {
+std::cerr << "SR: [" << i << "]: " << _sample_rates[i].first <<
std::endl;
 range += osmosdr::range_t( _sample_rates[i].first );
-
+  }
   return range;
 }

diff --git a/lib/config.h.in b/lib/config.h.in
index 42e72f1..dac7e39 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -19,6 +19,7 @@
 #cmakedefine ENABLE_SOAPY
 #cmakedefine ENABLE_REDPITAYA
 #cmakedefine ENABLE_FREESRP
+#cmakedefine ENABLE_PERSEUS

 //provide NAN define for MSVC older than VC12
 #if defined(_MSC_VER) && (_MSC_VER < 1800)
diff --git a/lib/device.cc b/lib/device.cc
index 025a22b..df0d734 100644
--- a/lib/device.cc
+++ b/lib/device.cc
@@ -90,6 +90,10 @@
 #include 
 #endif

+#ifdef ENABLE_PERSEUS
+#include 
+#endif
+
 #include "arg_helpers.h"

 using namespace osmosdr;
@@ -194,6 +198,10 @@ devices_t device::find(const device_t &hint)
   BOOST_FOREACH( std::string dev, soapy_source_c::get_devices() )
 devices.push_back( device_t(dev) );
 #endif
+#ifdef ENABLE_PERSEUS
+  BOOST_FOREACH( std::string dev, perseus_source_c::get_devices() )
+devices.push_back( device_t(dev) );
+#endif

   /* software-only sources should be appended at the very end,
* hopefully resulting in hardware sources to be shown first
diff --git a/lib/perseus/CMakeLists.txt b/lib/perseus/CMakeLists.txt
new file mode 100644
index 000..f45a10d
--- /dev/null
+++ b/lib/perseus/CMakeLists.txt
@@ -0,0 +1,37 @@
+# Copyright 2017 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foun

[PATCH] gr-osmosdr: Microtelecom Perseus HF receiver support

2018-02-02 Thread andrea montefusco
Hi maintainer and all,

Below you find a patch that implements Microtelecom Perseus support in
gr-osmosdr.
I have tested it in gqrx SDR software.

---
 CMakeLists.txt |   1 +
 cmake/Modules/FindLibPERSEUS.cmake |  24 ++
 lib/CMakeLists.txt |   8 +
 lib/airspy/airspy_source_c.cc  |   5 +-
 lib/config.h.in|   1 +
 lib/device.cc  |   8 +
 lib/perseus/CMakeLists.txt |  37 +++
 lib/perseus/perseus_source_c.cc| 507 ++
+++
 lib/perseus/perseus_source_c.h | 120 +
 lib/rtl/rtl_source_c.cc|   2 +-
 lib/source_impl.cc |  18 +-
 11 files changed, 727 insertions(+), 4 deletions(-)
 create mode 100644 cmake/Modules/FindLibPERSEUS.cmake
 create mode 100644 lib/perseus/CMakeLists.txt
 create mode 100644 lib/perseus/perseus_source_c.cc
 create mode 100644 lib/perseus/perseus_source_c.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 296456d..94acd4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -173,6 +173,7 @@ find_package(Volk)
 find_package(LibbladeRF)
 find_package(SoapySDR NO_MODULE)
 find_package(LibFreeSRP)
+find_package(LibPERSEUS)
 find_package(Doxygen)

 if(NOT GNURADIO_RUNTIME_FOUND)
diff --git a/cmake/Modules/FindLibPERSEUS.cmake b/cmake/Modules/
FindLibPERSEUS.cmake
new file mode 100644
index 000..5477327
--- /dev/null
+++ b/cmake/Modules/FindLibPERSEUS.cmake
@@ -0,0 +1,24 @@
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PC_LIBPERSEUS libperseus-sdr)
+
+FIND_PATH(
+LIBPERSEUS_INCLUDE_DIRS
+NAMES perseus-sdr.h
+HINTS $ENV{LIBPERSEUS_DIR}/include
+${PC_LIBPERSEUS_INCLUDEDIR}
+PATHS /usr/local/include
+  /usr/include
+)
+
+FIND_LIBRARY(
+LIBPERSEUS_LIBRARIES
+NAMES perseus-sdr
+HINTS $ENV{LIBPERSEUS_DIR}/lib
+${PC_LIBPERSEUS_LIBDIR}
+PATHS /usr/local/lib
+  /usr/lib
+)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPERSEUS DEFAULT_MSG
LIBPERSEUS_LIBRARIES LIBPERSEUS_INCLUDE_DIRS)
+MARK_AS_ADVANCED(LIBPERSEUS_LIBRARIES LIBPERSEUS_INCLUDE_DIRS)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index c05b8d9..f555816 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -249,6 +249,14 @@ GR_INCLUDE_SUBDIRECTORY(freesrp)
 endif(ENABLE_FREESRP)

 
+# Setup PERSEUS component
+
+GR_REGISTER_COMPONENT("Microtelecom Perseus Receiver" ENABLE_PERSEUS
LIBPERSEUS_FOUND)
+if(ENABLE_PERSEUS)
+GR_INCLUDE_SUBDIRECTORY(perseus)
+endif(ENABLE_PERSEUS)
+
+
 # Setup configuration file
 
 ADD_DEFINITIONS(-DHAVE_CONFIG_H=1)
diff --git a/lib/airspy/airspy_source_c.cc b/lib/airspy/airspy_source_c.cc
index 50150e5..02fc6ab 100644
--- a/lib/airspy/airspy_source_c.cc
+++ b/lib/airspy/airspy_source_c.cc
@@ -350,9 +350,10 @@ osmosdr::meta_range_t airspy_source_c::get_sample_
rates()
 {
   osmosdr::meta_range_t range;

-  for (size_t i = 0; i < _sample_rates.size(); i++)
+  for (size_t i = 0; i < _sample_rates.size(); i++) {
+std::cerr << "SR: [" << i << "]: " << _sample_rates[i].first <<
std::endl;
 range += osmosdr::range_t( _sample_rates[i].first );
-
+  }
   return range;
 }

diff --git a/lib/config.h.in b/lib/config.h.in
index 42e72f1..dac7e39 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -19,6 +19,7 @@
 #cmakedefine ENABLE_SOAPY
 #cmakedefine ENABLE_REDPITAYA
 #cmakedefine ENABLE_FREESRP
+#cmakedefine ENABLE_PERSEUS

 //provide NAN define for MSVC older than VC12
 #if defined(_MSC_VER) && (_MSC_VER < 1800)
diff --git a/lib/device.cc b/lib/device.cc
index 025a22b..df0d734 100644
--- a/lib/device.cc
+++ b/lib/device.cc
@@ -90,6 +90,10 @@
 #include 
 #endif

+#ifdef ENABLE_PERSEUS
+#include 
+#endif
+
 #include "arg_helpers.h"

 using namespace osmosdr;
@@ -194,6 +198,10 @@ devices_t device::find(const device_t &hint)
   BOOST_FOREACH( std::string dev, soapy_source_c::get_devices() )
 devices.push_back( device_t(dev) );
 #endif
+#ifdef ENABLE_PERSEUS
+  BOOST_FOREACH( std::string dev, perseus_source_c::get_devices() )
+devices.push_back( device_t(dev) );
+#endif

   /* software-only sources should be appended at the very end,
* hopefully resulting in hardware sources to be shown first
diff --git a/lib/perseus/CMakeLists.txt b/lib/perseus/CMakeLists.txt
new file mode 100644
index 000..f45a10d
--- /dev/null
+++ b/lib/perseus/CMakeLists.txt
@@ -0,0 +1,37 @@
+# Copyright 2017 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+