diff options
author | Josh Blum <josh@joshknows.com> | 2011-08-17 12:30:09 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-08-17 12:30:09 -0700 |
commit | fb2f45cdddc41d5aba177204aa419cea3a0aea49 (patch) | |
tree | e2d3195b9782e047518fe1ea9f848346b480cfd4 | |
parent | e6ed4fa7bb0d253adbf0cf2ae4da7c301b3c971f (diff) | |
parent | 626018eb037808cdc32b5eb1907ae9d5f80d3e55 (diff) |
Merge branch 'next' into digital
91 files changed, 2227 insertions, 195 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index eb520bf56c..2536a9731b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,9 +26,7 @@ ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) # Project setup ######################################################################## CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(gnuradio) -ENABLE_LANGUAGE(CXX) -ENABLE_LANGUAGE(C) +PROJECT(gnuradio CXX C) ENABLE_TESTING() #select the release build type by default to get optimization flags diff --git a/cmake/Modules/GrBoost.cmake b/cmake/Modules/GrBoost.cmake index 5e3ad1b435..4e515152d3 100644 --- a/cmake/Modules/GrBoost.cmake +++ b/cmake/Modules/GrBoost.cmake @@ -50,5 +50,13 @@ IF(MSVC) ENDIF(BOOST_ALL_DYN_LINK) ENDIF(MSVC) -SET(Boost_ADDITIONAL_VERSIONS "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44" "1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47") +SET(Boost_ADDITIONAL_VERSIONS + "1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39" + "1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44" + "1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49" + "1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54" + "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59" + "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" + "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" +) FIND_PACKAGE(Boost "1.35" COMPONENTS ${BOOST_REQUIRED_COMPONENTS}) diff --git a/cmake/Modules/GrMiscUtils.cmake b/cmake/Modules/GrMiscUtils.cmake index a7e20124f5..c36c509b57 100644 --- a/cmake/Modules/GrMiscUtils.cmake +++ b/cmake/Modules/GrMiscUtils.cmake @@ -84,17 +84,3 @@ MACRO(GR_INCLUDE_SUBDIRECTORY subdir) LIST(REMOVE_AT _cmake_source_dirs 0) LIST(REMOVE_AT _cmake_binary_dirs 0) ENDMACRO(GR_INCLUDE_SUBDIRECTORY) - -######################################################################## -# Create an always-built target with a unique name -# Usage: GR_UNIQUE_TARGET(<description> <dependencies list>) -######################################################################## -FUNCTION(GR_UNIQUE_TARGET desc) - INCLUDE(GrPython) - FILE(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib -unique = hashlib.md5('${reldir}${ARGN}').hexdigest()[:5] -print re.sub('\\W', '_', '${desc} ${reldir} ' + unique)" - OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE) - ADD_CUSTOM_TARGET(${_target} ALL DEPENDS ${ARGN}) -ENDFUNCTION(GR_UNIQUE_TARGET) diff --git a/cmake/Modules/GrPython.cmake b/cmake/Modules/GrPython.cmake index 8cffd7a010..f54dbc9ba7 100644 --- a/cmake/Modules/GrPython.cmake +++ b/cmake/Modules/GrPython.cmake @@ -51,10 +51,6 @@ ENDIF(PYTHON_EXECUTABLE) #make the path to the executable appear in the cmake gui SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter") -IF(NOT PYTHONINTERP_FOUND) - MESSAGE(FATAL_ERROR "Error: Python interpretor required by the build system.") -ENDIF(NOT PYTHONINTERP_FOUND) - ######################################################################## # Check for the existence of a python module: # - desc a string description of the check @@ -95,6 +91,19 @@ print sysconfig.get_python_lib(plat_specific=True, prefix='') FILE(TO_CMAKE_PATH ${GR_PYTHON_DIR} GR_PYTHON_DIR) ######################################################################## +# Create an always-built target with a unique name +# Usage: GR_UNIQUE_TARGET(<description> <dependencies list>) +######################################################################## +FUNCTION(GR_UNIQUE_TARGET desc) + FILE(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib +unique = hashlib.md5('${reldir}${ARGN}').hexdigest()[:5] +print(re.sub('\\W', '_', '${desc} ${reldir} ' + unique))" + OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE) + ADD_CUSTOM_TARGET(${_target} ALL DEPENDS ${ARGN}) +ENDFUNCTION(GR_UNIQUE_TARGET) + +######################################################################## # Install python sources (also builds and installs byte-compiled python) ######################################################################## FUNCTION(GR_PYTHON_INSTALL) @@ -163,7 +172,6 @@ FUNCTION(GR_PYTHON_INSTALL) ENDIF() - INCLUDE(GrMiscUtils) #unique target GR_UNIQUE_TARGET("pygen" ${python_install_gen_targets}) ENDFUNCTION(GR_PYTHON_INSTALL) diff --git a/cmake/Modules/GrTest.cmake b/cmake/Modules/GrTest.cmake index 1851437afc..e9e2a0c2e2 100644 --- a/cmake/Modules/GrTest.cmake +++ b/cmake/Modules/GrTest.cmake @@ -98,6 +98,9 @@ FUNCTION(GR_ADD_TEST test_name) ENDFOREACH(arg) FILE(APPEND ${sh_file} "\n") + #make the shell file executable + EXECUTE_PROCESS(COMMAND chmod +x ${sh_file}) + ADD_TEST(${test_name} ${SHELL} ${sh_file}) ENDIF(UNIX) diff --git a/cmake/msvc/sys/time.h b/cmake/msvc/sys/time.h deleted file mode 100644 index 998b5d7bba..0000000000 --- a/cmake/msvc/sys/time.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_SYS_TIME_H_ -#define _MSC_SYS_TIME_H_ - -//http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/430449b3-f6dd-4e18-84de-eebd26a8d668 -#include < time.h > -#include <windows.h> //I've ommited this line. -#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) - #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 -#else - #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL -#endif - -struct timespec { - -time_t tv_sec; /* Seconds since 00:00:00 GMT, */ - -/* 1 January 1970 */ - -long tv_nsec; /* Additional nanoseconds since */ - -/* tv_sec */ - -}; - -struct timezone -{ - int tz_minuteswest; /* minutes W of Greenwich */ - int tz_dsttime; /* type of dst correction */ -}; - -static inline int gettimeofday(struct timeval *tv, struct timezone *tz) -{ - FILETIME ft; - unsigned __int64 tmpres = 0; - static int tzflag; - - if (NULL != tv) - { - GetSystemTimeAsFileTime(&ft); - - tmpres |= ft.dwHighDateTime; - tmpres <<= 32; - tmpres |= ft.dwLowDateTime; - - /*converting file time to unix epoch*/ - tmpres -= DELTA_EPOCH_IN_MICROSECS; - tv->tv_sec = (long)(tmpres / 1000000UL); - tv->tv_usec = (long)(tmpres % 1000000UL); - } - - if (NULL != tz) - { - if (!tzflag) - { - _tzset(); - tzflag++; - } - tz->tz_minuteswest = _timezone / 60; - tz->tz_dsttime = _daylight; - } - - return 0; -} - -#endif //_MSC_SYS_TIME_H_ diff --git a/gnuradio-core/CMakeLists.txt b/gnuradio-core/CMakeLists.txt index 1c133efb93..b72bf70d68 100644 --- a/gnuradio-core/CMakeLists.txt +++ b/gnuradio-core/CMakeLists.txt @@ -130,8 +130,6 @@ ENDIF(ENABLE_PYTHON) ######################################################################## # Create Pkg Config File ######################################################################## -FILE(TO_NATIVE_PATH "\${prefix}/${GR_INCLUDE_DIR}/gnuradio" includedir) #different from other gr modules - CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-core.pc.in ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.pc diff --git a/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt b/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt index 4a495f9f91..5640b12a20 100644 --- a/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt +++ b/gnuradio-core/src/lib/reed-solomon/CMakeLists.txt @@ -20,10 +20,18 @@ ######################################################################## # This file included, use CMake directory variables ######################################################################## -IF(NOT MSVC) #FIXME can't build reed-solomon in MSVC. -#The rs sources use a lot of non-standard code -#like the array allocation and some c99 functions. -#In short, will not fix unless someone asks nicely. +#MSVC workaround: we cant have dynamically sized arrays. +#So ifdef a max array bounds that is larger than NN and NROOTS +#Its a bit of a hack, but if you look at the code, its so full of ifdefs, +#and lacks optimization where it should be pre-allocating these arrays. +IF(MSVC) + SET_SOURCE_FILES_PROPERTIES( + ${CMAKE_CURRENT_SOURCE_DIR}/exercise.c + ${CMAKE_CURRENT_SOURCE_DIR}/decode_rs.c + PROPERTIES COMPILE_DEFINITIONS "MAX_ARRAY=256;" + ) +ENDIF(MSVC) + SET(gr_core_rs_sources ${CMAKE_CURRENT_SOURCE_DIR}/encode_rs.c ${CMAKE_CURRENT_SOURCE_DIR}/decode_rs.c @@ -52,4 +60,3 @@ ADD_EXECUTABLE(gr_core_rstest ) ADD_TEST(gr-core-reed-solomon-test gr_core_rstest) ENDIF(ENABLE_TESTING) -ENDIF(NOT MSVC) diff --git a/gnuradio-core/src/lib/reed-solomon/decode_rs.c b/gnuradio-core/src/lib/reed-solomon/decode_rs.c index ca409782fa..ba60b89ee4 100644 --- a/gnuradio-core/src/lib/reed-solomon/decode_rs.c +++ b/gnuradio-core/src/lib/reed-solomon/decode_rs.c @@ -31,11 +31,19 @@ DTYPE *data, int *eras_pos, int no_eras){ #endif int deg_lambda, el, deg_omega; int i, j, r,k; +#ifdef MAX_ARRAY + DTYPE u,q,tmp,num1,num2,den,discr_r; + DTYPE lambda[MAX_ARRAY], s[MAX_ARRAY]; /* Err+Eras Locator poly + * and syndrome poly */ + DTYPE b[MAX_ARRAY], t[MAX_ARRAY], omega[MAX_ARRAY]; + DTYPE root[MAX_ARRAY], reg[MAX_ARRAY], loc[MAX_ARRAY]; +#else DTYPE u,q,tmp,num1,num2,den,discr_r; DTYPE lambda[NROOTS+1], s[NROOTS]; /* Err+Eras Locator poly * and syndrome poly */ DTYPE b[NROOTS+1], t[NROOTS+1], omega[NROOTS+1]; DTYPE root[NROOTS], reg[NROOTS+1], loc[NROOTS]; +#endif int syn_error, count; /* form the syndromes; i.e., evaluate data(x) at roots of g(x) */ diff --git a/gnuradio-core/src/lib/reed-solomon/exercise.c b/gnuradio-core/src/lib/reed-solomon/exercise.c index 1e04f618d7..987fe1aeba 100644 --- a/gnuradio-core/src/lib/reed-solomon/exercise.c +++ b/gnuradio-core/src/lib/reed-solomon/exercise.c @@ -13,7 +13,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <strings.h> #ifdef FIXED #include "fixed.h" @@ -47,11 +46,19 @@ int trials){ #if !defined(CCSDS) && !defined(FIXED) struct rs *rs = (struct rs *)p; #endif +#if MAX_ARRAY + DTYPE block[MAX_ARRAY],tblock[MAX_ARRAY]; + int i; + int errors; + int errlocs[MAX_ARRAY]; + int derrlocs[MAX_ARRAY]; +#else DTYPE block[NN],tblock[NN]; int i; int errors; int errlocs[NN]; int derrlocs[NROOTS]; +#endif int derrors; int errval,errloc; int erasures; diff --git a/gr-atsc/CMakeLists.txt b/gr-atsc/CMakeLists.txt index ab5bf82310..86aa53991a 100644 --- a/gr-atsc/CMakeLists.txt +++ b/gr-atsc/CMakeLists.txt @@ -27,13 +27,10 @@ INCLUDE(GrBoost) ######################################################################## INCLUDE(GrComponent) GR_REGISTER_COMPONENT("gr-atsc" ENABLE_GR_ATSC - UNIX #FIXME until we get MSVC working with this and Reed-Solomon codec Boost_FOUND ENABLE_GR_CORE_ ) -REMOVE_DEFINITIONS(-fvisibility=hidden) #FIXME until we do symbol visibility - GR_SET_GLOBAL(GR_ATSC_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/lib ) diff --git a/gr-atsc/src/lib/CMakeLists.txt b/gr-atsc/src/lib/CMakeLists.txt index 51acf89311..9b03d48dc5 100644 --- a/gr-atsc/src/lib/CMakeLists.txt +++ b/gr-atsc/src/lib/CMakeLists.txt @@ -131,7 +131,7 @@ LIST(APPEND test_atsci_sources ) INCLUDE(GrTest) -SET(GR_TEST_TARGET_DEPS gnuradio-atsc) +SET(GR_TEST_TARGET_DEPS gnuradio-atsc gnuradio-core gruel) ADD_EXECUTABLE(test_atsci ${test_atsci_sources} test_atsci.cc) TARGET_LINK_LIBRARIES(test_atsci gnuradio-atsc gnuradio-core ${CPPUNIT_LIBRARIES}) GR_ADD_TEST(atsci-test test_atsci) @@ -142,6 +142,7 @@ ENDIF(ENABLE_TESTING) # Install public header files ######################################################################## INSTALL(FILES + atsc_api.h atsc_consts.h atsc_derandomizer.h atsc_randomizer.h diff --git a/gr-atsc/src/lib/Makefile.am b/gr-atsc/src/lib/Makefile.am index b1bda90ff4..3cbdc8a1b4 100644 --- a/gr-atsc/src/lib/Makefile.am +++ b/gr-atsc/src/lib/Makefile.am @@ -123,6 +123,7 @@ libgnuradio_atsc_qa_la_LDFLAGS = \ # These headers get installed in ${prefix}/include/gnuradio grinclude_HEADERS = \ + atsc_api.h \ atsc_consts.h \ atsc_derandomizer.h \ atsc_randomizer.h \ diff --git a/gr-atsc/src/lib/atsc_api.h b/gr-atsc/src/lib/atsc_api.h new file mode 100644 index 0000000000..5add37762b --- /dev/null +++ b/gr-atsc/src/lib/atsc_api.h @@ -0,0 +1,33 @@ +/* + * Copyright 2011 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. + */ + +#ifndef INCLUDED_ATSC_API_H +#define INCLUDED_ATSC_API_H + +#include <gruel/attributes.h> + +#ifdef gnuradio_atsc_EXPORTS +# define ATSC_API __GR_ATTR_EXPORT +#else +# define ATSC_API __GR_ATTR_IMPORT +#endif + +#endif /* INCLUDED_ATSC_API_H */ diff --git a/gr-atsc/src/lib/atsc_bit_timing_loop.h b/gr-atsc/src/lib/atsc_bit_timing_loop.h index c9b63fee9e..2adff26b86 100644 --- a/gr-atsc/src/lib/atsc_bit_timing_loop.h +++ b/gr-atsc/src/lib/atsc_bit_timing_loop.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_ATSC_BIT_TIMING_LOOP_H #define INCLUDED_ATSC_BIT_TIMING_LOOP_H +#include <atsc_api.h> #include <cstdio> #include <gr_block.h> #include <atsci_diag_output.h> @@ -31,7 +32,7 @@ class atsc_bit_timing_loop; typedef boost::shared_ptr<atsc_bit_timing_loop> atsc_bit_timing_loop_sptr; -atsc_bit_timing_loop_sptr atsc_make_bit_timing_loop(); +ATSC_API atsc_bit_timing_loop_sptr atsc_make_bit_timing_loop(); /*! * \brief ATSC BitTimingLoop3 @@ -40,9 +41,9 @@ atsc_bit_timing_loop_sptr atsc_make_bit_timing_loop(); * This class accepts a single real input and produces two outputs, * the raw symbol (float) and the tag (atsc_syminfo) */ -class atsc_bit_timing_loop : public gr_block +class ATSC_API atsc_bit_timing_loop : public gr_block { - friend atsc_bit_timing_loop_sptr atsc_make_bit_timing_loop(); + friend ATSC_API atsc_bit_timing_loop_sptr atsc_make_bit_timing_loop(); atsc_bit_timing_loop(); diff --git a/gr-atsc/src/lib/atsc_deinterleaver.h b/gr-atsc/src/lib/atsc_deinterleaver.h index 0920818a48..8cab62b627 100644 --- a/gr-atsc/src/lib/atsc_deinterleaver.h +++ b/gr-atsc/src/lib/atsc_deinterleaver.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_ATSC_DEINTERLEAVER_H #define INCLUDED_ATSC_DEINTERLEAVER_H +#include <atsc_api.h> #include <gr_sync_block.h> #include <atsci_data_interleaver.h> class atsc_deinterleaver; typedef boost::shared_ptr<atsc_deinterleaver> atsc_deinterleaver_sptr; -atsc_deinterleaver_sptr atsc_make_deinterleaver(); +ATSC_API atsc_deinterleaver_sptr atsc_make_deinterleaver(); /*! * \brief Deinterleave RS encoded ATSC data ( atsc_mpeg_packet_rs_encoded --> atsc_mpeg_packet_rs_encoded) @@ -36,9 +37,9 @@ atsc_deinterleaver_sptr atsc_make_deinterleaver(); * * input: atsc_mpeg_packet_rs_encoded; output: atsc_mpeg_packet_rs_encoded */ -class atsc_deinterleaver : public gr_sync_block +class ATSC_API atsc_deinterleaver : public gr_sync_block { - friend atsc_deinterleaver_sptr atsc_make_deinterleaver(); + friend ATSC_API atsc_deinterleaver_sptr atsc_make_deinterleaver(); atsci_data_deinterleaver d_deinterleaver; diff --git a/gr-atsc/src/lib/atsc_depad.h b/gr-atsc/src/lib/atsc_depad.h index 58dfdaf62d..b514efe28a 100644 --- a/gr-atsc/src/lib/atsc_depad.h +++ b/gr-atsc/src/lib/atsc_depad.h @@ -22,12 +22,13 @@ #ifndef INCLUDED_ATSC_DEPAD_H #define INCLUDED_ATSC_DEPAD_H +#include <atsc_api.h> #include <gr_sync_interpolator.h> class atsc_depad; typedef boost::shared_ptr<atsc_depad> atsc_depad_sptr; -atsc_depad_sptr atsc_make_depad(); +ATSC_API atsc_depad_sptr atsc_make_depad(); /*! * \brief depad mpeg ts packets from 256 byte atsc_mpeg_packet to 188 byte char @@ -35,9 +36,9 @@ atsc_depad_sptr atsc_make_depad(); * * input: atsc_mpeg_packet; output: unsigned char */ -class atsc_depad : public gr_sync_interpolator +class ATSC_API atsc_depad : public gr_sync_interpolator { - friend atsc_depad_sptr atsc_make_depad(); + friend ATSC_API atsc_depad_sptr atsc_make_depad(); atsc_depad(); diff --git a/gr-atsc/src/lib/atsc_derandomizer.h b/gr-atsc/src/lib/atsc_derandomizer.h index a72efbd4eb..54254d0c5c 100644 --- a/gr-atsc/src/lib/atsc_derandomizer.h +++ b/gr-atsc/src/lib/atsc_derandomizer.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_ATSC_DERANDOMIZER_H #define INCLUDED_ATSC_DERANDOMIZER_H +#include <atsc_api.h> #include <gr_sync_block.h> #include <atsci_randomizer.h> class atsc_derandomizer; typedef boost::shared_ptr<atsc_derandomizer> atsc_derandomizer_sptr; -atsc_derandomizer_sptr atsc_make_derandomizer(); +ATSC_API atsc_derandomizer_sptr atsc_make_derandomizer(); /*! * \brief "dewhiten" incoming mpeg transport stream packets @@ -36,9 +37,9 @@ atsc_derandomizer_sptr atsc_make_derandomizer(); * * input: atsc_mpeg_packet_no_sync; output: atsc_mpeg_packet; */ -class atsc_derandomizer : public gr_sync_block +class ATSC_API atsc_derandomizer : public gr_sync_block { - friend atsc_derandomizer_sptr atsc_make_derandomizer(); + friend ATSC_API atsc_derandomizer_sptr atsc_make_derandomizer(); atsci_randomizer d_rand; diff --git a/gr-atsc/src/lib/atsc_ds_to_softds.h b/gr-atsc/src/lib/atsc_ds_to_softds.h index f8623e3b05..1021eed6fc 100644 --- a/gr-atsc/src/lib/atsc_ds_to_softds.h +++ b/gr-atsc/src/lib/atsc_ds_to_softds.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_ATSC_DS_TO_SOFTDS_H #define INCLUDED_ATSC_DS_TO_SOFTDS_H +#include <atsc_api.h> #include <gr_sync_block.h> #include <atsc_types.h> class atsc_ds_to_softds; typedef boost::shared_ptr<atsc_ds_to_softds> atsc_ds_to_softds_sptr; -atsc_ds_to_softds_sptr atsc_make_ds_to_softds(); +ATSC_API atsc_ds_to_softds_sptr atsc_make_ds_to_softds(); /*! * \brief Debug glue routine (atsc_data_segment --> atsc_soft_data_segment) @@ -36,9 +37,9 @@ atsc_ds_to_softds_sptr atsc_make_ds_to_softds(); * * input: atsc_data_segment; output: atsc_soft_data_segment */ -class atsc_ds_to_softds : public gr_sync_block +class ATSC_API atsc_ds_to_softds : public gr_sync_block { - friend atsc_ds_to_softds_sptr atsc_make_ds_to_softds(); + friend ATSC_API atsc_ds_to_softds_sptr atsc_make_ds_to_softds(); atsc_ds_to_softds(); diff --git a/gr-atsc/src/lib/atsc_equalizer.h b/gr-atsc/src/lib/atsc_equalizer.h index 52b5cd38d8..773cd1a04e 100644 --- a/gr-atsc/src/lib/atsc_equalizer.h +++ b/gr-atsc/src/lib/atsc_equalizer.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_ATSC_EQUALIZER_H #define INCLUDED_ATSC_EQUALIZER_H +#include <atsc_api.h> #include <gr_sync_block.h> #include <atsci_equalizer.h> class atsc_equalizer; typedef boost::shared_ptr<atsc_equalizer> atsc_equalizer_sptr; -atsc_equalizer_sptr atsc_make_equalizer(); +atsc_equalizer_sptr ATSC_API atsc_make_equalizer(); /*! * \brief ATSC equalizer (float,syminfo --> float,syminfo) @@ -37,9 +38,9 @@ atsc_equalizer_sptr atsc_make_equalizer(); * first inputs are data samples, second inputs are tags. * first outputs are equalized data samples, second outputs are tags. */ -class atsc_equalizer : public gr_sync_block +class ATSC_API atsc_equalizer : public gr_sync_block { - friend atsc_equalizer_sptr atsc_make_equalizer(); + friend ATSC_API atsc_equalizer_sptr atsc_make_equalizer(); atsc_equalizer(); diff --git a/gr-atsc/src/lib/atsc_field_sync_demux.h b/gr-atsc/src/lib/atsc_field_sync_demux.h index 01cc33f87a..0e3a5003d1 100644 --- a/gr-atsc/src/lib/atsc_field_sync_demux.h +++ b/gr-atsc/src/lib/atsc_field_sync_demux.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_ATSC_FIELD_SYNC_DEMUX_H #define INCLUDED_ATSC_FIELD_SYNC_DEMUX_H +#include <atsc_api.h> #include <gr_block.h> #include <atsc_types.h> class atsc_field_sync_demux; typedef boost::shared_ptr<atsc_field_sync_demux> atsc_field_sync_demux_sptr; -atsc_field_sync_demux_sptr atsc_make_field_sync_demux(); +ATSC_API atsc_field_sync_demux_sptr atsc_make_field_sync_demux(); /*! * \brief ATSC Field Sync Demux @@ -37,9 +38,9 @@ atsc_field_sync_demux_sptr atsc_make_field_sync_demux(); * \ingroup atsc * */ -class atsc_field_sync_demux : public gr_block +class ATSC_API atsc_field_sync_demux : public gr_block { - friend atsc_field_sync_demux_sptr atsc_make_field_sync_demux(); + friend ATSC_API atsc_field_sync_demux_sptr atsc_make_field_sync_demux(); atsc_field_sync_demux(); diff --git a/gr-atsc/src/lib/atsc_field_sync_mux.h b/gr-atsc/src/lib/atsc_field_sync_mux.h index 189341cb96..d08a99b5ba 100644 --- a/gr-atsc/src/lib/atsc_field_sync_mux.h +++ b/gr-atsc/src/lib/atsc_field_sync_mux.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_ATSC_FIELD_SYNC_MUX_H #define INCLUDED_ATSC_FIELD_SYNC_MUX_H +#include <atsc_api.h> #include <gr_sync_block.h> #include <atsc_types.h> class atsc_field_sync_mux; typedef boost::shared_ptr<atsc_field_sync_mux> atsc_field_sync_mux_sptr; -atsc_field_sync_mux_sptr atsc_make_field_sync_mux(); +ATSC_API atsc_field_sync_mux_sptr atsc_make_field_sync_mux(); /*! * \brief Insert ATSC Field Syncs as required (atsc_data_segment --> atsc_data_segment) @@ -36,9 +37,9 @@ atsc_field_sync_mux_sptr atsc_make_field_sync_mux(); * * input: atsc_data_segment; output: atsc_data_segment */ -class atsc_field_sync_mux : public gr_sync_block +class ATSC_API atsc_field_sync_mux : public gr_sync_block { - friend atsc_field_sync_mux_sptr atsc_make_field_sync_mux(); + friend ATSC_API atsc_field_sync_mux_sptr atsc_make_field_sync_mux(); atsc_field_sync_mux(); diff --git a/gr-atsc/src/lib/atsc_fpll.h b/gr-atsc/src/lib/atsc_fpll.h index 1ed41d8653..dac3cda866 100644 --- a/gr-atsc/src/lib/atsc_fpll.h +++ b/gr-atsc/src/lib/atsc_fpll.h @@ -22,6 +22,7 @@ #ifndef INCLUDED_ATSC_FPLL_H #define INCLUDED_ATSC_FPLL_H +#include <atsc_api.h> #include <gr_sync_block.h> #include <gr_nco.h> #include <gr_single_pole_iir.h> @@ -32,7 +33,7 @@ class atsc_fpll; typedef boost::shared_ptr<atsc_fpll> atsc_fpll_sptr; -atsc_fpll_sptr atsc_make_fpll(); +ATSC_API atsc_fpll_sptr atsc_make_fpll(); /*! * \brief ATSC FPLL (2nd Version) @@ -45,9 +46,9 @@ atsc_fpll_sptr atsc_make_fpll(); * This class accepts a single real input and produces a single real output */ -class atsc_fpll : public gr_sync_block +class ATSC_API atsc_fpll : public gr_sync_block { - friend atsc_fpll_sptr atsc_make_fpll(); + friend ATSC_API atsc_fpll_sptr atsc_make_fpll(); atsc_fpll(); diff --git a/gr-atsc/src/lib/atsc_fs_checker.h b/gr-atsc/src/lib/atsc_fs_checker.h index e7271af22e..03e50ee9d9 100644 --- a/gr-atsc/src/lib/atsc_fs_checker.h +++ b/gr-atsc/src/lib/atsc_fs_checker.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_ATSC_FS_CHECKER_H #define INCLUDED_ATSC_FS_CHECKER_H +#include <atsc_api.h> #include <atsci_fs_checker.h> #include <gr_sync_block.h> class atsc_fs_checker; typedef boost::shared_ptr<atsc_fs_checker> atsc_fs_checker_sptr; -atsc_fs_checker_sptr atsc_make_fs_checker(); +ATSC_API atsc_fs_checker_sptr atsc_make_fs_checker(); /*! * \brief ATSC field sync checker (float,syminfo --> float,syminfo) @@ -38,7 +39,7 @@ atsc_fs_checker_sptr atsc_make_fs_checker(); * second output is set of tags, one-for-one with first output. */ -class atsc_fs_checker : public gr_sync_block +class ATSC_API atsc_fs_checker : public gr_sync_block { friend atsc_fs_checker_sptr atsc_make_fs_checker(); diff --git a/gr-atsc/src/lib/atsc_interleaver.h b/gr-atsc/src/lib/atsc_interleaver.h index 5f82b7596a..00cd54c11a 100644 --- a/gr-atsc/src/lib/atsc_interleaver.h +++ b/gr-atsc/src/lib/atsc_interleaver.h @@ -22,22 +22,23 @@ #ifndef INCLUDED_ATSC_INTERLEAVER_H #define INCLUDED_ATSC_INTERLEAVER_H +#include <atsc_api.h> #include <gr_sync_block.h> #include <atsci_data_interleaver.h> class atsc_interleaver; typedef boost::shared_ptr<atsc_interleaver> atsc_interleaver_sptr; -atsc_interleaver_sptr atsc_make_interleaver(); +ATSC_API atsc_interleaver_sptr atsc_make_interleaver(); /*! \brief Interleave RS encoded ATSC data ( atsc_mpeg_packet_rs_encoded --> atsc_mpeg_packet_rs_encoded)* * \ingroup atsc * * input: atsc_mpeg_packet_rs_encoded; output: atsc_mpeg_packet_rs_encoded */ -class atsc_interleaver : public gr_sync_block +class ATSC_API atsc_interleaver : public gr_sync_block { - friend atsc_interleaver_sptr atsc_make_interleaver(); + friend ATSC_API atsc_interleaver_sptr atsc_make_interleaver(); atsci_data_interleaver d_interleaver; diff --git a/gr-atsc/src/lib/atsc_pad.h b/gr-atsc/src/lib/atsc_pad.h index e7e6874fb3..866c72552d 100644 --- a/gr-atsc/src/lib/atsc_pad.h +++ b/gr-atsc/src/lib/atsc_pad.h @@ -22,12 +22,13 @@ #ifndef INCLUDED_ATSC_PAD_H #define INCLUDED_ATSC_PAD_H +#include <atsc_api.h> #include <gr_sync_decimator.h> class atsc_pad; typedef boost::shared_ptr<atsc_pad> atsc_pad_sptr; -atsc_pad_sptr atsc_make_pad(); +ATSC_API atsc_pad_sptr atsc_make_pad(); /*! * \brief pad mpeg ts packets from 188 byte char to @@ -36,9 +37,9 @@ atsc_pad_sptr atsc_make_pad(); * * input: unsigned char; output: atsc_mpeg_packet */ -class atsc_pad : public gr_sync_decimator +class ATSC_API atsc_pad : public gr_sync_decimator { - friend atsc_pad_sptr atsc_make_pad(); + friend ATSC_API atsc_pad_sptr atsc_make_pad(); atsc_pad(); diff --git a/gr-atsc/src/lib/atsc_randomizer.h b/gr-atsc/src/lib/atsc_randomizer.h index 6617bcc28b..1178f06c04 100644 --- a/gr-atsc/src/lib/atsc_randomizer.h +++ b/gr-atsc/src/lib/atsc_randomizer.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_ATSC_RANDOMIZER_H #define INCLUDED_ATSC_RANDOMIZER_H +#include <atsc_api.h> #include <gr_sync_block.h> #include <atsci_randomizer.h> class atsc_randomizer; typedef boost::shared_ptr<atsc_randomizer> atsc_randomizer_sptr; -atsc_randomizer_sptr atsc_make_randomizer(); +ATSC_API atsc_randomizer_sptr atsc_make_randomizer(); /*! * \brief "Whiten" incoming mpeg transport stream packets @@ -36,9 +37,9 @@ atsc_randomizer_sptr atsc_make_randomizer(); * * input: atsc_mpeg_packet; output: atsc_mpeg_packet_no_sync */ -class atsc_randomizer : public gr_sync_block +class ATSC_API atsc_randomizer : public gr_sync_block { - friend atsc_randomizer_sptr atsc_make_randomizer(); + friend ATSC_API atsc_randomizer_sptr atsc_make_randomizer(); atsci_randomizer d_rand; bool d_field2; // user to init plinfo in output diff --git a/gr-atsc/src/lib/atsc_rs_decoder.h b/gr-atsc/src/lib/atsc_rs_decoder.h index 00dea16034..4b8d6c1b46 100644 --- a/gr-atsc/src/lib/atsc_rs_decoder.h +++ b/gr-atsc/src/lib/atsc_rs_decoder.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_ATSC_RS_DECODER_H #define INCLUDED_ATSC_RS_DECODER_H +#include <atsc_api.h> #include <gr_sync_block.h> #include <atsci_reed_solomon.h> class atsc_rs_decoder; typedef boost::shared_ptr<atsc_rs_decoder> atsc_rs_decoder_sptr; -atsc_rs_decoder_sptr atsc_make_rs_decoder(); +ATSC_API atsc_rs_decoder_sptr atsc_make_rs_decoder(); /*! * \brief Reed-Solomon decoder for ATSC @@ -36,9 +37,9 @@ atsc_rs_decoder_sptr atsc_make_rs_decoder(); * * input: atsc_mpeg_packet_rs_encoded; output: atsc_mpeg_packet_no_sync */ -class atsc_rs_decoder : public gr_sync_block +class ATSC_API atsc_rs_decoder : public gr_sync_block { - friend atsc_rs_decoder_sptr atsc_make_rs_decoder(); + friend ATSC_API atsc_rs_decoder_sptr atsc_make_rs_decoder(); atsci_reed_solomon d_rs_decoder; diff --git a/gr-atsc/src/lib/atsc_rs_encoder.h b/gr-atsc/src/lib/atsc_rs_encoder.h index 312b2e1cb7..d9812678a2 100644 --- a/gr-atsc/src/lib/atsc_rs_encoder.h +++ b/gr-atsc/src/lib/atsc_rs_encoder.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_ATSC_RS_ENCODER_H #define INCLUDED_ATSC_RS_ENCODER_H +#include <atsc_api.h> #include <gr_sync_block.h> #include <atsci_reed_solomon.h> class atsc_rs_encoder; typedef boost::shared_ptr<atsc_rs_encoder> atsc_rs_encoder_sptr; -atsc_rs_encoder_sptr atsc_make_rs_encoder(); +ATSC_API atsc_rs_encoder_sptr atsc_make_rs_encoder(); /*! * \brief Reed-Solomon encoder for ATSC @@ -36,9 +37,9 @@ atsc_rs_encoder_sptr atsc_make_rs_encoder(); * * input: atsc_mpeg_packet_no_sync; output: atsc_mpeg_packet_rs_encoded */ -class atsc_rs_encoder : public gr_sync_block +class ATSC_API atsc_rs_encoder : public gr_sync_block { - friend atsc_rs_encoder_sptr atsc_make_rs_encoder(); + friend ATSC_API atsc_rs_encoder_sptr atsc_make_rs_encoder(); atsci_reed_solomon d_rs_encoder; diff --git a/gr-atsc/src/lib/atsc_trellis_encoder.h b/gr-atsc/src/lib/atsc_trellis_encoder.h index 5c93daf996..c848161187 100644 --- a/gr-atsc/src/lib/atsc_trellis_encoder.h +++ b/gr-atsc/src/lib/atsc_trellis_encoder.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_ATSC_TRELLIS_ENCODER_H #define INCLUDED_ATSC_TRELLIS_ENCODER_H +#include <atsc_api.h> #include <gr_sync_block.h> #include <atsci_trellis_encoder.h> class atsc_trellis_encoder; typedef boost::shared_ptr<atsc_trellis_encoder> atsc_trellis_encoder_sptr; -atsc_trellis_encoder_sptr atsc_make_trellis_encoder(); +ATSC_API atsc_trellis_encoder_sptr atsc_make_trellis_encoder(); /*! * \brief ATSC 12-way interleaved trellis encoder (atsc_mpeg_packet_rs_encoded --> atsc_data_segment) @@ -36,9 +37,9 @@ atsc_trellis_encoder_sptr atsc_make_trellis_encoder(); * * input: atsc_mpeg_packet_rs_encoded; output: atsc_data_segment */ -class atsc_trellis_encoder : public gr_sync_block +class ATSC_API atsc_trellis_encoder : public gr_sync_block { - friend atsc_trellis_encoder_sptr atsc_make_trellis_encoder(); + friend ATSC_API atsc_trellis_encoder_sptr atsc_make_trellis_encoder(); atsci_trellis_encoder d_trellis_encoder; diff --git a/gr-atsc/src/lib/atsc_viterbi_decoder.h b/gr-atsc/src/lib/atsc_viterbi_decoder.h index 511df0dffd..1a43b49521 100644 --- a/gr-atsc/src/lib/atsc_viterbi_decoder.h +++ b/gr-atsc/src/lib/atsc_viterbi_decoder.h @@ -22,13 +22,14 @@ #ifndef INCLUDED_ATSC_VITERBI_DECODER_H #define INCLUDED_ATSC_VITERBI_DECODER_H +#include <atsc_api.h> #include <gr_sync_block.h> #include <atsci_viterbi_decoder.h> class atsc_viterbi_decoder; typedef boost::shared_ptr<atsc_viterbi_decoder> atsc_viterbi_decoder_sptr; -atsc_viterbi_decoder_sptr atsc_make_viterbi_decoder(); +ATSC_API atsc_viterbi_decoder_sptr atsc_make_viterbi_decoder(); /*! * \brief ATSC 12-way interleaved viterbi decoder (atsc_soft_data_segment --> atsc_mpeg_packet_rs_encoded) @@ -36,9 +37,9 @@ atsc_viterbi_decoder_sptr atsc_make_viterbi_decoder(); * * input: atsc_soft_data_segment; output: atsc_mpeg_packet_rs_encoded */ -class atsc_viterbi_decoder : public gr_sync_block +class ATSC_API atsc_viterbi_decoder : public gr_sync_block { - friend atsc_viterbi_decoder_sptr atsc_make_viterbi_decoder(); + friend ATSC_API atsc_viterbi_decoder_sptr atsc_make_viterbi_decoder(); atsci_viterbi_decoder d_viterbi_decoder; diff --git a/gr-atsc/src/lib/atsci_basic_trellis_encoder.h b/gr-atsc/src/lib/atsci_basic_trellis_encoder.h index 1e40731443..c17e5653e4 100644 --- a/gr-atsc/src/lib/atsci_basic_trellis_encoder.h +++ b/gr-atsc/src/lib/atsci_basic_trellis_encoder.h @@ -22,6 +22,7 @@ #ifndef _ATSC_BASIC_TRELLIS_ENCODER_H_ #define _ATSC_BASIC_TRELLIS_ENCODER_H_ +#include <atsc_api.h> #include <assert.h> /*! @@ -36,7 +37,7 @@ * filter is not supported. */ -class atsci_basic_trellis_encoder { +class ATSC_API atsci_basic_trellis_encoder { private: int state; // two bit state; diff --git a/gr-atsc/src/lib/atsci_data_interleaver.h b/gr-atsc/src/lib/atsci_data_interleaver.h index ab4b64d4ff..e7f982db40 100644 --- a/gr-atsc/src/lib/atsci_data_interleaver.h +++ b/gr-atsc/src/lib/atsci_data_interleaver.h @@ -23,13 +23,14 @@ #ifndef _ATSC_DATA_INTERLEAVER_H_ #define _ATSC_DATA_INTERLEAVER_H_ +#include <atsc_api.h> #include <atsc_types.h> #include <convolutional_interleaver.h> /*! * \brief atsc convolutional data interleaver */ -class atsci_data_interleaver : public convolutional_interleaver<unsigned char> { +class ATSC_API atsci_data_interleaver : public convolutional_interleaver<unsigned char> { public: atsci_data_interleaver () : convolutional_interleaver<unsigned char>(true, 52, 4) {} @@ -40,7 +41,7 @@ class atsci_data_interleaver : public convolutional_interleaver<unsigned char> { /*! * \brief atsc convolutional data deinterleaver */ -class atsci_data_deinterleaver : public convolutional_interleaver<unsigned char> { +class ATSC_API atsci_data_deinterleaver : public convolutional_interleaver<unsigned char> { public: atsci_data_deinterleaver () : convolutional_interleaver<unsigned char>(false, 52, 4), alignment_fifo (156) {} diff --git a/gr-atsc/src/lib/atsci_equalizer.h b/gr-atsc/src/lib/atsci_equalizer.h index 2120ea90a7..853c52689a 100644 --- a/gr-atsc/src/lib/atsci_equalizer.h +++ b/gr-atsc/src/lib/atsci_equalizer.h @@ -23,12 +23,13 @@ #ifndef _ATSC_EQUALIZER_H_ #define _ATSC_EQUALIZER_H_ +#include <atsc_api.h> #include <atsci_syminfo.h> /*! * \brief abstract base class for ATSC equalizer */ -class atsci_equalizer { +class ATSC_API atsci_equalizer { private: diff --git a/gr-atsc/src/lib/atsci_equalizer_lms.h b/gr-atsc/src/lib/atsci_equalizer_lms.h index 1626da234b..8a39255c62 100644 --- a/gr-atsc/src/lib/atsci_equalizer_lms.h +++ b/gr-atsc/src/lib/atsci_equalizer_lms.h @@ -23,11 +23,12 @@ #ifndef _ATSC_EQUALIZER_LMS_H_ #define _ATSC_EQUALIZER_LMS_H_ +#include <atsc_api.h> #include <atsci_equalizer.h> #include <vector> #include <stdio.h> -class atsci_equalizer_lms : public atsci_equalizer +class ATSC_API atsci_equalizer_lms : public atsci_equalizer { public: atsci_equalizer_lms (); diff --git a/gr-atsc/src/lib/atsci_equalizer_lms2.h b/gr-atsc/src/lib/atsci_equalizer_lms2.h index 45b25b73ff..7c60fc1745 100644 --- a/gr-atsc/src/lib/atsci_equalizer_lms2.h +++ b/gr-atsc/src/lib/atsci_equalizer_lms2.h @@ -23,11 +23,12 @@ #ifndef _ATSC_EQUALIZER_LMS2_H_ #define _ATSC_EQUALIZER_LMS2_H_ +#include <atsc_api.h> #include <atsci_equalizer.h> #include <vector> #include <stdio.h> -class atsci_equalizer_lms2 : public atsci_equalizer +class ATSC_API atsci_equalizer_lms2 : public atsci_equalizer { public: atsci_equalizer_lms2 (); diff --git a/gr-atsc/src/lib/atsci_equalizer_nop.h b/gr-atsc/src/lib/atsci_equalizer_nop.h index 399f2da468..6d842601f6 100644 --- a/gr-atsc/src/lib/atsci_equalizer_nop.h +++ b/gr-atsc/src/lib/atsci_equalizer_nop.h @@ -23,9 +23,10 @@ #ifndef _ATSC_EQUALIZER_NOP_H_ #define _ATSC_EQUALIZER_NOP_H_ +#include <atsc_api.h> #include <atsci_equalizer.h> -class atsci_equalizer_nop : public atsci_equalizer +class ATSC_API atsci_equalizer_nop : public atsci_equalizer { private: float scale (float input) { return input; } diff --git a/gr-atsc/src/lib/atsci_exp2_lp.h b/gr-atsc/src/lib/atsci_exp2_lp.h index cf66843c2d..12d08fa6d9 100644 --- a/gr-atsc/src/lib/atsci_exp2_lp.h +++ b/gr-atsc/src/lib/atsci_exp2_lp.h @@ -23,9 +23,10 @@ #ifndef _ATSC_EXP2_LP_H_ #define _ATSC_EXP2_LP_H_ +#include <atsc_api.h> #include <gr_fir_builder.h> -class atsci_exp2_lp : public gr_fir_builder +class ATSC_API atsci_exp2_lp : public gr_fir_builder { public: virtual std::vector<float> taps (double sampling_freq); diff --git a/gr-atsc/src/lib/atsci_fake_single_viterbi.h b/gr-atsc/src/lib/atsci_fake_single_viterbi.h index 1318256ecc..b4cb6e3b36 100644 --- a/gr-atsc/src/lib/atsci_fake_single_viterbi.h +++ b/gr-atsc/src/lib/atsci_fake_single_viterbi.h @@ -23,10 +23,12 @@ #ifndef _ATSCFAKESINGLEVITERBI_H_ #define _ATSCFAKESINGLEVITERBI_H_ +#include <atsc_api.h> + /*! * \brief single channel viterbi decoder */ -class atsci_fake_single_viterbi +class ATSC_API atsci_fake_single_viterbi { public: diff --git a/gr-atsc/src/lib/atsci_fs_checker.h b/gr-atsc/src/lib/atsci_fs_checker.h index 76b7549040..cdcd541e89 100644 --- a/gr-atsc/src/lib/atsci_fs_checker.h +++ b/gr-atsc/src/lib/atsci_fs_checker.h @@ -22,6 +22,7 @@ #ifndef _ATSC_FS_CHECKER_H_ #define _ATSC_FS_CHECKER_H_ +#include <atsc_api.h> #include <atsci_syminfo.h> /*! @@ -47,7 +48,7 @@ * occur every 832 samples assuming everything is working. */ -class atsci_fs_checker { +class ATSC_API atsci_fs_checker { public: diff --git a/gr-atsc/src/lib/atsci_fs_checker_naive.h b/gr-atsc/src/lib/atsci_fs_checker_naive.h index 9518204926..3ef507111f 100644 --- a/gr-atsc/src/lib/atsci_fs_checker_naive.h +++ b/gr-atsc/src/lib/atsci_fs_checker_naive.h @@ -23,12 +23,13 @@ #ifndef _ATSC_FS_CHECKER_NAIVE_H_ #define _ATSC_FS_CHECKER_NAIVE_H_ +#include <atsc_api.h> #include <atsci_fs_checker.h> /*! * \brief Naive concrete implementation of field sync checker */ -class atsci_fs_checker_naive : public atsci_fs_checker { +class ATSC_API atsci_fs_checker_naive : public atsci_fs_checker { private: static const int SRSIZE = 1024; // must be power of two diff --git a/gr-atsc/src/lib/atsci_fs_correlator.h b/gr-atsc/src/lib/atsci_fs_correlator.h index f7915364a9..a6db7f5189 100644 --- a/gr-atsc/src/lib/atsci_fs_correlator.h +++ b/gr-atsc/src/lib/atsci_fs_correlator.h @@ -22,6 +22,8 @@ #ifndef _ATSC_FS_CORRELATOR_H_ #define _ATSC_FS_CORRELATOR_H_ +#include <atsc_api.h> + /*! * \brief abstract base class for ATSC field sync correlator * @@ -42,7 +44,7 @@ * occur every 832 samples assuming everything is working. */ -class atsci_fs_correlator { +class ATSC_API atsci_fs_correlator { public: diff --git a/gr-atsc/src/lib/atsci_fs_correlator_naive.h b/gr-atsc/src/lib/atsci_fs_correlator_naive.h index c05cff0f7c..92e3f7499a 100644 --- a/gr-atsc/src/lib/atsci_fs_correlator_naive.h +++ b/gr-atsc/src/lib/atsci_fs_correlator_naive.h @@ -23,12 +23,13 @@ #ifndef _ATSC_FS_CORRELATOR_NAIVE_H_ #define _ATSC_FS_CORRELATOR_NAIVE_H_ +#include <atsc_api.h> #include <atsci_fs_correlator.h> /*! * \brief Naive concrete implementation of field sync correlator */ -class atsci_fs_correlator_naive : public atsci_fs_correlator { +class ATSC_API atsci_fs_correlator_naive : public atsci_fs_correlator { private: static const int SRSIZE = 1024; // must be power of two diff --git a/gr-atsc/src/lib/atsci_pnXXX.h b/gr-atsc/src/lib/atsci_pnXXX.h index 0e09ae8317..58cb2d02db 100644 --- a/gr-atsc/src/lib/atsci_pnXXX.h +++ b/gr-atsc/src/lib/atsci_pnXXX.h @@ -20,5 +20,7 @@ * Boston, MA 02110-1301, USA. */ -extern const unsigned char atsc_pn511[]; -extern const unsigned char atsc_pn63[]; +#include <atsc_api.h> + +ATSC_API extern const unsigned char atsc_pn511[]; +ATSC_API extern const unsigned char atsc_pn63[]; diff --git a/gr-atsc/src/lib/atsci_randomizer.h b/gr-atsc/src/lib/atsci_randomizer.h index 36025d10b8..30c3235bb0 100644 --- a/gr-atsc/src/lib/atsci_randomizer.h +++ b/gr-atsc/src/lib/atsci_randomizer.h @@ -23,6 +23,7 @@ #ifndef _ATSC_RANDOMIZER_H_ #define _ATSC_RANDOMIZER_H_ +#include <atsc_api.h> #include <atsc_types.h> /*! @@ -32,7 +33,7 @@ * See figure D4 on page 54. */ -class atsci_randomizer { +class ATSC_API atsci_randomizer { friend class qa_atsci_randomizer; public: diff --git a/gr-atsc/src/lib/atsci_reed_solomon.h b/gr-atsc/src/lib/atsci_reed_solomon.h index c9cdca94b4..6f53c77cab 100644 --- a/gr-atsc/src/lib/atsci_reed_solomon.h +++ b/gr-atsc/src/lib/atsci_reed_solomon.h @@ -23,6 +23,7 @@ #ifndef _ATSC_REED_SOLOMON_H_ #define _ATSC_REED_SOLOMON_H_ +#include <atsc_api.h> #include <atsc_types.h> /*! @@ -32,7 +33,7 @@ * See figure D5 on page 55. */ -class atsci_reed_solomon { +class ATSC_API atsci_reed_solomon { public: atsci_reed_solomon(); diff --git a/gr-atsc/src/lib/atsci_root_raised_cosine.h b/gr-atsc/src/lib/atsci_root_raised_cosine.h index cb2798ae50..12870faba7 100644 --- a/gr-atsc/src/lib/atsci_root_raised_cosine.h +++ b/gr-atsc/src/lib/atsci_root_raised_cosine.h @@ -22,9 +22,10 @@ #ifndef _ATSC_RRC_H_ #define _ATSC_RRC_H_ +#include <atsc_api.h> #include <gr_fir_builder.h> -class atsc_root_raised_cosine : public gr_fir_builder +class ATSC_API atsc_root_raised_cosine : public gr_fir_builder { public: virtual std::vector<float> taps (double sampling_freq); diff --git a/gr-atsc/src/lib/atsci_root_raised_cosine_bandpass.h b/gr-atsc/src/lib/atsci_root_raised_cosine_bandpass.h index 00f609929d..98329ab533 100644 --- a/gr-atsc/src/lib/atsci_root_raised_cosine_bandpass.h +++ b/gr-atsc/src/lib/atsci_root_raised_cosine_bandpass.h @@ -22,9 +22,10 @@ #ifndef _ATSC_RRC_BANDPASS_H_ #define _ATSC_RRC_BANDPASS_H_ +#include <atsc_api.h> #include <atsci_root_raised_cosine.h> -class atsc_root_raised_cosine_bandpass : public atsc_root_raised_cosine +class ATSC_API atsc_root_raised_cosine_bandpass : public atsc_root_raised_cosine { public: atsc_root_raised_cosine_bandpass (double center_freq) : _center_freq (center_freq) {} diff --git a/gr-atsc/src/lib/atsci_single_viterbi.h b/gr-atsc/src/lib/atsci_single_viterbi.h index a722a4aafe..cc752cb3a4 100644 --- a/gr-atsc/src/lib/atsci_single_viterbi.h +++ b/gr-atsc/src/lib/atsci_single_viterbi.h @@ -23,10 +23,12 @@ #ifndef _ATSCSINGLEVITERBI_H_ #define _ATSCSINGLEVITERBI_H_ +#include <atsc_api.h> + /*! * \brief single channel viterbi decoder */ -class atsci_single_viterbi +class ATSC_API atsci_single_viterbi { public: diff --git a/gr-atsc/src/lib/atsci_slicer_agc.h b/gr-atsc/src/lib/atsci_slicer_agc.h index 2e7d3be7a7..520fec44bf 100644 --- a/gr-atsc/src/lib/atsci_slicer_agc.h +++ b/gr-atsc/src/lib/atsci_slicer_agc.h @@ -23,6 +23,7 @@ #ifndef _ATSC_SLICER_AGC_H_ #define _ATSC_SLICER_AGC_H_ +#include <atsc_api.h> #include <math.h> #include <gr_single_pole_iir.h> @@ -32,7 +33,7 @@ * Given perfect data, output values will be +/- {7, 5, 3, 1} */ -class atsci_slicer_agc { +class ATSC_API atsci_slicer_agc { public: atsci_slicer_agc () : _gain(1), dc(0.0025) {}; diff --git a/gr-atsc/src/lib/atsci_sliding_correlator.h b/gr-atsc/src/lib/atsci_sliding_correlator.h index c01bc9a20d..64834a4e20 100644 --- a/gr-atsc/src/lib/atsci_sliding_correlator.h +++ b/gr-atsc/src/lib/atsci_sliding_correlator.h @@ -22,15 +22,17 @@ #ifndef _ATSC_SLIDING_CORRELATOR_H_ #define _ATSC_SLIDING_CORRELATOR_H_ +#include <atsc_api.h> #include <string.h> -extern const unsigned char atsc_pn511[511]; -extern const unsigned char atsc_pn63[63]; +#include <atsci_pnXXX.h> +//extern const unsigned char atsc_pn511[511]; +//extern const unsigned char atsc_pn63[63]; /*! * \brief look for the PN 511 field sync pattern */ -class atsci_sliding_correlator { +class ATSC_API atsci_sliding_correlator { public: atsci_sliding_correlator (); diff --git a/gr-atsc/src/lib/atsci_sssr.h b/gr-atsc/src/lib/atsci_sssr.h index 4555dc23ce..1dee54c1dd 100644 --- a/gr-atsc/src/lib/atsci_sssr.h +++ b/gr-atsc/src/lib/atsci_sssr.h @@ -27,6 +27,7 @@ #ifndef _ATSC_SSSR_H_ #define _ATSC_SSSR_H_ +#include <atsc_api.h> #include <atsc_consts.h> #include <gri_mmse_fir_interpolator.h> #include <gr_single_pole_iir.h> @@ -43,7 +44,7 @@ namespace sssr { // ---------------------------------------------------------------- //! digital correlator for 1001 and 0110 patterns - class digital_correlator { + class ATSC_API digital_correlator { int d_sr; // 4 bit shift register public: @@ -70,7 +71,7 @@ namespace sssr { // ---------------------------------------------------------------- //! segment sync integrator - class seg_sync_integrator { + class ATSC_API seg_sync_integrator { signed char d_integrator[ATSC_DATA_SEGMENT_LENGTH]; public: @@ -94,7 +95,7 @@ namespace sssr { // ---------------------------------------------------------------- //! quad filter (used to compute timing error) - class quad_filter { + class ATSC_API quad_filter { sample_t d_delay[4]; public: @@ -128,7 +129,7 @@ namespace sssr { * by Wayne E. Bretl of Zenith, pgs 41-45. */ -class atsci_sssr { +class ATSC_API atsci_sssr { sssr::digital_correlator d_correlator; sssr::seg_sync_integrator d_integrator; sssr::quad_filter d_quad_filter; @@ -193,7 +194,7 @@ public: * \brief interpolator control for segment and symbol sync recovery */ -class atsci_interpolator { +class ATSC_API atsci_interpolator { gri_mmse_fir_interpolator d_interp; gr_single_pole_iir<float,float,float> d_loop; // ``VCO'' loop filter double d_nominal_ratio_of_rx_clock_to_symbol_freq; // FREQ diff --git a/gr-atsc/src/lib/atsci_trellis_encoder.h b/gr-atsc/src/lib/atsci_trellis_encoder.h index dc5c16d76a..53be3fc22b 100644 --- a/gr-atsc/src/lib/atsci_trellis_encoder.h +++ b/gr-atsc/src/lib/atsci_trellis_encoder.h @@ -23,6 +23,7 @@ #ifndef _ATSC_TRELLIS_ENCODER_H_ #define _ATSC_TRELLIS_ENCODER_H_ +#include <atsc_api.h> #include <atsci_basic_trellis_encoder.h> #include <atsc_types.h> @@ -30,7 +31,7 @@ * \brief fancy, schmancy 12-way interleaved trellis encoder for ATSC */ -class atsci_trellis_encoder { +class ATSC_API atsci_trellis_encoder { public: static const int NCODERS = 12; diff --git a/gr-atsc/src/lib/atsci_viterbi_decoder.h b/gr-atsc/src/lib/atsci_viterbi_decoder.h index 22e3c18923..1243feeb5a 100644 --- a/gr-atsc/src/lib/atsci_viterbi_decoder.h +++ b/gr-atsc/src/lib/atsci_viterbi_decoder.h @@ -25,6 +25,7 @@ #define USE_SIMPLE_SLICER 0 +#include <atsc_api.h> #include <atsc_types.h> #include <interleaver_fifo.h> @@ -40,7 +41,7 @@ typedef atsci_single_viterbi single_viterbi_t; * \brief fancy, schmancy 12-way interleaved viterbi decoder for ATSC */ -class atsci_viterbi_decoder { +class ATSC_API atsci_viterbi_decoder { public: static const int NCODERS = 12; diff --git a/gr-atsc/src/lib/atsci_vsbtx_lp.h b/gr-atsc/src/lib/atsci_vsbtx_lp.h index 7193c87d09..d3bb0c9d1f 100644 --- a/gr-atsc/src/lib/atsci_vsbtx_lp.h +++ b/gr-atsc/src/lib/atsci_vsbtx_lp.h @@ -23,9 +23,10 @@ #ifndef _ATSC_VSBTX_LP_H_ #define _ATSC_VSBTX_LP_H_ +#include <atsc_api.h> #include <gr_fir_builder.h> -class atsc_vsbtx_lp : public gr_fir_builder +class ATSC_API atsc_vsbtx_lp : public gr_fir_builder { public: virtual std::vector<float> taps (double sampling_freq); diff --git a/gr-atsc/src/lib/create_atsci_equalizer.h b/gr-atsc/src/lib/create_atsci_equalizer.h index 57c167f592..fd26237d88 100644 --- a/gr-atsc/src/lib/create_atsci_equalizer.h +++ b/gr-atsc/src/lib/create_atsci_equalizer.h @@ -22,10 +22,12 @@ #ifndef _CREATE_ATSC_EQUALIZER_H_ #define _CREATE_ATSC_EQUALIZER_H_ +#include <atsc_api.h> + class atsci_equalizer; -atsci_equalizer *create_atsci_equalizer_nop (); -atsci_equalizer *create_atsci_equalizer_lms (); -atsci_equalizer *create_atsci_equalizer_lms2 (); +ATSC_API atsci_equalizer *create_atsci_equalizer_nop (); +ATSC_API atsci_equalizer *create_atsci_equalizer_lms (); +ATSC_API atsci_equalizer *create_atsci_equalizer_lms2 (); #endif /* _CREATE_ATSC_EQUALIZER_H_ */ diff --git a/gr-atsc/src/lib/create_atsci_fs_checker.h b/gr-atsc/src/lib/create_atsci_fs_checker.h index d087450524..23451757ab 100644 --- a/gr-atsc/src/lib/create_atsci_fs_checker.h +++ b/gr-atsc/src/lib/create_atsci_fs_checker.h @@ -23,12 +23,14 @@ #ifndef _CREATE_ATSC_FS_CHECKER_H_ #define _CREATE_ATSC_FS_CHECKER_H_ +#include <atsc_api.h> + class atsci_fs_checker; /*! * Factory that creates appropriate atsci_fs_checker */ -atsci_fs_checker *create_atsci_fs_checker (); +ATSC_API atsci_fs_checker *create_atsci_fs_checker (); #endif /* _CREATE_ATSC_FS_CHECKER_H_ */ diff --git a/gr-atsc/src/lib/create_atsci_fs_correlator.h b/gr-atsc/src/lib/create_atsci_fs_correlator.h index 9162be888d..7b663fd565 100644 --- a/gr-atsc/src/lib/create_atsci_fs_correlator.h +++ b/gr-atsc/src/lib/create_atsci_fs_correlator.h @@ -23,12 +23,14 @@ #ifndef _CREATE_ATSC_FS_CORRELATOR_H_ #define _CREATE_ATSC_FS_CORRELATOR_H_ +#include <atsc_api.h> + class atsci_fs_correlator; /*! * Factory that creates appropriate atsci_fs_correlator */ -atsci_fs_correlator *create_atsci_fs_correlator (); +ATSC_API atsci_fs_correlator *create_atsci_fs_correlator (); #endif /* _CREATE_ATSC_FS_CORRELATOR_H_ */ diff --git a/gr-atsc/src/lib/interleaver_fifo.h b/gr-atsc/src/lib/interleaver_fifo.h index 98764af49e..6d1a445806 100644 --- a/gr-atsc/src/lib/interleaver_fifo.h +++ b/gr-atsc/src/lib/interleaver_fifo.h @@ -26,7 +26,6 @@ #include <interleaver_fifo.h> #include <string.h> -#include <strings.h> /*! * \brief template class for interleaver fifo diff --git a/gr-atsc/src/lib/qa_atsci_fake_single_viterbi.cc b/gr-atsc/src/lib/qa_atsci_fake_single_viterbi.cc index f50f3b6b8c..1f5ba6b591 100644 --- a/gr-atsc/src/lib/qa_atsci_fake_single_viterbi.cc +++ b/gr-atsc/src/lib/qa_atsci_fake_single_viterbi.cc @@ -70,7 +70,7 @@ qa_atsci_fake_single_viterbi::noise () void qa_atsci_fake_single_viterbi::t0 () { - int blocklen = NN; + static const int blocklen = NN; unsigned char in[blocklen]; unsigned char enc[blocklen]; unsigned char out[blocklen]; diff --git a/gr-atsc/src/lib/qa_atsci_single_viterbi.cc b/gr-atsc/src/lib/qa_atsci_single_viterbi.cc index d7c29097e9..dac1e94c33 100644 --- a/gr-atsc/src/lib/qa_atsci_single_viterbi.cc +++ b/gr-atsc/src/lib/qa_atsci_single_viterbi.cc @@ -67,7 +67,7 @@ qa_atsci_single_viterbi::noise () void qa_atsci_single_viterbi::t0 () { - int blocklen = NN; + static const int blocklen = NN; unsigned char in[blocklen]; unsigned char enc[blocklen]; unsigned char out[blocklen]; @@ -142,7 +142,7 @@ qa_atsci_single_viterbi::t0 () void qa_atsci_single_viterbi::t1 () { - int blocklen = NN; + static const int blocklen = NN; unsigned char in[blocklen]; unsigned char enc[blocklen]; unsigned char out[blocklen]; diff --git a/gr-howto-write-a-block-cmake/CMakeLists.txt b/gr-howto-write-a-block-cmake/CMakeLists.txt new file mode 100644 index 0000000000..9de0614144 --- /dev/null +++ b/gr-howto-write-a-block-cmake/CMakeLists.txt @@ -0,0 +1,103 @@ +# Copyright 2011 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. + + +######################################################################## +# Project setup +######################################################################## +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(gr-howto-write-a-block CXX) +ENABLE_TESTING() + +#select the release build type by default to get optimization flags +IF(NOT CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE "Release") + MESSAGE(STATUS "Build type not specified: defaulting to release.") +ENDIF(NOT CMAKE_BUILD_TYPE) +SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") + +LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) + +######################################################################## +# Compiler specific setup +######################################################################## +IF(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + #http://gcc.gnu.org/wiki/Visibility + ADD_DEFINITIONS(-fvisibility=hidden) +ENDIF() + +######################################################################## +# Find boost +######################################################################## +IF(UNIX AND EXISTS "/usr/lib64") + LIST(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix +ENDIF(UNIX AND EXISTS "/usr/lib64") +SET(Boost_ADDITIONAL_VERSIONS + "1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39" + "1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44" + "1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49" + "1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54" + "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59" + "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" + "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" +) +FIND_PACKAGE(Boost "1.35") + +IF(NOT Boost_FOUND) + MESSAGE(FATAL_ERROR "Boost required to compile howto") +ENDIF() + +######################################################################## +# Find gnuradio build dependencies +######################################################################## +FIND_PACKAGE(Gruel) +FIND_PACKAGE(GnuradioCore) + +IF(NOT GRUEL_FOUND) + MESSAGE(FATAL_ERROR "Gruel required to compile howto") +ENDIF() + +IF(NOT GNURADIO_CORE_FOUND) + MESSAGE(FATAL_ERROR "GnuRadio Core required to compile howto") +ENDIF() + +######################################################################## +# Setup the include and linker paths +######################################################################## +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/lib + ${Boost_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${GNURADIO_CORE_INCLUDE_DIRS} +) + +LINK_DIRECTORIES( + ${Boost_LIBRARY_DIRS} + ${GRUEL_LIBRARY_DIRS} + ${GNURADIO_CORE_LIBRARY_DIRS} +) + +######################################################################## +# Add subdirectories +######################################################################## +ADD_SUBDIRECTORY(lib) +ADD_SUBDIRECTORY(swig) +ADD_SUBDIRECTORY(python) +ADD_SUBDIRECTORY(grc) +ADD_SUBDIRECTORY(apps) diff --git a/gr-howto-write-a-block-cmake/apps/CMakeLists.txt b/gr-howto-write-a-block-cmake/apps/CMakeLists.txt new file mode 100644 index 0000000000..e89cae26ba --- /dev/null +++ b/gr-howto-write-a-block-cmake/apps/CMakeLists.txt @@ -0,0 +1,26 @@ +# Copyright 2011 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. + +INCLUDE(GrPython) + +GR_PYTHON_INSTALL( + PROGRAMS + howto_square.py + DESTINATION bin +) diff --git a/gr-howto-write-a-block-cmake/apps/howto_square.grc b/gr-howto-write-a-block-cmake/apps/howto_square.grc new file mode 100644 index 0000000000..a8563698b8 --- /dev/null +++ b/gr-howto-write-a-block-cmake/apps/howto_square.grc @@ -0,0 +1,325 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Thu Nov 12 11:26:07 2009</timestamp> + <block> + <key>options</key> + <param> + <key>id</key> + <value>howto_square</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value></value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value></value> + </param> + <param> + <key>window_size</key> + <value>1280, 1024</value> + </param> + <param> + <key>generate_options</key> + <value>wx_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>prompt</value> + </param> + <param> + <key>run</key> + <value>True</value> + </param> + <param> + <key>realtime_scheduling</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(10, 10)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>samp_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>10e3</value> + </param> + <param> + <key>_coordinate</key> + <value>(10, 170)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_scopesink2</key> + <param> + <key>id</key> + <value>sink</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>title</key> + <value>Input</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>v_scale</key> + <value>20</value> + </param> + <param> + <key>v_offset</key> + <value>0</value> + </param> + <param> + <key>t_scale</key> + <value>0.002</value> + </param> + <param> + <key>ac_couple</key> + <value>False</value> + </param> + <param> + <key>xy_mode</key> + <value>False</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(691, 222)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>howto_square_ff</key> + <param> + <key>id</key> + <value>sqr</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(709, 344)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_throttle</key> + <param> + <key>id</key> + <value>thr</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>samples_per_second</key> + <value>samp_rate</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(497, 340)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_vector_source_x</key> + <param> + <key>id</key> + <value>src</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>vector</key> + <value>[float(n)-50 for n in range(100)]</value> + </param> + <param> + <key>repeat</key> + <value>True</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(246, 332)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_scopesink2</key> + <param> + <key>id</key> + <value>sink2</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>title</key> + <value>Output</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>v_scale</key> + <value>0</value> + </param> + <param> + <key>v_offset</key> + <value>0</value> + </param> + <param> + <key>t_scale</key> + <value>0.002</value> + </param> + <param> + <key>ac_couple</key> + <value>False</value> + </param> + <param> + <key>xy_mode</key> + <value>False</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(869, 324)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>thr</source_block_id> + <sink_block_id>sqr</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>src</source_block_id> + <sink_block_id>thr</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>thr</source_block_id> + <sink_block_id>sink</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>sqr</source_block_id> + <sink_block_id>sink2</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gr-howto-write-a-block-cmake/apps/howto_square.py b/gr-howto-write-a-block-cmake/apps/howto_square.py new file mode 100755 index 0000000000..f14e28325d --- /dev/null +++ b/gr-howto-write-a-block-cmake/apps/howto_square.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: Howto Square +# Generated: Thu Nov 12 11:26:07 2009 +################################################## + +import howto +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio.eng_option import eng_option +from gnuradio.gr import firdes +from gnuradio.wxgui import scopesink2 +from grc_gnuradio import wxgui as grc_wxgui +from optparse import OptionParser +import wx + +class howto_square(grc_wxgui.top_block_gui): + + def __init__(self): + grc_wxgui.top_block_gui.__init__(self, title="Howto Square") + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 10e3 + + ################################################## + # Blocks + ################################################## + self.sink = scopesink2.scope_sink_f( + self.GetWin(), + title="Input", + sample_rate=samp_rate, + v_scale=20, + v_offset=0, + t_scale=0.002, + ac_couple=False, + xy_mode=False, + num_inputs=1, + ) + self.Add(self.sink.win) + self.sink2 = scopesink2.scope_sink_f( + self.GetWin(), + title="Output", + sample_rate=samp_rate, + v_scale=0, + v_offset=0, + t_scale=0.002, + ac_couple=False, + xy_mode=False, + num_inputs=1, + ) + self.Add(self.sink2.win) + self.sqr = howto.square_ff() + self.src = gr.vector_source_f(([float(n)-50 for n in range(100)]), True, 1) + self.thr = gr.throttle(gr.sizeof_float*1, samp_rate) + + ################################################## + # Connections + ################################################## + self.connect((self.thr, 0), (self.sqr, 0)) + self.connect((self.src, 0), (self.thr, 0)) + self.connect((self.thr, 0), (self.sink, 0)) + self.connect((self.sqr, 0), (self.sink2, 0)) + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.sink.set_sample_rate(self.samp_rate) + self.sink2.set_sample_rate(self.samp_rate) + +if __name__ == '__main__': + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + (options, args) = parser.parse_args() + tb = howto_square() + tb.Run(True) + diff --git a/gr-howto-write-a-block-cmake/cmake/Modules/CMakeParseArgumentsCopy.cmake b/gr-howto-write-a-block-cmake/cmake/Modules/CMakeParseArgumentsCopy.cmake new file mode 100644 index 0000000000..7ce4c49ae5 --- /dev/null +++ b/gr-howto-write-a-block-cmake/cmake/Modules/CMakeParseArgumentsCopy.cmake @@ -0,0 +1,138 @@ +# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...) +# +# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for +# parsing the arguments given to that macro or function. +# It processes the arguments and defines a set of variables which hold the +# values of the respective options. +# +# The <options> argument contains all options for the respective macro, +# i.e. keywords which can be used when calling the macro without any value +# following, like e.g. the OPTIONAL keyword of the install() command. +# +# The <one_value_keywords> argument contains all keywords for this macro +# which are followed by one value, like e.g. DESTINATION keyword of the +# install() command. +# +# The <multi_value_keywords> argument contains all keywords for this macro +# which can be followed by more than one value, like e.g. the TARGETS or +# FILES keywords of the install() command. +# +# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the +# keywords listed in <options>, <one_value_keywords> and +# <multi_value_keywords> a variable composed of the given <prefix> +# followed by "_" and the name of the respective keyword. +# These variables will then hold the respective value from the argument list. +# For the <options> keywords this will be TRUE or FALSE. +# +# All remaining arguments are collected in a variable +# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether +# your macro was called with unrecognized parameters. +# +# As an example here a my_install() macro, which takes similar arguments as the +# real install() command: +# +# function(MY_INSTALL) +# set(options OPTIONAL FAST) +# set(oneValueArgs DESTINATION RENAME) +# set(multiValueArgs TARGETS CONFIGURATIONS) +# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) +# ... +# +# Assume my_install() has been called like this: +# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) +# +# After the cmake_parse_arguments() call the macro will have set the following +# variables: +# MY_INSTALL_OPTIONAL = TRUE +# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() +# MY_INSTALL_DESTINATION = "bin" +# MY_INSTALL_RENAME = "" (was not used) +# MY_INSTALL_TARGETS = "foo;bar" +# MY_INSTALL_CONFIGURATIONS = "" (was not used) +# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" +# +# You can the continue and process these variables. +# +# Keywords terminate lists of values, e.g. if directly after a one_value_keyword +# another recognized keyword follows, this is interpreted as the beginning of +# the new option. +# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in +# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would +# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. + +#============================================================================= +# Copyright 2010 Alexander Neundorf <neundorf@kde.org> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + + +if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) + return() +endif() +set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) + + +function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) + # first set all result variables to empty/FALSE + foreach(arg_name ${_singleArgNames} ${_multiArgNames}) + set(${prefix}_${arg_name}) + endforeach(arg_name) + + foreach(option ${_optionNames}) + set(${prefix}_${option} FALSE) + endforeach(option) + + set(${prefix}_UNPARSED_ARGUMENTS) + + set(insideValues FALSE) + set(currentArgName) + + # now iterate over all arguments and fill the result variables + foreach(currentArg ${ARGN}) + list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword + list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword + list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword + + if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) + if(insideValues) + if("${insideValues}" STREQUAL "SINGLE") + set(${prefix}_${currentArgName} ${currentArg}) + set(insideValues FALSE) + elseif("${insideValues}" STREQUAL "MULTI") + list(APPEND ${prefix}_${currentArgName} ${currentArg}) + endif() + else(insideValues) + list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) + endif(insideValues) + else() + if(NOT ${optionIndex} EQUAL -1) + set(${prefix}_${currentArg} TRUE) + set(insideValues FALSE) + elseif(NOT ${singleArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "SINGLE") + elseif(NOT ${multiArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "MULTI") + endif() + endif() + + endforeach(currentArg) + + # propagate the result variables to the caller: + foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) + set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) + endforeach(arg_name) + set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) + +endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) diff --git a/gr-howto-write-a-block-cmake/cmake/Modules/FindGnuradioCore.cmake b/gr-howto-write-a-block-cmake/cmake/Modules/FindGnuradioCore.cmake new file mode 100644 index 0000000000..f76364acfd --- /dev/null +++ b/gr-howto-write-a-block-cmake/cmake/Modules/FindGnuradioCore.cmake @@ -0,0 +1,26 @@ +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(GNURADIO_CORE gnuradio-core) +IF(NOT GNURADIO_CORE_FOUND) + +FIND_PATH( + GNURADIO_CORE_INCLUDE_DIRS + NAMES gr_random.h + HINTS $ENV{GNURADIO_CORE_DIR}/include/gnuradio + PATHS /usr/local/include/gnuradio + /usr/include/gnuradio +) + +FIND_LIBRARY( + GNURADIO_CORE_LIBRARIES + NAMES gnuradio-core + HINTS $ENV{GNURADIO_CORE_DIR}/lib + PATHS /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 +) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_CORE DEFAULT_MSG GNURADIO_CORE_LIBRARIES GNURADIO_CORE_INCLUDE_DIRS) + +ENDIF(NOT GNURADIO_CORE_FOUND) diff --git a/gr-howto-write-a-block-cmake/cmake/Modules/FindGruel.cmake b/gr-howto-write-a-block-cmake/cmake/Modules/FindGruel.cmake new file mode 100644 index 0000000000..c142c905ef --- /dev/null +++ b/gr-howto-write-a-block-cmake/cmake/Modules/FindGruel.cmake @@ -0,0 +1,26 @@ +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(GRUEL gnuradio-core) +IF(NOT GRUEL_FOUND) + +FIND_PATH( + GRUEL_INCLUDE_DIRS + NAMES gruel/attributes.h + HINTS $ENV{GRUEL_DIR}/include + PATHS /usr/local/include + /usr/include +) + +FIND_LIBRARY( + GRUEL_LIBRARIES + NAMES gruel + HINTS $ENV{GRUEL_DIR}/lib + PATHS /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 +) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GRUEL DEFAULT_MSG GRUEL_LIBRARIES GRUEL_INCLUDE_DIRS) + +ENDIF(NOT GRUEL_FOUND) diff --git a/gr-howto-write-a-block-cmake/cmake/Modules/GrPlatform.cmake b/gr-howto-write-a-block-cmake/cmake/Modules/GrPlatform.cmake new file mode 100644 index 0000000000..85f3186188 --- /dev/null +++ b/gr-howto-write-a-block-cmake/cmake/Modules/GrPlatform.cmake @@ -0,0 +1,46 @@ +# Copyright 2011 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. + +IF(DEFINED __INCLUDED_GR_PLATFORM_CMAKE) + RETURN() +ENDIF() +SET(__INCLUDED_GR_PLATFORM_CMAKE TRUE) + +######################################################################## +# Setup additional defines for OS types +######################################################################## +IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + SET(LINUX TRUE) +ENDIF() + +IF(LINUX AND EXISTS "/etc/debian_version") + SET(DEBIAN TRUE) +ENDIF() + +IF(LINUX AND EXISTS "/etc/redhat-release") + SET(REDHAT TRUE) +ENDIF() + +######################################################################## +# when the library suffix should be 64 (applies to redhat linux family) +######################################################################## +IF(NOT DEFINED LIB_SUFFIX AND REDHAT AND CMAKE_SYSTEM_PROCESSOR MATCHES "64$") + SET(LIB_SUFFIX 64) +ENDIF() +SET(LIB_SUFFIX ${LIB_SUFFIX} CACHE STRING "lib directory suffix") diff --git a/gr-howto-write-a-block-cmake/cmake/Modules/GrPython.cmake b/gr-howto-write-a-block-cmake/cmake/Modules/GrPython.cmake new file mode 100644 index 0000000000..f54dbc9ba7 --- /dev/null +++ b/gr-howto-write-a-block-cmake/cmake/Modules/GrPython.cmake @@ -0,0 +1,177 @@ +# Copyright 2010-2011 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. + +IF(DEFINED __INCLUDED_GR_PYTHON_CMAKE) + RETURN() +ENDIF() +SET(__INCLUDED_GR_PYTHON_CMAKE TRUE) + +######################################################################## +# Setup the python interpreter: +# This allows the user to specify a specific interpreter, +# or finds the interpreter via the built-in cmake module. +######################################################################## +#this allows the user to override PYTHON_EXECUTABLE +IF(PYTHON_EXECUTABLE) + + SET(PYTHONINTERP_FOUND TRUE) + +#otherwise if not set, try to automatically find it +ELSE(PYTHON_EXECUTABLE) + + #use the built-in find script + FIND_PACKAGE(PythonInterp) + + #and if that fails use the find program routine + IF(NOT PYTHONINTERP_FOUND) + FIND_PROGRAM(PYTHON_EXECUTABLE NAMES python python2.7 python2.6 python2.5) + IF(PYTHON_EXECUTABLE) + SET(PYTHONINTERP_FOUND TRUE) + ENDIF(PYTHON_EXECUTABLE) + ENDIF(NOT PYTHONINTERP_FOUND) + +ENDIF(PYTHON_EXECUTABLE) + +#make the path to the executable appear in the cmake gui +SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter") + +######################################################################## +# Check for the existence of a python module: +# - desc a string description of the check +# - mod the name of the module to import +# - cmd an additional command to run +# - have the result variable to set +######################################################################## +MACRO(GR_PYTHON_CHECK_MODULE desc mod cmd have) + MESSAGE(STATUS "") + MESSAGE(STATUS "Python checking for ${desc}") + EXECUTE_PROCESS( + COMMAND ${PYTHON_EXECUTABLE} -c " +######################################### +try: import ${mod} +except: exit(-1) +try: assert ${cmd} +except: exit(-1) +#########################################" + RESULT_VARIABLE ${have} + ) + IF(${have} EQUAL 0) + MESSAGE(STATUS "Python checking for ${desc} - found") + SET(${have} TRUE) + ELSE(${have} EQUAL 0) + MESSAGE(STATUS "Python checking for ${desc} - not found") + SET(${have} FALSE) + ENDIF(${have} EQUAL 0) +ENDMACRO(GR_PYTHON_CHECK_MODULE) + +######################################################################## +# Sets the python installation directory GR_PYTHON_DIR +######################################################################## +EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c " +from distutils import sysconfig +print sysconfig.get_python_lib(plat_specific=True, prefix='') +" OUTPUT_VARIABLE GR_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE +) +FILE(TO_CMAKE_PATH ${GR_PYTHON_DIR} GR_PYTHON_DIR) + +######################################################################## +# Create an always-built target with a unique name +# Usage: GR_UNIQUE_TARGET(<description> <dependencies list>) +######################################################################## +FUNCTION(GR_UNIQUE_TARGET desc) + FILE(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib +unique = hashlib.md5('${reldir}${ARGN}').hexdigest()[:5] +print(re.sub('\\W', '_', '${desc} ${reldir} ' + unique))" + OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE) + ADD_CUSTOM_TARGET(${_target} ALL DEPENDS ${ARGN}) +ENDFUNCTION(GR_UNIQUE_TARGET) + +######################################################################## +# Install python sources (also builds and installs byte-compiled python) +######################################################################## +FUNCTION(GR_PYTHON_INSTALL) + INCLUDE(CMakeParseArgumentsCopy) + CMAKE_PARSE_ARGUMENTS(GR_PYTHON_INSTALL "" "DESTINATION;COMPONENT" "FILES;PROGRAMS" ${ARGN}) + + #################################################################### + IF(GR_PYTHON_INSTALL_FILES) + #################################################################### + INSTALL(${ARGN}) #installs regular python files + + FOREACH(pyfile ${GR_PYTHON_INSTALL_FILES}) + GET_FILENAME_COMPONENT(pyfile_name ${pyfile} NAME) + GET_FILENAME_COMPONENT(pyfile ${pyfile} ABSOLUTE) + STRING(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" pycfile "${pyfile}c") + LIST(APPEND python_install_gen_targets ${pycfile}) + + GET_FILENAME_COMPONENT(pycfile_path ${pycfile} PATH) + FILE(MAKE_DIRECTORY ${pycfile_path}) + + #create a command to generate the byte-compiled pyc file + ADD_CUSTOM_COMMAND( + OUTPUT ${pycfile} DEPENDS ${pyfile} + COMMAND ${PYTHON_EXECUTABLE} -c + \"import py_compile\; py_compile.compile(file='${pyfile}', cfile='${pycfile}', doraise=True)\" + COMMENT "Byte-compiling ${pyfile_name}" + ) + INSTALL(FILES ${pycfile} + DESTINATION ${GR_PYTHON_INSTALL_DESTINATION} + COMPONENT ${GR_PYTHON_INSTALL_COMPONENT} + ) + ENDFOREACH(pyfile) + + #################################################################### + ELSEIF(GR_PYTHON_INSTALL_PROGRAMS) + #################################################################### + FILE(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native) + + FOREACH(pyfile ${GR_PYTHON_INSTALL_PROGRAMS}) + GET_FILENAME_COMPONENT(pyfile_name ${pyfile} NAME) + GET_FILENAME_COMPONENT(pyfile ${pyfile} ABSOLUTE) + STRING(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" pyexefile "${pyfile}.exe") + LIST(APPEND python_install_gen_targets ${pyexefile}) + + GET_FILENAME_COMPONENT(pyexefile_path ${pyexefile} PATH) + FILE(MAKE_DIRECTORY ${pyexefile_path}) + + ADD_CUSTOM_COMMAND( + OUTPUT ${pyexefile} DEPENDS ${pyfile} + COMMAND ${PYTHON_EXECUTABLE} -c + \"open('${pyexefile}', 'w').write('\#!${pyexe_native}\\n'+open('${pyfile}').read())\" + COMMENT "Shebangin ${pyfile_name}" + ) + + #on windows, python files need an extension to execute + GET_FILENAME_COMPONENT(pyfile_ext ${pyfile} EXT) + IF(WIN32 AND NOT pyfile_ext) + SET(pyfile_name "${pyfile_name}.py") + ENDIF() + + INSTALL(PROGRAMS ${pyexefile} RENAME ${pyfile_name} + DESTINATION ${GR_PYTHON_INSTALL_DESTINATION} + COMPONENT ${GR_PYTHON_INSTALL_COMPONENT} + ) + ENDFOREACH(pyfile) + + ENDIF() + + GR_UNIQUE_TARGET("pygen" ${python_install_gen_targets}) + +ENDFUNCTION(GR_PYTHON_INSTALL) diff --git a/gr-howto-write-a-block-cmake/cmake/Modules/GrSwig.cmake b/gr-howto-write-a-block-cmake/cmake/Modules/GrSwig.cmake new file mode 100644 index 0000000000..9fca29a4fc --- /dev/null +++ b/gr-howto-write-a-block-cmake/cmake/Modules/GrSwig.cmake @@ -0,0 +1,90 @@ +# Copyright 2010-2011 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. + +IF(DEFINED __INCLUDED_GR_SWIG_CMAKE) + RETURN() +ENDIF() +SET(__INCLUDED_GR_SWIG_CMAKE TRUE) + +######################################################################## +# Build a swig target for the common gnuradio use case. Usage: +# GR_SWIG_MAKE(target ifile ifile ifile...) +# +# Set the following variables before calling: +# - GR_SWIG_FLAGS +# - GR_SWIG_INCLUDE_DIRS +# - GR_SWIG_LIBRARIES +# - GR_SWIG_SOURCE_DEPS +# - GR_SWIG_TARGET_DEPS +######################################################################## +MACRO(GR_SWIG_MAKE name) + SET(ifiles ${ARGN}) + + INCLUDE_DIRECTORIES(${GR_SWIG_INCLUDE_DIRS}) + SET(SWIG_MODULE_${name}_EXTRA_DEPS ${GR_SWIG_SOURCE_DEPS}) + + FIND_PACKAGE(PythonLibs) + INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS}) + + #setup the swig flags with flags and include directories + SET(CMAKE_SWIG_FLAGS -fvirtual -modern -keyword -w511 -module ${name} ${GR_SWIG_FLAGS}) + FOREACH(dir ${GR_SWIG_INCLUDE_DIRS}) + LIST(APPEND CMAKE_SWIG_FLAGS "-I${dir}") + ENDFOREACH(dir) + + #set the C++ property on the swig .i file so it builds + SET_SOURCE_FILES_PROPERTIES(${ifiles} PROPERTIES CPLUSPLUS ON) + + #setup the actual swig library target to be built + INCLUDE(UseSWIG) + SWIG_ADD_MODULE(${name} python ${ifiles}) + SWIG_LINK_LIBRARIES(${name} ${PYTHON_LIBRARIES} ${GR_SWIG_LIBRARIES}) + IF(GR_SWIG_TARGET_DEPS) + ADD_DEPENDENCIES(${SWIG_MODULE_${name}_REAL_NAME} ${GR_SWIG_TARGET_DEPS}) + ENDIF(GR_SWIG_TARGET_DEPS) + +ENDMACRO(GR_SWIG_MAKE) + +######################################################################## +# Install swig targets generated by GR_SWIG_MAKE. Usage: +# GR_SWIG_INSTALL( +# TARGETS target target target... +# [DESTINATION destination] +# [COMPONENT component] +# ) +######################################################################## +MACRO(GR_SWIG_INSTALL) + + INCLUDE(CMakeParseArgumentsCopy) + CMAKE_PARSE_ARGUMENTS(GR_SWIG_INSTALL "" "DESTINATION;COMPONENT" "TARGETS" ${ARGN}) + + FOREACH(name ${GR_SWIG_INSTALL_TARGETS}) + INSTALL(TARGETS ${SWIG_MODULE_${name}_REAL_NAME} + DESTINATION ${GR_SWIG_INSTALL_DESTINATION} + COMPONENT ${GR_SWIG_INSTALL_COMPONENT} + ) + + INCLUDE(GrPython) + GR_PYTHON_INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}.py + DESTINATION ${GR_SWIG_INSTALL_DESTINATION} + COMPONENT ${GR_SWIG_INSTALL_COMPONENT} + ) + ENDFOREACH(name) + +ENDMACRO(GR_SWIG_INSTALL) diff --git a/gr-howto-write-a-block-cmake/cmake/Modules/GrTest.cmake b/gr-howto-write-a-block-cmake/cmake/Modules/GrTest.cmake new file mode 100644 index 0000000000..e9e2a0c2e2 --- /dev/null +++ b/gr-howto-write-a-block-cmake/cmake/Modules/GrTest.cmake @@ -0,0 +1,133 @@ +# Copyright 2010-2011 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. + +IF(DEFINED __INCLUDED_GR_TEST_CMAKE) + RETURN() +ENDIF() +SET(__INCLUDED_GR_TEST_CMAKE TRUE) + +######################################################################## +# Add a unit test and setup the environment for a unit test. +# Takes the same arguments as the ADD_TEST function. +# +# Before calling set the following variables: +# GR_TEST_TARGET_DEPS - built targets for the library path +# GR_TEST_LIBRARY_DIRS - directories for the library path +# GR_TEST_PYTHON_DIRS - directories for the python path +######################################################################## +FUNCTION(GR_ADD_TEST test_name) + + IF(WIN32) + #Ensure that the build exe also appears in the PATH. + LIST(APPEND GR_TEST_TARGET_DEPS ${ARGN}) + + #In the land of windows, all libraries must be in the PATH. + #Since the dependent libraries are not yet installed, + #we must manually set them in the PATH to run tests. + #The following appends the path of a target dependency. + FOREACH(target ${GR_TEST_TARGET_DEPS}) + GET_TARGET_PROPERTY(location ${target} LOCATION) + IF(location) + GET_FILENAME_COMPONENT(path ${location} PATH) + STRING(REGEX REPLACE "\\$\\(.*\\)" ${CMAKE_BUILD_TYPE} path ${path}) + LIST(APPEND GR_TEST_LIBRARY_DIRS ${path}) + ENDIF(location) + ENDFOREACH(target) + + #SWIG generates the python library files into a subdirectory. + #Therefore, we must append this subdirectory into PYTHONPATH. + #Only do this for the python directories matching the following: + FOREACH(pydir ${GR_TEST_PYTHON_DIRS}) + GET_FILENAME_COMPONENT(name ${pydir} NAME) + IF(name MATCHES "^(swig|lib|src)$") + LIST(APPEND GR_TEST_PYTHON_DIRS ${pydir}/${CMAKE_BUILD_TYPE}) + ENDIF() + ENDFOREACH(pydir) + ENDIF(WIN32) + + FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} srcdir) + FILE(TO_NATIVE_PATH "${GR_TEST_LIBRARY_DIRS}" libpath) #ok to use on dir list? + FILE(TO_NATIVE_PATH "${GR_TEST_PYTHON_DIRS}" pypath) #ok to use on dir list? + + SET(environs "GR_DONT_LOAD_PREFS=1" "srcdir=${srcdir}") + + #http://www.cmake.org/pipermail/cmake/2009-May/029464.html + #Replaced this add test + set environs code with the shell script generation. + #Its nicer to be able to manually run the shell script to diagnose problems. + #ADD_TEST(${ARGV}) + #SET_TESTS_PROPERTIES(${test_name} PROPERTIES ENVIRONMENT "${environs}") + + IF(UNIX) + SET(binpath "${CMAKE_CURRENT_BINARY_DIR}:$PATH") + #set both LD and DYLD paths to cover multiple UNIX OS library paths + LIST(APPEND libpath "$LD_LIBRARY_PATH" "$DYLD_LIBRARY_PATH") + LIST(APPEND pypath "$PYTHONPATH") + + #replace list separator with the path separator + STRING(REPLACE ";" ":" libpath "${libpath}") + STRING(REPLACE ";" ":" pypath "${pypath}") + LIST(APPEND environs "PATH=${binpath}" "LD_LIBRARY_PATH=${libpath}" "DYLD_LIBRARY_PATH=${libpath}" "PYTHONPATH=${pypath}") + + #generate a bat file that sets the environment and runs the test + FIND_PROGRAM(SHELL sh) + SET(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh) + FILE(WRITE ${sh_file} "#!${SHELL}\n") + #each line sets an environment variable + FOREACH(environ ${environs}) + FILE(APPEND ${sh_file} "export ${environ}\n") + ENDFOREACH(environ) + #load the command to run with its arguments + FOREACH(arg ${ARGN}) + FILE(APPEND ${sh_file} "${arg} ") + ENDFOREACH(arg) + FILE(APPEND ${sh_file} "\n") + + #make the shell file executable + EXECUTE_PROCESS(COMMAND chmod +x ${sh_file}) + + ADD_TEST(${test_name} ${SHELL} ${sh_file}) + + ENDIF(UNIX) + + IF(WIN32) + LIST(APPEND libpath ${DLL_PATHS} "%PATH%") + LIST(APPEND pypath "%PYTHONPATH%") + + #replace list separator with the path separator (escaped) + STRING(REPLACE ";" "\\;" libpath "${libpath}") + STRING(REPLACE ";" "\\;" pypath "${pypath}") + LIST(APPEND environs "PATH=${libpath}" "PYTHONPATH=${pypath}") + + #generate a bat file that sets the environment and runs the test + SET(bat_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.bat) + FILE(WRITE ${bat_file} "@echo off\n") + #each line sets an environment variable + FOREACH(environ ${environs}) + FILE(APPEND ${bat_file} "SET ${environ}\n") + ENDFOREACH(environ) + #load the command to run with its arguments + FOREACH(arg ${ARGN}) + FILE(APPEND ${bat_file} "${arg} ") + ENDFOREACH(arg) + FILE(APPEND ${bat_file} "\n") + + ADD_TEST(${test_name} ${bat_file}) + ENDIF(WIN32) + +ENDFUNCTION(GR_ADD_TEST) diff --git a/gr-howto-write-a-block-cmake/grc/CMakeLists.txt b/gr-howto-write-a-block-cmake/grc/CMakeLists.txt new file mode 100644 index 0000000000..2571130792 --- /dev/null +++ b/gr-howto-write-a-block-cmake/grc/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright 2011 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. + +INSTALL(FILES + howto_square_ff.xml + howto_square2_ff.xml + DESTINATION share/gnuradio/grc/blocks +) diff --git a/gr-howto-write-a-block-cmake/grc/howto_square2_ff.xml b/gr-howto-write-a-block-cmake/grc/howto_square2_ff.xml new file mode 100644 index 0000000000..c58ef00478 --- /dev/null +++ b/gr-howto-write-a-block-cmake/grc/howto_square2_ff.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<block> + <name>Square2</name> + <key>howto_square2_ff</key> + <category>HOWTO</category> + <import>import howto</import> + <make>howto.square2_ff()</make> + + <sink> + <name>in</name> + <type>float</type> + </sink> + + <source> + <name>out</name> + <type>float</type> + </source> +</block> diff --git a/gr-howto-write-a-block-cmake/grc/howto_square_ff.xml b/gr-howto-write-a-block-cmake/grc/howto_square_ff.xml new file mode 100644 index 0000000000..34a0b0a3f2 --- /dev/null +++ b/gr-howto-write-a-block-cmake/grc/howto_square_ff.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<block> + <name>Square</name> + <key>howto_square_ff</key> + <category>HOWTO</category> + <import>import howto</import> + <make>howto.square_ff()</make> + + <sink> + <name>in</name> + <type>float</type> + </sink> + + <source> + <name>out</name> + <type>float</type> + </source> +</block> diff --git a/gr-howto-write-a-block-cmake/lib/CMakeLists.txt b/gr-howto-write-a-block-cmake/lib/CMakeLists.txt new file mode 100644 index 0000000000..798bc6ad62 --- /dev/null +++ b/gr-howto-write-a-block-cmake/lib/CMakeLists.txt @@ -0,0 +1,64 @@ +# Copyright 2011 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. + +######################################################################## +# Setup library +######################################################################## +INCLUDE(GrPlatform) #define LIB_SUFFIX + +ADD_LIBRARY(gnuradio-howto SHARED howto_square_ff.cc howto_square2_ff.cc) +TARGET_LINK_LIBRARIES(gnuradio-howto ${Boost_LIBRARIES} ${GRUEL_LIBRARIES} ${GNURADIO_CORE_LIBRARIES}) +SET_TARGET_PROPERTIES(gnuradio-howto PROPERTIES DEFINE_SYMBOL "gnuradio_howto_EXPORTS") + +######################################################################## +# Install built library files +######################################################################## +INSTALL(TARGETS gnuradio-howto + LIBRARY DESTINATION ${LIB_SUFFIX}/lib # .so/.dylib file + ARCHIVE DESTINATION ${LIB_SUFFIX}/lib # .lib file + RUNTIME DESTINATION bin # .dll file +) + +######################################################################## +# Install public header files +######################################################################## +INSTALL(FILES + howto_api.h + howto_square_ff.h + howto_square2_ff.h + DESTINATION include/howto +) + +######################################################################## +# Build and register unit test +######################################################################## +FIND_PACKAGE(Boost COMPONENTS unit_test_framework) + +INCLUDE(GrTest) +SET(GR_TEST_TARGET_DEPS gnuradio-howto) +#turn each test cpp file into an executable with an int main() function +ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN) + +ADD_EXECUTABLE(qa_howto_square_ff qa_howto_square_ff.cc) +TARGET_LINK_LIBRARIES(qa_howto_square_ff gnuradio-howto ${Boost_LIBRARIES}) +GR_ADD_TEST(qa_howto_square_ff qa_howto_square_ff) + +ADD_EXECUTABLE(qa_howto_square2_ff qa_howto_square2_ff.cc) +TARGET_LINK_LIBRARIES(qa_howto_square2_ff gnuradio-howto ${Boost_LIBRARIES}) +GR_ADD_TEST(qa_howto_square2_ff qa_howto_square2_ff) diff --git a/gr-howto-write-a-block-cmake/lib/howto_api.h b/gr-howto-write-a-block-cmake/lib/howto_api.h new file mode 100644 index 0000000000..5263a1cf70 --- /dev/null +++ b/gr-howto-write-a-block-cmake/lib/howto_api.h @@ -0,0 +1,33 @@ +/* + * Copyright 2011 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. + */ + +#ifndef INCLUDED_HOWTO_API_H +#define INCLUDED_HOWTO_API_H + +#include <gruel/attributes.h> + +#ifdef gnuradio_howto_EXPORTS +# define HOWTO_API __GR_ATTR_EXPORT +#else +# define HOWTO_API __GR_ATTR_IMPORT +#endif + +#endif /* INCLUDED_HOWTO_API_H */ diff --git a/gr-howto-write-a-block-cmake/lib/howto_square2_ff.cc b/gr-howto-write-a-block-cmake/lib/howto_square2_ff.cc new file mode 100644 index 0000000000..5e0fd7a436 --- /dev/null +++ b/gr-howto-write-a-block-cmake/lib/howto_square2_ff.cc @@ -0,0 +1,92 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010 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. + */ + +/* + * config.h is generated by configure. It contains the results + * of probing for features, options etc. It should be the first + * file included in your .cc file. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <howto_square2_ff.h> +#include <gr_io_signature.h> + +/* + * Create a new instance of howto_square2_ff and return + * a boost shared_ptr. This is effectively the public constructor. + */ +howto_square2_ff_sptr +howto_make_square2_ff () +{ + return gnuradio::get_initial_sptr(new howto_square2_ff ()); +} + +/* + * Specify constraints on number of input and output streams. + * This info is used to construct the input and output signatures + * (2nd & 3rd args to gr_block's constructor). The input and + * output signatures are used by the runtime system to + * check that a valid number and type of inputs and outputs + * are connected to this block. In this case, we accept + * only 1 input and 1 output. + */ +static const int MIN_IN = 1; // mininum number of input streams +static const int MAX_IN = 1; // maximum number of input streams +static const int MIN_OUT = 1; // minimum number of output streams +static const int MAX_OUT = 1; // maximum number of output streams + +/* + * The private constructor + */ +howto_square2_ff::howto_square2_ff () + : gr_sync_block ("square2_ff", + gr_make_io_signature (MIN_IN, MAX_IN, sizeof (float)), + gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (float))) +{ + // nothing else required in this example +} + +/* + * Our virtual destructor. + */ +howto_square2_ff::~howto_square2_ff () +{ + // nothing else required in this example +} + +int +howto_square2_ff::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const float *in = (const float *) input_items[0]; + float *out = (float *) output_items[0]; + + for (int i = 0; i < noutput_items; i++){ + out[i] = in[i] * in[i]; + } + + // Tell runtime system how many output items we produced. + return noutput_items; +} diff --git a/gr-howto-write-a-block-cmake/lib/howto_square2_ff.h b/gr-howto-write-a-block-cmake/lib/howto_square2_ff.h new file mode 100644 index 0000000000..c45a1851f5 --- /dev/null +++ b/gr-howto-write-a-block-cmake/lib/howto_square2_ff.h @@ -0,0 +1,78 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 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. + */ +#ifndef INCLUDED_HOWTO_SQUARE2_FF_H +#define INCLUDED_HOWTO_SQUARE2_FF_H + +#include <howto_api.h> +#include <gr_sync_block.h> + +class howto_square2_ff; + +/* + * We use boost::shared_ptr's instead of raw pointers for all access + * to gr_blocks (and many other data structures). The shared_ptr gets + * us transparent reference counting, which greatly simplifies storage + * management issues. This is especially helpful in our hybrid + * C++ / Python system. + * + * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm + * + * As a convention, the _sptr suffix indicates a boost::shared_ptr + */ +typedef boost::shared_ptr<howto_square2_ff> howto_square2_ff_sptr; + +/*! + * \brief Return a shared_ptr to a new instance of howto_square2_ff. + * + * To avoid accidental use of raw pointers, howto_square2_ff's + * constructor is private. howto_make_square2_ff is the public + * interface for creating new instances. + */ +HOWTO_API howto_square2_ff_sptr howto_make_square2_ff (); + +/*! + * \brief square2 a stream of floats. + * \ingroup block + * + * This uses the preferred technique: subclassing gr_sync_block. + */ +class HOWTO_API howto_square2_ff : public gr_sync_block +{ +private: + // The friend declaration allows howto_make_square2_ff to + // access the private constructor. + + friend HOWTO_API howto_square2_ff_sptr howto_make_square2_ff (); + + howto_square2_ff (); // private constructor + + public: + ~howto_square2_ff (); // public destructor + + // Where all the action really happens + + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_HOWTO_SQUARE2_FF_H */ diff --git a/gr-howto-write-a-block-cmake/lib/howto_square_ff.cc b/gr-howto-write-a-block-cmake/lib/howto_square_ff.cc new file mode 100644 index 0000000000..f1d5a78482 --- /dev/null +++ b/gr-howto-write-a-block-cmake/lib/howto_square_ff.cc @@ -0,0 +1,98 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010 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. + */ + +/* + * config.h is generated by configure. It contains the results + * of probing for features, options etc. It should be the first + * file included in your .cc file. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <howto_square_ff.h> +#include <gr_io_signature.h> + +/* + * Create a new instance of howto_square_ff and return + * a boost shared_ptr. This is effectively the public constructor. + */ +howto_square_ff_sptr +howto_make_square_ff () +{ + return gnuradio::get_initial_sptr(new howto_square_ff ()); +} + +/* + * Specify constraints on number of input and output streams. + * This info is used to construct the input and output signatures + * (2nd & 3rd args to gr_block's constructor). The input and + * output signatures are used by the runtime system to + * check that a valid number and type of inputs and outputs + * are connected to this block. In this case, we accept + * only 1 input and 1 output. + */ +static const int MIN_IN = 1; // mininum number of input streams +static const int MAX_IN = 1; // maximum number of input streams +static const int MIN_OUT = 1; // minimum number of output streams +static const int MAX_OUT = 1; // maximum number of output streams + +/* + * The private constructor + */ +howto_square_ff::howto_square_ff () + : gr_block ("square_ff", + gr_make_io_signature (MIN_IN, MAX_IN, sizeof (float)), + gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (float))) +{ + // nothing else required in this example +} + +/* + * Our virtual destructor. + */ +howto_square_ff::~howto_square_ff () +{ + // nothing else required in this example +} + +int +howto_square_ff::general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const float *in = (const float *) input_items[0]; + float *out = (float *) output_items[0]; + + for (int i = 0; i < noutput_items; i++){ + out[i] = in[i] * in[i]; + } + + // Tell runtime system how many input items we consumed on + // each input stream. + + consume_each (noutput_items); + + // Tell runtime system how many output items we produced. + return noutput_items; +} diff --git a/gr-howto-write-a-block-cmake/lib/howto_square_ff.h b/gr-howto-write-a-block-cmake/lib/howto_square_ff.h new file mode 100644 index 0000000000..f07a1d4f66 --- /dev/null +++ b/gr-howto-write-a-block-cmake/lib/howto_square_ff.h @@ -0,0 +1,79 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 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. + */ +#ifndef INCLUDED_HOWTO_SQUARE_FF_H +#define INCLUDED_HOWTO_SQUARE_FF_H + +#include <howto_api.h> +#include <gr_block.h> + +class howto_square_ff; + +/* + * We use boost::shared_ptr's instead of raw pointers for all access + * to gr_blocks (and many other data structures). The shared_ptr gets + * us transparent reference counting, which greatly simplifies storage + * management issues. This is especially helpful in our hybrid + * C++ / Python system. + * + * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm + * + * As a convention, the _sptr suffix indicates a boost::shared_ptr + */ +typedef boost::shared_ptr<howto_square_ff> howto_square_ff_sptr; + +/*! + * \brief Return a shared_ptr to a new instance of howto_square_ff. + * + * To avoid accidental use of raw pointers, howto_square_ff's + * constructor is private. howto_make_square_ff is the public + * interface for creating new instances. + */ +HOWTO_API howto_square_ff_sptr howto_make_square_ff (); + +/*! + * \brief square a stream of floats. + * \ingroup block + * + * \sa howto_square2_ff for a version that subclasses gr_sync_block. + */ +class HOWTO_API howto_square_ff : public gr_block +{ +private: + // The friend declaration allows howto_make_square_ff to + // access the private constructor. + + friend HOWTO_API howto_square_ff_sptr howto_make_square_ff (); + + howto_square_ff (); // private constructor + + public: + ~howto_square_ff (); // public destructor + + // Where all the action really happens + + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_HOWTO_SQUARE_FF_H */ diff --git a/gr-howto-write-a-block-cmake/lib/qa_howto_square2_ff.cc b/gr-howto-write-a-block-cmake/lib/qa_howto_square2_ff.cc new file mode 100644 index 0000000000..9c37b62c1c --- /dev/null +++ b/gr-howto-write-a-block-cmake/lib/qa_howto_square2_ff.cc @@ -0,0 +1,32 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <boost/test/unit_test.hpp> + +BOOST_AUTO_TEST_CASE(qa_howto_square2_ff_t1){ + BOOST_CHECK_EQUAL(2 + 2, 4); + // TODO BOOST_* test macros here +} + +BOOST_AUTO_TEST_CASE(qa_howto_square2_ff_t2){ + BOOST_CHECK_EQUAL(2 + 2, 4); + // TODO BOOST_* test macros here +} diff --git a/gr-howto-write-a-block-cmake/lib/qa_howto_square_ff.cc b/gr-howto-write-a-block-cmake/lib/qa_howto_square_ff.cc new file mode 100644 index 0000000000..da1d3040a2 --- /dev/null +++ b/gr-howto-write-a-block-cmake/lib/qa_howto_square_ff.cc @@ -0,0 +1,32 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <boost/test/unit_test.hpp> + +BOOST_AUTO_TEST_CASE(qa_howto_square_ff_t1){ + BOOST_CHECK_EQUAL(2 + 2, 4); + // TODO BOOST_* test macros here +} + +BOOST_AUTO_TEST_CASE(qa_howto_square_ff_t2){ + BOOST_CHECK_EQUAL(2 + 2, 4); + // TODO BOOST_* test macros here +} diff --git a/gr-howto-write-a-block-cmake/python/CMakeLists.txt b/gr-howto-write-a-block-cmake/python/CMakeLists.txt new file mode 100644 index 0000000000..6208f8a870 --- /dev/null +++ b/gr-howto-write-a-block-cmake/python/CMakeLists.txt @@ -0,0 +1,44 @@ +# Copyright 2011 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. + +######################################################################## +# Include python install macros +######################################################################## +INCLUDE(GrPython) +IF(NOT PYTHONINTERP_FOUND) + RETURN() +ENDIF() + +######################################################################## +# Install python sources +######################################################################## +GR_PYTHON_INSTALL( + FILES + __init__.py + DESTINATION ${GR_PYTHON_DIR}/howto +) + +######################################################################## +# Handle the unit tests +######################################################################## +INCLUDE(GrTest) + +SET(GR_TEST_TARGET_DEPS gnuradio-howto) +SET(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig) +GR_ADD_TEST(qa_howto ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_howto.py) diff --git a/gr-howto-write-a-block-cmake/python/__init__.py b/gr-howto-write-a-block-cmake/python/__init__.py new file mode 100644 index 0000000000..d4a41c271b --- /dev/null +++ b/gr-howto-write-a-block-cmake/python/__init__.py @@ -0,0 +1,49 @@ +# +# Copyright 2008,2009 Free Software Foundation, Inc. +# +# This application 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. +# +# This application 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 this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +# The presence of this file turns this directory into a Python package + +# ---------------------------------------------------------------- +# Temporary workaround for ticket:181 (swig+python problem) +import sys +_RTLD_GLOBAL = 0 +try: + from dl import RTLD_GLOBAL as _RTLD_GLOBAL +except ImportError: + try: + from DLFCN import RTLD_GLOBAL as _RTLD_GLOBAL + except ImportError: + pass + +if _RTLD_GLOBAL != 0: + _dlopenflags = sys.getdlopenflags() + sys.setdlopenflags(_dlopenflags|_RTLD_GLOBAL) +# ---------------------------------------------------------------- + + +# import swig generated symbols into the howto namespace +from howto_swig import * + +# import any pure python here +# + +# ---------------------------------------------------------------- +# Tail of workaround +if _RTLD_GLOBAL != 0: + sys.setdlopenflags(_dlopenflags) # Restore original flags +# ---------------------------------------------------------------- diff --git a/gr-howto-write-a-block-cmake/python/qa_howto.py b/gr-howto-write-a-block-cmake/python/qa_howto.py new file mode 100755 index 0000000000..630f57bf42 --- /dev/null +++ b/gr-howto-write-a-block-cmake/python/qa_howto.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# Copyright 2004,2007 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. +# + +from gnuradio import gr, gr_unittest +import howto_swig + +class qa_howto (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_square_ff (self): + src_data = (-3, 4, -5.5, 2, 3) + expected_result = (9, 16, 30.25, 4, 9) + src = gr.vector_source_f (src_data) + sqr = howto_swig.square_ff () + dst = gr.vector_sink_f () + self.tb.connect (src, sqr) + self.tb.connect (sqr, dst) + self.tb.run () + result_data = dst.data () + self.assertFloatTuplesAlmostEqual (expected_result, result_data, 6) + + def test_002_square2_ff (self): + src_data = (-3, 4, -5.5, 2, 3) + expected_result = (9, 16, 30.25, 4, 9) + src = gr.vector_source_f (src_data) + sqr = howto_swig.square2_ff () + dst = gr.vector_sink_f () + self.tb.connect (src, sqr) + self.tb.connect (sqr, dst) + self.tb.run () + result_data = dst.data () + self.assertFloatTuplesAlmostEqual (expected_result, result_data, 6) + +if __name__ == '__main__': + gr_unittest.main () diff --git a/gr-howto-write-a-block-cmake/swig/CMakeLists.txt b/gr-howto-write-a-block-cmake/swig/CMakeLists.txt new file mode 100644 index 0000000000..40f2b1051e --- /dev/null +++ b/gr-howto-write-a-block-cmake/swig/CMakeLists.txt @@ -0,0 +1,55 @@ +# Copyright 2011 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. + +######################################################################## +# Include swig generation macros +######################################################################## +FIND_PACKAGE(SWIG) +FIND_PACKAGE(PythonLibs) +IF(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) + RETURN() +ENDIF() +INCLUDE(GrSwig) + +######################################################################## +# Setup swig generation +######################################################################## +FOREACH(incdir ${GNURADIO_CORE_INCLUDE_DIRS}) + LIST(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/swig) +ENDFOREACH(incdir) + +SET(GR_SWIG_LIBRARIES gnuradio-howto) + +GR_SWIG_MAKE(howto_swig howto_swig.i) + +######################################################################## +# Install the build swig module +######################################################################## +GR_SWIG_INSTALL(TARGETS howto_swig DESTINATION ${GR_PYTHON_DIR}/howto) + +######################################################################## +# Install swig .i files for development +######################################################################## +INSTALL( + FILES + howto_swig.i + howto_square_ff.i + howto_square2_ff.i + DESTINATION include/howto/swig +) diff --git a/gr-howto-write-a-block-cmake/swig/howto_square2_ff.i b/gr-howto-write-a-block-cmake/swig/howto_square2_ff.i new file mode 100644 index 0000000000..683a93d612 --- /dev/null +++ b/gr-howto-write-a-block-cmake/swig/howto_square2_ff.i @@ -0,0 +1,9 @@ +GR_SWIG_BLOCK_MAGIC(howto,square2_ff); + +howto_square2_ff_sptr howto_make_square2_ff (); + +class howto_square2_ff : public gr_sync_block +{ +private: + howto_square2_ff (); +}; diff --git a/gr-howto-write-a-block-cmake/swig/howto_square_ff.i b/gr-howto-write-a-block-cmake/swig/howto_square_ff.i new file mode 100644 index 0000000000..f8ae769868 --- /dev/null +++ b/gr-howto-write-a-block-cmake/swig/howto_square_ff.i @@ -0,0 +1,16 @@ +/* + * First arg is the package prefix. + * Second arg is the name of the class minus the prefix. + * + * This does some behind-the-scenes magic so we can + * access howto_square_ff from python as howto.square_ff + */ +GR_SWIG_BLOCK_MAGIC(howto,square_ff); + +howto_square_ff_sptr howto_make_square_ff (); + +class howto_square_ff : public gr_block +{ +private: + howto_square_ff (); +}; diff --git a/gr-howto-write-a-block-cmake/swig/howto_swig.i b/gr-howto-write-a-block-cmake/swig/howto_swig.i new file mode 100644 index 0000000000..d0bbcdc115 --- /dev/null +++ b/gr-howto-write-a-block-cmake/swig/howto_swig.i @@ -0,0 +1,21 @@ +/* -*- c++ -*- */ + +%include "gnuradio.i" // the common stuff + +%{ +#include "howto_square_ff.h" +#include "howto_square2_ff.h" +%} + +%include "howto_square_ff.i" +%include "howto_square2_ff.i" + +#if SWIGGUILE +%scheme %{ +(load-extension-global "libguile-gnuradio-howto_swig" "scm_init_gnuradio_howto_swig_module") +%} + +%goops %{ +(use-modules (gnuradio gnuradio_core_runtime)) +%} +#endif diff --git a/gruel/src/include/gruel/attributes.h b/gruel/src/include/gruel/attributes.h index 8c9a57b475..baa5521c81 100644 --- a/gruel/src/include/gruel/attributes.h +++ b/gruel/src/include/gruel/attributes.h @@ -54,6 +54,13 @@ #endif //////////////////////////////////////////////////////////////////////// +// define inline when building C +//////////////////////////////////////////////////////////////////////// +#if defined(_MSC_VER) && !defined(__cplusplus) && !defined(inline) +# define inline __inline +#endif + +//////////////////////////////////////////////////////////////////////// // suppress warnings //////////////////////////////////////////////////////////////////////// #ifdef _MSC_VER |