summaryrefslogtreecommitdiff
path: root/gnuradio-runtime
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime')
-rw-r--r--gnuradio-runtime/CMakeLists.txt39
-rw-r--r--gnuradio-runtime/ConfigChecks.cmake28
-rw-r--r--gnuradio-runtime/apps/CMakeLists.txt1
-rw-r--r--gnuradio-runtime/apps/evaluation_random_numbers.py23
-rw-r--r--gnuradio-runtime/examples/mp-sched/CMakeLists.txt2
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/mp-sched/affinity_set.py14
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/mp-sched/plot_flops.py16
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/mp-sched/run_synthetic.py43
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/mp-sched/synthetic.py70
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py42
-rw-r--r--gnuradio-runtime/examples/network/CMakeLists.txt2
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/network/audio_sink.py30
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/network/audio_source.py32
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/network/dial_tone_sink.py30
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/network/dial_tone_source.py40
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/network/vector_sink.py27
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/network/vector_source.py24
-rw-r--r--gnuradio-runtime/examples/volk_benchmark/CMakeLists.txt2
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/volk_benchmark/volk_math.py12
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/volk_benchmark/volk_plot.py8
-rw-r--r--gnuradio-runtime/examples/volk_benchmark/volk_test_funcs.py14
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/examples/volk_benchmark/volk_types.py12
-rw-r--r--gnuradio-runtime/include/gnuradio/CMakeLists.txt13
-rw-r--r--gnuradio-runtime/include/gnuradio/basic_block.h24
-rw-r--r--gnuradio-runtime/include/gnuradio/block.h32
-rw-r--r--gnuradio-runtime/include/gnuradio/flowgraph.h18
-rw-r--r--gnuradio-runtime/include/gnuradio/hier_block2.h25
-rw-r--r--gnuradio-runtime/include/gnuradio/logger.h (renamed from gnuradio-runtime/include/gnuradio/logger.h.in)217
-rw-r--r--gnuradio-runtime/include/gnuradio/math.h18
-rw-r--r--gnuradio-runtime/include/gnuradio/messages/CMakeLists.txt1
-rw-r--r--gnuradio-runtime/include/gnuradio/nco.h24
-rw-r--r--gnuradio-runtime/include/gnuradio/realtime_impl.h2
-rw-r--r--gnuradio-runtime/include/gnuradio/rpcmanager.h4
-rw-r--r--gnuradio-runtime/include/gnuradio/sptr_magic.h2
-rw-r--r--gnuradio-runtime/include/gnuradio/sys_pri.h42
-rw-r--r--gnuradio-runtime/include/gnuradio/thread/CMakeLists.txt1
-rw-r--r--gnuradio-runtime/include/gnuradio/tpb_detail.h3
-rw-r--r--gnuradio-runtime/include/gnuradio/types.h1
-rw-r--r--gnuradio-runtime/include/pmt/CMakeLists.txt3
-rw-r--r--gnuradio-runtime/include/pmt/pmt_serial_tags.h (renamed from gnuradio-runtime/lib/pmt/gen-serial-tags.py)59
-rw-r--r--gnuradio-runtime/lib/CMakeLists.txt27
-rw-r--r--gnuradio-runtime/lib/basic_block.cc23
-rw-r--r--gnuradio-runtime/lib/block.cc22
-rw-r--r--gnuradio-runtime/lib/complex_vec_test.cc82
-rw-r--r--gnuradio-runtime/lib/complex_vec_test.h50
-rw-r--r--gnuradio-runtime/lib/controlport/CMakeLists.txt1
-rw-r--r--gnuradio-runtime/lib/controlport/rpcserver_selector.cc4
-rw-r--r--gnuradio-runtime/lib/flat_flowgraph.cc233
-rw-r--r--gnuradio-runtime/lib/hier_block2.cc12
-rw-r--r--gnuradio-runtime/lib/hier_block2_detail.cc18
-rw-r--r--gnuradio-runtime/lib/hier_block2_detail.h3
-rw-r--r--gnuradio-runtime/lib/logger.cc46
-rw-r--r--gnuradio-runtime/lib/malloc16.c46
-rw-r--r--gnuradio-runtime/lib/malloc16.h37
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/lib/math/gen_sine_table.py6
-rw-r--r--gnuradio-runtime/lib/math/qa_fxpt.cc16
-rw-r--r--gnuradio-runtime/lib/math/qa_fxpt_nco.cc8
-rw-r--r--gnuradio-runtime/lib/math/random.cc8
-rw-r--r--gnuradio-runtime/lib/math/vco.h14
-rw-r--r--gnuradio-runtime/lib/pmt/CMakeLists.txt97
-rwxr-xr-xgnuradio-runtime/lib/pmt/generate_unv.py162
-rw-r--r--gnuradio-runtime/lib/pmt/pmt-serial-tags.scm77
-rw-r--r--gnuradio-runtime/lib/pmt/pmt.cc8
-rw-r--r--gnuradio-runtime/lib/pmt/pmt_int.h24
-rw-r--r--gnuradio-runtime/lib/pmt/pmt_unv.cc1821
-rw-r--r--gnuradio-runtime/lib/pmt/pmt_unv_int.h331
-rw-r--r--gnuradio-runtime/lib/pmt/qa_pmt_unv.h61
-rw-r--r--gnuradio-runtime/lib/pmt/unv_template.cc.t149
-rw-r--r--gnuradio-runtime/lib/pmt/unv_template.h.t25
-rw-r--r--gnuradio-runtime/lib/posix_memalign.cc114
-rw-r--r--gnuradio-runtime/lib/posix_memalign.h42
-rw-r--r--gnuradio-runtime/lib/qa_logger.cc2
-rw-r--r--gnuradio-runtime/lib/scheduler_sts.cc90
-rw-r--r--gnuradio-runtime/lib/scheduler_sts.h66
-rw-r--r--gnuradio-runtime/lib/single_threaded_scheduler.cc366
-rw-r--r--gnuradio-runtime/lib/single_threaded_scheduler.h65
-rw-r--r--gnuradio-runtime/lib/sptr_magic.cc2
-rw-r--r--gnuradio-runtime/lib/sys_pri.cc63
-rw-r--r--gnuradio-runtime/lib/thread/thread_group.cc2
-rw-r--r--gnuradio-runtime/lib/top_block_impl.cc4
-rw-r--r--gnuradio-runtime/lib/tpb_thread_body.cc92
-rw-r--r--gnuradio-runtime/python/build_utils.py226
-rw-r--r--gnuradio-runtime/python/build_utils_codes.py52
-rw-r--r--gnuradio-runtime/python/gnuradio/CMakeLists.txt1
-rw-r--r--gnuradio-runtime/python/gnuradio/__init__.py6
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/CMakeLists.txt14
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py12
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py23
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/RPCConnection.py21
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py17
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/__init__.py4
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx16
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/monitor.py21
-rw-r--r--gnuradio-runtime/python/gnuradio/eng_arg.py1
-rw-r--r--gnuradio-runtime/python/gnuradio/eng_notation.py3
-rw-r--r--gnuradio-runtime/python/gnuradio/eng_option.py20
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt4
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/__init__.py18
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/exceptions.py1
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/gateway.py15
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/gr_threading.py6
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py26
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/gr_threading_24.py26
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/hier_block2.py3
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/packet_utils.py13
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/pubsub.py89
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/python/gnuradio/gr/qa_feval.py1
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/python/gnuradio/gr/qa_flowgraph.py1
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/qa_hier_block2.py8
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/python/gnuradio/gr/qa_kludged_imports.py1
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/qa_random.py1
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/python/gnuradio/gr/qa_tag_utils.py10
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/tag_utils.py17
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/top_block.py15
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/python/gnuradio/gr_unittest.py63
-rw-r--r--gnuradio-runtime/python/gnuradio/gr_xmlrunner.py86
-rw-r--r--gnuradio-runtime/python/gnuradio/gru/CMakeLists.txt1
-rw-r--r--gnuradio-runtime/python/gnuradio/gru/__init__.py22
-rw-r--r--gnuradio-runtime/python/gnuradio/gru/daemon.py46
-rw-r--r--gnuradio-runtime/python/gnuradio/gru/freqz.py32
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/python/gnuradio/gru/gnuplot_freqz.py8
-rw-r--r--gnuradio-runtime/python/gnuradio/gru/hexint.py1
-rw-r--r--gnuradio-runtime/python/gnuradio/gru/listmisc.py1
-rw-r--r--gnuradio-runtime/python/gnuradio/gru/mathmisc.py4
-rw-r--r--gnuradio-runtime/python/gnuradio/gru/msgq_runner.py3
-rw-r--r--gnuradio-runtime/python/gnuradio/gru/os_read_exactly.py1
-rw-r--r--gnuradio-runtime/python/gnuradio/gru/seq_with_cursor.py13
-rw-r--r--gnuradio-runtime/python/gnuradio/gru/socket_stuff.py5
-rw-r--r--gnuradio-runtime/python/pmt/CMakeLists.txt3
-rw-r--r--gnuradio-runtime/python/pmt/__init__.py11
-rw-r--r--gnuradio-runtime/python/pmt/pmt_to_python.py29
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/python/pmt/qa_pmt.py6
-rw-r--r--[-rwxr-xr-x]gnuradio-runtime/python/pmt/qa_pmt_to_python.py7
-rw-r--r--gnuradio-runtime/swig/CMakeLists.txt13
-rw-r--r--gnuradio-runtime/swig/basic_block.i6
-rw-r--r--gnuradio-runtime/swig/block.i3
-rw-r--r--gnuradio-runtime/swig/complex_vec_test.i25
-rw-r--r--gnuradio-runtime/swig/gnuradio.i12
-rw-r--r--gnuradio-runtime/swig/gr_swig_block_magic.i12
-rw-r--r--gnuradio-runtime/swig/hier_block2.i21
-rw-r--r--gnuradio-runtime/swig/message.i8
-rw-r--r--gnuradio-runtime/swig/pmt_swig.i47
-rw-r--r--gnuradio-runtime/swig/py3compat.i7
-rw-r--r--gnuradio-runtime/swig/single_threaded_scheduler.i54
-rw-r--r--gnuradio-runtime/swig/top_block.i14
145 files changed, 3380 insertions, 3195 deletions
diff --git a/gnuradio-runtime/CMakeLists.txt b/gnuradio-runtime/CMakeLists.txt
index 47d690a77d..73d5fdd54c 100644
--- a/gnuradio-runtime/CMakeLists.txt
+++ b/gnuradio-runtime/CMakeLists.txt
@@ -83,39 +83,6 @@ get_filename_component(GR_RUNTIME_PYTHONPATH
)
GR_SET_GLOBAL(GR_RUNTIME_PYTHONPATH ${GR_RUNTIME_PYTHONPATH})
-########################################################################
-# Setup CPack components
-########################################################################
-include(GrPackage)
-CPACK_SET(CPACK_COMPONENT_GROUP_RUNTIME_DESCRIPTION "GNU Radio Runtime")
-
-CPACK_COMPONENT("runtime_runtime"
- GROUP "Runtime"
- DISPLAY_NAME "Runtime"
- DESCRIPTION "Dynamic link libraries"
- DEPENDS "runtime_runtime"
-)
-
-CPACK_COMPONENT("runtime_devel"
- GROUP "Runtime"
- DISPLAY_NAME "Development"
- DESCRIPTION "C++ headers, package config, import libraries"
- DEPENDS "runtime_devel"
-)
-
-CPACK_COMPONENT("runtime_python"
- GROUP "Runtime"
- DISPLAY_NAME "Python"
- DESCRIPTION "Python modules for runtime"
- DEPENDS "runtime_python;runtime_runtime"
-)
-
-CPACK_COMPONENT("runtime_swig"
- GROUP "Runtime"
- DISPLAY_NAME "SWIG"
- DESCRIPTION "SWIG development .i files"
- DEPENDS "runtime_swig;runtime_python;runtime_devel"
-)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-runtime.conf.in
${CMAKE_CURRENT_BINARY_DIR}/gnuradio-runtime.conf
@@ -124,17 +91,12 @@ configure_file(
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-runtime.conf
DESTINATION ${GR_PREFSDIR}
- COMPONENT "runtime_runtime"
)
-if(ENABLE_GR_LOG AND HAVE_LOG4CPP)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/gr_log_default.conf
DESTINATION ${GR_PREFSDIR}
- COMPONENT "runtime_runtime"
)
-set(PC_ADD_LIBS -llog4cpp)
-endif(ENABLE_GR_LOG AND HAVE_LOG4CPP)
set(PC_ADD_LIBS "${MPLIB_PC_ADD_LIBS} ${PC_ADD_LIBS}")
set(PC_ADD_CFLAGS ${MPLIB_PC_ADD_CFLAGS})
@@ -162,7 +124,6 @@ configure_file(
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-runtime.pc
DESTINATION ${GR_LIBRARY_DIR}/pkgconfig
- COMPONENT "runtime_devel"
)
endif(ENABLE_GNURADIO_RUNTIME)
diff --git a/gnuradio-runtime/ConfigChecks.cmake b/gnuradio-runtime/ConfigChecks.cmake
index 9487d6ad60..e1ba20c1f1 100644
--- a/gnuradio-runtime/ConfigChecks.cmake
+++ b/gnuradio-runtime/ConfigChecks.cmake
@@ -25,10 +25,8 @@ IF(MSVC) #add this directory for our provided headers
LIST(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_SOURCE_DIR}/msvc)
ENDIF(MSVC)
-GR_CHECK_HDR_N_DEF(netdb.h HAVE_NETDB_H)
GR_CHECK_HDR_N_DEF(sys/time.h HAVE_SYS_TIME_H)
GR_CHECK_HDR_N_DEF(sys/types.h HAVE_SYS_TYPES_H)
-GR_CHECK_HDR_N_DEF(sys/select.h HAVE_SYS_SELECT_H)
GR_CHECK_HDR_N_DEF(sys/socket.h HAVE_SYS_SOCKET_H)
GR_CHECK_HDR_N_DEF(io.h HAVE_IO_H)
GR_CHECK_HDR_N_DEF(sys/mman.h HAVE_SYS_MMAN_H)
@@ -37,9 +35,6 @@ GR_CHECK_HDR_N_DEF(sys/shm.h HAVE_SYS_SHM_H)
GR_CHECK_HDR_N_DEF(signal.h HAVE_SIGNAL_H)
GR_CHECK_HDR_N_DEF(netinet/in.h HAVE_NETINET_IN_H)
GR_CHECK_HDR_N_DEF(arpa/inet.h HAVE_ARPA_INET_H)
-GR_CHECK_HDR_N_DEF(byteswap.h HAVE_BYTESWAP_H)
-GR_CHECK_HDR_N_DEF(linux/ppdev.h HAVE_LINUX_PPDEV_H)
-GR_CHECK_HDR_N_DEF(dev/ppbus/ppi.h HAVE_DEV_PPBUS_PPI_H)
GR_CHECK_HDR_N_DEF(unistd.h HAVE_UNISTD_H)
GR_CHECK_HDR_N_DEF(malloc.h HAVE_MALLOC_H)
@@ -62,15 +57,6 @@ GR_ADD_COND_DEF(HAVE_SIGACTION)
########################################################################
CHECK_CXX_SOURCE_COMPILES("
- #include <sys/select.h>
- int main(){select(0, 0, 0, 0, 0); return 0;}
- " HAVE_SELECT
-)
-GR_ADD_COND_DEF(HAVE_SELECT)
-
-
-########################################################################
-CHECK_CXX_SOURCE_COMPILES("
#include <unistd.h>
int main(){sysconf(0); return 0;}
" HAVE_SYSCONF
@@ -93,20 +79,6 @@ CHECK_CXX_SOURCE_COMPILES("
)
GR_ADD_COND_DEF(HAVE_SSLEEP)
-CHECK_CXX_SOURCE_COMPILES("
- #include <time.h>
- int main(){nanosleep(0, 0); return 0;}
- " HAVE_NANOSLEEP
-)
-GR_ADD_COND_DEF(HAVE_NANOSLEEP)
-
-CHECK_CXX_SOURCE_COMPILES("
- #include <sys/time.h>
- int main(){gettimeofday(0, 0); return 0;}
- " HAVE_GETTIMEOFDAY
-)
-GR_ADD_COND_DEF(HAVE_GETTIMEOFDAY)
-
########################################################################
CHECK_CXX_SOURCE_COMPILES("
#include <stdlib.h>
diff --git a/gnuradio-runtime/apps/CMakeLists.txt b/gnuradio-runtime/apps/CMakeLists.txt
index 3dea7268ff..4a73f3c18f 100644
--- a/gnuradio-runtime/apps/CMakeLists.txt
+++ b/gnuradio-runtime/apps/CMakeLists.txt
@@ -37,5 +37,4 @@ target_link_libraries(gnuradio-config-info gnuradio-runtime ${Boost_LIBRARIES})
install(
TARGETS gnuradio-config-info
DESTINATION ${GR_RUNTIME_DIR}
- COMPONENT "runtime_runtime"
)
diff --git a/gnuradio-runtime/apps/evaluation_random_numbers.py b/gnuradio-runtime/apps/evaluation_random_numbers.py
index 069493c73e..30b61be858 100644
--- a/gnuradio-runtime/apps/evaluation_random_numbers.py
+++ b/gnuradio-runtime/apps/evaluation_random_numbers.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr
import numpy as np
from scipy.stats import norm, laplace, rayleigh
@@ -40,7 +43,7 @@ laplace_num_bins = 31
rndm = gr.random() # instance of gnuradio random class (gr::random)
-print 'All histograms contain',num_tests,'realisations.'
+print('All histograms contain',num_tests,'realisations.')
#*** GENERATE DATA ***#
@@ -73,7 +76,7 @@ rayleigh_expected = np.zeros(rayleigh_num_bins-1)
laplace_expected = np.zeros(laplace_num_bins-1)
for k in range(len(uniform_hist[0])):
- uniform_expected[k] = num_tests/float(uniform_num_bins-1)
+ uniform_expected[k] = num_tests / float(uniform_num_bins-1)
for k in range(len(gauss_hist[0])):
gauss_expected[k] = float(norm.cdf(gauss_hist[1][k+1])-norm.cdf(gauss_hist[1][k]))*num_tests
@@ -86,10 +89,10 @@ for k in range(len(laplace_hist[0])):
#*** PLOT HISTOGRAMS AND EXPECTATIONS TAKEN FROM SCIPY ***#
-uniform_bins_center = uniform_bins[0:-1]+(uniform_bins[1]-uniform_bins[0])/2.0
-gauss_bins_center = gauss_bins[0:-1]+(gauss_bins[1]-gauss_bins[0])/2.0
-rayleigh_bins_center = rayleigh_bins[0:-1]+(rayleigh_bins[1]-rayleigh_bins[0])/2.0
-laplace_bins_center = laplace_bins[0:-1]+(laplace_bins[1]-laplace_bins[0])/2.0
+uniform_bins_center = uniform_bins[0:-1]+(uniform_bins[1]-uniform_bins[0]) / 2.0
+gauss_bins_center = gauss_bins[0:-1]+(gauss_bins[1]-gauss_bins[0]) / 2.0
+rayleigh_bins_center = rayleigh_bins[0:-1]+(rayleigh_bins[1]-rayleigh_bins[0]) / 2.0
+laplace_bins_center = laplace_bins[0:-1]+(laplace_bins[1]-laplace_bins[0]) / 2.0
plt.figure(1)
@@ -99,7 +102,7 @@ plt.xlabel('Bins'), plt.ylabel('Count'), plt.title('Uniform: Distribution')
plt.legend(['histogram gr::random','calculation scipy'],loc=1)
plt.subplot(2,1,2)
-plt.plot(uniform_bins_center,uniform_hist[0]/uniform_expected,'rs--')
+plt.plot(uniform_bins_center,uniform_hist[0] / uniform_expected,'rs--')
plt.xlabel('Bins'), plt.ylabel('Relative deviation'), plt.title('Uniform: Relative deviation to scipy')
plt.figure(2)
@@ -110,7 +113,7 @@ plt.xlabel('Bins'), plt.ylabel('Count'), plt.title('Gauss: Distribution')
plt.legend(['histogram gr::random','calculation scipy'],loc=1)
plt.subplot(2,1,2)
-plt.plot(gauss_bins_center,gauss_hist[0]/gauss_expected,'rs--')
+plt.plot(gauss_bins_center,gauss_hist[0] / gauss_expected,'rs--')
plt.xlabel('Bins'), plt.ylabel('Relative deviation'), plt.title('Gauss: Relative deviation to scipy')
plt.figure(3)
@@ -122,7 +125,7 @@ plt.legend(['histogram gr::random','calculation scipy'],loc=1)
plt.subplot(2,1,2)
-plt.plot(rayleigh_bins_center,rayleigh_hist[0]/rayleigh_expected,'rs--')
+plt.plot(rayleigh_bins_center,rayleigh_hist[0] / rayleigh_expected,'rs--')
plt.xlabel('Bins'), plt.ylabel('Relative deviation'), plt.title('Rayleigh: Relative deviation to scipy')
plt.figure(4)
@@ -133,7 +136,7 @@ plt.xlabel('Bins'), plt.ylabel('Count'), plt.title('Laplace: Distribution')
plt.legend(['histogram gr::random','calculation scipy'],loc=1)
plt.subplot(2,1,2)
-plt.plot(laplace_bins_center,laplace_hist[0]/laplace_expected,'rs--')
+plt.plot(laplace_bins_center,laplace_hist[0] / laplace_expected,'rs--')
plt.xlabel('Bins'), plt.ylabel('Relative deviation'), plt.title('Laplace: Relative deviation to scipy')
plt.show()
diff --git a/gnuradio-runtime/examples/mp-sched/CMakeLists.txt b/gnuradio-runtime/examples/mp-sched/CMakeLists.txt
index 863cfa733a..4e07366d4f 100644
--- a/gnuradio-runtime/examples/mp-sched/CMakeLists.txt
+++ b/gnuradio-runtime/examples/mp-sched/CMakeLists.txt
@@ -26,11 +26,9 @@ GR_PYTHON_INSTALL(PROGRAMS
synthetic.py
wfm_rcv_pll_to_wav.py
DESTINATION ${GR_PKG_DATA_DIR}/examples/mp-sched
- COMPONENT "runtime_python"
)
install(
FILES README
DESTINATION ${GR_PKG_DATA_DIR}/examples/mp-sched
- COMPONENT "runtime_python"
)
diff --git a/gnuradio-runtime/examples/mp-sched/affinity_set.py b/gnuradio-runtime/examples/mp-sched/affinity_set.py
index 15d2233b6a..a253c8081c 100755..100644
--- a/gnuradio-runtime/examples/mp-sched/affinity_set.py
+++ b/gnuradio-runtime/examples/mp-sched/affinity_set.py
@@ -4,13 +4,15 @@
# Title: Affinity Set Test
##################################################
+from __future__ import print_function
+from __future__ import unicode_literals
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
-from gnuradio.eng_option import eng_option
+from gnuradio.eng_arg import eng_arg
from gnuradio.filter import firdes
-from optparse import OptionParser
+from argparse import ArgumentParser
import sys
class affinity_set(gr.top_block):
@@ -51,13 +53,13 @@ class affinity_set(gr.top_block):
self.samp_rate = samp_rate
if __name__ == '__main__':
- parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
- (options, args) = parser.parse_args()
+ parser = ArgumentParser()
+ args = parser.parse_args()
tb = affinity_set()
tb.start()
while(1):
- ret = raw_input('Enter a new Core # or Press Enter to quit: ')
+ ret = input('Enter a new Core # or Press Enter to quit: ')
if(len(ret) == 0):
tb.stop()
sys.exit(0)
@@ -67,6 +69,6 @@ if __name__ == '__main__':
try:
n = int(ret)
except ValueError:
- print "Invalid number"
+ print("Invalid number")
else:
tb.filter_filt_0.set_processor_affinity([n,])
diff --git a/gnuradio-runtime/examples/mp-sched/plot_flops.py b/gnuradio-runtime/examples/mp-sched/plot_flops.py
index d9d810ae2f..e71770aee3 100755..100644
--- a/gnuradio-runtime/examples/mp-sched/plot_flops.py
+++ b/gnuradio-runtime/examples/mp-sched/plot_flops.py
@@ -23,12 +23,13 @@
Reads output from run_synthetic.py and runs gnuplot showing
GFLOPS as f(npipes, nstages)
"""
+from __future__ import unicode_literals
import re
import sys
import os
import tempfile
-from optparse import OptionParser
+from argparse import ArgumentParser
def parse_file(input_filename, output):
@@ -84,14 +85,11 @@ def handle_file(input_filename):
def main():
- usage = "usage: %prog [options] file.dat"
- parser = OptionParser(usage=usage)
- (options, args) = parser.parse_args()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
-
- handle_file(args[0])
+ parser = ArgumentParser()
+ parser.add_argument('file', help='Input file')
+ args = parser.parse_args()
+
+ handle_file(args.file)
if __name__ == '__main__':
diff --git a/gnuradio-runtime/examples/mp-sched/run_synthetic.py b/gnuradio-runtime/examples/mp-sched/run_synthetic.py
index 4896bca462..684f95bd87 100755..100644
--- a/gnuradio-runtime/examples/mp-sched/run_synthetic.py
+++ b/gnuradio-runtime/examples/mp-sched/run_synthetic.py
@@ -22,12 +22,14 @@
"""
Run synthetic.py for npipes in [1,16], nstages in [1,16]
"""
+from __future__ import division
+from __future__ import unicode_literals
import re
import sys
import os
import tempfile
-from optparse import OptionParser
+from argparse import ArgumentParser
def write_shell_script(f, data_filename, description, ncores, gflops, max_pipes_and_stages):
@@ -49,7 +51,7 @@ def write_shell_script(f, data_filename, description, ncores, gflops, max_pipes_
# We'd like each run of synthetic to take ~10 seconds
desired_time_per_run = 10
est_gflops_avail = min(nstages * npipes, ncores) * gflops
- nsamples = (est_gflops_avail * desired_time_per_run)/(512.0 * nstages * npipes)
+ nsamples = (est_gflops_avail * desired_time_per_run) / (512.0 * nstages * npipes)
nsamples = int(nsamples * 1e9)
cmd = "./synthetic.py -m -s %d -p %d -N %d\n" % (nstages, npipes, nsamples)
@@ -70,31 +72,26 @@ total runtime of about 43 minutes, assuming that your values for -n and -f are r
For x86 machines, assume 3 FLOPS per processor Hz. E.g., 3 GHz machine -> 9 GFLOPS.
plot_flops.py will make pretty graphs from the output data generated by %prog.
"""
- usage = "usage: %prog [options] output.dat"
- parser = OptionParser(usage=usage, description=description)
- parser.add_option("-d", "--description", metavar="DESC",
- help="machine description, e.g., \"Dual quad-core Xeon 3 GHz\"", default=None)
- parser.add_option("-n", "--ncores", type="int", default=1,
- help="number of processor cores [default=%default]")
- parser.add_option("-g", "--gflops", metavar="GFLOPS", type="float", default=3.0,
- help="estimated GFLOPS per core [default=%default]")
- parser.add_option("-m", "--max-pipes-and-stages", metavar="MAX", type="int", default=16,
- help="maximum number of pipes and stages to use [default=%default]")
- (options, args) = parser.parse_args()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
-
- output_filename = args[0]
+ parser = ArgumentParser(description=description)
+ parser.add_argument("-d", "--description", metavar="DESC",
+ help="machine description, e.g., \"Dual quad-core Xeon 3 GHz\"")
+ parser.add_argument("-n", "--ncores", type=int, default=1,
+ help="number of processor cores [default=%(default)s]")
+ parser.add_argument("-g", "--gflops", metavar="GFLOPS", type=float, default=3.0,
+ help="estimated GFLOPS per core [default=%(default)s]")
+ parser.add_argument("-m", "--max-pipes-and-stages", metavar="MAX", type=int, default=16,
+ help="maximum number of pipes and stages to use [default=%(default)s]")
+ parser.add_argument("output_file_name", metavar="FILE", help="output file name")
+ args = parser.parse_args()
shell = os.popen("/bin/sh", "w")
write_shell_script(shell,
- output_filename,
- options.description,
- options.ncores,
- options.gflops,
- options.max_pipes_and_stages)
+ args.output_file_name,
+ args.description,
+ args.ncores,
+ args.gflops,
+ args.max_pipes_and_stages)
if __name__ == '__main__':
main()
diff --git a/gnuradio-runtime/examples/mp-sched/synthetic.py b/gnuradio-runtime/examples/mp-sched/synthetic.py
index d815879cff..0f0b7b37cc 100755..100644
--- a/gnuradio-runtime/examples/mp-sched/synthetic.py
+++ b/gnuradio-runtime/examples/mp-sched/synthetic.py
@@ -19,10 +19,13 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr, eng_notation
from gnuradio import blocks, filter
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from gnuradio.eng_arg import eng_float, intx
+from argparse import ArgumentParser
import os
@@ -35,7 +38,7 @@ class pipeline(gr.hier_block2):
gr.hier_block2.__init__(self, "pipeline",
gr.io_signature(1, 1, gr.sizeof_float),
gr.io_signature(0, 0, 0))
- taps = ntaps*[1.0/ntaps]
+ taps = ntaps*[1.0 / ntaps]
upstream = self
for i in range(nstages):
op = filter.fir_filter_fff(1, taps)
@@ -50,61 +53,58 @@ class top(gr.top_block):
gr.top_block.__init__(self)
default_nsamples = 10e6
- parser=OptionParser(option_class=eng_option)
- parser.add_option("-p", "--npipelines", type="intx", default=1,
- metavar="NPIPES", help="the number of pipelines to create (default=%default)")
- parser.add_option("-s", "--nstages", type="intx", default=1,
- metavar="NSTAGES", help="the number of stages in each pipeline (default=%default)")
- parser.add_option("-N", "--nsamples", type="eng_float", default=default_nsamples,
+ parser = ArgumentParser()
+ parser.add_argument("-p", "--npipelines", type=intx, default=1,
+ metavar="NPIPES", help="the number of pipelines to create (default=%(default)s)")
+ parser.add_argument("-s", "--nstages", type=intx, default=1, metavar="NSTAGES",
+ help="the number of stages in each pipeline (default=%(default)s)")
+ parser.add_argument("-N", "--nsamples", type=eng_float, default=default_nsamples,
help=("the number of samples to run through the graph (default=%s)" %
(eng_notation.num_to_str(default_nsamples))))
- parser.add_option("-m", "--machine-readable", action="store_true", default=False,
+ parser.add_argument("-m", "--machine-readable", action="store_true", default=False,
help="enable machine readable output")
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- raise SystemExit, 1
+ args = parser.parse_args()
- self.npipes = options.npipelines
- self.nstages = options.nstages
- self.nsamples = options.nsamples
- self.machine_readable = options.machine_readable
+ self.npipes = args.npipelines
+ self.nstages = args.nstages
+ self.nsamples = args.nsamples
+ self.machine_readable = args.machine_readable
ntaps = 256
# Something vaguely like floating point ops
- self.flop = 2 * ntaps * options.npipelines * options.nstages * options.nsamples
+ self.flop = 2 * ntaps * args.npipelines * args.nstages * args.nsamples
src = blocks.null_source(gr.sizeof_float)
- head = blocks.head(gr.sizeof_float, int(options.nsamples))
+ head = blocks.head(gr.sizeof_float, int(args.nsamples))
self.connect(src, head)
- for n in range(options.npipelines):
- self.connect(head, pipeline(options.nstages, ntaps))
+ for n in range(args.npipelines):
+ self.connect(head, pipeline(args.nstages, ntaps))
def time_it(tb):
start = os.times()
tb.run()
stop = os.times()
- delta = map((lambda a, b: a-b), stop, start)
+ delta = list(map((lambda a, b: a-b), stop, start))
user, sys, childrens_user, childrens_sys, real = delta
total_user = user + childrens_user
total_sys = sys + childrens_sys
if tb.machine_readable:
- print "%3d %3d %.3e %7.3f %7.3f %7.3f %7.3f %.6e %.3e" % (
- tb.npipes, tb.nstages, tb.nsamples, real, total_user, total_sys, (total_user+total_sys)/real, tb.flop, tb.flop/real)
+ print("%3d %3d %.3e %7.3f %7.3f %7.3f %7.3f %.6e %.3e" % (
+ tb.npipes, tb.nstages, tb.nsamples, real, total_user, total_sys, (total_user+total_sys) / real, tb.flop, tb.flop / real))
else:
- print "npipes %7d" % (tb.npipes,)
- print "nstages %7d" % (tb.nstages,)
- print "nsamples %s" % (eng_notation.num_to_str(tb.nsamples),)
- print "real %7.3f" % (real,)
- print "user %7.3f" % (total_user,)
- print "sys %7.3f" % (total_sys,)
- print "(user+sys)/real %7.3f" % ((total_user + total_sys)/real,)
- print "pseudo_flop %s" % (eng_notation.num_to_str(tb.flop),)
- print "pseudo_flop/real %s" % (eng_notation.num_to_str(tb.flop/real),)
+ print("npipes %7d" % (tb.npipes,))
+ print("nstages %7d" % (tb.nstages,))
+ print("nsamples %s" % (eng_notation.num_to_str(tb.nsamples),))
+ print("real %7.3f" % (real,))
+ print("user %7.3f" % (total_user,))
+ print("sys %7.3f" % (total_sys,))
+ print("(user+sys)/real %7.3f" % ((total_user + total_sys) / real,))
+ print("pseudo_flop %s" % (eng_notation.num_to_str(tb.flop),))
+ print("pseudo_flop/real %s" % (eng_notation.num_to_str(tb.flop / real),))
if __name__ == "__main__":
@@ -112,7 +112,7 @@ if __name__ == "__main__":
tb = top()
time_it(tb)
except KeyboardInterrupt:
- raise SystemExit, 128
+ raise SystemExit(128)
diff --git a/gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py b/gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py
index 1a43dc3a11..93f26c6637 100755..100644
--- a/gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py
+++ b/gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py
@@ -20,12 +20,14 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr, gru, eng_notation, filter
from gnuradio import audio
from gnuradio import analog
from gnuradio import blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from gnuradio.eng_arg import eng_float, intx
+from argparse import ArgumentParser
import sys
import math
@@ -33,24 +35,20 @@ class wfm_rx_block (gr.top_block):
def __init__(self):
gr.top_block.__init__(self)
- usage = "usage: %prog [options] input-samples-320kS.dat output.wav"
- parser=OptionParser(option_class=eng_option, usage=usage)
- parser.add_option("-V", "--volume", type="eng_float", default=None,
- help="set volume (default is midpoint)")
+ parser = ArgumentParser(description="Decode WFM signal into WAV file.")
+ parser.add_argument("-V", "--volume", type=eng_float,
+ help="Volume (dB) <%r, %r> (default is midpoint)" % \
+ self.volume_range()[:2])
+ parser.add_argument("input_file", help="Input file (complex samples)")
+ parser.add_argument("output_file", help="Output WAV file")
- (options, args) = parser.parse_args()
- if len(args) != 2:
- parser.print_help()
- sys.exit(1)
-
- input_filename = args[0]
- output_filename = args[1]
+ args = parser.parse_args()
self.vol = 0
# build graph
- self.src = blocks.file_source(gr.sizeof_gr_complex, input_filename, False)
+ self.src = blocks.file_source(gr.sizeof_gr_complex, args.input_file, False)
adc_rate = 64e6 # 64 MS/s
usrp_decim = 200
@@ -80,10 +78,10 @@ class wfm_rx_block (gr.top_block):
# wave file as final sink
if 1:
- sink = blocks.wavfile_sink(output_filename, 2, int(audio_rate), 16)
+ sink = blocks.wavfile_sink(args.output_file, 2, int(audio_rate), 16)
else:
sink = audio.sink (int (audio_rate),
- options.audio_output,
+ args.audio_output,
False) # ok_to_block
# now wire it all together
@@ -96,15 +94,15 @@ class wfm_rx_block (gr.top_block):
pass
#print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet"
- if options.volume is None:
+ if args.volume is None:
g = self.volume_range()
- options.volume = float(g[0]+g[1])/2
+ args.volume = float(g[0]+g[1]) / 2
# set initial values
- self.set_vol(options.volume)
+ self.set_vol(args.volume)
try:
- self.guts.stereo_carrier_pll_recovery.set_lock_threshold(options.squelch)
+ self.guts.stereo_carrier_pll_recovery.set_lock_threshold(args.squelch)
except:
pass
#print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet"
@@ -113,8 +111,8 @@ class wfm_rx_block (gr.top_block):
def set_vol (self, vol):
g = self.volume_range()
self.vol = max(g[0], min(g[1], vol))
- self.volume_control_l.set_k(10**(self.vol/10))
- self.volume_control_r.set_k(10**(self.vol/10))
+ self.volume_control_l.set_k(10**(self.vol / 10))
+ self.volume_control_r.set_k(10**(self.vol / 10))
def volume_range(self):
return (-20.0, 0.0, 0.5)
diff --git a/gnuradio-runtime/examples/network/CMakeLists.txt b/gnuradio-runtime/examples/network/CMakeLists.txt
index 92eb734768..08f498b469 100644
--- a/gnuradio-runtime/examples/network/CMakeLists.txt
+++ b/gnuradio-runtime/examples/network/CMakeLists.txt
@@ -25,6 +25,4 @@ GR_PYTHON_INSTALL(PROGRAMS
vector_sink.py
vector_source.py
DESTINATION ${GR_PKG_DATA_DIR}/examples/network
- COMPONENT "runtime_python"
)
-
diff --git a/gnuradio-runtime/examples/network/audio_sink.py b/gnuradio-runtime/examples/network/audio_sink.py
index de20abe48d..9ebe8a4c80 100755..100644
--- a/gnuradio-runtime/examples/network/audio_sink.py
+++ b/gnuradio-runtime/examples/network/audio_sink.py
@@ -20,10 +20,10 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from argparse import ArgumentParser
import sys
try:
@@ -40,26 +40,22 @@ class audio_sink(gr.top_block):
self.connect(src, dst)
if __name__ == '__main__':
- parser = OptionParser(option_class=eng_option)
- parser.add_option("", "--host", type="string", default="0.0.0.0",
+ parser = ArgumentParser()
+ parser.add_argument("--host", default="0.0.0.0",
help="local host name (domain name or IP address)")
- parser.add_option("", "--port", type="int", default=65500,
+ parser.add_argument("--port", type=int, default=65500,
help="port value to listen to for connection")
- parser.add_option("", "--packet-size", type="int", default=1472,
+ parser.add_argument("--packet-size", type=int, default=1472,
help="packet size.")
- parser.add_option("-r", "--sample-rate", type="int", default=32000,
- help="audio signal sample rate [default=%default]")
- parser.add_option("", "--no-eof", action="store_true", default=False,
+ parser.add_argument("-r", "--sample-rate", type=int, default=32000,
+ help="audio signal sample rate [default=%(default)r]")
+ parser.add_argument("--no-eof", action="store_true", default=False,
help="don't send EOF on disconnect")
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- raise SystemExit, 1
-
+ args = parser.parse_args()
# Create an instance of a hierarchical block
- top_block = audio_sink(options.host, options.port,
- options.packet_size, options.sample_rate,
- not options.no_eof)
+ top_block = audio_sink(args.host, args.port,
+ args.packet_size, args.sample_rate,
+ not args.no_eof)
try:
# Run forever
diff --git a/gnuradio-runtime/examples/network/audio_source.py b/gnuradio-runtime/examples/network/audio_source.py
index 881efff81a..cc4a34c63f 100755..100644
--- a/gnuradio-runtime/examples/network/audio_source.py
+++ b/gnuradio-runtime/examples/network/audio_source.py
@@ -20,10 +20,10 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from argparse import ArgumentParser
import sys
try:
@@ -36,30 +36,26 @@ class audio_source(gr.top_block):
def __init__(self, host, port, pkt_size, sample_rate, eof):
gr.top_block.__init__(self, "audio_source")
self.audio = audio.source(sample_rate)
- self.sink = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
+ self.sink = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
self.connect(self.audio, self.sink)
if __name__ == '__main__':
- parser = OptionParser(option_class=eng_option)
- parser.add_option("", "--host", type="string", default="127.0.0.1",
+ parser = ArgumentParser()
+ parser.add_argument("--host", default="127.0.0.1",
help="Remote host name (domain name or IP address")
- parser.add_option("", "--port", type="int", default=65500,
+ parser.add_argument("--port", type=int, default=65500,
help="port number to connect to")
- parser.add_option("", "--packet-size", type="int", default=1472,
+ parser.add_argument("--packet-size", type=int, default=1472,
help="packet size.")
- parser.add_option("-r", "--sample-rate", type="int", default=32000 ,
- help="audio signal sample rate [default=%default]")
- parser.add_option("", "--no-eof", action="store_true", default=False,
+ parser.add_argument("-r", "--sample-rate", type=int, default=32000 ,
+ help="audio signal sample rate [default=%(default)r]")
+ parser.add_argument("--no-eof", action="store_true", default=False,
help="don't send EOF on disconnect")
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- raise SystemExit, 1
-
+ args = parser.parse_args()
# Create an instance of a hierarchical block
- top_block = audio_source(options.host, options.port,
- options.packet_size, options.sample_rate,
- not options.no_eof)
+ top_block = audio_source(args.host, args.port,
+ args.packet_size, args.sample_rate,
+ not args.no_eof)
try:
# Run forever
diff --git a/gnuradio-runtime/examples/network/dial_tone_sink.py b/gnuradio-runtime/examples/network/dial_tone_sink.py
index 7139a13250..e6acbb08d4 100755..100644
--- a/gnuradio-runtime/examples/network/dial_tone_sink.py
+++ b/gnuradio-runtime/examples/network/dial_tone_sink.py
@@ -20,10 +20,10 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import unicode_literals
from gnuradio import gr, audio
from gnuradio import blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from argparse import ArgumentParser
class dial_tone_sink(gr.top_block):
def __init__(self, host, port, pkt_size, sample_rate, eof):
@@ -33,26 +33,22 @@ class dial_tone_sink(gr.top_block):
self.connect(udp, sink)
if __name__ == '__main__':
- parser = OptionParser(option_class=eng_option)
- parser.add_option("", "--host", type="string", default="0.0.0.0",
+ parser = ArgumentParser()
+ parser.add_argument("--host", default="0.0.0.0",
help="local host name (domain name or IP address)")
- parser.add_option("", "--port", type="int", default=65500,
+ parser.add_argument("--port", type=int, default=65500,
help="port value to listen to for connection")
- parser.add_option("", "--packet-size", type="int", default=1472,
+ parser.add_argument("--packet-size", type=int, default=1472,
help="packet size.")
- parser.add_option("-r", "--sample-rate", type="int", default=8000,
- help="audio signal sample rate [default=%default]")
- parser.add_option("", "--no-eof", action="store_true", default=False,
+ parser.add_argument("-r", "--sample-rate", type=int, default=8000,
+ help="audio signal sample rate [default=%(default)r]")
+ parser.add_argument("--no-eof", action="store_true", default=False,
help="don't send EOF on disconnect")
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- raise SystemExit, 1
-
+ args = parser.parse_args()
# Create an instance of a hierarchical block
- top_block = dial_tone_sink(options.host, options.port,
- options.packet_size, options.sample_rate,
- not options.no_eof)
+ top_block = dial_tone_sink(args.host, args.port,
+ args.packet_size, args.sample_rate,
+ not args.no_eof)
try:
# Run forever
diff --git a/gnuradio-runtime/examples/network/dial_tone_source.py b/gnuradio-runtime/examples/network/dial_tone_source.py
index 20c9a3b800..aa3ab9954f 100755..100644
--- a/gnuradio-runtime/examples/network/dial_tone_source.py
+++ b/gnuradio-runtime/examples/network/dial_tone_source.py
@@ -20,9 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import unicode_literals
from gnuradio import gr
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from argparse import ArgumentParser
import sys
try:
@@ -45,33 +45,29 @@ class dial_tone_source(gr.top_block):
add = blocks.add_ff()
# Throttle needed here to account for the other side's audio card sampling rate
- thr = blocks.throttle(gr.sizeof_float, sample_rate)
- sink = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
- self.connect(src0, (add, 0))
- self.connect(src1, (add, 1))
- self.connect(add, thr, sink)
+ thr = blocks.throttle(gr.sizeof_float, sample_rate)
+ sink = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
+ self.connect(src0, (add, 0))
+ self.connect(src1, (add, 1))
+ self.connect(add, thr, sink)
if __name__ == '__main__':
- parser = OptionParser(option_class=eng_option)
- parser.add_option("", "--host", type="string", default="127.0.0.1",
+ parser = ArgumentParser()
+ parser.add_argument("--host", default="127.0.0.1",
help="Remote host name (domain name or IP address")
- parser.add_option("", "--port", type="int", default=65500,
+ parser.add_argument("--port", type=int, default=65500,
help="port number to connect to")
- parser.add_option("", "--packet-size", type="int", default=1472,
+ parser.add_argument("--packet-size", type=int, default=1472,
help="packet size.")
- parser.add_option("-r", "--sample-rate", type="int", default=8000,
- help="audio signal sample rate [default=%default]")
- parser.add_option("", "--no-eof", action="store_true", default=False,
+ parser.add_argument("-r", "--sample-rate", type=int, default=8000,
+ help="audio signal sample rate [default=%(default)r]")
+ parser.add_argument("--no-eof", action="store_true", default=False,
help="don't send EOF on disconnect")
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- raise SystemExit, 1
-
+ args = parser.parse_args()
# Create an instance of a hierarchical block
- top_block = dial_tone_source(options.host, options.port,
- options.packet_size, options.sample_rate,
- not options.no_eof)
+ top_block = dial_tone_source(args.host, args.port,
+ args.packet_size, args.sample_rate,
+ not args.no_eof)
try:
# Run forever
diff --git a/gnuradio-runtime/examples/network/vector_sink.py b/gnuradio-runtime/examples/network/vector_sink.py
index c756f36f42..a8850d8a01 100755..100644
--- a/gnuradio-runtime/examples/network/vector_sink.py
+++ b/gnuradio-runtime/examples/network/vector_sink.py
@@ -20,10 +20,11 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from gnuradio.eng_arg import eng_float, intx
+from argparse import ArgumentParser
class vector_sink(gr.top_block):
def __init__(self, host, port, pkt_size, eof):
@@ -34,24 +35,20 @@ class vector_sink(gr.top_block):
self.connect(udp, sink)
if __name__ == "__main__":
- parser = OptionParser(option_class=eng_option)
- parser.add_option("", "--host", type="string", default="0.0.0.0",
+ parser = ArgumentParser()
+ parser.add_argument("-H", "--host", default="0.0.0.0",
help="local host name (domain name or IP address)")
- parser.add_option("", "--port", type="int", default=65500,
+ parser.add_argument("-p", "--port", type=int, default=65500,
help="port value to listen to for connection")
- parser.add_option("", "--packet-size", type="int", default=1471,
+ parser.add_argument("-s", "--packet-size", type=int, default=1471,
help="packet size.")
- parser.add_option("", "--no-eof", action="store_true", default=False,
+ parser.add_argument("--no-eof", action="store_true", default=False,
help="don't send EOF on disconnect")
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- raise SystemExit, 1
-
+ args = parser.parse_args()
# Create an instance of a hierarchical block
- top_block = vector_sink(options.host, options.port,
- options.packet_size,
- not options.no_eof)
+ top_block = vector_sink(args.host, args.port,
+ args.packet_size,
+ not args.no_eof)
try:
# Run forever
diff --git a/gnuradio-runtime/examples/network/vector_source.py b/gnuradio-runtime/examples/network/vector_source.py
index c13b4b1d6f..cf8d0000c2 100755..100644
--- a/gnuradio-runtime/examples/network/vector_source.py
+++ b/gnuradio-runtime/examples/network/vector_source.py
@@ -20,10 +20,10 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
+from argparse import ArgumentParser
class vector_source(gr.top_block):
def __init__(self, host, port, pkt_size, eof):
@@ -34,23 +34,19 @@ class vector_source(gr.top_block):
self.connect(vec, udp)
if __name__ == '__main__':
- parser = OptionParser(option_class=eng_option)
- parser.add_option("", "--host", type="string", default="127.0.0.1",
+ parser = ArgumentParser()
+ parser.add_argument("--host", default="127.0.0.1",
help="Remote host name (domain name or IP address")
- parser.add_option("", "--port", type="int", default=65500,
+ parser.add_argument("--port", type=int, default=65500,
help="port number to connect to")
- parser.add_option("", "--packet-size", type="int", default=1471,
+ parser.add_argument("--packet-size", type=int, default=1471,
help="packet size.")
- parser.add_option("", "--no-eof", action="store_true", default=False,
+ parser.add_argument("--no-eof", action="store_true", default=False,
help="don't send EOF on disconnect")
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- raise SystemExit, 1
-
+ args = parser.parse_args()
# Create an instance of a hierarchical block
- top_block = vector_source(options.host, options.port, options.packet_size,
- not options.no_eof)
+ top_block = vector_source(args.host, args.port, args.packet_size,
+ not args.no_eof)
try:
# Run forever
diff --git a/gnuradio-runtime/examples/volk_benchmark/CMakeLists.txt b/gnuradio-runtime/examples/volk_benchmark/CMakeLists.txt
index f56675e556..076ef359e8 100644
--- a/gnuradio-runtime/examples/volk_benchmark/CMakeLists.txt
+++ b/gnuradio-runtime/examples/volk_benchmark/CMakeLists.txt
@@ -25,11 +25,9 @@ GR_PYTHON_INSTALL(PROGRAMS
volk_test_funcs.py
volk_types.py
DESTINATION ${GR_PKG_DATA_DIR}/examples/volk_benchmark
- COMPONENT "runtime_python"
)
install(
FILES README
DESTINATION ${GR_PKG_DATA_DIR}/examples/volk_benchmark
- COMPONENT "runtime_python"
)
diff --git a/gnuradio-runtime/examples/volk_benchmark/volk_math.py b/gnuradio-runtime/examples/volk_benchmark/volk_math.py
index 753257c237..6fc6cfa78d 100755..100644
--- a/gnuradio-runtime/examples/volk_benchmark/volk_math.py
+++ b/gnuradio-runtime/examples/volk_benchmark/volk_math.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+from __future__ import print_function
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import blocks
import argparse
@@ -87,7 +89,7 @@ def run_tests(func, N, iters):
res = format_results(func.__name__, t)
return res
except AttributeError:
- print "\tCould not run test. Skipping."
+ print("\tCould not run test. Skipping.")
return None
def main():
@@ -119,7 +121,7 @@ def main():
default=20,
help='Number of iterations [default: %(default)s]')
parser.add_argument('--tests', type=int, nargs='*',
- choices=xrange(len(avail_tests)),
+ choices=list(range(len(avail_tests))),
help='A list of tests to run; can be a single test or a \
space-separated list.')
parser.add_argument('--list', action='store_true',
@@ -129,8 +131,8 @@ def main():
args = parser.parse_args()
if(args.list):
- print "Available Tests to Run:"
- print "\n".join(["\t{0}: {1}".format(i,f.__name__) for i,f in enumerate(avail_tests)])
+ print("Available Tests to Run:")
+ print("\n".join(["\t{0}: {1}".format(i,f.__name__) for i,f in enumerate(avail_tests)]))
sys.exit(0)
N = int(args.nitems)
@@ -141,7 +143,7 @@ def main():
new_table(conn, label)
if args.all:
- tests = xrange(len(avail_tests))
+ tests = list(range(len(avail_tests)))
else:
tests = args.tests
diff --git a/gnuradio-runtime/examples/volk_benchmark/volk_plot.py b/gnuradio-runtime/examples/volk_benchmark/volk_plot.py
index 48f9922054..2e02773e05 100755..100644
--- a/gnuradio-runtime/examples/volk_benchmark/volk_plot.py
+++ b/gnuradio-runtime/examples/volk_benchmark/volk_plot.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+from __future__ import division
+from __future__ import unicode_literals
import sys, math
import argparse
from volk_test_funcs import *
@@ -100,7 +102,7 @@ def main():
# Plot the results
- x0 = xrange(len(name_reg))
+ x0 = list(range(len(name_reg)))
i = 0
for t in (table_data):
ydata = []
@@ -119,7 +121,7 @@ def main():
if(args.percent != t):
# makes x values for this data set placement
# width of bars depends on number of comparisons
- wdth = 0.80/(M-1)
+ wdth = 0.80 / (M-1)
x1 = [x + i*wdth for x in x0]
i += 1
@@ -130,7 +132,7 @@ def main():
else:
# makes x values for this data set placement
# width of bars depends on number of comparisons
- wdth = 0.80/M
+ wdth = 0.80 / M
x1 = [x + i*wdth for x in x0]
i += 1
diff --git a/gnuradio-runtime/examples/volk_benchmark/volk_test_funcs.py b/gnuradio-runtime/examples/volk_benchmark/volk_test_funcs.py
index a7dd7b705c..603c2ae5c3 100644
--- a/gnuradio-runtime/examples/volk_benchmark/volk_test_funcs.py
+++ b/gnuradio-runtime/examples/volk_benchmark/volk_test_funcs.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+from __future__ import print_function
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import blocks
import math, sys, os, time
@@ -122,18 +124,18 @@ class helper(gr.top_block):
self.snks = []
self.head = blocks.head(isizeof, N)
- for n in xrange(nsrcs):
+ for n in range(nsrcs):
self.srcs.append(blocks.null_source(isizeof))
- for n in xrange(nsnks):
+ for n in range(nsnks):
self.snks.append(blocks.null_sink(osizeof))
self.connect(self.srcs[0], self.head, (self.op,0))
- for n in xrange(1, nsrcs):
+ for n in range(1, nsrcs):
self.connect(self.srcs[n], (self.op,n))
- for n in xrange(nsnks):
+ for n in range(nsnks):
self.connect((self.op,n), self.snks[n])
def timeit(tb, iterations):
@@ -143,10 +145,10 @@ def timeit(tb, iterations):
'''
r = gr.enable_realtime_scheduling()
if r != gr.RT_OK:
- print "Warning: failed to enable realtime scheduling"
+ print("Warning: failed to enable realtime scheduling")
times = []
- for i in xrange(iterations):
+ for i in range(iterations):
start_time = time.time()
tb.run()
end_time = time.time()
diff --git a/gnuradio-runtime/examples/volk_benchmark/volk_types.py b/gnuradio-runtime/examples/volk_benchmark/volk_types.py
index 546e9629c0..697ec213c1 100755..100644
--- a/gnuradio-runtime/examples/volk_benchmark/volk_types.py
+++ b/gnuradio-runtime/examples/volk_benchmark/volk_types.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+from __future__ import print_function
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import blocks
import argparse
@@ -105,7 +107,7 @@ def run_tests(func, N, iters):
res = format_results(func.__name__, t)
return res
except AttributeError:
- print "\tCould not run test. Skipping."
+ print("\tCould not run test. Skipping.")
return None
def main():
@@ -143,7 +145,7 @@ def main():
default=20,
help='Number of iterations [default: %(default)s]')
parser.add_argument('--tests', type=int, nargs='*',
- choices=xrange(len(avail_tests)),
+ choices=list(range(len(avail_tests))),
help='A list of tests to run; can be a single test or a \
space-separated list.')
parser.add_argument('--list', action='store_true',
@@ -153,8 +155,8 @@ def main():
args = parser.parse_args()
if(args.list):
- print "Available Tests to Run:"
- print "\n".join(["\t{0}: {1}".format(i,f.__name__) for i,f in enumerate(avail_tests)])
+ print("Available Tests to Run:")
+ print("\n".join(["\t{0}: {1}".format(i,f.__name__) for i,f in enumerate(avail_tests)]))
sys.exit(0)
N = int(args.nitems)
@@ -165,7 +167,7 @@ def main():
new_table(conn, label)
if args.all:
- tests = xrange(len(avail_tests))
+ tests = list(range(len(avail_tests)))
else:
tests = args.tests
diff --git a/gnuradio-runtime/include/gnuradio/CMakeLists.txt b/gnuradio-runtime/include/gnuradio/CMakeLists.txt
index 472f91847b..045f140e75 100644
--- a/gnuradio-runtime/include/gnuradio/CMakeLists.txt
+++ b/gnuradio-runtime/include/gnuradio/CMakeLists.txt
@@ -44,6 +44,7 @@ install(FILES
hier_block2.h
high_res_timer.h
io_signature.h
+ logger.h
math.h
message.h
misc.h
@@ -70,7 +71,6 @@ install(FILES
sys_paths.h
tag_checker.h
types.h
- sys_pri.h
unittests.h
rpccallbackregister_base.h
rpcmanager_base.h
@@ -81,9 +81,7 @@ install(FILES
rpcserver_booter_aggregator.h
rpcserver_booter_base.h
rpcserver_selector.h
- ${CMAKE_CURRENT_BINARY_DIR}/logger.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio
- COMPONENT "runtime_devel"
)
if(THRIFT_FOUND)
@@ -92,14 +90,5 @@ install(FILES
thrift_application_base.h
thrift_server_template.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio
- COMPONENT "runtime_devel"
)
endif(THRIFT_FOUND)
-
-##########################################################################
-# Configure logger
-##########################################################################
-CONFIGURE_FILE(
- ${CMAKE_CURRENT_SOURCE_DIR}/logger.h.in
- ${CMAKE_CURRENT_BINARY_DIR}/logger.h
-)
diff --git a/gnuradio-runtime/include/gnuradio/basic_block.h b/gnuradio-runtime/include/gnuradio/basic_block.h
index 3c54d0ad8b..1b36999f5a 100644
--- a/gnuradio-runtime/include/gnuradio/basic_block.h
+++ b/gnuradio-runtime/include/gnuradio/basic_block.h
@@ -153,6 +153,7 @@ namespace gr {
* and never changes during the life of the block.
*/
std::string symbol_name() const { return d_symbol_name; }
+ std::string identifier() const { return this->name() + "(" + std::to_string(this->unique_id()) + ")"; }
gr::io_signature::sptr input_signature() const { return d_input_signature; }
gr::io_signature::sptr output_signature() const { return d_output_signature; }
@@ -252,13 +253,6 @@ namespace gr {
*/
pmt::pmt_t delete_head_nowait( pmt::pmt_t which_port);
- /*!
- * \param[in] which_port The message port from which to get the message.
- * \param[in] millisec Optional timeout value (0=no timeout).
- * \returns returns pmt at head of queue or pmt::pmt_t() if empty.
- */
- pmt::pmt_t delete_head_blocking(pmt::pmt_t which_port, unsigned int millisec = 0);
-
msg_queue_t::iterator get_iterator(pmt::pmt_t which_port) {
return msg_queue[which_port].begin();
}
@@ -376,15 +370,15 @@ namespace gr {
d_msg_handlers[which_port] = msg_handler_t(msg_handler);
}
- virtual void set_processor_affinity(const std::vector<int> &mask)
- { (void) mask;
- throw std::runtime_error("set_processor_affinity not overloaded in child class."); }
+ virtual void set_processor_affinity(const std::vector<int> &mask) = 0;
+
+ virtual void unset_processor_affinity() = 0;
+
+ virtual std::vector<int> processor_affinity() = 0;
- virtual void unset_processor_affinity()
- { throw std::runtime_error("unset_processor_affinity not overloaded in child class."); }
+ virtual void set_log_level(std::string level) = 0;
- virtual std::vector<int> processor_affinity()
- { throw std::runtime_error("processor_affinity not overloaded in child class."); }
+ virtual std::string log_level() = 0;
};
inline bool operator<(basic_block_sptr lhs, basic_block_sptr rhs)
@@ -399,7 +393,7 @@ namespace gr {
inline std::ostream &operator << (std::ostream &os, basic_block_sptr basic_block)
{
- os << basic_block->name() << "(" << basic_block->unique_id() << ")";
+ os << basic_block->identifier();
return os;
}
diff --git a/gnuradio-runtime/include/gnuradio/block.h b/gnuradio-runtime/include/gnuradio/block.h
index 6fce9a9e72..e2b35309dc 100644
--- a/gnuradio-runtime/include/gnuradio/block.h
+++ b/gnuradio-runtime/include/gnuradio/block.h
@@ -584,17 +584,17 @@ namespace gr {
std::vector<float> pc_input_buffers_full_var();
/*!
- * \brief Gets instantaneous fullness of \p which input buffer.
+ * \brief Gets instantaneous fullness of \p which output buffer.
*/
float pc_output_buffers_full(int which);
/*!
- * \brief Gets average fullness of \p which input buffer.
+ * \brief Gets average fullness of \p which output buffer.
*/
float pc_output_buffers_full_avg(int which);
/*!
- * \brief Gets variance of fullness of \p which input buffer.
+ * \brief Gets variance of fullness of \p which output buffer.
*/
float pc_output_buffers_full_var(int which);
@@ -706,6 +706,30 @@ namespace gr {
*/
void system_handler(pmt::pmt_t msg);
+ /*!
+ * \brief Set the logger's output level.
+ *
+ * Sets the level of the logger. This takes a string that is
+ * translated to the standard levels and can be (case insensitive):
+ *
+ * \li off , notset
+ * \li debug
+ * \li info
+ * \li notice
+ * \li warn
+ * \li error
+ * \li crit
+ * \li alert
+ * \li fatal
+ * \li emerg
+ */
+ void set_log_level(std::string level);
+
+ /*!
+ * \brief Get the logger's output level
+ */
+ std::string log_level();
+
/*!
* \brief returns true when execution has completed due to a message connection
*/
@@ -929,6 +953,8 @@ namespace gr {
*/
void clear_finished(){ d_finished = false; }
+ std::string identifier() const;
+
};
typedef std::vector<block_sptr> block_vector_t;
diff --git a/gnuradio-runtime/include/gnuradio/flowgraph.h b/gnuradio-runtime/include/gnuradio/flowgraph.h
index 280c01fc28..c7e5cb9a5c 100644
--- a/gnuradio-runtime/include/gnuradio/flowgraph.h
+++ b/gnuradio-runtime/include/gnuradio/flowgraph.h
@@ -45,8 +45,11 @@ namespace gr {
endpoint(basic_block_sptr block, int port) { d_basic_block = block; d_port = port; }
basic_block_sptr block() const { return d_basic_block; }
int port() const { return d_port; }
+ std::string identifier() const {
+ return d_basic_block->alias() + ":" + std::to_string(d_port);
+ };
- bool operator==(const endpoint &other) const;
+ bool operator==(const endpoint& other) const;
};
inline bool endpoint::operator==(const endpoint &other) const
@@ -71,6 +74,9 @@ namespace gr {
pmt::pmt_t port() const { return d_port; }
bool is_hier() const { return d_is_hier; }
void set_hier(bool h) { d_is_hier = h; }
+ std::string identifier() const {
+ return d_basic_block->alias() + ":" + pmt::symbol_to_string(d_port);
+ }
bool operator==(const msg_endpoint &other) const;
};
@@ -99,6 +105,7 @@ namespace gr {
const endpoint &src() const { return d_src; }
const endpoint &dst() const { return d_dst; }
+ std::string identifier() const { return d_src.identifier() + "->" + d_dst.identifier(); }
private:
endpoint d_src;
@@ -123,6 +130,7 @@ namespace gr {
const msg_endpoint &src() const { return d_src; }
const msg_endpoint &dst() const { return d_dst; }
+ std::string identifier() const { return d_src.identifier() + "->" + d_dst.identifier(); }
private:
msg_endpoint d_src;
@@ -286,28 +294,28 @@ namespace gr {
inline std::ostream&
operator <<(std::ostream &os, const endpoint endp)
{
- os << endp.block()->alias() << ":" << endp.port();
+ os << endp.identifier();
return os;
}
inline std::ostream&
operator <<(std::ostream &os, const edge edge)
{
- os << edge.src() << "->" << edge.dst();
+ os << edge.identifier();
return os;
}
inline std::ostream&
operator <<(std::ostream &os, const msg_endpoint endp)
{
- os << endp.block()->alias() << ":" << pmt::symbol_to_string(endp.port());
+ os << endp.identifier();
return os;
}
inline std::ostream&
operator <<(std::ostream &os, const msg_edge edge)
{
- os << edge.src() << "->" << edge.dst();
+ os << edge.identifier();
return os;
}
diff --git a/gnuradio-runtime/include/gnuradio/hier_block2.h b/gnuradio-runtime/include/gnuradio/hier_block2.h
index 08a5389e96..b7c6be2441 100644
--- a/gnuradio-runtime/include/gnuradio/hier_block2.h
+++ b/gnuradio-runtime/include/gnuradio/hier_block2.h
@@ -267,6 +267,31 @@ namespace gr {
std::vector<int> processor_affinity();
/*!
+ * \brief Set the logger's output level.
+ *
+ * Sets the level of the logger for all connected blocks. This takes
+ * a string that is translated to the standard levels and can be
+ * (case insensitive):
+ *
+ * \li off , notset
+ * \li debug
+ * \li info
+ * \li notice
+ * \li warn
+ * \li error
+ * \li crit
+ * \li alert
+ * \li fatal
+ * \li emerg
+ */
+ void set_log_level(std::string level);
+
+ /*!
+ * \brief Get the logger's output level
+ */
+ std::string log_level();
+
+ /*!
* \brief Get if all block min buffers should be set.
*
* \details this returns whether all the block min output buffers
diff --git a/gnuradio-runtime/include/gnuradio/logger.h.in b/gnuradio-runtime/include/gnuradio/logger.h
index e9296dbaab..12585159be 100644
--- a/gnuradio-runtime/include/gnuradio/logger.h.in
+++ b/gnuradio-runtime/include/gnuradio/logger.h
@@ -20,12 +20,6 @@
* Boston, MA 02110-1301, USA.
*/
-/*******************************************************************************
-* Author: Mark Plett
-* Description:
-* The gr::logger module wraps the log4cpp library for logging in gnuradio
-*******************************************************************************/
-
#ifndef INCLUDED_GR_LOGGER_H
#define INCLUDED_GR_LOGGER_H
@@ -35,62 +29,8 @@
*
*/
-// handle current status of GR_LOG
-#ifdef EXT_ENABLE_GR_LOG
-#undef EXT_ENABLE_GR_LOG
-#endif
-#ifdef ENABLE_GR_LOG
-#define EXT_ENABLE_GR_LOG
-#undef ENABLE_GR_LOG
-#endif
-
-// did GR enable LOG?
-#cmakedefine ENABLE_GR_LOG
-
-// if GR does not provide logging and the current module is requesting
-// it, disable it.
-#if defined(EXT_ENABLE_GR_LOG) && !defined(ENABLE_GR_LOG)
-#warning "Logging was requested but is not enabled in GNU Radio, so disabling."
-#undef EXT_ENABLE_GR_LOG
-#endif
-
-// if GR provides logging but the current module is not requesting it,
-// disable it.
-#if !defined(EXT_ENABLE_GR_LOG) && defined(ENABLE_GR_LOG)
-#undef ENABLE_GR_LOG
-#endif
-
-// the other 2 cases work; no need to check them!
-
-// handle current status of LOG4CPP
-#ifdef EXT_HAVE_LOG4CPP
-#undef EXT_HAVE_LOG4CPP
-#endif
-#ifdef HAVE_LOG4CPP
-#define EXT_HAVE_LOG4CPP
-#undef HAVE_LOG4CPP
-#endif
-
-// did GR use log4cpp?
-#cmakedefine HAVE_LOG4CPP
-
-// if GR does not use log4cpp and the current module is requesting it,
-// disable it & print a warning.
-#if defined(EXT_HAVE_LOG4CPP) && !defined(HAVE_LOG4CPP)
-#warning "Log4Cpp use was requested but was not in GNU Radio, so disabling."
-#undef EXT_HAVE_LOG4CPP
-#endif
-
-// if GR provides for using log4cpp but the current module is not
-// requesting it, disable it quietly.
-#if !defined(EXT_HAVE_LOG4CPP) && defined(HAVE_LOG4CPP)
-#undef HAVE_LOG4CPP
-#endif
-
-// the other 2 cases work; no need to check them!
-
#ifdef _MSC_VER
-typedef unsigned short mode_t;
+typedef int mode_t;
#else
#include <sys/types.h>
#endif
@@ -103,71 +43,6 @@ typedef unsigned short mode_t;
#include <boost/thread.hpp>
#include <boost/format.hpp>
#include <pmt/pmt.h>
-
-#ifdef ENABLE_GR_LOG
-
-// We have three configurations... first logging to stdout/stderr
-#ifndef HAVE_LOG4CPP
-
-namespace gr {
- //#warning GR logging Enabled and using std::cout
- typedef void* logger_ptr;
-} /* namespace gr */
-
-#define GR_LOG_DECLARE_LOGPTR(logger)
-#define GR_LOG_ASSIGN_LOGPTR(logger,name)
-#define GR_CONFIG_LOGGER(config)
-#define GR_CONFIG_AND_WATCH_LOGGER(config,period)
-#define GR_LOG_GETLOGGER(logger, name)
-#define GR_SET_LEVEL(name, level)
-#define GR_LOG_SET_LEVEL(logger, level)
-#define GR_GET_LEVEL(name, level)
-#define GR_LOG_GET_LEVEL(logger, level)
-#define GR_ADD_APPENDER(name,appender)
-#define GR_LOG_ADD_APPENDER(logger,appender)
-#define GR_SET_APPENDER(name,appender)
-#define GR_LOG_SET_APPENDER(logger,appender)
-#define GR_ADD_CONSOLE_APPENDER(logger,target,pattern)
-#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern)
-#define GR_SET_CONSOLE_APPENDER(logger,target,pattern)
-#define GR_LOG_SET_CONSOLE_APPENDER(logger,target,pattern)
-#define GR_ADD_FILE_APPENDER(name,filename,append,pattern)
-#define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern)
-#define GR_SET_FILE_APPENDER(name,filename,append,pattern)
-#define GR_LOG_SET_FILE_APPENDER(logger,filename,append,pattern)
-#define GR_ADD_ROLLINGFILE_APPENDER(name,filename,filesize,bkup_index,append,mode,pattern)
-#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,filename,filesize,bkup_index,append,mode,pattern)
-#define GR_GET_LOGGER_NAMES(names)
-#define GR_RESET_CONFIGURATION()
-#define GR_DEBUG(name, msg) std::cout<<"DEBUG: "<<msg<<std::endl
-#define GR_INFO(name, msg) std::cout<<"INFO: "<<msg<<std::endl
-#define GR_NOTICE(name, msg) std::cout<<"NOTICE: "<<msg<<std::endl
-#define GR_WARN(name, msg) std::cerr<<"WARN: "<<msg<<std::endl
-#define GR_ERROR(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl
-#define GR_ALERT(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl
-#define GR_CRIT(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl
-#define GR_FATAL(name, msg) std::cerr<<"FATAL: "<<msg<<std::endl
-#define GR_EMERG(name, msg) std::cerr<<"EMERG: "<<msg<<std::endl
-#define GR_ERRORIF(name, cond, msg) {if((cond)) std::cerr<<"ERROR: "<<msg<<std::endl;}
-#define GR_ASSERT(name, cond, msg) {if(!(cond)) std::cerr<<"FATAL: "<<msg<<std::endl; assert(cond);}
-#define GR_LOG_DEBUG(logger, msg) std::cout<<"DEBUG: "<<msg<<std::endl
-#define GR_LOG_INFO(logger, msg) std::cout<<"INFO: "<<msg<<std::endl
-#define GR_LOG_NOTICE(logger, msg) std::cout<<"NOTICE: "<<msg<<std::endl
-#define GR_LOG_WARN(logger, msg) std::cerr<<"WARN: "<<msg<<std::endl
-#define GR_LOG_ERROR(logger, msg) std::cerr<<"ERROR: "<<msg<<std::endl
-#define GR_LOG_ALERT(logger, msg) std::cerr<<"ALERT: "<<msg<<std::endl
-#define GR_LOG_CRIT(logger, msg) std::cerr<<"CRIT: "<<msg<<std::endl
-#define GR_LOG_FATAL(logger, msg) std::cerr<<"FATAL: "<<msg<<std::endl
-#define GR_LOG_EMERG(logger, msg) std::cerr<<"EMERG: "<<msg<<std::endl
-#define GR_LOG_ERRORIF(logger, cond, msg) { \
- if((cond)) std::cerr<<"ERROR: "<<msg<<std::endl;}
-#define GR_LOG_ASSERT(logger, cond, msg) { \
- if(!(cond)) {std::cerr<<"FATAL: "<<msg<<std::endl; assert(cond);};}
-
-
-#else /* HAVE_LOG4CPP */
-
-// Second configuration...logging to log4cpp
#include <log4cpp/Category.hh>
#include <log4cpp/PropertyConfigurator.hh>
#include <log4cpp/FileAppender.hh>
@@ -197,7 +72,6 @@ namespace gr {
} /* namespace gr */
-
/* Macros for Programmatic Configuration */
#define GR_LOG_DECLARE_LOGPTR(logger) \
gr::logger_ptr logger;
@@ -228,20 +102,6 @@ namespace gr {
#define GR_LOG_GET_LEVEL(logger, level) \
gr::logger_get_level(logger,level);
-#define GR_ADD_APPENDER(name, appender) { \
- gr::logger_ptr logger = gr::logger_get_logger(name); \
- gr::logger_add_appender(logger,appender);}
-
-#define GR_LOG_ADD_APPENDER(logger, appender) { \
- gr::logger_add_appender(logger, appender);}
-
-#define GR_SET_APPENDER(name, appender) { \
- gr::logger_ptr logger = gr::logger_get_logger(name); \
- gr::logger_set_appender(logger,appender);}
-
-#define GR_LOG_SET_APPENDER(logger, appender) { \
- gr::logger_set_appender(logger, appender);}
-
#define GR_ADD_CONSOLE_APPENDER(name, target, pattern) { \
gr::logger_ptr logger = gr::logger_get_logger(name); \
gr::logger_add_console_appender(logger,target,pattern);}
@@ -687,69 +547,8 @@ namespace gr {
} /* namespace gr */
-#endif /* HAVE_LOG4CPP */
-
// If Logger disable do nothing
-#else /* ENABLE_GR_LOG */
-
namespace gr {
- typedef void* logger_ptr;
-} /* namespace gr */
-
-#define GR_LOG_DECLARE_LOGPTR(logger)
-#define GR_LOG_ASSIGN_LOGPTR(logger,name)
-#define GR_CONFIG_LOGGER(config)
-#define GR_CONFIG_AND_WATCH_LOGGER(config,period)
-#define GR_LOG_GETLOGGER(logger, name)
-#define GR_SET_LEVEL(name, level)
-#define GR_LOG_SET_LEVEL(logger, level)
-#define GR_GET_LEVEL(name, level)
-#define GR_LOG_GET_LEVEL(logger, level)
-#define GR_ADD_APPENDER(name,appender)
-#define GR_LOG_ADD_APPENDER(logger,appender)
-#define GR_SET_APPENDER(name,appender)
-#define GR_LOG_SET_APPENDER(logger,appender)
-#define GR_ADD_CONSOLE_APPENDER(logger,target,pattern)
-#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern)
-#define GR_SET_CONSOLE_APPENDER(logger,target,pattern)
-#define GR_LOG_SET_CONSOLE_APPENDER(logger,target,pattern)
-#define GR_ADD_FILE_APPENDER(name,filename,append,pattern)
-#define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern)
-#define GR_SET_FILE_APPENDER(name,filename,append,pattern)
-#define GR_LOG_SET_FILE_APPENDER(logger,filename,append,pattern)
-#define GR_ADD_ROLLINGFILE_APPENDER(name,filename,filesize,bkup_index,append,mode,pattern)
-#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,filename,filesize,bkup_index,append,mode,pattern)
-#define GR_GET_LOGGER_NAMES(names)
-#define GR_RESET_CONFIGURATION()
-#define GR_DEBUG(name, msg)
-#define GR_INFO(name, msg)
-#define GR_NOTICE(name, msg)
-#define GR_WARN(name, msg)
-#define GR_ERROR(name, msg)
-#define GR_ALERT(name, msg)
-#define GR_CRIT(name, msg)
-#define GR_FATAL(name, msg)
-#define GR_EMERG(name, msg)
-#define GR_ERRORIF(name, cond, msg)
-#define GR_ASSERT(name, cond, msg)
-#define GR_LOG_DEBUG(logger, msg)
-#define GR_LOG_INFO(logger, msg)
-#define GR_LOG_NOTICE(logger, msg)
-#define GR_LOG_WARN(logger, msg)
-#define GR_LOG_ERROR(logger, msg)
-#define GR_LOG_ALERT(logger, msg)
-#define GR_LOG_CRIT(logger, msg)
-#define GR_LOG_FATAL(logger, msg)
-#define GR_LOG_EMERG(logger, msg)
-#define GR_LOG_ERRORIF(logger, cond, msg)
-#define GR_LOG_ASSERT(logger, cond, msg)
-
-#endif /* ENABLE_GR_LOG */
-
-namespace gr {
-
- // Even if logger is disabled we'll need for methods below to exist in python.
- // The macros these call will be disabled if ENABLE_GR_LOG is undefined
/********************* Start Classes and Methods for Python ******************/
/*!
@@ -764,7 +563,6 @@ namespace gr {
private:
/*! \brief logger pointer to logger associated wiith this wrapper class */
GR_LOG_DECLARE_LOGPTR(d_logger);
-
public:
/*!
* \brief constructor Provide name of logger to associate with this class
@@ -817,18 +615,6 @@ namespace gr {
/*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */
void log_assert(bool cond,std::string msg){GR_LOG_ASSERT(d_logger,cond,msg);}
- /*! \brief inline function, Method to add appender to logger by
- name (define appender in conf file) */
- void add_appender(std::string appender) {
- GR_LOG_ADD_APPENDER(d_logger, appender);
- }
-
- /*! \brief inline function, Method to set an appender to logger by
- name (define appender in conf file) */
- void set_appender(std::string appender) {
- GR_LOG_SET_APPENDER(d_logger, appender);
- }
-
/*! \brief inline function, Method to add console appender to logger */
void add_console_appender(std::string target,std::string pattern) {
GR_LOG_ADD_CONSOLE_APPENDER(d_logger, target, pattern);
@@ -901,5 +687,4 @@ namespace gr {
} /* namespace gr */
-
#endif /* INCLUDED_GR_LOGGER_H */
diff --git a/gnuradio-runtime/include/gnuradio/math.h b/gnuradio-runtime/include/gnuradio/math.h
index e60f56b594..ce37f6ca84 100644
--- a/gnuradio-runtime/include/gnuradio/math.h
+++ b/gnuradio-runtime/include/gnuradio/math.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2003,2005,2008,2013 Free Software Foundation, Inc.
+ * Copyright 2003,2005,2008,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -31,6 +31,22 @@
#include <gnuradio/api.h>
#include <gnuradio/gr_complex.h>
+/*
+ * \brief Define commonly used mathematical constants
+ * \ingroup misc
+ *
+ * Mathematical constants are neither defined in the C standard
+ * nor the C++ standard. For -std=c{++}11 M_LOG2E and M_SQRT2 won't
+ * compile. GR_M_PI actually works with C++ but is defined here for the sake
+ * of consistency.
+ */
+#define GR_M_LOG2E 1.4426950408889634074 /* log_2 e */
+#define GR_M_PI 3.14159265358979323846 /* pi */
+#define GR_M_PI_4 0.78539816339744830961566084582 /* pi/4 */
+#define GR_M_TWOPI (2*GR_M_PI) /* 2*pi */
+#define GR_M_SQRT2 1.41421356237309504880 /* sqrt(2) */
+
+
namespace gr {
static inline bool
diff --git a/gnuradio-runtime/include/gnuradio/messages/CMakeLists.txt b/gnuradio-runtime/include/gnuradio/messages/CMakeLists.txt
index f79f2bd24f..7504cfeeb1 100644
--- a/gnuradio-runtime/include/gnuradio/messages/CMakeLists.txt
+++ b/gnuradio-runtime/include/gnuradio/messages/CMakeLists.txt
@@ -27,5 +27,4 @@ install(FILES
msg_producer.h
msg_queue.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/messages
- COMPONENT "runtime_devel"
)
diff --git a/gnuradio-runtime/include/gnuradio/nco.h b/gnuradio-runtime/include/gnuradio/nco.h
index aff72068b9..e2256c3b70 100644
--- a/gnuradio-runtime/include/gnuradio/nco.h
+++ b/gnuradio-runtime/include/gnuradio/nco.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2002,2013 Free Software Foundation, Inc.
+ * Copyright 2002,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -25,6 +25,8 @@
#include <gnuradio/sincos.h>
#include <gnuradio/gr_complex.h>
+#include <gnuradio/math.h>
+
#include <vector>
#include <cmath>
@@ -69,24 +71,24 @@ namespace gr {
void step()
{
phase += phase_inc;
- if(fabs(phase) > M_PI) {
- while(phase > M_PI)
- phase -= 2*M_PI;
+ if(fabs(phase) > GR_M_PI) {
+ while(phase > GR_M_PI)
+ phase -= 2*GR_M_PI;
- while(phase < -M_PI)
- phase += 2*M_PI;
+ while(phase < -GR_M_PI)
+ phase += 2*GR_M_PI;
}
}
void step(int n)
{
phase += phase_inc * n;
- if(fabs(phase) > M_PI){
- while(phase > M_PI)
- phase -= 2*M_PI;
+ if(fabs(phase) > GR_M_PI){
+ while(phase > GR_M_PI)
+ phase -= 2*GR_M_PI;
- while(phase < -M_PI)
- phase += 2*M_PI;
+ while(phase < -GR_M_PI)
+ phase += 2*GR_M_PI;
}
}
diff --git a/gnuradio-runtime/include/gnuradio/realtime_impl.h b/gnuradio-runtime/include/gnuradio/realtime_impl.h
index bc2250257b..7d8fbc85c2 100644
--- a/gnuradio-runtime/include/gnuradio/realtime_impl.h
+++ b/gnuradio-runtime/include/gnuradio/realtime_impl.h
@@ -28,8 +28,6 @@
/*!
* \brief System independent way to ask for realtime scheduling
- *
- * \sa sys_pri.h
*/
namespace gr {
diff --git a/gnuradio-runtime/include/gnuradio/rpcmanager.h b/gnuradio-runtime/include/gnuradio/rpcmanager.h
index e7ee4c4942..57682ac251 100644
--- a/gnuradio-runtime/include/gnuradio/rpcmanager.h
+++ b/gnuradio-runtime/include/gnuradio/rpcmanager.h
@@ -54,8 +54,8 @@ class GR_RUNTIME_API rpcmanager : public virtual rpcmanager_base
static bool booter_registered;
static bool aggregator_registered;
static void rpcserver_booter_base_sptr_dest(rpcserver_booter_base* b) {;}
- static std::auto_ptr<rpcserver_booter_base> boot;
- static std::auto_ptr<rpcserver_booter_aggregator> aggregator;
+ static std::unique_ptr<rpcserver_booter_base> boot;
+ static std::unique_ptr<rpcserver_booter_aggregator> aggregator;
};
#endif /* RPCMANAGER_H */
diff --git a/gnuradio-runtime/include/gnuradio/sptr_magic.h b/gnuradio-runtime/include/gnuradio/sptr_magic.h
index 6deb3062ae..d5e587186a 100644
--- a/gnuradio-runtime/include/gnuradio/sptr_magic.h
+++ b/gnuradio-runtime/include/gnuradio/sptr_magic.h
@@ -40,7 +40,7 @@ namespace gnuradio {
static void create_and_stash_initial_sptr(gr::hier_block2 *p);
static void cancel_initial_sptr(gr::hier_block2 *p);
};
- };
+ }
/*
* \brief New! Improved! Standard method to get/create the
diff --git a/gnuradio-runtime/include/gnuradio/sys_pri.h b/gnuradio-runtime/include/gnuradio/sys_pri.h
deleted file mode 100644
index d251455a11..0000000000
--- a/gnuradio-runtime/include/gnuradio/sys_pri.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008,2013 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.
- */
-
-#ifndef INCLUDED_GNURADIO_SYS_PRI_H
-#define INCLUDED_GNURADIO_SYS_PRI_H
-
-#include <gnuradio/api.h>
-#include <gnuradio/realtime.h>
-
-/*
- * A single place to define real-time priorities used by the system itself
- */
-namespace gr {
-
- struct GR_RUNTIME_API sys_pri {
- static struct GR_RUNTIME_API rt_sched_param python(); // python code
- static struct GR_RUNTIME_API rt_sched_param normal(); // normal blocks
- static struct GR_RUNTIME_API rt_sched_param gcell_event_handler();
- static struct GR_RUNTIME_API rt_sched_param usrp2_backend(); // thread that services the ethernet
- };
-
-} /* namespace gr */
-
-#endif /* INCLUDED_GNURADIO_SYS_PRI_H */
diff --git a/gnuradio-runtime/include/gnuradio/thread/CMakeLists.txt b/gnuradio-runtime/include/gnuradio/thread/CMakeLists.txt
index 8ea4bfc66e..b9a4a98c13 100644
--- a/gnuradio-runtime/include/gnuradio/thread/CMakeLists.txt
+++ b/gnuradio-runtime/include/gnuradio/thread/CMakeLists.txt
@@ -25,5 +25,4 @@ install(FILES
thread_body_wrapper.h
thread_group.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/thread
- COMPONENT "runtime_devel"
)
diff --git a/gnuradio-runtime/include/gnuradio/tpb_detail.h b/gnuradio-runtime/include/gnuradio/tpb_detail.h
index 9b7454b508..4e660144f2 100644
--- a/gnuradio-runtime/include/gnuradio/tpb_detail.h
+++ b/gnuradio-runtime/include/gnuradio/tpb_detail.h
@@ -58,7 +58,10 @@ namespace gr {
//! Called by pmt msg posters
void notify_msg() {
+ gr::thread::scoped_lock guard(mutex);
+ input_changed = true;
input_cond.notify_one();
+ output_changed = true;
output_cond.notify_one();
}
diff --git a/gnuradio-runtime/include/gnuradio/types.h b/gnuradio-runtime/include/gnuradio/types.h
index 7e13d3bf32..5d645ad3f9 100644
--- a/gnuradio-runtime/include/gnuradio/types.h
+++ b/gnuradio-runtime/include/gnuradio/types.h
@@ -39,5 +39,4 @@ typedef std::vector<double> gr_vector_double;
typedef std::vector<void *> gr_vector_void_star;
typedef std::vector<const void *> gr_vector_const_void_star;
-
#endif /* INCLUDED_GR_TYPES_H */
diff --git a/gnuradio-runtime/include/pmt/CMakeLists.txt b/gnuradio-runtime/include/pmt/CMakeLists.txt
index 4ae0e22431..2b33ea0105 100644
--- a/gnuradio-runtime/include/pmt/CMakeLists.txt
+++ b/gnuradio-runtime/include/pmt/CMakeLists.txt
@@ -25,5 +25,6 @@ install(FILES
pmt.h
pmt_pool.h
pmt_sugar.h
+ pmt_serial_tags.h
DESTINATION ${GR_INCLUDE_DIR}/pmt
- COMPONENT "runtime_devel")
+)
diff --git a/gnuradio-runtime/lib/pmt/gen-serial-tags.py b/gnuradio-runtime/include/pmt/pmt_serial_tags.h
index 18e927beb5..ea89693a49 100644
--- a/gnuradio-runtime/lib/pmt/gen-serial-tags.py
+++ b/gnuradio-runtime/include/pmt/pmt_serial_tags.h
@@ -1,4 +1,4 @@
-"""
+
//
// Copyright 2011 Free Software Foundation, Inc.
//
@@ -19,35 +19,44 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
//
-// THIS FILE IS MACHINE GENERATED FROM %s. DO NOT EDIT BY HAND.
-// See %s for additional commentary.
+// THIS FILE IS MACHINE GENERATED FROM gen-serial-tags.py. DO NOT EDIT BY HAND.
+// See pmt-serial-tags.scm for additional commentary.
//
#ifndef INCLUDED_PMT_SERIAL_TAGS_H
#define INCLUDED_PMT_SERIAL_TAGS_H
enum pst_tags {
-%s
+ PST_TRUE = 0x00,
+ PST_FALSE = 0x01,
+ PST_SYMBOL = 0x02,
+ PST_INT32 = 0x03,
+ PST_DOUBLE = 0x04,
+ PST_COMPLEX = 0x05,
+ PST_NULL = 0x06,
+ PST_PAIR = 0x07,
+ PST_VECTOR = 0x08,
+ PST_DICT = 0x09,
+ PST_UNIFORM_VECTOR = 0x0a,
+ PST_UINT64 = 0x0b,
+ PST_TUPLE = 0x0c,
+ UVI_ENDIAN_MASK = 0x80,
+ UVI_SUBTYPE_MASK = 0x7f,
+ UVI_LITTLE_ENDIAN = 0x00,
+ UVI_BIG_ENDIAN = 0x80,
+ UVI_U8 = 0x00,
+ UVI_S8 = 0x01,
+ UVI_U16 = 0x02,
+ UVI_S16 = 0x03,
+ UVI_U32 = 0x04,
+ UVI_S32 = 0x05,
+ UVI_U64 = 0x06,
+ UVI_S64 = 0x07,
+ UVI_F32 = 0x08,
+ UVI_F64 = 0x09,
+ UVI_C32 = 0x0a,
+ UVI_C64 = 0x0b,
+ PST_COMMENT = 0x3b,
+ PST_COMMENT_END = 0x0a
};
#endif /* INCLUDED_PMT_SERIAL_TAGS_H */
-"""
-
-import sys, os, re
-
-if __name__ == '__main__':
- if len(sys.argv) != 3:
- print "Usage %s <input_scm_file> <output_hdr_file>"%__file__
- exit()
- input_scm_file, output_hdr_file = sys.argv[1:]
- enums = list()
- for line in open(input_scm_file).readlines():
- match = re.match('^\s*\(define\s+([\w|-]+)\s+#x([0-9a-fA-F]+)\)', line)
- if not match: continue
- name, value = match.groups()
- name = name.upper().replace('-', '_')
- enums.append(' %s = 0x%s'%(name, value))
- open(output_hdr_file, 'w').write(__doc__%(
- os.path.basename(__file__),
- os.path.basename(input_scm_file),
- ',\n'.join(enums),
- ))
diff --git a/gnuradio-runtime/lib/CMakeLists.txt b/gnuradio-runtime/lib/CMakeLists.txt
index 3482c69d3f..58cd9866fa 100644
--- a/gnuradio-runtime/lib/CMakeLists.txt
+++ b/gnuradio-runtime/lib/CMakeLists.txt
@@ -24,7 +24,7 @@ GR_CHECK_HDR_N_DEF(sys/resource.h HAVE_SYS_RESOURCE_H)
# Handle the generated constants
########################################################################
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
- "import time;print time.strftime('%a, %d %b %Y %H:%M:%S', time.gmtime())"
+ "import time;print(time.strftime('%a, %d %b %Y %H:%M:%S', time.gmtime()))"
OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Loading build date ${BUILD_DATE} into constants...")
@@ -48,8 +48,8 @@ list(APPEND gnuradio_runtime_sources ${CMAKE_CURRENT_BINARY_DIR}/constants.cc)
########################################################################
include_directories(${GNURADIO_RUNTIME_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}/../include/
- ${VOLK_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_BINARY_DIR}/../include/
+ ${VOLK_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${MPLIB_INCLUDE_DIRS}
)
@@ -81,7 +81,6 @@ list(APPEND gnuradio_runtime_sources
block_registry.cc
buffer.cc
circular_file.cc
- complex_vec_test.cc
feval.cc
flat_flowgraph.cc
flowgraph.cc
@@ -91,7 +90,6 @@ list(APPEND gnuradio_runtime_sources
io_signature.cc
local_sighandler.cc
logger.cc
- malloc16.c
message.cc
misc.cc
msg_accepter.cc
@@ -102,9 +100,7 @@ list(APPEND gnuradio_runtime_sources
realtime.cc
realtime_impl.cc
scheduler.cc
- scheduler_sts.cc
scheduler_tpb.cc
- single_threaded_scheduler.cc
sptr_magic.cc
sync_block.cc
sync_decimator.cc
@@ -125,14 +121,6 @@ list(APPEND gnuradio_runtime_sources
${gnuradio_ctrlport_sources}
)
-# PowerPC workaround for posix_memalign
-# Might not be needed, but we'll keep it for now.
-if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
- list(APPEND gnuradio_runtime_sources
- ${CMAKE_CURRENT_SOURCE_DIR}/posix_memalign.cc
- )
-endif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
-
list(APPEND gnuradio_runtime_libs
gnuradio-pmt
${VOLK_LIBRARIES}
@@ -200,12 +188,7 @@ endif(TRY_SHM_VMCIRCBUF)
#######################################################
add_library(gnuradio-runtime SHARED ${gnuradio_runtime_sources})
target_link_libraries(gnuradio-runtime ${gnuradio_runtime_libs})
-GR_LIBRARY_FOO(gnuradio-runtime RUNTIME_COMPONENT "runtime_runtime" DEVEL_COMPONENT "runtime_devel")
-
-add_dependencies(gnuradio-runtime
- pmt_generated runtime_generated_includes
-)
-
+GR_LIBRARY_FOO(gnuradio-runtime)
#######################################################
# STATIC LIB BUILD
@@ -238,7 +221,7 @@ if(ENABLE_STATIC_LIBS)
endif(NOT WIN32)
install(TARGETS gnuradio-runtime_static
- ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "runtime_devel" # .lib file
+ ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file
)
endif(ENABLE_STATIC_LIBS)
diff --git a/gnuradio-runtime/lib/basic_block.cc b/gnuradio-runtime/lib/basic_block.cc
index 082d0753c8..89aa9b8671 100644
--- a/gnuradio-runtime/lib/basic_block.cc
+++ b/gnuradio-runtime/lib/basic_block.cc
@@ -228,29 +228,6 @@ namespace gr {
}
pmt::pmt_t
- basic_block::delete_head_blocking(pmt::pmt_t which_port, unsigned int millisec)
- {
- gr::thread::scoped_lock guard(mutex);
-
- if (millisec) {
- boost::system_time const timeout = boost::get_system_time() + boost::posix_time::milliseconds(millisec);
- while (empty_p(which_port)) {
- if (!msg_queue_ready[which_port]->timed_wait(guard, timeout)) {
- return pmt::pmt_t();
- }
- }
- } else {
- while(empty_p(which_port)) {
- msg_queue_ready[which_port]->wait(guard);
- }
- }
-
- pmt::pmt_t m(msg_queue[which_port].front());
- msg_queue[which_port].pop_front();
- return m;
- }
-
- pmt::pmt_t
basic_block::message_subscribers(pmt::pmt_t port)
{
return pmt::dict_ref(d_message_subscribers,port,pmt::PMT_NIL);
diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc
index 7d364de32d..c86e792127 100644
--- a/gnuradio-runtime/lib/block.cc
+++ b/gnuradio-runtime/lib/block.cc
@@ -745,6 +745,20 @@ namespace gr {
}
void
+ block::set_log_level(std::string level)
+ {
+ logger_set_level(d_logger, level);
+ }
+
+ std::string
+ block::log_level()
+ {
+ std::string level;
+ logger_get_level(d_logger, level);
+ return level;
+ }
+
+ void
block::notify_msg_neighbors()
{
size_t len = pmt::length(d_message_subscribers);
@@ -773,7 +787,7 @@ namespace gr {
bool
block::finished()
{
- if((detail()->ninputs() != 0) || (detail()->noutputs() != 0))
+ if(detail()->ninputs() != 0)
return false;
else
return d_finished;
@@ -913,10 +927,14 @@ namespace gr {
#endif /* defined(GR_CTRLPORT) && defined(GR_PERFORMANCE_COUNTERS) */
}
+ std::string block::identifier() const {
+ return d_name + "(" + std::to_string(d_unique_id) + ")";
+ }
+
std::ostream&
operator << (std::ostream& os, const block *m)
{
- os << "<block " << m->name() << " (" << m->unique_id() << ")>";
+ os << "<block " << m->identifier() << ">";
return os;
}
diff --git a/gnuradio-runtime/lib/complex_vec_test.cc b/gnuradio-runtime/lib/complex_vec_test.cc
deleted file mode 100644
index 99acc2f355..0000000000
--- a/gnuradio-runtime/lib/complex_vec_test.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-#include <complex_vec_test.h>
-#include <stddef.h>
-
-std::vector<std::complex<float> >
-complex_vec_test0()
-{
- std::vector<std::complex<float> > r(5);
-
- for (size_t i = 0; i < r.size(); i++)
- r[i] = std::complex<float>(i, i);
-
- return r;
-}
-
-std::vector<std::complex<float> >
-complex_vec_test1(const std::vector<std::complex<float> > &input)
-{
- std::vector<std::complex<float> > r(input.size());
-
- for (size_t i = 0; i < input.size(); i++)
- r[i] = std::complex<float>(input[i].real()+0.5, input[i].imag()-0.5);
-
- return r;
-}
-
-std::complex<float>
-complex_scalar_test0()
-{
- return std::complex<float>(5, 5);
-}
-
-std::complex<float>
-complex_scalar_test1(std::complex<float> input)
-{
- return std::complex<float>(input.real()+0.5, input.imag()-0.5);
-}
-
-
-std::vector<float>
-float_vec_test0()
-{
- std::vector<float> r(5);
-
- for (size_t i = 0; i < r.size(); i++)
- r[i] = (float) i;
-
- return r;
-}
-
-std::vector<float>
-float_vec_test1(const std::vector<float> &input)
-{
- std::vector<float> r(input.size());
-
- for (size_t i = 0; i < input.size(); i++)
- r[i] = input[i] + 0.5;
-
- return r;
-}
-
-std::vector<int>
-int_vec_test0()
-{
- std::vector<int> r(5);
-
- for (size_t i = 0; i < r.size(); i++)
- r[i] = (int) i;
-
- return r;
-}
-
-std::vector<int>
-int_vec_test1(const std::vector<int> &input)
-{
- std::vector<int> r(input.size());
-
- for (size_t i = 0; i < input.size(); i++)
- r[i] = input[i] + 1;
-
- return r;
-}
-
diff --git a/gnuradio-runtime/lib/complex_vec_test.h b/gnuradio-runtime/lib/complex_vec_test.h
deleted file mode 100644
index d69d523374..0000000000
--- a/gnuradio-runtime/lib/complex_vec_test.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2013 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 <gnuradio/api.h>
-#include <vector>
-#include <complex>
-
-GR_RUNTIME_API std::vector<std::complex<float> >
-complex_vec_test0();
-
-GR_RUNTIME_API std::vector<std::complex<float> >
-complex_vec_test1(const std::vector<std::complex<float> > &input);
-
-GR_RUNTIME_API std::complex<float>
-complex_scalar_test0();
-
-GR_RUNTIME_API std::complex<float>
-complex_scalar_test1(std::complex<float> input);
-
-GR_RUNTIME_API std::vector<int>
-int_vec_test0();
-
-GR_RUNTIME_API std::vector<int>
-int_vec_test1(const std::vector<int> &input);
-
-GR_RUNTIME_API std::vector<float>
-float_vec_test0();
-
-GR_RUNTIME_API std::vector<float>
-float_vec_test1(const std::vector<float> &input);
-
diff --git a/gnuradio-runtime/lib/controlport/CMakeLists.txt b/gnuradio-runtime/lib/controlport/CMakeLists.txt
index 0d5d0376cc..0aa8539742 100644
--- a/gnuradio-runtime/lib/controlport/CMakeLists.txt
+++ b/gnuradio-runtime/lib/controlport/CMakeLists.txt
@@ -84,7 +84,6 @@ list(APPEND gnuradio_runtime_libs
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/thrift/thrift.conf.example
DESTINATION ${SYSCONFDIR}/${CMAKE_PROJECT_NAME}
- COMPONENT "runtime_runtime"
)
endif(THRIFT_FOUND)
diff --git a/gnuradio-runtime/lib/controlport/rpcserver_selector.cc b/gnuradio-runtime/lib/controlport/rpcserver_selector.cc
index fcba1ab524..2785513a46 100644
--- a/gnuradio-runtime/lib/controlport/rpcserver_selector.cc
+++ b/gnuradio-runtime/lib/controlport/rpcserver_selector.cc
@@ -27,8 +27,8 @@
bool rpcmanager::make_aggregator(false);
bool rpcmanager::booter_registered(false);
bool rpcmanager::aggregator_registered(false);
-std::auto_ptr<rpcserver_booter_base> rpcmanager::boot(0);
-std::auto_ptr<rpcserver_booter_aggregator> rpcmanager::aggregator(0);
+std::unique_ptr<rpcserver_booter_base> rpcmanager::boot;
+std::unique_ptr<rpcserver_booter_aggregator> rpcmanager::aggregator;
#ifdef GR_RPCSERVER_ENABLED
rpcmanager manager_instance;
diff --git a/gnuradio-runtime/lib/flat_flowgraph.cc b/gnuradio-runtime/lib/flat_flowgraph.cc
index b7e949127a..c83ab20769 100644
--- a/gnuradio-runtime/lib/flat_flowgraph.cc
+++ b/gnuradio-runtime/lib/flat_flowgraph.cc
@@ -27,6 +27,7 @@
#include "flat_flowgraph.h"
#include <gnuradio/block_detail.h>
#include <gnuradio/buffer.h>
+#include <gnuradio/logger.h>
#include <gnuradio/prefs.h>
#include <volk/volk.h>
#include <iostream>
@@ -35,8 +36,6 @@
namespace gr {
-#define FLAT_FLOWGRAPH_DEBUG 0
-
// 32Kbyte buffer size between blocks
#define GR_FIXED_BUFFER_SIZE (32*(1L<<10))
@@ -77,11 +76,12 @@ namespace gr {
// Connect message ports connetions
for(msg_edge_viter_t i = d_msg_edges.begin(); i != d_msg_edges.end(); i++) {
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << boost::format("flat_fg connecting msg primitives: (%s, %s)->(%s, %s)\n") %
- i->src().block() % i->src().port() %
- i->dst().block() % i->dst().port();
- i->src().block()->message_port_sub(i->src().port(), pmt::cons(i->dst().block()->alias_pmt(), i->dst().port()));
+ GR_LOG_DEBUG(d_debug_logger,
+ boost::format("flat_fg connecting msg primitives: (%s, %s)->(%s, %s)\n") %
+ i->src().block() % i->src().port() %
+ i->dst().block() % i->dst().port()
+ );
+ i->src().block()->message_port_sub(i->src().port(), pmt::cons(i->dst().block()->alias_pmt(), i->dst().port()));
}
}
@@ -98,15 +98,13 @@ namespace gr {
(boost::format("allocate_block_detail found non-gr::block (%s)")%
block->alias()).str());
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "Creating block detail for " << block << std::endl;
+ GR_LOG_DEBUG(d_debug_logger, "Creating block detail for " + block->identifier());
for(int i = 0; i < noutputs; i++) {
grblock->expand_minmax_buffer(i);
buffer_sptr buffer = allocate_buffer(block, i);
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "Allocated buffer for output " << block << ":" << i << std::endl;
+ GR_LOG_DEBUG(d_debug_logger, "Allocated buffer for output " + block->identifier() + " " + std::to_string(i));
detail->set_output(i, buffer);
// Update the block's max_output_buffer based on what was actually allocated.
@@ -210,8 +208,8 @@ namespace gr {
throw std::runtime_error("connect_block_inputs found non-gr::block");
buffer_sptr src_buffer = src_grblock->detail()->output(src_port);
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "Setting input " << dst_port << " from edge " << (*e) << std::endl;
+
+ GR_LOG_DEBUG(d_debug_logger, "Setting input " + std::to_string(dst_port) + " from edge " + (*e).identifier());
detail->set_input(dst_port, buffer_add_reader(src_buffer, grblock->history()-1, grblock,
grblock->sample_delay(src_port)));
@@ -227,89 +225,81 @@ namespace gr {
for(basic_block_viter_t p = d_blocks.begin(); p != d_blocks.end(); p++) {
block_sptr block = cast_to_block_sptr(*p);
- if(!block->detail()) {
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "merge: allocating new detail for block " << (*p) << std::endl;
- block->set_detail(allocate_block_detail(block));
- }
- else {
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "merge: reusing original detail for block " << (*p) << std::endl;
+ if (!block->detail()) {
+ GR_LOG_DEBUG(d_debug_logger,
+ "merge: allocating new detail for block " + block->identifier());
+ block->set_detail(allocate_block_detail(block));
+ } else {
+ GR_LOG_DEBUG(d_debug_logger,
+ "merge: reusing original detail for block " + block->identifier());
}
}
// Calculate the old edges that will be going away, and clear the
// buffer readers on the RHS.
- for(edge_viter_t old_edge = old_ffg->d_edges.begin(); old_edge != old_ffg->d_edges.end(); old_edge++) {
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "merge: testing old edge " << (*old_edge) << "...";
-
- edge_viter_t new_edge;
- for(new_edge = d_edges.begin(); new_edge != d_edges.end(); new_edge++)
- if(new_edge->src() == old_edge->src() &&
- new_edge->dst() == old_edge->dst())
- break;
-
- if(new_edge == d_edges.end()) { // not found in new edge list
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "not in new edge list" << std::endl;
- // zero the buffer reader on RHS of old edge
- block_sptr block(cast_to_block_sptr(old_edge->dst().block()));
- int port = old_edge->dst().port();
- block->detail()->set_input(port, buffer_reader_sptr());
- }
- else {
- if (FLAT_FLOWGRAPH_DEBUG)
- std::cout << "found in new edge list" << std::endl;
- }
+ for (edge_viter_t old_edge = old_ffg->d_edges.begin(); old_edge != old_ffg->d_edges.end();
+ old_edge++) {
+ GR_LOG_DEBUG(d_debug_logger,
+ "merge: testing old edge " + old_edge->identifier() + "...");
+
+ edge_viter_t new_edge;
+ for (new_edge = d_edges.begin(); new_edge != d_edges.end(); new_edge++)
+ if (new_edge->src() == old_edge->src() && new_edge->dst() == old_edge->dst())
+ break;
+
+ if (new_edge == d_edges.end()) { // not found in new edge list
+ GR_LOG_DEBUG(d_debug_logger, "not in new edge list");
+ // zero the buffer reader on RHS of old edge
+ block_sptr block(cast_to_block_sptr(old_edge->dst().block()));
+ int port = old_edge->dst().port();
+ block->detail()->set_input(port, buffer_reader_sptr());
+ } else {
+ GR_LOG_DEBUG(d_debug_logger, "found in new edge list");
+ }
}
// Now connect inputs to outputs, reusing old buffer readers if they exist
for(basic_block_viter_t p = d_blocks.begin(); p != d_blocks.end(); p++) {
block_sptr block = cast_to_block_sptr(*p);
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "merge: merging " << (*p) << "...";
-
- if(old_ffg->has_block_p(*p)) {
- // Block exists in old flow graph
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "used in old flow graph" << std::endl;
- block_detail_sptr detail = block->detail();
-
- // Iterate through the inputs and see what needs to be done
- int ninputs = calc_used_ports(block, true).size(); // Might be different now
- for(int i = 0; i < ninputs; i++) {
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "Checking input " << block << ":" << i << "...";
- edge edge = calc_upstream_edge(*p, i);
-
- // Fish out old buffer reader and see if it matches correct buffer from edge list
- block_sptr src_block = cast_to_block_sptr(edge.src().block());
- block_detail_sptr src_detail = src_block->detail();
- buffer_sptr src_buffer = src_detail->output(edge.src().port());
- buffer_reader_sptr old_reader;
- if(i < detail->ninputs()) // Don't exceed what the original detail has
- old_reader = detail->input(i);
-
- // If there's a match, use it
- if(old_reader && (src_buffer == old_reader->buffer())) {
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "matched, reusing" << std::endl;
- }
- else {
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "needs a new reader" << std::endl;
-
- // Create new buffer reader and assign
- detail->set_input(i, buffer_add_reader(src_buffer, block->history()-1, block));
+ GR_LOG_DEBUG(d_debug_logger,
+ "merge: merging " + block->identifier() + "...");
+
+ if (old_ffg->has_block_p(*p)) {
+ // Block exists in old flow graph
+ GR_LOG_DEBUG(d_debug_logger, "used in old flow graph")
+ block_detail_sptr detail = block->detail();
+
+ // Iterate through the inputs and see what needs to be done
+ int ninputs = calc_used_ports(block, true).size(); // Might be different now
+ for (int i = 0; i < ninputs; i++) {
+ GR_LOG_DEBUG(d_debug_logger,
+ "Checking input " + block->identifier() + ":" + std::to_string(i) +
+ "...");
+ edge edge = calc_upstream_edge(*p, i);
+
+ // Fish out old buffer reader and see if it matches correct buffer from edge list
+ block_sptr src_block = cast_to_block_sptr(edge.src().block());
+ block_detail_sptr src_detail = src_block->detail();
+ buffer_sptr src_buffer = src_detail->output(edge.src().port());
+ buffer_reader_sptr old_reader;
+ if (i < detail->ninputs()) // Don't exceed what the original detail has
+ old_reader = detail->input(i);
+
+ // If there's a match, use it
+ if (old_reader && (src_buffer == old_reader->buffer())) {
+ GR_LOG_DEBUG(d_debug_logger, "matched, reusing");
+ } else {
+ GR_LOG_DEBUG(d_debug_logger, "needs a new reader");
+
+ // Create new buffer reader and assign
+ detail->set_input(i, buffer_add_reader(src_buffer, block->history() - 1, block));
+ }
}
- }
}
else {
// Block is new, it just needs buffer readers at this point
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "new block" << std::endl;
+ GR_LOG_DEBUG(d_debug_logger, "new block");
connect_block_inputs(block);
// Make sure all buffers are aligned
@@ -317,12 +307,12 @@ namespace gr {
}
// Connect message ports connetions
- for(msg_edge_viter_t i = d_msg_edges.begin(); i != d_msg_edges.end(); i++) {
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << boost::format("flat_fg connecting msg primitives: (%s, %s)->(%s, %s)\n") %
- i->src().block() % i->src().port() %
- i->dst().block() % i->dst().port();
- i->src().block()->message_port_sub(i->src().port(), pmt::cons(i->dst().block()->alias_pmt(), i->dst().port()));
+ for (msg_edge_viter_t i = d_msg_edges.begin(); i != d_msg_edges.end(); i++) {
+ GR_LOG_DEBUG(d_debug_logger,
+ boost::format("flat_fg connecting msg primitives: (%s, %s)->(%s, %s)\n") %
+ i->src().block() % i->src().port() % i->dst().block() % i->dst().port());
+ i->src().block()->message_port_sub(
+ i->src().port(), pmt::cons(i->dst().block()->alias_pmt(), i->dst().port()));
}
// Now deal with the fact that the block details might have
@@ -439,45 +429,48 @@ namespace gr {
void
flat_flowgraph::clear_hier()
{
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "Clear_hier()" << std::endl;
- for(size_t i=0; i<d_msg_edges.size(); i++) {
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "edge: " << d_msg_edges[i].src() << "-->" << d_msg_edges[i].dst() << std::endl;
- if(d_msg_edges[i].src().is_hier() || d_msg_edges[i].dst().is_hier()){
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << "is hier" << std::endl;
- d_msg_edges.erase(d_msg_edges.begin() + i);
- i--;
- }
+ GR_LOG_DEBUG(d_debug_logger, "Clear_hier()");
+ for (size_t i = 0; i < d_msg_edges.size(); i++) {
+ GR_LOG_DEBUG(d_debug_logger,
+ "edge: " + d_msg_edges[i].src().identifier() + "-->" +
+ d_msg_edges[i].dst().identifier());
+ if (d_msg_edges[i].src().is_hier() || d_msg_edges[i].dst().is_hier()) {
+ GR_LOG_DEBUG(d_debug_logger, "is hier");
+ d_msg_edges.erase(d_msg_edges.begin() + i);
+ i--;
+ }
}
}
void
flat_flowgraph::replace_endpoint(const msg_endpoint &e, const msg_endpoint &r, bool is_src)
{
- size_t n_replr(0);
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << boost::format("flat_flowgraph::replace_endpoint( %s, %s, %d )\n") % e.block()% r.block()% is_src;
- for(size_t i=0; i<d_msg_edges.size(); i++) {
- if(is_src) {
- if(d_msg_edges[i].src() == e) {
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << boost::format("flat_flowgraph::replace_endpoint() flattening to ( %s, %s )\n") \
- % r% d_msg_edges[i].dst();
- d_msg_edges.push_back( msg_edge(r, d_msg_edges[i].dst() ) );
- n_replr++;
- }
- }
- else {
- if(d_msg_edges[i].dst() == e) {
- if(FLAT_FLOWGRAPH_DEBUG)
- std::cout << boost::format("flat_flowgraph::replace_endpoint() flattening to ( %s, %s )\n") \
- % r% d_msg_edges[i].src();
- d_msg_edges.push_back( msg_edge(d_msg_edges[i].src(), r ) );
- n_replr++;
- }
- }
+ size_t n_replr(0);
+ GR_LOG_DEBUG(d_debug_logger,
+ boost::format("flat_flowgraph::replace_endpoint( %s, %s, %d )\n") % e.block() %
+ r.block() % is_src);
+ for (size_t i = 0; i < d_msg_edges.size(); i++) {
+ if (is_src) {
+ if (d_msg_edges[i].src() == e) {
+ GR_LOG_DEBUG(
+ d_debug_logger,
+ boost::format(
+ "flat_flowgraph::replace_endpoint() flattening to ( %s, %s )\n") %
+ r % d_msg_edges[i].dst())
+ d_msg_edges.push_back(msg_edge(r, d_msg_edges[i].dst()));
+ n_replr++;
+ }
+ } else {
+ if (d_msg_edges[i].dst() == e) {
+ GR_LOG_DEBUG(
+ d_debug_logger,
+ boost::format(
+ "flat_flowgraph::replace_endpoint() flattening to ( %s, %s )\n") %
+ r % d_msg_edges[i].src());
+ d_msg_edges.push_back(msg_edge(d_msg_edges[i].src(), r));
+ n_replr++;
+ }
+ }
}
}
diff --git a/gnuradio-runtime/lib/hier_block2.cc b/gnuradio-runtime/lib/hier_block2.cc
index 597ae032ec..8ebbbda587 100644
--- a/gnuradio-runtime/lib/hier_block2.cc
+++ b/gnuradio-runtime/lib/hier_block2.cc
@@ -178,6 +178,18 @@ namespace gr {
return d_detail->processor_affinity();
}
+ void
+ hier_block2::set_log_level(std::string level)
+ {
+ d_detail->set_log_level(level);
+ }
+
+ std::string
+ hier_block2::log_level()
+ {
+ return d_detail->log_level();
+ }
+
std::string
dot_graph(hier_block2_sptr hierblock2)
{
diff --git a/gnuradio-runtime/lib/hier_block2_detail.cc b/gnuradio-runtime/lib/hier_block2_detail.cc
index 82a40fe211..dbf519b6ef 100644
--- a/gnuradio-runtime/lib/hier_block2_detail.cc
+++ b/gnuradio-runtime/lib/hier_block2_detail.cc
@@ -955,4 +955,22 @@ namespace gr {
return tmp[0]->processor_affinity();
}
+ void
+ hier_block2_detail::set_log_level(std::string level)
+ {
+ basic_block_vector_t tmp = d_fg->calc_used_blocks();
+ for(basic_block_viter_t p = tmp.begin(); p != tmp.end(); p++) {
+ (*p)->set_log_level(level);
+ }
+ }
+
+ std::string
+ hier_block2_detail::log_level()
+ {
+ // Assume that log_level was set for all hier_block2 blocks
+ basic_block_vector_t tmp = d_fg->calc_used_blocks();
+ return tmp[0]->log_level();
+ }
+
+
} /* namespace gr */
diff --git a/gnuradio-runtime/lib/hier_block2_detail.h b/gnuradio-runtime/lib/hier_block2_detail.h
index a5584fe92a..aa419c49bd 100644
--- a/gnuradio-runtime/lib/hier_block2_detail.h
+++ b/gnuradio-runtime/lib/hier_block2_detail.h
@@ -57,6 +57,9 @@ namespace gr {
void set_processor_affinity(const std::vector<int> &mask);
void unset_processor_affinity();
std::vector<int> processor_affinity();
+
+ void set_log_level(std::string level);
+ std::string log_level();
// Track output buffer min/max settings
std::vector<size_t> d_max_output_buffer;
diff --git a/gnuradio-runtime/lib/logger.cc b/gnuradio-runtime/lib/logger.cc
index 17e1aa154c..064b74b3ed 100644
--- a/gnuradio-runtime/lib/logger.cc
+++ b/gnuradio-runtime/lib/logger.cc
@@ -35,10 +35,6 @@
#include <stdexcept>
#include <algorithm>
-
-#ifdef ENABLE_GR_LOG
-#ifdef HAVE_LOG4CPP
-
namespace gr {
bool logger_config::logger_configured(false);
@@ -311,8 +307,6 @@ namespace gr {
} /* namespace gr */
-#endif /* HAVE_LOG4CPP */
-
/****** Start Methods to provide Python the capabilities of the macros ********/
void
gr_logger_config(const std::string config_filename, unsigned int watch_period)
@@ -336,38 +330,12 @@ gr_logger_reset_config(void)
// Remaining capability provided by gr::logger class in gnuradio/logger.h
-#else /* ENABLE_GR_LOG */
-
-/****** Start Methods to provide Python the capabilities of the macros ********/
-void
-gr_logger_config(const std::string config_filename, unsigned int watch_period)
-{
- //NOP
-}
-
-std::vector<std::string>
-gr_logger_get_logger_names(void)
-{
- return std::vector<std::string>(1, "");
-}
-
-void
-gr_logger_reset_config(void)
-{
- //NOP
-}
-
-#endif /* ENABLE_GR_LOG */
-
-
namespace gr {
bool
configure_default_loggers(gr::logger_ptr &l, gr::logger_ptr &d,
const std::string name)
{
-#ifdef ENABLE_GR_LOG
-#ifdef HAVE_LOG4CPP
prefs *p = prefs::singleton();
std::string config_file = p->get_string("LOG", "log_config", "");
std::string log_level = p->get_string("LOG", "log_level", "off");
@@ -408,21 +376,11 @@ namespace gr {
}
d = DLOG;
return true;
-#endif /* HAVE_LOG4CPP */
-
-#else /* ENABLE_GR_LOG */
- l = NULL;
- d = NULL;
- return false;
-#endif /* ENABLE_GR_LOG */
- return false;
}
bool
update_logger_alias(const std::string &name, const std::string &alias)
{
-#ifdef ENABLE_GR_LOG
-#ifdef HAVE_LOG4CPP
prefs *p = prefs::singleton();
std::string log_file = p->get_string("LOG", "log_file", "");
std::string debug_file = p->get_string("LOG", "debug_file", "");
@@ -443,10 +401,6 @@ namespace gr {
}
}
return true;
-#endif /* HAVE_LOG4CPP */
-#endif /* ENABLE_GR_LOG */
-
- return false;
}
} /* namespace gr */
diff --git a/gnuradio-runtime/lib/malloc16.c b/gnuradio-runtime/lib/malloc16.c
deleted file mode 100644
index 2cc6135e77..0000000000
--- a/gnuradio-runtime/lib/malloc16.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Wrapper functions for malloc/free that force 16-byte alignment
- * See http://perso.club-internet.fr/matmac/sourcesc.htm
-
- * Copyright 2001 Phil Karn, KA9Q
- * May be used under the terms of the GNU Public License (GPL)
- */
-
-#include "malloc16.h"
-#include <string.h>
-
-void *malloc16Align(int size){
- void *p;
- void **p1;
-
- if((p = malloc(size+31)) == NULL)
- return NULL;
-
- /* Round up to next 16-byte boundary */
- p1 = (void **)(((long)p + 31) & (~15));
-
- /* Stash actual start of block just before ptr we return */
- p1[-1] = p;
-
- /* Return 16-byte aligned address */
- return (void *)p1;
-}
-
-void *calloc16Align(size_t nmemb,size_t size){
- int nbytes;
- void *p;
-
- nbytes = nmemb*size;
- if((p = malloc16Align(nbytes)) == NULL)
- return NULL;
-
- memset(p,0,nbytes);
- return p;
-}
-
-void free16Align(void *p){
-
- if(p != NULL){
- /* Retrieve pointer to actual start of block and free it */
- free(((void **)p)[-1]);
- }
-}
diff --git a/gnuradio-runtime/lib/malloc16.h b/gnuradio-runtime/lib/malloc16.h
deleted file mode 100644
index 05f80cbf4f..0000000000
--- a/gnuradio-runtime/lib/malloc16.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2002 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 <gnuradio/api.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdlib.h>
-
-GR_RUNTIME_API void *malloc16Align(int size);
-GR_RUNTIME_API void *calloc16Align(size_t nmemb,size_t size);
-GR_RUNTIME_API void free16Align(void *p);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/gnuradio-runtime/lib/math/gen_sine_table.py b/gnuradio-runtime/lib/math/gen_sine_table.py
index d7d11eff11..5b459fa1a3 100755..100644
--- a/gnuradio-runtime/lib/math/gen_sine_table.py
+++ b/gnuradio-runtime/lib/math/gen_sine_table.py
@@ -20,6 +20,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import division
+from __future__ import unicode_literals
import math
import sys
@@ -38,8 +40,8 @@ def gen_approx_table (f, nentries, min_x, max_x):
for i in range (nentries):
a = (i * incx) + min_x
b = ((i + 1) * incx) + min_x
- m = (f(b)-f(a))/(b-a)
- c = (3*a+b)*(f(a)-f(b))/(4*(b-a)) + (f((a+b)/2) + f(a))/2
+ m = (f(b)-f(a)) / (b-a)
+ c = (3*a+b)*(f(a)-f(b))/(4*(b-a)) + (f((a+b)/2) + f(a))//2
abs_error = c+m*a-f(a)
r.append ((m, c, abs_error))
return r
diff --git a/gnuradio-runtime/lib/math/qa_fxpt.cc b/gnuradio-runtime/lib/math/qa_fxpt.cc
index f369cd356a..5073df6e39 100644
--- a/gnuradio-runtime/lib/math/qa_fxpt.cc
+++ b/gnuradio-runtime/lib/math/qa_fxpt.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2013 Free Software Foundation, Inc.
+ * Copyright 2004,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -34,9 +34,9 @@
static const float SIN_COS_TOLERANCE = 1e-5;
BOOST_AUTO_TEST_CASE(t0) {
- BOOST_CHECK(std::abs(M_PI/2 - gr::fxpt::fixed_to_float(0x40000000)) <= SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(GR_M_PI/2 - gr::fxpt::fixed_to_float(0x40000000)) <= SIN_COS_TOLERANCE);
BOOST_CHECK(std::abs(0.0 - gr::fxpt::fixed_to_float(0x00000000)) <= SIN_COS_TOLERANCE);
- BOOST_CHECK(std::abs(-M_PI - gr::fxpt::fixed_to_float(0x80000000)) <= SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(-GR_M_PI - gr::fxpt::fixed_to_float(0x80000000)) <= SIN_COS_TOLERANCE);
if(0) {
/*
@@ -48,9 +48,9 @@ BOOST_AUTO_TEST_CASE(t0) {
* sometimes the answer is off by a few bits at the bottom.
* Hence, the disabled check.
*/
- BOOST_CHECK_EQUAL((int32_t)0x40000000, gr::fxpt::float_to_fixed(M_PI/2));
+ BOOST_CHECK_EQUAL((int32_t)0x40000000, gr::fxpt::float_to_fixed(GR_M_PI/2));
BOOST_CHECK_EQUAL((int32_t)0, gr::fxpt::float_to_fixed(0));
- BOOST_CHECK_EQUAL((int32_t)0x80000000, gr::fxpt::float_to_fixed(-M_PI));
+ BOOST_CHECK_EQUAL((int32_t)0x80000000, gr::fxpt::float_to_fixed(-GR_M_PI));
}
}
@@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE(t1) {
BOOST_CHECK(std::abs(-1 - gr::fxpt::sin(-0x40000000)) <= SIN_COS_TOLERANCE);
BOOST_CHECK(std::abs(-0.707106781 - gr::fxpt::sin(-0x20000000)) <= SIN_COS_TOLERANCE);
- for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) {
+ for(float p = -GR_M_PI; p < GR_M_PI; p += 2 * GR_M_PI / 3600) {
float expected = sin(p);
float actual = gr::fxpt::sin(gr::fxpt::float_to_fixed (p));
BOOST_CHECK(std::abs(expected - actual) <= SIN_COS_TOLERANCE);
@@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(t1) {
}
BOOST_AUTO_TEST_CASE(t2) {
- for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) {
+ for(float p = -GR_M_PI; p < GR_M_PI; p += 2 * GR_M_PI / 3600) {
float expected = cos(p);
float actual = gr::fxpt::cos(gr::fxpt::float_to_fixed(p));
BOOST_CHECK(std::abs(expected - actual) <= SIN_COS_TOLERANCE);
@@ -81,7 +81,7 @@ BOOST_AUTO_TEST_CASE(t2) {
}
BOOST_AUTO_TEST_CASE(t3) {
- for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) {
+ for(float p = -GR_M_PI; p < GR_M_PI; p += 2 * GR_M_PI / 3600) {
float expected_sin = sin(p);
float expected_cos = cos(p);
float actual_sin;
diff --git a/gnuradio-runtime/lib/math/qa_fxpt_nco.cc b/gnuradio-runtime/lib/math/qa_fxpt_nco.cc
index cd05747630..da10f49c92 100644
--- a/gnuradio-runtime/lib/math/qa_fxpt_nco.cc
+++ b/gnuradio-runtime/lib/math/qa_fxpt_nco.cc
@@ -50,8 +50,8 @@ BOOST_AUTO_TEST_CASE(t0) {
gr::fxpt_nco new_nco;
double max_error = 0, max_phase_error = 0;
- ref_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ));
- new_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ));
+ ref_nco.set_freq((float)(2 * GR_M_PI / SIN_COS_FREQ));
+ new_nco.set_freq((float)(2 * GR_M_PI / SIN_COS_FREQ));
BOOST_CHECK(std::abs(ref_nco.get_freq() - new_nco.get_freq()) <= SIN_COS_TOLERANCE);
@@ -86,8 +86,8 @@ BOOST_AUTO_TEST_CASE(t1) {
gr_complex* new_block = new gr_complex[SIN_COS_BLOCK_SIZE];
double max_error = 0;
- ref_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ));
- new_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ));
+ ref_nco.set_freq((float)(2 * GR_M_PI / SIN_COS_FREQ));
+ new_nco.set_freq((float)(2 * GR_M_PI / SIN_COS_FREQ));
BOOST_CHECK(std::abs(ref_nco.get_freq() - new_nco.get_freq()) <= SIN_COS_TOLERANCE);
diff --git a/gnuradio-runtime/lib/math/random.cc b/gnuradio-runtime/lib/math/random.cc
index cedaf4b97f..6a509f1796 100644
--- a/gnuradio-runtime/lib/math/random.cc
+++ b/gnuradio-runtime/lib/math/random.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2002, 2015 Free Software Foundation, Inc.
+ * Copyright 2002,2015,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -39,8 +39,10 @@
#include <config.h>
#endif
-#include <math.h>
#include <gnuradio/random.h>
+#include <gnuradio/math.h>
+
+#include <cmath>
namespace gr {
@@ -155,7 +157,7 @@ namespace gr {
float
random::impulse(float factor = 5)
{
- float z = -M_SQRT2 * logf(ran1());
+ float z = -GR_M_SQRT2 * logf(ran1());
if(fabsf(z) <= factor)
return 0.0;
else
diff --git a/gnuradio-runtime/lib/math/vco.h b/gnuradio-runtime/lib/math/vco.h
index d8a6fbb415..7ac1e1ca6d 100644
--- a/gnuradio-runtime/lib/math/vco.h
+++ b/gnuradio-runtime/lib/math/vco.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005,2013 Free Software Foundation, Inc.
+ * Copyright 2005,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -25,6 +25,8 @@
#include <gnuradio/sincos.h>
#include <gnuradio/gr_complex.h>
+#include <gnuradio/math.h>
+
#include <vector>
#include <cmath>
@@ -49,13 +51,13 @@ namespace gr {
void adjust_phase(double delta_phase) {
d_phase += delta_phase;
- if(fabs (d_phase) > M_PI){
+ if(fabs (d_phase) > GR_M_PI){
- while(d_phase > M_PI)
- d_phase -= 2*M_PI;
+ while(d_phase > GR_M_PI)
+ d_phase -= 2*GR_M_PI;
- while(d_phase < -M_PI)
- d_phase += 2*M_PI;
+ while(d_phase < -GR_M_PI)
+ d_phase += 2*GR_M_PI;
}
}
diff --git a/gnuradio-runtime/lib/pmt/CMakeLists.txt b/gnuradio-runtime/lib/pmt/CMakeLists.txt
index 469c569cdc..c840b8b930 100644
--- a/gnuradio-runtime/lib/pmt/CMakeLists.txt
+++ b/gnuradio-runtime/lib/pmt/CMakeLists.txt
@@ -23,57 +23,8 @@
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-########################################################################
-# Generate serial tags header file
-########################################################################
-
-get_filename_component(PMT_SERIAL_TAGS_H
- ${CMAKE_CURRENT_BINARY_DIR}/../../include/pmt/pmt_serial_tags.h ABSOLUTE
-)
-
-add_custom_command(
- OUTPUT ${PMT_SERIAL_TAGS_H}
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen-serial-tags.py
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/pmt-serial-tags.scm
- COMMAND ${PYTHON_EXECUTABLE}
- ${CMAKE_CURRENT_SOURCE_DIR}/gen-serial-tags.py
- ${CMAKE_CURRENT_SOURCE_DIR}/pmt-serial-tags.scm
- ${PMT_SERIAL_TAGS_H}
-)
-
-install(
- FILES ${PMT_SERIAL_TAGS_H}
- DESTINATION ${GR_INCLUDE_DIR}/pmt
- COMPONENT "runtime_devel"
-)
-
-include(AddFileDependencies)
-ADD_FILE_DEPENDENCIES(
- ${CMAKE_CURRENT_SOURCE_DIR}/pmt_serialize.cc
- ${PMT_SERIAL_TAGS_H}
-)
-
-########################################################################
-# Generate other pmt stuff
-########################################################################
-add_custom_command(
- OUTPUT
- ${CMAKE_CURRENT_BINARY_DIR}/pmt_unv_int.h
- ${CMAKE_CURRENT_BINARY_DIR}/qa_pmt_unv.h
- ${CMAKE_CURRENT_BINARY_DIR}/pmt_unv.cc
- DEPENDS
- ${CMAKE_CURRENT_SOURCE_DIR}/generate_unv.py
- ${CMAKE_CURRENT_SOURCE_DIR}/unv_template.h.t
- ${CMAKE_CURRENT_SOURCE_DIR}/unv_template.cc.t
- ${CMAKE_CURRENT_SOURCE_DIR}/unv_qa_template.h.t
- COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} -c
- "import os, sys; srcdir='${CMAKE_CURRENT_SOURCE_DIR}'; sys.path.append(srcdir); os.environ['srcdir']=srcdir; from generate_unv import main; main()"
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- VERBATIM
-)
-
set(pmt_sources
- ${CMAKE_CURRENT_BINARY_DIR}/pmt_unv.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/pmt_unv.cc
${CMAKE_CURRENT_SOURCE_DIR}/pmt.cc
${CMAKE_CURRENT_SOURCE_DIR}/pmt_io.cc
${CMAKE_CURRENT_SOURCE_DIR}/pmt_pool.cc
@@ -85,10 +36,6 @@ list(APPEND gnuradio_pmt_libs
${LOG4CPP_LIBRARIES}
)
-add_custom_target(pmt_generated
- DEPENDS ${PMT_SERIAL_TAGS_H} ${CMAKE_CURRENT_BINARY_DIR}/pmt_unv_int.h)
-
-
#Add Windows DLL resource file if using MSVC
if(MSVC)
include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
@@ -107,16 +54,12 @@ endif(MSVC)
add_library(gnuradio-pmt SHARED ${pmt_sources})
target_link_libraries(gnuradio-pmt ${gnuradio_pmt_libs})
-GR_LIBRARY_FOO(gnuradio-pmt RUNTIME_COMPONENT "runtime_runtime" DEVEL_COMPONENT "runtime_devel")
-
-add_dependencies(gnuradio-pmt
- pmt_generated
-)
+GR_LIBRARY_FOO(gnuradio-pmt)
if(ENABLE_STATIC_LIBS)
add_library(gnuradio-pmt_static STATIC ${pmt_sources})
- add_dependencies(gnuradio-pmt_static pmt_generated)
+ add_dependencies(gnuradio-pmt_static)
if(NOT WIN32)
set_target_properties(gnuradio-pmt_static
@@ -124,7 +67,39 @@ if(ENABLE_STATIC_LIBS)
endif(NOT WIN32)
install(TARGETS gnuradio-pmt_static
- ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "runtime_devel" # .lib file
+ ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file
)
endif(ENABLE_STATIC_LIBS)
+########################################################################
+# Setup tests
+########################################################################
+if(ENABLE_TESTING)
+include(GrTest)
+
+########################################################################
+# Append gnuradio-runtime test sources
+########################################################################
+list(APPEND test_gnuradio_pmt_sources
+ qa_pmt.cc
+ qa_pmt_prims.cc
+ qa_pmt_unv.cc
+)
+
+include_directories(${CPPUNIT_INCLUDE_DIRS})
+link_directories(${CPPUNIT_LIBRARY_DIRS})
+
+add_library(test-gnuradio-pmt SHARED ${test_gnuradio_pmt_sources})
+target_link_libraries(test-gnuradio-pmt gnuradio-runtime gnuradio-pmt
+ ${CPPUNIT_LIBRARIES} ${Boost_LIBRARIES} ${LOG4CPP_LIBRARIES})
+
+########################################################################
+# Build the test executable
+# Set the test environment so the build libs will be found under MSVC.
+########################################################################
+list(APPEND GR_TEST_TARGET_DEPS test-gnuradio-pmt)
+add_executable(gr_pmt_test test_pmt.cc)
+target_link_libraries(gr_pmt_test test-gnuradio-pmt)
+GR_ADD_TEST(gr-pmt-test gr_pmt_test)
+
+endif(ENABLE_TESTING)
diff --git a/gnuradio-runtime/lib/pmt/generate_unv.py b/gnuradio-runtime/lib/pmt/generate_unv.py
deleted file mode 100755
index c7daee9e45..0000000000
--- a/gnuradio-runtime/lib/pmt/generate_unv.py
+++ /dev/null
@@ -1,162 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2006,2009 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.
-#
-
-"""
-Generate code for uniform numeric vectors
-"""
-
-import re, os, os.path
-
-
-unv_types = (
- ('u8', 'uint8_t'),
- ('s8', 'int8_t'),
- ('u16', 'uint16_t'),
- ('s16', 'int16_t'),
- ('u32', 'uint32_t'),
- ('s32', 'int32_t'),
- ('u64', 'uint64_t'),
- ('s64', 'int64_t'),
- ('f32', 'float'),
- ('f64', 'double'),
- ('c32', 'std::complex<float>'),
- ('c64', 'std::complex<double>')
- )
-
-header = """\
-/* -*- c++ -*- */
-/*
- * Copyright 2006,2009 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.
- */
-"""
-
-guard_tail = """
-#endif
-"""
-
-includes = """
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <vector>
-#include <pmt/pmt.h>
-#include <boost/lexical_cast.hpp>
-#include "pmt_int.h"
-"""
-
-qa_includes = """
-#include <pmt/pmt.h>
-#include <stdio.h>
-
-using namespace pmt;
-"""
-
-
-# set srcdir to the directory that contains Makefile.am
-try:
- srcdir = os.environ['srcdir']
-except KeyError, e:
- srcdir = "."
-srcdir = srcdir + '/'
-
-
-def open_src (name, mode):
- global srcdir
- return open(os.path.join (srcdir, name), mode)
-
-
-def guard_name(filename):
- return 'INCLUDED_' + re.sub('\.', '_', filename.upper())
-
-def guard_head(filename):
- guard = guard_name(filename)
- return """
-#ifndef %s
-#define %s
-""" % (guard, guard)
-
-
-def do_substitution (d, input, out_file):
- def repl (match_obj):
- key = match_obj.group (1)
- # print key
- return d[key]
-
- out = re.sub (r"@([a-zA-Z0-9_]+)@", repl, input)
- out_file.write (out)
-
-
-def generate_h():
- template = open_src('unv_template.h.t', 'r').read()
- output_filename = 'pmt_unv_int.h'
- output = open(output_filename, 'w')
- output.write(header)
- output.write(guard_head(output_filename))
- for tag, typ in unv_types:
- d = { 'TAG' : tag, 'TYPE' : typ }
- do_substitution(d, template, output)
- output.write(guard_tail)
-
-def generate_cc():
- template = open_src('unv_template.cc.t', 'r').read()
- output = open('pmt_unv.cc', 'w')
- output.write(header)
- output.write(includes)
- for tag, typ in unv_types:
- d = { 'TAG' : tag, 'TYPE' : typ }
- do_substitution(d, template, output)
-
-
-def generate_qa_h():
- template = open_src('unv_qa_template.h.t', 'r').read()
- output = open('qa_pmt_unv.h', 'w')
- output.write(header)
- output.write(qa_includes)
- for tag, typ in unv_types:
- d = { 'TAG' : tag, 'TYPE' : typ }
- do_substitution(d, template, output)
-
-
-def main():
- generate_h()
- generate_cc()
- generate_qa_h()
-
-if __name__ == '__main__':
- main()
diff --git a/gnuradio-runtime/lib/pmt/pmt-serial-tags.scm b/gnuradio-runtime/lib/pmt/pmt-serial-tags.scm
deleted file mode 100644
index 4f06bf75f8..0000000000
--- a/gnuradio-runtime/lib/pmt/pmt-serial-tags.scm
+++ /dev/null
@@ -1,77 +0,0 @@
-;;; -*-scheme-*-
-;;;
-;;; Copyright 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 (define 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.
-;;;
-
-;;; definitions of tag values used for marshalling pmt data
-
-(define pst-true #x00)
-(define pst-false #x01)
-(define pst-symbol #x02) ; untagged-int16 n; followed by n bytes of symbol name
-(define pst-int32 #x03)
-(define pst-double #x04)
-(define pst-complex #x05) ; complex<double>: real, imag
-(define pst-null #x06)
-(define pst-pair #x07) ; followed by two objects
-(define pst-vector #x08) ; untagged-int32 n; followed by n objects
-(define pst-dict #x09) ; untagged-int32 n; followed by n key/value tuples
-
-(define pst-uniform-vector #x0a)
-(define pst-uint64 #x0b)
-(define pst-tuple #x0c)
-
-;; u8, s8, u16, s16, u32, s32, u64, s64, f32, f64, c32, c64
-;;
-;; untagged-uint8 tag
-;; untagged-uint8 uvi (define uniform vector info, see below)
-;; untagged-int32 n-items
-;; untagged-uint8 npad
-;; npad bytes of zeros to align binary data
-;; n-items binary numeric items
-;;
-;; uvi:
-;; +-+-+-+-+-+-+-+-+
-;; |B| subtype |
-;; +-+-+-+-+-+-+-+-+
-;;
-;; B == 0, numeric data is little-endian.
-;; B == 1, numeric data is big-endian.
-
- (define uvi-endian-mask #x80)
- (define uvi-subtype-mask #x7f)
-
- (define uvi-little-endian #x00)
- (define uvi-big-endian #x80)
-
- (define uvi-u8 #x00)
- (define uvi-s8 #x01)
- (define uvi-u16 #x02)
- (define uvi-s16 #x03)
- (define uvi-u32 #x04)
- (define uvi-s32 #x05)
- (define uvi-u64 #x06)
- (define uvi-s64 #x07)
- (define uvi-f32 #x08)
- (define uvi-f64 #x09)
- (define uvi-c32 #x0a)
- (define uvi-c64 #x0b)
-
-
-(define pst-comment #x3b) ; ascii ';'
-(define pst-comment-end #x0a) ; ascii '\n'
diff --git a/gnuradio-runtime/lib/pmt/pmt.cc b/gnuradio-runtime/lib/pmt/pmt.cc
index 0fe4dbde8e..763007132f 100644
--- a/gnuradio-runtime/lib/pmt/pmt.cc
+++ b/gnuradio-runtime/lib/pmt/pmt.cc
@@ -63,7 +63,6 @@ pmt_base::operator delete(void *p, size_t size)
#endif
-#if ((BOOST_VERSION / 100000 >= 1) && (BOOST_VERSION / 100 % 1000 >= 53))
void intrusive_ptr_add_ref(pmt_base* p)
{
p->refcount_.fetch_add(1, boost::memory_order_relaxed);
@@ -75,13 +74,6 @@ void intrusive_ptr_release(pmt_base* p) {
delete p;
}
}
-#else
-// boost::atomic not available before 1.53
-// This section will be removed when support for boost 1.48 ceases
-// NB: This code is prone to segfault on non-Intel architectures.
-void intrusive_ptr_add_ref(pmt_base* p) { ++(p->count_); }
-void intrusive_ptr_release(pmt_base* p) { if (--(p->count_) == 0 ) delete p; }
-#endif
pmt_base::~pmt_base()
{
diff --git a/gnuradio-runtime/lib/pmt/pmt_int.h b/gnuradio-runtime/lib/pmt/pmt_int.h
index da48a0ddc8..ead058598d 100644
--- a/gnuradio-runtime/lib/pmt/pmt_int.h
+++ b/gnuradio-runtime/lib/pmt/pmt_int.h
@@ -25,13 +25,7 @@
#include <pmt/pmt.h>
#include <boost/utility.hpp>
#include <boost/version.hpp>
-#if ((BOOST_VERSION / 100000 >= 1) && (BOOST_VERSION / 100 % 1000 >= 53))
- #include <boost/atomic.hpp>
-#else
- // boost::atomic not available before 1.53
- // This section will be removed when support for boost 1.48 ceases
- #include <boost/detail/atomic_count.hpp>
-#endif
+#include <boost/atomic.hpp>
/*
* EVERYTHING IN THIS FILE IS PRIVATE TO THE IMPLEMENTATION!
@@ -43,23 +37,10 @@
namespace pmt {
class PMT_API pmt_base : boost::noncopyable {
-
-#if ((BOOST_VERSION / 100000 >= 1) && (BOOST_VERSION / 100 % 1000 >= 53))
mutable boost::atomic<int> refcount_;
-#else
- // boost::atomic not available before 1.53
- // This section will be removed when support for boost 1.48 ceases
- mutable boost::detail::atomic_count count_;
-#endif
protected:
-#if ((BOOST_VERSION / 100000 >= 1) && (BOOST_VERSION / 100 % 1000 >= 53))
pmt_base() : refcount_(0) {};
-#else
- // boost::atomic not available before 1.53
- // This section will be removed when support for boost 1.48 ceases
- pmt_base() : count_(0) {};
-#endif
virtual ~pmt_base();
public:
@@ -261,9 +242,6 @@ public:
virtual size_t itemsize() const = 0;
virtual const std::string string_ref(size_t k) const { return std::string("not implemented"); }
};
-
-#include "pmt_unv_int.h"
-
} /* namespace pmt */
#endif /* INCLUDED_PMT_INT_H */
diff --git a/gnuradio-runtime/lib/pmt/pmt_unv.cc b/gnuradio-runtime/lib/pmt/pmt_unv.cc
new file mode 100644
index 0000000000..cda0c085cd
--- /dev/null
+++ b/gnuradio-runtime/lib/pmt/pmt_unv.cc
@@ -0,0 +1,1821 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2009,2018 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// This file is machine generated using the generate_unv.py tool
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "pmt_unv_int.h"
+#include "pmt_int.h"
+#include <pmt/pmt.h>
+#include <boost/lexical_cast.hpp>
+#include <vector>
+////////////////////////////////////////////////////////////////////////////
+// pmt_u8vector
+////////////////////////////////////////////////////////////////////////////
+
+namespace pmt {
+
+static pmt_u8vector *
+_u8vector(pmt_t x)
+{
+ return dynamic_cast<pmt_u8vector*>(x.get());
+}
+
+
+pmt_u8vector::pmt_u8vector(size_t k, uint8_t fill)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = fill;
+}
+
+pmt_u8vector::pmt_u8vector(size_t k, const uint8_t *data)
+ : d_v(k)
+{
+ if(k)
+ memcpy( &d_v[0], data, k * sizeof(uint8_t) );
+}
+
+uint8_t
+pmt_u8vector::ref(size_t k) const
+{
+ if (k >= length())
+ throw out_of_range("pmt_u8vector_ref", from_long(k));
+ return d_v[k];
+}
+
+void
+pmt_u8vector::set(size_t k, uint8_t x)
+{
+ if (k >= length())
+ throw out_of_range("pmt_u8vector_set", from_long(k));
+ d_v[k] = x;
+}
+
+const uint8_t *
+pmt_u8vector::elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+uint8_t *
+pmt_u8vector::writable_elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+const void*
+pmt_u8vector::uniform_elements(size_t &len)
+{
+ len = length() * sizeof(uint8_t);
+ return len ? &d_v[0] : nullptr;
+}
+
+void*
+pmt_u8vector::uniform_writable_elements(size_t &len)
+{
+ len = length() * sizeof(uint8_t);
+ return len ? (&d_v[0]) : nullptr;
+}
+
+bool
+is_u8vector(pmt_t obj)
+{
+ return obj->is_u8vector();
+}
+
+pmt_t
+make_u8vector(size_t k, uint8_t fill)
+{
+ return pmt_t(new pmt_u8vector(k, fill));
+}
+
+pmt_t
+init_u8vector(size_t k, const uint8_t *data)
+{
+ return pmt_t(new pmt_u8vector(k, data));
+}
+
+pmt_t
+init_u8vector(size_t k, const std::vector< uint8_t > &data)
+{
+ if(k) {
+ return pmt_t(new pmt_u8vector(k, &data[0]));
+ }
+ return pmt_t(new pmt_u8vector(k, static_cast< uint8_t >(0))); // fills an empty vector with 0
+}
+
+uint8_t
+u8vector_ref(pmt_t vector, size_t k)
+{
+ if (!vector->is_u8vector())
+ throw wrong_type("pmt_u8vector_ref", vector);
+ return _u8vector(vector)->ref(k);
+}
+
+void
+u8vector_set(pmt_t vector, size_t k, uint8_t obj)
+{
+ if (!vector->is_u8vector())
+ throw wrong_type("pmt_u8vector_set", vector);
+ _u8vector(vector)->set(k, obj);
+}
+
+const uint8_t *
+u8vector_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_u8vector())
+ throw wrong_type("pmt_u8vector_elements", vector);
+ return _u8vector(vector)->elements(len);
+}
+
+const std::vector< uint8_t >
+u8vector_elements(pmt_t vector)
+{
+ if (!vector->is_u8vector())
+ throw wrong_type("pmt_u8vector_elements", vector);
+ size_t len;
+ const uint8_t *array = _u8vector(vector)->elements(len);
+ const std::vector< uint8_t > vec(array, array+len);
+ return vec;
+}
+
+
+uint8_t *
+u8vector_writable_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_u8vector())
+ throw wrong_type("pmt_u8vector_writable_elements", vector);
+ return _u8vector(vector)->writable_elements(len);
+}
+
+const std::string
+pmt_u8vector::string_ref(size_t k) const
+{
+ return boost::lexical_cast< std::string, uint8_t > (ref(k));
+}
+
+} /* namespace pmt */
+////////////////////////////////////////////////////////////////////////////
+// pmt_s8vector
+////////////////////////////////////////////////////////////////////////////
+
+namespace pmt {
+
+static pmt_s8vector *
+_s8vector(pmt_t x)
+{
+ return dynamic_cast<pmt_s8vector*>(x.get());
+}
+
+
+pmt_s8vector::pmt_s8vector(size_t k, int8_t fill)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = fill;
+}
+
+pmt_s8vector::pmt_s8vector(size_t k, const int8_t *data)
+ : d_v(k)
+{
+ if(k)
+ memcpy( &d_v[0], data, k * sizeof(int8_t) );
+}
+
+int8_t
+pmt_s8vector::ref(size_t k) const
+{
+ if (k >= length())
+ throw out_of_range("pmt_s8vector_ref", from_long(k));
+ return d_v[k];
+}
+
+void
+pmt_s8vector::set(size_t k, int8_t x)
+{
+ if (k >= length())
+ throw out_of_range("pmt_s8vector_set", from_long(k));
+ d_v[k] = x;
+}
+
+const int8_t *
+pmt_s8vector::elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+int8_t *
+pmt_s8vector::writable_elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+const void*
+pmt_s8vector::uniform_elements(size_t &len)
+{
+ len = length() * sizeof(int8_t);
+ return len ? &d_v[0] : nullptr;
+}
+
+void*
+pmt_s8vector::uniform_writable_elements(size_t &len)
+{
+ len = length() * sizeof(int8_t);
+ return len ? (&d_v[0]) : nullptr;
+}
+
+bool
+is_s8vector(pmt_t obj)
+{
+ return obj->is_s8vector();
+}
+
+pmt_t
+make_s8vector(size_t k, int8_t fill)
+{
+ return pmt_t(new pmt_s8vector(k, fill));
+}
+
+pmt_t
+init_s8vector(size_t k, const int8_t *data)
+{
+ return pmt_t(new pmt_s8vector(k, data));
+}
+
+pmt_t
+init_s8vector(size_t k, const std::vector< int8_t > &data)
+{
+ if(k) {
+ return pmt_t(new pmt_s8vector(k, &data[0]));
+ }
+ return pmt_t(new pmt_s8vector(k, static_cast< int8_t >(0))); // fills an empty vector with 0
+}
+
+int8_t
+s8vector_ref(pmt_t vector, size_t k)
+{
+ if (!vector->is_s8vector())
+ throw wrong_type("pmt_s8vector_ref", vector);
+ return _s8vector(vector)->ref(k);
+}
+
+void
+s8vector_set(pmt_t vector, size_t k, int8_t obj)
+{
+ if (!vector->is_s8vector())
+ throw wrong_type("pmt_s8vector_set", vector);
+ _s8vector(vector)->set(k, obj);
+}
+
+const int8_t *
+s8vector_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_s8vector())
+ throw wrong_type("pmt_s8vector_elements", vector);
+ return _s8vector(vector)->elements(len);
+}
+
+const std::vector< int8_t >
+s8vector_elements(pmt_t vector)
+{
+ if (!vector->is_s8vector())
+ throw wrong_type("pmt_s8vector_elements", vector);
+ size_t len;
+ const int8_t *array = _s8vector(vector)->elements(len);
+ const std::vector< int8_t > vec(array, array+len);
+ return vec;
+}
+
+
+int8_t *
+s8vector_writable_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_s8vector())
+ throw wrong_type("pmt_s8vector_writable_elements", vector);
+ return _s8vector(vector)->writable_elements(len);
+}
+
+const std::string
+pmt_s8vector::string_ref(size_t k) const
+{
+ return boost::lexical_cast< std::string, int8_t > (ref(k));
+}
+
+} /* namespace pmt */
+////////////////////////////////////////////////////////////////////////////
+// pmt_u16vector
+////////////////////////////////////////////////////////////////////////////
+
+namespace pmt {
+
+static pmt_u16vector *
+_u16vector(pmt_t x)
+{
+ return dynamic_cast<pmt_u16vector*>(x.get());
+}
+
+
+pmt_u16vector::pmt_u16vector(size_t k, uint16_t fill)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = fill;
+}
+
+pmt_u16vector::pmt_u16vector(size_t k, const uint16_t *data)
+ : d_v(k)
+{
+ if(k)
+ memcpy( &d_v[0], data, k * sizeof(uint16_t) );
+}
+
+uint16_t
+pmt_u16vector::ref(size_t k) const
+{
+ if (k >= length())
+ throw out_of_range("pmt_u16vector_ref", from_long(k));
+ return d_v[k];
+}
+
+void
+pmt_u16vector::set(size_t k, uint16_t x)
+{
+ if (k >= length())
+ throw out_of_range("pmt_u16vector_set", from_long(k));
+ d_v[k] = x;
+}
+
+const uint16_t *
+pmt_u16vector::elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+uint16_t *
+pmt_u16vector::writable_elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+const void*
+pmt_u16vector::uniform_elements(size_t &len)
+{
+ len = length() * sizeof(uint16_t);
+ return len ? &d_v[0] : nullptr;
+}
+
+void*
+pmt_u16vector::uniform_writable_elements(size_t &len)
+{
+ len = length() * sizeof(uint16_t);
+ return len ? (&d_v[0]) : nullptr;
+}
+
+bool
+is_u16vector(pmt_t obj)
+{
+ return obj->is_u16vector();
+}
+
+pmt_t
+make_u16vector(size_t k, uint16_t fill)
+{
+ return pmt_t(new pmt_u16vector(k, fill));
+}
+
+pmt_t
+init_u16vector(size_t k, const uint16_t *data)
+{
+ return pmt_t(new pmt_u16vector(k, data));
+}
+
+pmt_t
+init_u16vector(size_t k, const std::vector< uint16_t > &data)
+{
+ if(k) {
+ return pmt_t(new pmt_u16vector(k, &data[0]));
+ }
+ return pmt_t(new pmt_u16vector(k, static_cast< uint16_t >(0))); // fills an empty vector with 0
+}
+
+uint16_t
+u16vector_ref(pmt_t vector, size_t k)
+{
+ if (!vector->is_u16vector())
+ throw wrong_type("pmt_u16vector_ref", vector);
+ return _u16vector(vector)->ref(k);
+}
+
+void
+u16vector_set(pmt_t vector, size_t k, uint16_t obj)
+{
+ if (!vector->is_u16vector())
+ throw wrong_type("pmt_u16vector_set", vector);
+ _u16vector(vector)->set(k, obj);
+}
+
+const uint16_t *
+u16vector_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_u16vector())
+ throw wrong_type("pmt_u16vector_elements", vector);
+ return _u16vector(vector)->elements(len);
+}
+
+const std::vector< uint16_t >
+u16vector_elements(pmt_t vector)
+{
+ if (!vector->is_u16vector())
+ throw wrong_type("pmt_u16vector_elements", vector);
+ size_t len;
+ const uint16_t *array = _u16vector(vector)->elements(len);
+ const std::vector< uint16_t > vec(array, array+len);
+ return vec;
+}
+
+
+uint16_t *
+u16vector_writable_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_u16vector())
+ throw wrong_type("pmt_u16vector_writable_elements", vector);
+ return _u16vector(vector)->writable_elements(len);
+}
+
+const std::string
+pmt_u16vector::string_ref(size_t k) const
+{
+ return boost::lexical_cast< std::string, uint16_t > (ref(k));
+}
+
+} /* namespace pmt */
+////////////////////////////////////////////////////////////////////////////
+// pmt_s16vector
+////////////////////////////////////////////////////////////////////////////
+
+namespace pmt {
+
+static pmt_s16vector *
+_s16vector(pmt_t x)
+{
+ return dynamic_cast<pmt_s16vector*>(x.get());
+}
+
+
+pmt_s16vector::pmt_s16vector(size_t k, int16_t fill)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = fill;
+}
+
+pmt_s16vector::pmt_s16vector(size_t k, const int16_t *data)
+ : d_v(k)
+{
+ if(k)
+ memcpy( &d_v[0], data, k * sizeof(int16_t) );
+}
+
+int16_t
+pmt_s16vector::ref(size_t k) const
+{
+ if (k >= length())
+ throw out_of_range("pmt_s16vector_ref", from_long(k));
+ return d_v[k];
+}
+
+void
+pmt_s16vector::set(size_t k, int16_t x)
+{
+ if (k >= length())
+ throw out_of_range("pmt_s16vector_set", from_long(k));
+ d_v[k] = x;
+}
+
+const int16_t *
+pmt_s16vector::elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+int16_t *
+pmt_s16vector::writable_elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+const void*
+pmt_s16vector::uniform_elements(size_t &len)
+{
+ len = length() * sizeof(int16_t);
+ return len ? &d_v[0] : nullptr;
+}
+
+void*
+pmt_s16vector::uniform_writable_elements(size_t &len)
+{
+ len = length() * sizeof(int16_t);
+ return len ? (&d_v[0]) : nullptr;
+}
+
+bool
+is_s16vector(pmt_t obj)
+{
+ return obj->is_s16vector();
+}
+
+pmt_t
+make_s16vector(size_t k, int16_t fill)
+{
+ return pmt_t(new pmt_s16vector(k, fill));
+}
+
+pmt_t
+init_s16vector(size_t k, const int16_t *data)
+{
+ return pmt_t(new pmt_s16vector(k, data));
+}
+
+pmt_t
+init_s16vector(size_t k, const std::vector< int16_t > &data)
+{
+ if(k) {
+ return pmt_t(new pmt_s16vector(k, &data[0]));
+ }
+ return pmt_t(new pmt_s16vector(k, static_cast< int16_t >(0))); // fills an empty vector with 0
+}
+
+int16_t
+s16vector_ref(pmt_t vector, size_t k)
+{
+ if (!vector->is_s16vector())
+ throw wrong_type("pmt_s16vector_ref", vector);
+ return _s16vector(vector)->ref(k);
+}
+
+void
+s16vector_set(pmt_t vector, size_t k, int16_t obj)
+{
+ if (!vector->is_s16vector())
+ throw wrong_type("pmt_s16vector_set", vector);
+ _s16vector(vector)->set(k, obj);
+}
+
+const int16_t *
+s16vector_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_s16vector())
+ throw wrong_type("pmt_s16vector_elements", vector);
+ return _s16vector(vector)->elements(len);
+}
+
+const std::vector< int16_t >
+s16vector_elements(pmt_t vector)
+{
+ if (!vector->is_s16vector())
+ throw wrong_type("pmt_s16vector_elements", vector);
+ size_t len;
+ const int16_t *array = _s16vector(vector)->elements(len);
+ const std::vector< int16_t > vec(array, array+len);
+ return vec;
+}
+
+
+int16_t *
+s16vector_writable_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_s16vector())
+ throw wrong_type("pmt_s16vector_writable_elements", vector);
+ return _s16vector(vector)->writable_elements(len);
+}
+
+const std::string
+pmt_s16vector::string_ref(size_t k) const
+{
+ return boost::lexical_cast< std::string, int16_t > (ref(k));
+}
+
+} /* namespace pmt */
+////////////////////////////////////////////////////////////////////////////
+// pmt_u32vector
+////////////////////////////////////////////////////////////////////////////
+
+namespace pmt {
+
+static pmt_u32vector *
+_u32vector(pmt_t x)
+{
+ return dynamic_cast<pmt_u32vector*>(x.get());
+}
+
+
+pmt_u32vector::pmt_u32vector(size_t k, uint32_t fill)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = fill;
+}
+
+pmt_u32vector::pmt_u32vector(size_t k, const uint32_t *data)
+ : d_v(k)
+{
+ if(k)
+ memcpy( &d_v[0], data, k * sizeof(uint32_t) );
+}
+
+uint32_t
+pmt_u32vector::ref(size_t k) const
+{
+ if (k >= length())
+ throw out_of_range("pmt_u32vector_ref", from_long(k));
+ return d_v[k];
+}
+
+void
+pmt_u32vector::set(size_t k, uint32_t x)
+{
+ if (k >= length())
+ throw out_of_range("pmt_u32vector_set", from_long(k));
+ d_v[k] = x;
+}
+
+const uint32_t *
+pmt_u32vector::elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+uint32_t *
+pmt_u32vector::writable_elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+const void*
+pmt_u32vector::uniform_elements(size_t &len)
+{
+ len = length() * sizeof(uint32_t);
+ return len ? &d_v[0] : nullptr;
+}
+
+void*
+pmt_u32vector::uniform_writable_elements(size_t &len)
+{
+ len = length() * sizeof(uint32_t);
+ return len ? (&d_v[0]) : nullptr;
+}
+
+bool
+is_u32vector(pmt_t obj)
+{
+ return obj->is_u32vector();
+}
+
+pmt_t
+make_u32vector(size_t k, uint32_t fill)
+{
+ return pmt_t(new pmt_u32vector(k, fill));
+}
+
+pmt_t
+init_u32vector(size_t k, const uint32_t *data)
+{
+ return pmt_t(new pmt_u32vector(k, data));
+}
+
+pmt_t
+init_u32vector(size_t k, const std::vector< uint32_t > &data)
+{
+ if(k) {
+ return pmt_t(new pmt_u32vector(k, &data[0]));
+ }
+ return pmt_t(new pmt_u32vector(k, static_cast< uint32_t >(0))); // fills an empty vector with 0
+}
+
+uint32_t
+u32vector_ref(pmt_t vector, size_t k)
+{
+ if (!vector->is_u32vector())
+ throw wrong_type("pmt_u32vector_ref", vector);
+ return _u32vector(vector)->ref(k);
+}
+
+void
+u32vector_set(pmt_t vector, size_t k, uint32_t obj)
+{
+ if (!vector->is_u32vector())
+ throw wrong_type("pmt_u32vector_set", vector);
+ _u32vector(vector)->set(k, obj);
+}
+
+const uint32_t *
+u32vector_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_u32vector())
+ throw wrong_type("pmt_u32vector_elements", vector);
+ return _u32vector(vector)->elements(len);
+}
+
+const std::vector< uint32_t >
+u32vector_elements(pmt_t vector)
+{
+ if (!vector->is_u32vector())
+ throw wrong_type("pmt_u32vector_elements", vector);
+ size_t len;
+ const uint32_t *array = _u32vector(vector)->elements(len);
+ const std::vector< uint32_t > vec(array, array+len);
+ return vec;
+}
+
+
+uint32_t *
+u32vector_writable_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_u32vector())
+ throw wrong_type("pmt_u32vector_writable_elements", vector);
+ return _u32vector(vector)->writable_elements(len);
+}
+
+const std::string
+pmt_u32vector::string_ref(size_t k) const
+{
+ return boost::lexical_cast< std::string, uint32_t > (ref(k));
+}
+
+} /* namespace pmt */
+////////////////////////////////////////////////////////////////////////////
+// pmt_s32vector
+////////////////////////////////////////////////////////////////////////////
+
+namespace pmt {
+
+static pmt_s32vector *
+_s32vector(pmt_t x)
+{
+ return dynamic_cast<pmt_s32vector*>(x.get());
+}
+
+
+pmt_s32vector::pmt_s32vector(size_t k, int32_t fill)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = fill;
+}
+
+pmt_s32vector::pmt_s32vector(size_t k, const int32_t *data)
+ : d_v(k)
+{
+ if(k)
+ memcpy( &d_v[0], data, k * sizeof(int32_t) );
+}
+
+int32_t
+pmt_s32vector::ref(size_t k) const
+{
+ if (k >= length())
+ throw out_of_range("pmt_s32vector_ref", from_long(k));
+ return d_v[k];
+}
+
+void
+pmt_s32vector::set(size_t k, int32_t x)
+{
+ if (k >= length())
+ throw out_of_range("pmt_s32vector_set", from_long(k));
+ d_v[k] = x;
+}
+
+const int32_t *
+pmt_s32vector::elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+int32_t *
+pmt_s32vector::writable_elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+const void*
+pmt_s32vector::uniform_elements(size_t &len)
+{
+ len = length() * sizeof(int32_t);
+ return len ? &d_v[0] : nullptr;
+}
+
+void*
+pmt_s32vector::uniform_writable_elements(size_t &len)
+{
+ len = length() * sizeof(int32_t);
+ return len ? (&d_v[0]) : nullptr;
+}
+
+bool
+is_s32vector(pmt_t obj)
+{
+ return obj->is_s32vector();
+}
+
+pmt_t
+make_s32vector(size_t k, int32_t fill)
+{
+ return pmt_t(new pmt_s32vector(k, fill));
+}
+
+pmt_t
+init_s32vector(size_t k, const int32_t *data)
+{
+ return pmt_t(new pmt_s32vector(k, data));
+}
+
+pmt_t
+init_s32vector(size_t k, const std::vector< int32_t > &data)
+{
+ if(k) {
+ return pmt_t(new pmt_s32vector(k, &data[0]));
+ }
+ return pmt_t(new pmt_s32vector(k, static_cast< int32_t >(0))); // fills an empty vector with 0
+}
+
+int32_t
+s32vector_ref(pmt_t vector, size_t k)
+{
+ if (!vector->is_s32vector())
+ throw wrong_type("pmt_s32vector_ref", vector);
+ return _s32vector(vector)->ref(k);
+}
+
+void
+s32vector_set(pmt_t vector, size_t k, int32_t obj)
+{
+ if (!vector->is_s32vector())
+ throw wrong_type("pmt_s32vector_set", vector);
+ _s32vector(vector)->set(k, obj);
+}
+
+const int32_t *
+s32vector_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_s32vector())
+ throw wrong_type("pmt_s32vector_elements", vector);
+ return _s32vector(vector)->elements(len);
+}
+
+const std::vector< int32_t >
+s32vector_elements(pmt_t vector)
+{
+ if (!vector->is_s32vector())
+ throw wrong_type("pmt_s32vector_elements", vector);
+ size_t len;
+ const int32_t *array = _s32vector(vector)->elements(len);
+ const std::vector< int32_t > vec(array, array+len);
+ return vec;
+}
+
+
+int32_t *
+s32vector_writable_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_s32vector())
+ throw wrong_type("pmt_s32vector_writable_elements", vector);
+ return _s32vector(vector)->writable_elements(len);
+}
+
+const std::string
+pmt_s32vector::string_ref(size_t k) const
+{
+ return boost::lexical_cast< std::string, int32_t > (ref(k));
+}
+
+} /* namespace pmt */
+////////////////////////////////////////////////////////////////////////////
+// pmt_u64vector
+////////////////////////////////////////////////////////////////////////////
+
+namespace pmt {
+
+static pmt_u64vector *
+_u64vector(pmt_t x)
+{
+ return dynamic_cast<pmt_u64vector*>(x.get());
+}
+
+
+pmt_u64vector::pmt_u64vector(size_t k, uint64_t fill)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = fill;
+}
+
+pmt_u64vector::pmt_u64vector(size_t k, const uint64_t *data)
+ : d_v(k)
+{
+ if(k)
+ memcpy( &d_v[0], data, k * sizeof(uint64_t) );
+}
+
+uint64_t
+pmt_u64vector::ref(size_t k) const
+{
+ if (k >= length())
+ throw out_of_range("pmt_u64vector_ref", from_long(k));
+ return d_v[k];
+}
+
+void
+pmt_u64vector::set(size_t k, uint64_t x)
+{
+ if (k >= length())
+ throw out_of_range("pmt_u64vector_set", from_long(k));
+ d_v[k] = x;
+}
+
+const uint64_t *
+pmt_u64vector::elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+uint64_t *
+pmt_u64vector::writable_elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+const void*
+pmt_u64vector::uniform_elements(size_t &len)
+{
+ len = length() * sizeof(uint64_t);
+ return len ? &d_v[0] : nullptr;
+}
+
+void*
+pmt_u64vector::uniform_writable_elements(size_t &len)
+{
+ len = length() * sizeof(uint64_t);
+ return len ? (&d_v[0]) : nullptr;
+}
+
+bool
+is_u64vector(pmt_t obj)
+{
+ return obj->is_u64vector();
+}
+
+pmt_t
+make_u64vector(size_t k, uint64_t fill)
+{
+ return pmt_t(new pmt_u64vector(k, fill));
+}
+
+pmt_t
+init_u64vector(size_t k, const uint64_t *data)
+{
+ return pmt_t(new pmt_u64vector(k, data));
+}
+
+pmt_t
+init_u64vector(size_t k, const std::vector< uint64_t > &data)
+{
+ if(k) {
+ return pmt_t(new pmt_u64vector(k, &data[0]));
+ }
+ return pmt_t(new pmt_u64vector(k, static_cast< uint64_t >(0))); // fills an empty vector with 0
+}
+
+uint64_t
+u64vector_ref(pmt_t vector, size_t k)
+{
+ if (!vector->is_u64vector())
+ throw wrong_type("pmt_u64vector_ref", vector);
+ return _u64vector(vector)->ref(k);
+}
+
+void
+u64vector_set(pmt_t vector, size_t k, uint64_t obj)
+{
+ if (!vector->is_u64vector())
+ throw wrong_type("pmt_u64vector_set", vector);
+ _u64vector(vector)->set(k, obj);
+}
+
+const uint64_t *
+u64vector_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_u64vector())
+ throw wrong_type("pmt_u64vector_elements", vector);
+ return _u64vector(vector)->elements(len);
+}
+
+const std::vector< uint64_t >
+u64vector_elements(pmt_t vector)
+{
+ if (!vector->is_u64vector())
+ throw wrong_type("pmt_u64vector_elements", vector);
+ size_t len;
+ const uint64_t *array = _u64vector(vector)->elements(len);
+ const std::vector< uint64_t > vec(array, array+len);
+ return vec;
+}
+
+
+uint64_t *
+u64vector_writable_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_u64vector())
+ throw wrong_type("pmt_u64vector_writable_elements", vector);
+ return _u64vector(vector)->writable_elements(len);
+}
+
+const std::string
+pmt_u64vector::string_ref(size_t k) const
+{
+ return boost::lexical_cast< std::string, uint64_t > (ref(k));
+}
+
+} /* namespace pmt */
+////////////////////////////////////////////////////////////////////////////
+// pmt_s64vector
+////////////////////////////////////////////////////////////////////////////
+
+namespace pmt {
+
+static pmt_s64vector *
+_s64vector(pmt_t x)
+{
+ return dynamic_cast<pmt_s64vector*>(x.get());
+}
+
+
+pmt_s64vector::pmt_s64vector(size_t k, int64_t fill)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = fill;
+}
+
+pmt_s64vector::pmt_s64vector(size_t k, const int64_t *data)
+ : d_v(k)
+{
+ if(k)
+ memcpy( &d_v[0], data, k * sizeof(int64_t) );
+}
+
+int64_t
+pmt_s64vector::ref(size_t k) const
+{
+ if (k >= length())
+ throw out_of_range("pmt_s64vector_ref", from_long(k));
+ return d_v[k];
+}
+
+void
+pmt_s64vector::set(size_t k, int64_t x)
+{
+ if (k >= length())
+ throw out_of_range("pmt_s64vector_set", from_long(k));
+ d_v[k] = x;
+}
+
+const int64_t *
+pmt_s64vector::elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+int64_t *
+pmt_s64vector::writable_elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+const void*
+pmt_s64vector::uniform_elements(size_t &len)
+{
+ len = length() * sizeof(int64_t);
+ return len ? &d_v[0] : nullptr;
+}
+
+void*
+pmt_s64vector::uniform_writable_elements(size_t &len)
+{
+ len = length() * sizeof(int64_t);
+ return len ? (&d_v[0]) : nullptr;
+}
+
+bool
+is_s64vector(pmt_t obj)
+{
+ return obj->is_s64vector();
+}
+
+pmt_t
+make_s64vector(size_t k, int64_t fill)
+{
+ return pmt_t(new pmt_s64vector(k, fill));
+}
+
+pmt_t
+init_s64vector(size_t k, const int64_t *data)
+{
+ return pmt_t(new pmt_s64vector(k, data));
+}
+
+pmt_t
+init_s64vector(size_t k, const std::vector< int64_t > &data)
+{
+ if(k) {
+ return pmt_t(new pmt_s64vector(k, &data[0]));
+ }
+ return pmt_t(new pmt_s64vector(k, static_cast< int64_t >(0))); // fills an empty vector with 0
+}
+
+int64_t
+s64vector_ref(pmt_t vector, size_t k)
+{
+ if (!vector->is_s64vector())
+ throw wrong_type("pmt_s64vector_ref", vector);
+ return _s64vector(vector)->ref(k);
+}
+
+void
+s64vector_set(pmt_t vector, size_t k, int64_t obj)
+{
+ if (!vector->is_s64vector())
+ throw wrong_type("pmt_s64vector_set", vector);
+ _s64vector(vector)->set(k, obj);
+}
+
+const int64_t *
+s64vector_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_s64vector())
+ throw wrong_type("pmt_s64vector_elements", vector);
+ return _s64vector(vector)->elements(len);
+}
+
+const std::vector< int64_t >
+s64vector_elements(pmt_t vector)
+{
+ if (!vector->is_s64vector())
+ throw wrong_type("pmt_s64vector_elements", vector);
+ size_t len;
+ const int64_t *array = _s64vector(vector)->elements(len);
+ const std::vector< int64_t > vec(array, array+len);
+ return vec;
+}
+
+
+int64_t *
+s64vector_writable_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_s64vector())
+ throw wrong_type("pmt_s64vector_writable_elements", vector);
+ return _s64vector(vector)->writable_elements(len);
+}
+
+const std::string
+pmt_s64vector::string_ref(size_t k) const
+{
+ return boost::lexical_cast< std::string, int64_t > (ref(k));
+}
+
+} /* namespace pmt */
+////////////////////////////////////////////////////////////////////////////
+// pmt_f32vector
+////////////////////////////////////////////////////////////////////////////
+
+namespace pmt {
+
+static pmt_f32vector *
+_f32vector(pmt_t x)
+{
+ return dynamic_cast<pmt_f32vector*>(x.get());
+}
+
+
+pmt_f32vector::pmt_f32vector(size_t k, float fill)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = fill;
+}
+
+pmt_f32vector::pmt_f32vector(size_t k, const float *data)
+ : d_v(k)
+{
+ if(k)
+ memcpy( &d_v[0], data, k * sizeof(float) );
+}
+
+float
+pmt_f32vector::ref(size_t k) const
+{
+ if (k >= length())
+ throw out_of_range("pmt_f32vector_ref", from_long(k));
+ return d_v[k];
+}
+
+void
+pmt_f32vector::set(size_t k, float x)
+{
+ if (k >= length())
+ throw out_of_range("pmt_f32vector_set", from_long(k));
+ d_v[k] = x;
+}
+
+const float *
+pmt_f32vector::elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+float *
+pmt_f32vector::writable_elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+const void*
+pmt_f32vector::uniform_elements(size_t &len)
+{
+ len = length() * sizeof(float);
+ return len ? &d_v[0] : nullptr;
+}
+
+void*
+pmt_f32vector::uniform_writable_elements(size_t &len)
+{
+ len = length() * sizeof(float);
+ return len ? (&d_v[0]) : nullptr;
+}
+
+bool
+is_f32vector(pmt_t obj)
+{
+ return obj->is_f32vector();
+}
+
+pmt_t
+make_f32vector(size_t k, float fill)
+{
+ return pmt_t(new pmt_f32vector(k, fill));
+}
+
+pmt_t
+init_f32vector(size_t k, const float *data)
+{
+ return pmt_t(new pmt_f32vector(k, data));
+}
+
+pmt_t
+init_f32vector(size_t k, const std::vector< float > &data)
+{
+ if(k) {
+ return pmt_t(new pmt_f32vector(k, &data[0]));
+ }
+ return pmt_t(new pmt_f32vector(k, static_cast< float >(0))); // fills an empty vector with 0
+}
+
+float
+f32vector_ref(pmt_t vector, size_t k)
+{
+ if (!vector->is_f32vector())
+ throw wrong_type("pmt_f32vector_ref", vector);
+ return _f32vector(vector)->ref(k);
+}
+
+void
+f32vector_set(pmt_t vector, size_t k, float obj)
+{
+ if (!vector->is_f32vector())
+ throw wrong_type("pmt_f32vector_set", vector);
+ _f32vector(vector)->set(k, obj);
+}
+
+const float *
+f32vector_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_f32vector())
+ throw wrong_type("pmt_f32vector_elements", vector);
+ return _f32vector(vector)->elements(len);
+}
+
+const std::vector< float >
+f32vector_elements(pmt_t vector)
+{
+ if (!vector->is_f32vector())
+ throw wrong_type("pmt_f32vector_elements", vector);
+ size_t len;
+ const float *array = _f32vector(vector)->elements(len);
+ const std::vector< float > vec(array, array+len);
+ return vec;
+}
+
+
+float *
+f32vector_writable_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_f32vector())
+ throw wrong_type("pmt_f32vector_writable_elements", vector);
+ return _f32vector(vector)->writable_elements(len);
+}
+
+const std::string
+pmt_f32vector::string_ref(size_t k) const
+{
+ return boost::lexical_cast< std::string, float > (ref(k));
+}
+
+} /* namespace pmt */
+////////////////////////////////////////////////////////////////////////////
+// pmt_f64vector
+////////////////////////////////////////////////////////////////////////////
+
+namespace pmt {
+
+static pmt_f64vector *
+_f64vector(pmt_t x)
+{
+ return dynamic_cast<pmt_f64vector*>(x.get());
+}
+
+
+pmt_f64vector::pmt_f64vector(size_t k, double fill)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = fill;
+}
+
+pmt_f64vector::pmt_f64vector(size_t k, const double *data)
+ : d_v(k)
+{
+ if(k)
+ memcpy( &d_v[0], data, k * sizeof(double) );
+}
+
+double
+pmt_f64vector::ref(size_t k) const
+{
+ if (k >= length())
+ throw out_of_range("pmt_f64vector_ref", from_long(k));
+ return d_v[k];
+}
+
+void
+pmt_f64vector::set(size_t k, double x)
+{
+ if (k >= length())
+ throw out_of_range("pmt_f64vector_set", from_long(k));
+ d_v[k] = x;
+}
+
+const double *
+pmt_f64vector::elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+double *
+pmt_f64vector::writable_elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+const void*
+pmt_f64vector::uniform_elements(size_t &len)
+{
+ len = length() * sizeof(double);
+ return len ? &d_v[0] : nullptr;
+}
+
+void*
+pmt_f64vector::uniform_writable_elements(size_t &len)
+{
+ len = length() * sizeof(double);
+ return len ? (&d_v[0]) : nullptr;
+}
+
+bool
+is_f64vector(pmt_t obj)
+{
+ return obj->is_f64vector();
+}
+
+pmt_t
+make_f64vector(size_t k, double fill)
+{
+ return pmt_t(new pmt_f64vector(k, fill));
+}
+
+pmt_t
+init_f64vector(size_t k, const double *data)
+{
+ return pmt_t(new pmt_f64vector(k, data));
+}
+
+pmt_t
+init_f64vector(size_t k, const std::vector< double > &data)
+{
+ if(k) {
+ return pmt_t(new pmt_f64vector(k, &data[0]));
+ }
+ return pmt_t(new pmt_f64vector(k, static_cast< double >(0))); // fills an empty vector with 0
+}
+
+double
+f64vector_ref(pmt_t vector, size_t k)
+{
+ if (!vector->is_f64vector())
+ throw wrong_type("pmt_f64vector_ref", vector);
+ return _f64vector(vector)->ref(k);
+}
+
+void
+f64vector_set(pmt_t vector, size_t k, double obj)
+{
+ if (!vector->is_f64vector())
+ throw wrong_type("pmt_f64vector_set", vector);
+ _f64vector(vector)->set(k, obj);
+}
+
+const double *
+f64vector_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_f64vector())
+ throw wrong_type("pmt_f64vector_elements", vector);
+ return _f64vector(vector)->elements(len);
+}
+
+const std::vector< double >
+f64vector_elements(pmt_t vector)
+{
+ if (!vector->is_f64vector())
+ throw wrong_type("pmt_f64vector_elements", vector);
+ size_t len;
+ const double *array = _f64vector(vector)->elements(len);
+ const std::vector< double > vec(array, array+len);
+ return vec;
+}
+
+
+double *
+f64vector_writable_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_f64vector())
+ throw wrong_type("pmt_f64vector_writable_elements", vector);
+ return _f64vector(vector)->writable_elements(len);
+}
+
+const std::string
+pmt_f64vector::string_ref(size_t k) const
+{
+ return boost::lexical_cast< std::string, double > (ref(k));
+}
+
+} /* namespace pmt */
+////////////////////////////////////////////////////////////////////////////
+// pmt_c32vector
+////////////////////////////////////////////////////////////////////////////
+
+namespace pmt {
+
+static pmt_c32vector *
+_c32vector(pmt_t x)
+{
+ return dynamic_cast<pmt_c32vector*>(x.get());
+}
+
+
+pmt_c32vector::pmt_c32vector(size_t k, std::complex<float> fill)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = fill;
+}
+
+pmt_c32vector::pmt_c32vector(size_t k, const std::complex<float> *data)
+ : d_v(k)
+{
+ if(k)
+ memcpy( &d_v[0], data, k * sizeof(std::complex<float>) );
+}
+
+std::complex<float>
+pmt_c32vector::ref(size_t k) const
+{
+ if (k >= length())
+ throw out_of_range("pmt_c32vector_ref", from_long(k));
+ return d_v[k];
+}
+
+void
+pmt_c32vector::set(size_t k, std::complex<float> x)
+{
+ if (k >= length())
+ throw out_of_range("pmt_c32vector_set", from_long(k));
+ d_v[k] = x;
+}
+
+const std::complex<float> *
+pmt_c32vector::elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+std::complex<float> *
+pmt_c32vector::writable_elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+const void*
+pmt_c32vector::uniform_elements(size_t &len)
+{
+ len = length() * sizeof(std::complex<float>);
+ return len ? &d_v[0] : nullptr;
+}
+
+void*
+pmt_c32vector::uniform_writable_elements(size_t &len)
+{
+ len = length() * sizeof(std::complex<float>);
+ return len ? (&d_v[0]) : nullptr;
+}
+
+bool
+is_c32vector(pmt_t obj)
+{
+ return obj->is_c32vector();
+}
+
+pmt_t
+make_c32vector(size_t k, std::complex<float> fill)
+{
+ return pmt_t(new pmt_c32vector(k, fill));
+}
+
+pmt_t
+init_c32vector(size_t k, const std::complex<float> *data)
+{
+ return pmt_t(new pmt_c32vector(k, data));
+}
+
+pmt_t
+init_c32vector(size_t k, const std::vector< std::complex<float> > &data)
+{
+ if(k) {
+ return pmt_t(new pmt_c32vector(k, &data[0]));
+ }
+ return pmt_t(new pmt_c32vector(k, static_cast< std::complex<float> >(0))); // fills an empty vector with 0
+}
+
+std::complex<float>
+c32vector_ref(pmt_t vector, size_t k)
+{
+ if (!vector->is_c32vector())
+ throw wrong_type("pmt_c32vector_ref", vector);
+ return _c32vector(vector)->ref(k);
+}
+
+void
+c32vector_set(pmt_t vector, size_t k, std::complex<float> obj)
+{
+ if (!vector->is_c32vector())
+ throw wrong_type("pmt_c32vector_set", vector);
+ _c32vector(vector)->set(k, obj);
+}
+
+const std::complex<float> *
+c32vector_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_c32vector())
+ throw wrong_type("pmt_c32vector_elements", vector);
+ return _c32vector(vector)->elements(len);
+}
+
+const std::vector< std::complex<float> >
+c32vector_elements(pmt_t vector)
+{
+ if (!vector->is_c32vector())
+ throw wrong_type("pmt_c32vector_elements", vector);
+ size_t len;
+ const std::complex<float> *array = _c32vector(vector)->elements(len);
+ const std::vector< std::complex<float> > vec(array, array+len);
+ return vec;
+}
+
+
+std::complex<float> *
+c32vector_writable_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_c32vector())
+ throw wrong_type("pmt_c32vector_writable_elements", vector);
+ return _c32vector(vector)->writable_elements(len);
+}
+
+const std::string
+pmt_c32vector::string_ref(size_t k) const
+{
+ return boost::lexical_cast< std::string, std::complex<float> > (ref(k));
+}
+
+} /* namespace pmt */
+////////////////////////////////////////////////////////////////////////////
+// pmt_c64vector
+////////////////////////////////////////////////////////////////////////////
+
+namespace pmt {
+
+static pmt_c64vector *
+_c64vector(pmt_t x)
+{
+ return dynamic_cast<pmt_c64vector*>(x.get());
+}
+
+
+pmt_c64vector::pmt_c64vector(size_t k, std::complex<double> fill)
+ : d_v(k)
+{
+ for (size_t i = 0; i < k; i++)
+ d_v[i] = fill;
+}
+
+pmt_c64vector::pmt_c64vector(size_t k, const std::complex<double> *data)
+ : d_v(k)
+{
+ if(k)
+ memcpy( &d_v[0], data, k * sizeof(std::complex<double>) );
+}
+
+std::complex<double>
+pmt_c64vector::ref(size_t k) const
+{
+ if (k >= length())
+ throw out_of_range("pmt_c64vector_ref", from_long(k));
+ return d_v[k];
+}
+
+void
+pmt_c64vector::set(size_t k, std::complex<double> x)
+{
+ if (k >= length())
+ throw out_of_range("pmt_c64vector_set", from_long(k));
+ d_v[k] = x;
+}
+
+const std::complex<double> *
+pmt_c64vector::elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+std::complex<double> *
+pmt_c64vector::writable_elements(size_t &len)
+{
+ len = length();
+ return len ? &d_v[0] : nullptr;
+}
+
+const void*
+pmt_c64vector::uniform_elements(size_t &len)
+{
+ len = length() * sizeof(std::complex<double>);
+ return len ? &d_v[0] : nullptr;
+}
+
+void*
+pmt_c64vector::uniform_writable_elements(size_t &len)
+{
+ len = length() * sizeof(std::complex<double>);
+ return len ? (&d_v[0]) : nullptr;
+}
+
+bool
+is_c64vector(pmt_t obj)
+{
+ return obj->is_c64vector();
+}
+
+pmt_t
+make_c64vector(size_t k, std::complex<double> fill)
+{
+ return pmt_t(new pmt_c64vector(k, fill));
+}
+
+pmt_t
+init_c64vector(size_t k, const std::complex<double> *data)
+{
+ return pmt_t(new pmt_c64vector(k, data));
+}
+
+pmt_t
+init_c64vector(size_t k, const std::vector< std::complex<double> > &data)
+{
+ if(k) {
+ return pmt_t(new pmt_c64vector(k, &data[0]));
+ }
+ return pmt_t(new pmt_c64vector(k, static_cast< std::complex<double> >(0))); // fills an empty vector with 0
+}
+
+std::complex<double>
+c64vector_ref(pmt_t vector, size_t k)
+{
+ if (!vector->is_c64vector())
+ throw wrong_type("pmt_c64vector_ref", vector);
+ return _c64vector(vector)->ref(k);
+}
+
+void
+c64vector_set(pmt_t vector, size_t k, std::complex<double> obj)
+{
+ if (!vector->is_c64vector())
+ throw wrong_type("pmt_c64vector_set", vector);
+ _c64vector(vector)->set(k, obj);
+}
+
+const std::complex<double> *
+c64vector_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_c64vector())
+ throw wrong_type("pmt_c64vector_elements", vector);
+ return _c64vector(vector)->elements(len);
+}
+
+const std::vector< std::complex<double> >
+c64vector_elements(pmt_t vector)
+{
+ if (!vector->is_c64vector())
+ throw wrong_type("pmt_c64vector_elements", vector);
+ size_t len;
+ const std::complex<double> *array = _c64vector(vector)->elements(len);
+ const std::vector< std::complex<double> > vec(array, array+len);
+ return vec;
+}
+
+
+std::complex<double> *
+c64vector_writable_elements(pmt_t vector, size_t &len)
+{
+ if (!vector->is_c64vector())
+ throw wrong_type("pmt_c64vector_writable_elements", vector);
+ return _c64vector(vector)->writable_elements(len);
+}
+
+const std::string
+pmt_c64vector::string_ref(size_t k) const
+{
+ return boost::lexical_cast< std::string, std::complex<double> > (ref(k));
+}
+
+} /* namespace pmt */
diff --git a/gnuradio-runtime/lib/pmt/pmt_unv_int.h b/gnuradio-runtime/lib/pmt/pmt_unv_int.h
new file mode 100644
index 0000000000..4b4364b411
--- /dev/null
+++ b/gnuradio-runtime/lib/pmt/pmt_unv_int.h
@@ -0,0 +1,331 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2009,2018 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_PMT_UNV_INT_H
+#define INCLUDED_PMT_UNV_INT_H
+
+#include "pmt_int.h"
+
+#include <vector>
+#include <cstdint>
+
+namespace pmt{
+////////////////////////////////////////////////////////////////////////////
+// pmt_u8vector
+////////////////////////////////////////////////////////////////////////////
+class PMT_API pmt_u8vector : public pmt_uniform_vector
+{
+ std::vector< uint8_t > d_v;
+
+public:
+ pmt_u8vector(size_t k, uint8_t fill);
+ pmt_u8vector(size_t k, const uint8_t *data);
+ // ~pmt_u8vector();
+
+ bool is_u8vector() const { return true; }
+ size_t length() const { return d_v.size(); }
+ size_t itemsize() const { return sizeof(uint8_t); }
+ uint8_t ref(size_t k) const;
+ void set(size_t k, uint8_t x);
+ const uint8_t *elements(size_t &len);
+ uint8_t *writable_elements(size_t &len);
+ const void *uniform_elements(size_t &len);
+ void *uniform_writable_elements(size_t &len);
+ virtual const std::string string_ref(size_t k) const;
+};
+
+////////////////////////////////////////////////////////////////////////////
+// pmt_s8vector
+////////////////////////////////////////////////////////////////////////////
+
+class pmt_s8vector : public pmt_uniform_vector
+{
+ std::vector< int8_t > d_v;
+
+public:
+ pmt_s8vector(size_t k, int8_t fill);
+ pmt_s8vector(size_t k, const int8_t *data);
+ // ~pmt_s8vector();
+
+ bool is_s8vector() const { return true; }
+ size_t length() const { return d_v.size(); }
+ size_t itemsize() const { return sizeof(int8_t); }
+ int8_t ref(size_t k) const;
+ void set(size_t k, int8_t x);
+ const int8_t *elements(size_t &len);
+ int8_t *writable_elements(size_t &len);
+ const void *uniform_elements(size_t &len);
+ void *uniform_writable_elements(size_t &len);
+ virtual const std::string string_ref(size_t k) const;
+};
+
+////////////////////////////////////////////////////////////////////////////
+// pmt_u16vector
+////////////////////////////////////////////////////////////////////////////
+
+class pmt_u16vector : public pmt_uniform_vector
+{
+ std::vector< uint16_t > d_v;
+
+public:
+ pmt_u16vector(size_t k, uint16_t fill);
+ pmt_u16vector(size_t k, const uint16_t *data);
+ // ~pmt_u16vector();
+
+ bool is_u16vector() const { return true; }
+ size_t length() const { return d_v.size(); }
+ size_t itemsize() const { return sizeof(uint16_t); }
+ uint16_t ref(size_t k) const;
+ void set(size_t k, uint16_t x);
+ const uint16_t *elements(size_t &len);
+ uint16_t *writable_elements(size_t &len);
+ const void *uniform_elements(size_t &len);
+ void *uniform_writable_elements(size_t &len);
+ virtual const std::string string_ref(size_t k) const;
+};
+
+////////////////////////////////////////////////////////////////////////////
+// pmt_s16vector
+////////////////////////////////////////////////////////////////////////////
+
+class pmt_s16vector : public pmt_uniform_vector
+{
+ std::vector< int16_t > d_v;
+
+public:
+ pmt_s16vector(size_t k, int16_t fill);
+ pmt_s16vector(size_t k, const int16_t *data);
+ // ~pmt_s16vector();
+
+ bool is_s16vector() const { return true; }
+ size_t length() const { return d_v.size(); }
+ size_t itemsize() const { return sizeof(int16_t); }
+ int16_t ref(size_t k) const;
+ void set(size_t k, int16_t x);
+ const int16_t *elements(size_t &len);
+ int16_t *writable_elements(size_t &len);
+ const void *uniform_elements(size_t &len);
+ void *uniform_writable_elements(size_t &len);
+ virtual const std::string string_ref(size_t k) const;
+};
+
+////////////////////////////////////////////////////////////////////////////
+// pmt_u32vector
+////////////////////////////////////////////////////////////////////////////
+
+class pmt_u32vector : public pmt_uniform_vector
+{
+ std::vector< uint32_t > d_v;
+
+public:
+ pmt_u32vector(size_t k, uint32_t fill);
+ pmt_u32vector(size_t k, const uint32_t *data);
+ // ~pmt_u32vector();
+
+ bool is_u32vector() const { return true; }
+ size_t length() const { return d_v.size(); }
+ size_t itemsize() const { return sizeof(uint32_t); }
+ uint32_t ref(size_t k) const;
+ void set(size_t k, uint32_t x);
+ const uint32_t *elements(size_t &len);
+ uint32_t *writable_elements(size_t &len);
+ const void *uniform_elements(size_t &len);
+ void *uniform_writable_elements(size_t &len);
+ virtual const std::string string_ref(size_t k) const;
+};
+
+////////////////////////////////////////////////////////////////////////////
+// pmt_s32vector
+////////////////////////////////////////////////////////////////////////////
+
+class pmt_s32vector : public pmt_uniform_vector
+{
+ std::vector< int32_t > d_v;
+
+public:
+ pmt_s32vector(size_t k, int32_t fill);
+ pmt_s32vector(size_t k, const int32_t *data);
+ // ~pmt_s32vector();
+
+ bool is_s32vector() const { return true; }
+ size_t length() const { return d_v.size(); }
+ size_t itemsize() const { return sizeof(int32_t); }
+ int32_t ref(size_t k) const;
+ void set(size_t k, int32_t x);
+ const int32_t *elements(size_t &len);
+ int32_t *writable_elements(size_t &len);
+ const void *uniform_elements(size_t &len);
+ void *uniform_writable_elements(size_t &len);
+ virtual const std::string string_ref(size_t k) const;
+};
+
+////////////////////////////////////////////////////////////////////////////
+// pmt_u64vector
+////////////////////////////////////////////////////////////////////////////
+
+class pmt_u64vector : public pmt_uniform_vector
+{
+ std::vector< uint64_t > d_v;
+
+public:
+ pmt_u64vector(size_t k, uint64_t fill);
+ pmt_u64vector(size_t k, const uint64_t *data);
+ // ~pmt_u64vector();
+
+ bool is_u64vector() const { return true; }
+ size_t length() const { return d_v.size(); }
+ size_t itemsize() const { return sizeof(uint64_t); }
+ uint64_t ref(size_t k) const;
+ void set(size_t k, uint64_t x);
+ const uint64_t *elements(size_t &len);
+ uint64_t *writable_elements(size_t &len);
+ const void *uniform_elements(size_t &len);
+ void *uniform_writable_elements(size_t &len);
+ virtual const std::string string_ref(size_t k) const;
+};
+
+////////////////////////////////////////////////////////////////////////////
+// pmt_s64vector
+////////////////////////////////////////////////////////////////////////////
+
+class pmt_s64vector : public pmt_uniform_vector
+{
+ std::vector< int64_t > d_v;
+
+public:
+ pmt_s64vector(size_t k, int64_t fill);
+ pmt_s64vector(size_t k, const int64_t *data);
+ // ~pmt_s64vector();
+
+ bool is_s64vector() const { return true; }
+ size_t length() const { return d_v.size(); }
+ size_t itemsize() const { return sizeof(int64_t); }
+ int64_t ref(size_t k) const;
+ void set(size_t k, int64_t x);
+ const int64_t *elements(size_t &len);
+ int64_t *writable_elements(size_t &len);
+ const void *uniform_elements(size_t &len);
+ void *uniform_writable_elements(size_t &len);
+ virtual const std::string string_ref(size_t k) const;
+};
+
+////////////////////////////////////////////////////////////////////////////
+// pmt_f32vector
+////////////////////////////////////////////////////////////////////////////
+
+class pmt_f32vector : public pmt_uniform_vector
+{
+ std::vector< float > d_v;
+
+public:
+ pmt_f32vector(size_t k, float fill);
+ pmt_f32vector(size_t k, const float *data);
+ // ~pmt_f32vector();
+
+ bool is_f32vector() const { return true; }
+ size_t length() const { return d_v.size(); }
+ size_t itemsize() const { return sizeof(float); }
+ float ref(size_t k) const;
+ void set(size_t k, float x);
+ const float *elements(size_t &len);
+ float *writable_elements(size_t &len);
+ const void *uniform_elements(size_t &len);
+ void *uniform_writable_elements(size_t &len);
+ virtual const std::string string_ref(size_t k) const;
+};
+
+////////////////////////////////////////////////////////////////////////////
+// pmt_f64vector
+////////////////////////////////////////////////////////////////////////////
+
+class pmt_f64vector : public pmt_uniform_vector
+{
+ std::vector< double > d_v;
+
+public:
+ pmt_f64vector(size_t k, double fill);
+ pmt_f64vector(size_t k, const double *data);
+ // ~pmt_f64vector();
+
+ bool is_f64vector() const { return true; }
+ size_t length() const { return d_v.size(); }
+ size_t itemsize() const { return sizeof(double); }
+ double ref(size_t k) const;
+ void set(size_t k, double x);
+ const double *elements(size_t &len);
+ double *writable_elements(size_t &len);
+ const void *uniform_elements(size_t &len);
+ void *uniform_writable_elements(size_t &len);
+ virtual const std::string string_ref(size_t k) const;
+};
+
+////////////////////////////////////////////////////////////////////////////
+// pmt_c32vector
+////////////////////////////////////////////////////////////////////////////
+
+class pmt_c32vector : public pmt_uniform_vector
+{
+ std::vector< std::complex<float> > d_v;
+
+public:
+ pmt_c32vector(size_t k, std::complex<float> fill);
+ pmt_c32vector(size_t k, const std::complex<float> *data);
+ // ~pmt_c32vector();
+
+ bool is_c32vector() const { return true; }
+ size_t length() const { return d_v.size(); }
+ size_t itemsize() const { return sizeof(std::complex<float>); }
+ std::complex<float> ref(size_t k) const;
+ void set(size_t k, std::complex<float> x);
+ const std::complex<float> *elements(size_t &len);
+ std::complex<float> *writable_elements(size_t &len);
+ const void *uniform_elements(size_t &len);
+ void *uniform_writable_elements(size_t &len);
+ virtual const std::string string_ref(size_t k) const;
+};
+
+////////////////////////////////////////////////////////////////////////////
+// pmt_c64vector
+////////////////////////////////////////////////////////////////////////////
+
+class pmt_c64vector : public pmt_uniform_vector
+{
+ std::vector< std::complex<double> > d_v;
+
+public:
+ pmt_c64vector(size_t k, std::complex<double> fill);
+ pmt_c64vector(size_t k, const std::complex<double> *data);
+ // ~pmt_c64vector();
+
+ bool is_c64vector() const { return true; }
+ size_t length() const { return d_v.size(); }
+ size_t itemsize() const { return sizeof(std::complex<double>); }
+ std::complex<double> ref(size_t k) const;
+ void set(size_t k, std::complex<double> x);
+ const std::complex<double> *elements(size_t &len);
+ std::complex<double> *writable_elements(size_t &len);
+ const void *uniform_elements(size_t &len);
+ void *uniform_writable_elements(size_t &len);
+ virtual const std::string string_ref(size_t k) const;
+};
+} /* namespace pmt */
+#endif
diff --git a/gnuradio-runtime/lib/pmt/qa_pmt_unv.h b/gnuradio-runtime/lib/pmt/qa_pmt_unv.h
new file mode 100644
index 0000000000..71462a9212
--- /dev/null
+++ b/gnuradio-runtime/lib/pmt/qa_pmt_unv.h
@@ -0,0 +1,61 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2009 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_QA_PMT_UNV_H
+#define INCLUDED_QA_PMT_UNV_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_pmt_unv : public CppUnit::TestCase {
+
+ CPPUNIT_TEST_SUITE(qa_pmt_unv);
+ CPPUNIT_TEST(test_u8vector);
+ CPPUNIT_TEST(test_s8vector);
+ CPPUNIT_TEST(test_u16vector);
+ CPPUNIT_TEST(test_s16vector);
+ CPPUNIT_TEST(test_u32vector);
+ CPPUNIT_TEST(test_s32vector);
+ CPPUNIT_TEST(test_u64vector);
+ CPPUNIT_TEST(test_s64vector);
+ CPPUNIT_TEST(test_f32vector);
+ CPPUNIT_TEST(test_f64vector);
+ CPPUNIT_TEST(test_c32vector);
+ CPPUNIT_TEST(test_c64vector);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ void test_u8vector();
+ void test_s8vector();
+ void test_u16vector();
+ void test_s16vector();
+ void test_u32vector();
+ void test_s32vector();
+ void test_u64vector();
+ void test_s64vector();
+ void test_f32vector();
+ void test_f64vector();
+ void test_c32vector();
+ void test_c64vector();
+};
+
+#endif
diff --git a/gnuradio-runtime/lib/pmt/unv_template.cc.t b/gnuradio-runtime/lib/pmt/unv_template.cc.t
deleted file mode 100644
index 62b810acab..0000000000
--- a/gnuradio-runtime/lib/pmt/unv_template.cc.t
+++ /dev/null
@@ -1,149 +0,0 @@
-////////////////////////////////////////////////////////////////////////////
-// pmt_@TAG@vector
-////////////////////////////////////////////////////////////////////////////
-
-namespace pmt {
-
-static pmt_@TAG@vector *
-_@TAG@vector(pmt_t x)
-{
- return dynamic_cast<pmt_@TAG@vector*>(x.get());
-}
-
-
-pmt_@TAG@vector::pmt_@TAG@vector(size_t k, @TYPE@ fill)
- : d_v(k)
-{
- for (size_t i = 0; i < k; i++)
- d_v[i] = fill;
-}
-
-pmt_@TAG@vector::pmt_@TAG@vector(size_t k, const @TYPE@ *data)
- : d_v(k)
-{
- if(k)
- memcpy( &d_v[0], data, k * sizeof(@TYPE@) );
-}
-
-@TYPE@
-pmt_@TAG@vector::ref(size_t k) const
-{
- if (k >= length())
- throw out_of_range("pmt_@TAG@vector_ref", from_long(k));
- return d_v[k];
-}
-
-void
-pmt_@TAG@vector::set(size_t k, @TYPE@ x)
-{
- if (k >= length())
- throw out_of_range("pmt_@TAG@vector_set", from_long(k));
- d_v[k] = x;
-}
-
-const @TYPE@ *
-pmt_@TAG@vector::elements(size_t &len)
-{
- len = length();
- return len ? &d_v[0] : NULL;
-}
-
-@TYPE@ *
-pmt_@TAG@vector::writable_elements(size_t &len)
-{
- len = length();
- return len ? &d_v[0] : NULL;
-}
-
-const void*
-pmt_@TAG@vector::uniform_elements(size_t &len)
-{
- len = length() * sizeof(@TYPE@);
- return len ? &d_v[0] : NULL;
-}
-
-void*
-pmt_@TAG@vector::uniform_writable_elements(size_t &len)
-{
- len = length() * sizeof(@TYPE@);
- return len ? (&d_v[0]) : NULL;
-}
-
-bool
-is_@TAG@vector(pmt_t obj)
-{
- return obj->is_@TAG@vector();
-}
-
-pmt_t
-make_@TAG@vector(size_t k, @TYPE@ fill)
-{
- return pmt_t(new pmt_@TAG@vector(k, fill));
-}
-
-pmt_t
-init_@TAG@vector(size_t k, const @TYPE@ *data)
-{
- return pmt_t(new pmt_@TAG@vector(k, data));
-}
-
-pmt_t
-init_@TAG@vector(size_t k, const std::vector< @TYPE@ > &data)
-{
- if(k) {
- return pmt_t(new pmt_@TAG@vector(k, &data[0]));
- }
- return pmt_t(new pmt_@TAG@vector(k, static_cast< @TYPE@ >(0))); // fills an empty vector with 0
-}
-
-@TYPE@
-@TAG@vector_ref(pmt_t vector, size_t k)
-{
- if (!vector->is_@TAG@vector())
- throw wrong_type("pmt_@TAG@vector_ref", vector);
- return _@TAG@vector(vector)->ref(k);
-}
-
-void
-@TAG@vector_set(pmt_t vector, size_t k, @TYPE@ obj)
-{
- if (!vector->is_@TAG@vector())
- throw wrong_type("pmt_@TAG@vector_set", vector);
- _@TAG@vector(vector)->set(k, obj);
-}
-
-const @TYPE@ *
-@TAG@vector_elements(pmt_t vector, size_t &len)
-{
- if (!vector->is_@TAG@vector())
- throw wrong_type("pmt_@TAG@vector_elements", vector);
- return _@TAG@vector(vector)->elements(len);
-}
-
-const std::vector< @TYPE@ >
-@TAG@vector_elements(pmt_t vector)
-{
- if (!vector->is_@TAG@vector())
- throw wrong_type("pmt_@TAG@vector_elements", vector);
- size_t len;
- const @TYPE@ *array = _@TAG@vector(vector)->elements(len);
- const std::vector< @TYPE@ > vec(array, array+len);
- return vec;
-}
-
-
-@TYPE@ *
-@TAG@vector_writable_elements(pmt_t vector, size_t &len)
-{
- if (!vector->is_@TAG@vector())
- throw wrong_type("pmt_@TAG@vector_writable_elements", vector);
- return _@TAG@vector(vector)->writable_elements(len);
-}
-
-const std::string
-pmt_@TAG@vector::string_ref(size_t k) const
-{
- return boost::lexical_cast< std::string, @TYPE@ > (ref(k));
-}
-
-} /* namespace pmt */
diff --git a/gnuradio-runtime/lib/pmt/unv_template.h.t b/gnuradio-runtime/lib/pmt/unv_template.h.t
deleted file mode 100644
index ab5c163570..0000000000
--- a/gnuradio-runtime/lib/pmt/unv_template.h.t
+++ /dev/null
@@ -1,25 +0,0 @@
-
-////////////////////////////////////////////////////////////////////////////
-// pmt_@TAG@vector
-////////////////////////////////////////////////////////////////////////////
-
-class pmt_@TAG@vector : public pmt_uniform_vector
-{
- std::vector< @TYPE@ > d_v;
-
-public:
- pmt_@TAG@vector(size_t k, @TYPE@ fill);
- pmt_@TAG@vector(size_t k, const @TYPE@ *data);
- // ~pmt_@TAG@vector();
-
- bool is_@TAG@vector() const { return true; }
- size_t length() const { return d_v.size(); }
- size_t itemsize() const { return sizeof(@TYPE@); }
- @TYPE@ ref(size_t k) const;
- void set(size_t k, @TYPE@ x);
- const @TYPE@ *elements(size_t &len);
- @TYPE@ *writable_elements(size_t &len);
- const void *uniform_elements(size_t &len);
- void *uniform_writable_elements(size_t &len);
- virtual const std::string string_ref(size_t k) const;
-};
diff --git a/gnuradio-runtime/lib/posix_memalign.cc b/gnuradio-runtime/lib/posix_memalign.cc
deleted file mode 100644
index eb3bbe3e0f..0000000000
--- a/gnuradio-runtime/lib/posix_memalign.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008,2009 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "posix_memalign.h"
-
-#ifdef HAVE_MALLOC_H
-// for Cygwin valloc () prototype
-#include <malloc.h>
-#endif
-
-#ifndef HAVE_POSIX_MEMALIGN
-
-/* emulate posix_memalign functionality, to some degree */
-
-#include <errno.h>
-#include "pagesize.h"
-
-int posix_memalign
-(void **memptr, size_t alignment, size_t size)
-{
- /* emulate posix_memalign functionality, to some degree */
-
- /* make sure the return handle is valid; return "bad address" if not valid */
- if (memptr == 0)
- return (EFAULT);
- *memptr = (void*) 0;
-
- /* make sure 'alignment' is a power of 2
- * and multiple of sizeof (void*)
- */
-
- /* make sure 'alignment' is a multiple of sizeof (void*) */
- if ((alignment % sizeof (void*)) != 0)
- return (EINVAL);
-
- /* make sure 'alignment' is a power of 2 */
- if ((alignment & (alignment - 1)) != 0)
- return (EINVAL);
-
- /* good alignment */
-
-#if (ALIGNED_MALLOC != 0)
-
- /* if 'malloc' is known to be aligned, and the desired 'alignment'
- * matches is <= that provided by 'malloc', then use 'malloc'. This
- * works on, e.g., Darwin for which malloc is 16-byte aligned.
- */
- size_t am = (size_t) ALIGNED_MALLOC;
- if (alignment <= am) {
- /* make sure ALIGNED_MALLOC is a power of 2, to guarantee that the
- * alignment is correct (since 'alignment' must be a power of 2).
- */
- if ((am & (am - 1)) != 0)
- return (EINVAL);
- /* good malloc alignment */
- *memptr = malloc (size);
- }
-
-#endif /* (ALIGNED_MALLOC != 0) */
-#ifdef HAVE_VALLOC
-
- if (*memptr == (void*) 0) {
- /* try valloc if it exists */
- /* cheap and easy way to make sure alignment is met, so long as it
- * is <= pagesize () */
- if (alignment <= (size_t) gr::pagesize ()) {
- *memptr = valloc (size);
- }
- }
-
-#endif /* HAVE_VALLOC */
-
-#if (ALIGNED_MALLOC == 0) && !defined (HAVE_VALLOC)
- /* no posix_memalign, valloc, and malloc isn't known to be aligned
- * (enough for the input arguments); no idea what to do.
- */
-
-#error gnuradio-runtime/lib/posix_memalign.cc: Cannot find a way to alloc aligned memory.
-
-#endif
-
- /* if the pointer wasn't allocated properly, return that there was
- * not enough memory to allocate; otherwise, return OK (0).
- */
- if (*memptr == (void*) 0)
- return (ENOMEM);
- else
- return (0);
-};
-
-#endif /* ! HAVE_POSIX_MEMALIGN */
diff --git a/gnuradio-runtime/lib/posix_memalign.h b/gnuradio-runtime/lib/posix_memalign.h
deleted file mode 100644
index ea79ced2ef..0000000000
--- a/gnuradio-runtime/lib/posix_memalign.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 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 _POSIX_MEMALIGN_H_
-#define _POSIX_MEMALIGN_H_
-
-#include <stdlib.h>
-
-#ifndef HAVE_POSIX_MEMALIGN
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int posix_memalign (void** memptr, size_t alignment, size_t size);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif /* ! HAVE_POSIX_MEMALIGN */
-
-#endif /* _POSIX_MEMALIGN_H_ */
diff --git a/gnuradio-runtime/lib/qa_logger.cc b/gnuradio-runtime/lib/qa_logger.cc
index b74a0c0e27..dc47b53cef 100644
--- a/gnuradio-runtime/lib/qa_logger.cc
+++ b/gnuradio-runtime/lib/qa_logger.cc
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012, 2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
diff --git a/gnuradio-runtime/lib/scheduler_sts.cc b/gnuradio-runtime/lib/scheduler_sts.cc
deleted file mode 100644
index 19d05b2316..0000000000
--- a/gnuradio-runtime/lib/scheduler_sts.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008,2013 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "scheduler_sts.h"
-#include "single_threaded_scheduler.h"
-#include <gnuradio/thread/thread_body_wrapper.h>
-
-namespace gr {
-
- class sts_container
- {
- block_vector_t d_blocks;
-
- public:
- sts_container(block_vector_t blocks)
- : d_blocks(blocks) {}
-
- void operator()()
- {
- make_single_threaded_scheduler(d_blocks)->run();
- }
- };
-
- scheduler_sptr
- scheduler_sts::make(flat_flowgraph_sptr ffg, int max_noutput_items)
- {
- return scheduler_sptr(new scheduler_sts(ffg, max_noutput_items));
- }
-
- scheduler_sts::scheduler_sts(flat_flowgraph_sptr ffg, int max_noutput_items)
- : scheduler(ffg, max_noutput_items)
- {
- // Split the flattened flow graph into discrete partitions, each
- // of which is topologically sorted.
-
- std::vector<basic_block_vector_t> graphs = ffg->partition();
-
- // For each partition, create a thread to evaluate it using
- // an instance of the gr_single_threaded_scheduler
-
- for(std::vector<basic_block_vector_t>::iterator p = graphs.begin();
- p != graphs.end(); p++) {
-
- block_vector_t blocks = flat_flowgraph::make_block_vector(*p);
- d_threads.create_thread(
- gr::thread::thread_body_wrapper<sts_container>(sts_container(blocks),
- "single-threaded-scheduler"));
- }
- }
-
- scheduler_sts::~scheduler_sts()
- {
- stop();
- }
-
- void
- scheduler_sts::stop()
- {
- d_threads.interrupt_all();
- }
-
- void
- scheduler_sts::wait()
- {
- d_threads.join_all();
- }
-
-} /* namespace gr */
diff --git a/gnuradio-runtime/lib/scheduler_sts.h b/gnuradio-runtime/lib/scheduler_sts.h
deleted file mode 100644
index b4cddb4614..0000000000
--- a/gnuradio-runtime/lib/scheduler_sts.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008,2013 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.
- */
-
-#ifndef INCLUDED_GR_SCHEDULER_STS_H
-#define INCLUDED_GR_SCHEDULER_STS_H
-
-#include <gnuradio/api.h>
-#include <gnuradio/thread/thread_group.h>
-#include "scheduler.h"
-
-namespace gr {
-
- /*!
- * \brief Concrete scheduler that uses the single_threaded_scheduler
- */
- class GR_RUNTIME_API scheduler_sts : public scheduler
- {
- gr::thread::thread_group d_threads;
-
- protected:
- /*!
- * \brief Construct a scheduler and begin evaluating the graph.
- *
- * The scheduler will continue running until all blocks until they
- * report that they are done or the stop method is called.
- */
- scheduler_sts(flat_flowgraph_sptr ffg, int max_noutput_items);
-
- public:
- static scheduler_sptr make(flat_flowgraph_sptr ffg,
- int max_noutput_items);
-
- ~scheduler_sts();
-
- /*!
- * \brief Tell the scheduler to stop executing.
- */
- void stop();
-
- /*!
- * \brief Block until the graph is done.
- */
- void wait();
- };
-
-} /* namespace gr */
-
-#endif /* INCLUDED_GR_SCHEDULER_STS_H */
diff --git a/gnuradio-runtime/lib/single_threaded_scheduler.cc b/gnuradio-runtime/lib/single_threaded_scheduler.cc
deleted file mode 100644
index a85f390a30..0000000000
--- a/gnuradio-runtime/lib/single_threaded_scheduler.cc
+++ /dev/null
@@ -1,366 +0,0 @@
-/* -*- 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "single_threaded_scheduler.h"
-#include <gnuradio/block.h>
-#include <gnuradio/block_detail.h>
-#include <gnuradio/buffer.h>
-#include <boost/thread.hpp>
-#include <boost/format.hpp>
-#include <iostream>
-#include <limits>
-#include <assert.h>
-#include <stdio.h>
-
-namespace gr {
-
- // must be defined to either 0 or 1
-#define ENABLE_LOGGING 0
-
-#if (ENABLE_LOGGING)
-#define LOG(x) do { x; } while(0)
-#else
-#define LOG(x) do {;} while(0)
-#endif
-
- static int which_scheduler = 0;
-
- single_threaded_scheduler_sptr
- make_single_threaded_scheduler(const std::vector<block_sptr> &blocks)
- {
- return single_threaded_scheduler_sptr
- (new single_threaded_scheduler(blocks));
- }
-
- single_threaded_scheduler::single_threaded_scheduler(const std::vector<block_sptr> &blocks)
- : d_blocks(blocks), d_enabled(true), d_log(0)
- {
- if(ENABLE_LOGGING) {
- std::string name = str(boost::format("sst-%d.log") % which_scheduler++);
- d_log = new std::ofstream(name.c_str());
- *d_log << "single_threaded_scheduler: "
- << d_blocks.size ()
- << " blocks\n";
- }
- }
-
- single_threaded_scheduler::~single_threaded_scheduler()
- {
- if(ENABLE_LOGGING)
- delete d_log;
- }
-
- void
- single_threaded_scheduler::run()
- {
- // d_enabled = true; // KLUDGE
- main_loop ();
- }
-
- void
- single_threaded_scheduler::stop()
- {
- if(0)
- std::cout << "gr_singled_threaded_scheduler::stop() "
- << this << std::endl;
- d_enabled = false;
- }
-
- inline static unsigned int
- round_up(unsigned int n, unsigned int multiple)
- {
- return ((n + multiple - 1) / multiple) * multiple;
- }
-
- inline static unsigned int
- round_down(unsigned int n, unsigned int multiple)
- {
- return (n / multiple) * multiple;
- }
-
- //
- // Return minimum available write space in all our downstream
- // buffers or -1 if we're output blocked and the output we're
- // blocked on is done.
- //
- static int
- min_available_space(block_detail *d, int output_multiple)
- {
- int min_space = std::numeric_limits<int>::max();
-
- for(int i = 0; i < d->noutputs (); i++) {
- buffer_sptr out_buf = d->output(i);
- int n = round_down (out_buf->space_available (), output_multiple);
- if(n == 0) { // We're blocked on output.
- if(out_buf->done()) { // Downstream is done, therefore we're done.
- return -1;
- }
- return 0;
- }
- min_space = std::min (min_space, n);
- }
- return min_space;
- }
-
- void
- single_threaded_scheduler::main_loop()
- {
- static const int DEFAULT_CAPACITY = 16;
-
- int noutput_items;
- gr_vector_int ninput_items_required(DEFAULT_CAPACITY);
- gr_vector_int ninput_items(DEFAULT_CAPACITY);
- gr_vector_const_void_star input_items(DEFAULT_CAPACITY);
- gr_vector_void_star output_items(DEFAULT_CAPACITY);
- unsigned int bi;
- unsigned int nalive;
- int max_items_avail;
- bool made_progress_last_pass;
- bool making_progress;
-
- for(unsigned i = 0; i < d_blocks.size (); i++)
- d_blocks[i]->detail()->set_done (false); // reset any done flags
-
- for(unsigned i = 0; i < d_blocks.size (); i++) // enable any drivers, etc.
- d_blocks[i]->start();
-
- bi = 0;
- made_progress_last_pass = true;
- making_progress = false;
-
- // Loop while there are still blocks alive
-
- nalive = d_blocks.size ();
- while(d_enabled && nalive > 0) {
- if(boost::this_thread::interruption_requested())
- break;
-
- block *m = d_blocks[bi].get ();
- block_detail *d = m->detail().get ();
-
- LOG(*d_log << std::endl << m);
-
- if(d->done ())
- goto next_block;
-
- if(d->source_p ()) {
- // Invoke sources as a last resort. As long as the previous
- // pass made progress, don't call a source.
- if(made_progress_last_pass) {
- LOG(*d_log << " Skipping source\n");
- goto next_block;
- }
-
- ninput_items_required.resize (0);
- ninput_items.resize (0);
- input_items.resize (0);
- output_items.resize (d->noutputs ());
-
- // determine the minimum available output space
- noutput_items = min_available_space (d, m->output_multiple ());
- LOG(*d_log << " source\n noutput_items = " << noutput_items << std::endl);
- if(noutput_items == -1) // we're done
- goto were_done;
-
- if(noutput_items == 0) { // we're output blocked
- LOG(*d_log << " BLKD_OUT\n");
- goto next_block;
- }
-
- goto setup_call_to_work; // jump to common code
- }
-
- else if(d->sink_p ()) {
- ninput_items_required.resize (d->ninputs ());
- ninput_items.resize (d->ninputs ());
- input_items.resize (d->ninputs ());
- output_items.resize (0);
- LOG(*d_log << " sink\n");
-
- max_items_avail = 0;
- for(int i = 0; i < d->ninputs (); i++) {
- buffer_reader_sptr in_buf = d->input(i);
- ninput_items[i] = in_buf->items_available();
- //if (ninput_items[i] == 0 && in_buf->done())
- if(ninput_items[i] < m->output_multiple() && in_buf->done())
- goto were_done;
-
- max_items_avail = std::max (max_items_avail, ninput_items[i]);
- }
-
- // take a swag at how much output we can sink
- noutput_items = (int) (max_items_avail * m->relative_rate ());
- noutput_items = round_down (noutput_items, m->output_multiple ());
- LOG(*d_log << " max_items_avail = " << max_items_avail << std::endl);
- LOG(*d_log << " noutput_items = " << noutput_items << std::endl);
-
- if(noutput_items == 0) { // we're blocked on input
- LOG(*d_log << " BLKD_IN\n");
- goto next_block;
- }
-
- goto try_again; // Jump to code shared with regular case.
- }
-
- else {
- // do the regular thing
- ninput_items_required.resize(d->ninputs ());
- ninput_items.resize(d->ninputs ());
- input_items.resize(d->ninputs ());
- output_items.resize(d->noutputs ());
-
- max_items_avail = 0;
- for(int i = 0; i < d->ninputs (); i++) {
- ninput_items[i] = d->input(i)->items_available ();
- max_items_avail = std::max(max_items_avail, ninput_items[i]);
- }
-
- // determine the minimum available output space
- noutput_items = min_available_space(d, m->output_multiple ());
- if(ENABLE_LOGGING){
- *d_log << " regular ";
- if(m->relative_rate() >= 1.0)
- *d_log << "1:" << m->relative_rate() << std::endl;
- else
- *d_log << 1.0/m->relative_rate() << ":1\n";
- *d_log << " max_items_avail = " << max_items_avail << std::endl;
- *d_log << " noutput_items = " << noutput_items << std::endl;
- }
- if(noutput_items == -1) // we're done
- goto were_done;
-
- if(noutput_items == 0) { // we're output blocked
- LOG(*d_log << " BLKD_OUT\n");
- goto next_block;
- }
-
-#if 0
- // Compute best estimate of noutput_items that we can really use.
- noutput_items =
- std::min((unsigned)noutput_items,
- std::max((unsigned)m->output_multiple(),
- round_up((unsigned)(max_items_avail * m->relative_rate()),
- m->output_multiple())));
-
- LOG(*d_log << " revised noutput_items = " << noutput_items << std::endl);
-#endif
-
- try_again:
- if(m->fixed_rate()) {
- // try to work it forward starting with max_items_avail.
- // We want to try to consume all the input we've got.
- int reqd_noutput_items = m->fixed_rate_ninput_to_noutput(max_items_avail);
- reqd_noutput_items = round_up(reqd_noutput_items, m->output_multiple());
- if(reqd_noutput_items > 0 && reqd_noutput_items <= noutput_items)
- noutput_items = reqd_noutput_items;
- }
-
- // ask the block how much input they need to produce noutput_items
- m->forecast(noutput_items, ninput_items_required);
-
- // See if we've got sufficient input available
- int i;
- for(i = 0; i < d->ninputs (); i++)
- if(ninput_items_required[i] > ninput_items[i]) // not enough
- break;
-
- if(i < d->ninputs()) { // not enough input on input[i]
- // if we can, try reducing the size of our output request
- if(noutput_items > m->output_multiple ()){
- noutput_items /= 2;
- noutput_items = round_up (noutput_items, m->output_multiple ());
- goto try_again;
- }
-
- // We're blocked on input
- buffer_reader_sptr in_buf = d->input(i);
- LOG(*d_log << " BLKD_IN\n");
- if(in_buf->done()) // If the upstream block is done, we're done
- goto were_done;
-
- // Is it possible to ever fulfill this request?
- if(ninput_items_required[i] > in_buf->max_possible_items_available ()) {
- // Nope, never going to happen...
- std::cerr << "\nsched: <block " << m->name()
- << " (" << m->unique_id() << ")>"
- << " is requesting more input data\n"
- << " than we can provide.\n"
- << " ninput_items_required = "
- << ninput_items_required[i] << "\n"
- << " max_possible_items_available = "
- << in_buf->max_possible_items_available() << "\n"
- << " If this is a filter, consider reducing the number of taps.\n";
- goto were_done;
- }
-
- goto next_block;
- }
-
- // We've got enough data on each input to produce noutput_items.
- // Finish setting up the call to work.
- for(int i = 0; i < d->ninputs (); i++)
- input_items[i] = d->input(i)->read_pointer();
-
- setup_call_to_work:
-
- for(int i = 0; i < d->noutputs (); i++)
- output_items[i] = d->output(i)->write_pointer();
-
- // Do the actual work of the block
- int n = m->general_work(noutput_items, ninput_items,
- input_items, output_items);
- LOG(*d_log << " general_work: noutput_items = " << noutput_items
- << " result = " << n << std::endl);
-
- if(n == -1) // block is done
- goto were_done;
-
- d->produce_each(n); // advance write pointers
- if(n > 0)
- making_progress = true;
-
- goto next_block;
- }
- assert(0);
-
- were_done:
- LOG(*d_log << " were_done\n");
- d->set_done (true);
- nalive--;
-
- next_block:
- if(++bi >= d_blocks.size ()) {
- bi = 0;
- made_progress_last_pass = making_progress;
- making_progress = false;
- }
- }
-
- for(unsigned i = 0; i < d_blocks.size(); i++) // disable any drivers, etc.
- d_blocks[i]->stop();
- }
-
-} /* namespace gr */
diff --git a/gnuradio-runtime/lib/single_threaded_scheduler.h b/gnuradio-runtime/lib/single_threaded_scheduler.h
deleted file mode 100644
index eccbf03b36..0000000000
--- a/gnuradio-runtime/lib/single_threaded_scheduler.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- 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_GR_SINGLE_THREADED_SCHEDULER_H
-#define INCLUDED_GR_SINGLE_THREADED_SCHEDULER_H
-
-#include <gnuradio/api.h>
-#include <gnuradio/runtime_types.h>
-#include <fstream>
-
-namespace gr {
-
- class single_threaded_scheduler;
- typedef boost::shared_ptr<single_threaded_scheduler> single_threaded_scheduler_sptr;
-
- /*!
- * \brief Simple scheduler for stream computations.
- * \ingroup internal
- */
- class GR_RUNTIME_API single_threaded_scheduler
- {
- public:
- ~single_threaded_scheduler();
-
- void run();
- void stop();
-
- private:
- const std::vector<block_sptr> d_blocks;
- volatile bool d_enabled;
- std::ofstream *d_log;
-
- single_threaded_scheduler(const std::vector<block_sptr> &blocks);
-
- void main_loop();
-
- friend GR_RUNTIME_API single_threaded_scheduler_sptr
- make_single_threaded_scheduler(const std::vector<block_sptr> &blocks);
- };
-
- GR_RUNTIME_API single_threaded_scheduler_sptr
- make_single_threaded_scheduler(const std::vector<block_sptr> &blocks);
-
-} /* namespace gr */
-
-#endif /* INCLUDED_GR_SINGLE_THREADED_SCHEDULER_H */
diff --git a/gnuradio-runtime/lib/sptr_magic.cc b/gnuradio-runtime/lib/sptr_magic.cc
index e5e83722fc..bffef04756 100644
--- a/gnuradio-runtime/lib/sptr_magic.cc
+++ b/gnuradio-runtime/lib/sptr_magic.cc
@@ -102,4 +102,4 @@ namespace gnuradio {
s_map.erase(pos);
return sptr;
}
-};
+}
diff --git a/gnuradio-runtime/lib/sys_pri.cc b/gnuradio-runtime/lib/sys_pri.cc
deleted file mode 100644
index aa005ecd75..0000000000
--- a/gnuradio-runtime/lib/sys_pri.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <sys_pri.h>
-
-namespace gr {
-
- /*
- * These may need per-OS tweaking.
- *
- * Under linux virtual_pri -> system_pri
- * 0 -> 0
- * 1 -> 5
- * 2 -> 10
- * 3 -> 15
- * 4 -> 20 // typically used by jack and pulse audio
- * 5 -> 25
- * 6 -> 30
- * 7 -> 35
- * 8 -> 40
- * 9 -> 45
- * 10 -> 50
- * 11 -> 54
- * 12 -> 59
- * 13 -> 64
- * 14 -> 69
- * 15 -> 74
- */
- rt_sched_param
- sys_pri::python() { return rt_sched_param(0, RT_SCHED_RR); }
-
- rt_sched_param
- sys_pri::normal() { return rt_sched_param(2, RT_SCHED_RR); }
-
- rt_sched_param
- sys_pri::gcell_event_handler(){ return rt_sched_param(5, RT_SCHED_FIFO); }
-
- rt_sched_param
- sys_pri::usrp2_backend() { return rt_sched_param(6, RT_SCHED_FIFO); }
-
-} /* namespace gr */
diff --git a/gnuradio-runtime/lib/thread/thread_group.cc b/gnuradio-runtime/lib/thread/thread_group.cc
index e467dfda5a..637525e19e 100644
--- a/gnuradio-runtime/lib/thread/thread_group.cc
+++ b/gnuradio-runtime/lib/thread/thread_group.cc
@@ -37,7 +37,7 @@ namespace gr {
{
// No scoped_lock required here since the only "shared data" that's
// modified here occurs inside add_thread which does scoped_lock.
- std::auto_ptr<boost::thread> thrd(new boost::thread(threadfunc));
+ std::unique_ptr<boost::thread> thrd(new boost::thread(threadfunc));
add_thread(thrd.get());
return thrd.release();
}
diff --git a/gnuradio-runtime/lib/top_block_impl.cc b/gnuradio-runtime/lib/top_block_impl.cc
index 3f94867bc2..d2a07e89ef 100644
--- a/gnuradio-runtime/lib/top_block_impl.cc
+++ b/gnuradio-runtime/lib/top_block_impl.cc
@@ -26,7 +26,6 @@
#include "top_block_impl.h"
#include "flat_flowgraph.h"
-#include "scheduler_sts.h"
#include "scheduler_tpb.h"
#include <gnuradio/top_block.h>
#include <gnuradio/prefs.h>
@@ -48,8 +47,7 @@ namespace gr {
const char *name;
scheduler_maker f;
} scheduler_table[] = {
- { "TPB", scheduler_tpb::make }, // first entry is default
- { "STS", scheduler_sts::make }
+ { "TPB", scheduler_tpb::make } // first entry is default
};
static scheduler_sptr
diff --git a/gnuradio-runtime/lib/tpb_thread_body.cc b/gnuradio-runtime/lib/tpb_thread_body.cc
index 45762b17f4..fa9de60ae3 100644
--- a/gnuradio-runtime/lib/tpb_thread_body.cc
+++ b/gnuradio-runtime/lib/tpb_thread_body.cc
@@ -55,8 +55,6 @@ namespace gr {
size_t max_nmsgs = static_cast<size_t>(p->get_long("DEFAULT", "max_messages", 100));
// Setup the logger for the scheduler
-#ifdef ENABLE_GR_LOG
-#ifdef HAVE_LOG4CPP
#undef LOG
std::string config_file = p->get_string("LOG", "log_config", "");
std::string log_level = p->get_string("LOG", "log_level", "off");
@@ -75,9 +73,6 @@ namespace gr {
GR_LOG_SET_FILE_APPENDER(LOG, log_file , true,"%r :%p: %c{1} - %m%n");
}
}
-#endif /* HAVE_LOG4CPP */
-#endif /* ENABLE_GR_LOG */
-
// Set thread affinity if it was set before fg was started.
if(block->processor_affinity().size() > 0) {
@@ -94,9 +89,10 @@ namespace gr {
start_sync->wait();
while(1) {
- tpb_loop_top:
boost::this_thread::interruption_point();
+ d->d_tpb.clear_changed();
+
// handle any queued up messages
BOOST_FOREACH(basic_block::msg_queue_map_t::value_type &i, block->msg_queue) {
// Check if we have a message handler attached before getting
@@ -117,97 +113,57 @@ namespace gr {
}
}
- d->d_tpb.clear_changed();
// run one iteration if we are a connected stream block
if(d->noutputs() >0 || d->ninputs()>0){
s = d_exec.run_one_iteration();
}
else {
s = block_executor::BLKD_IN;
+ // a msg port only block wants to shutdown
+ if(block->finished()) {
+ s = block_executor::DONE;
+ }
}
- // if msg ports think we are done, we are done
- if(block->finished())
+ if(block->finished() && s == block_executor::READY_NO_OUTPUT) {
s = block_executor::DONE;
+ d->set_done(true);
+ }
+
+ if(!d->ninputs() && s == block_executor::READY_NO_OUTPUT) {
+ s = block_executor::BLKD_IN;
+ }
switch(s){
- case block_executor::READY: // Tell neighbors we made progress.
+ case block_executor::READY: // Tell neighbors we made progress.
d->d_tpb.notify_neighbors(d);
break;
- case block_executor::READY_NO_OUTPUT: // Notify upstream only
+ case block_executor::READY_NO_OUTPUT: // Notify upstream only
d->d_tpb.notify_upstream(d);
break;
- case block_executor::DONE: // Game over.
+ case block_executor::DONE: // Game over.
block->notify_msg_neighbors();
d->d_tpb.notify_neighbors(d);
return;
- case block_executor::BLKD_IN: // Wait for input.
+ case block_executor::BLKD_IN: // Wait for input.
{
gr::thread::scoped_lock guard(d->d_tpb.mutex);
- while(!d->d_tpb.input_changed) {
-
- // wait for input or message
- while(!d->d_tpb.input_changed && block->empty_handled_p()){
- boost::system_time const timeout=boost::get_system_time()+ boost::posix_time::milliseconds(250);
- if(!d->d_tpb.input_cond.timed_wait(guard, timeout)){
- goto tpb_loop_top; // timeout occurred (perform sanity checks up top)
- }
- }
- // handle all pending messages
- BOOST_FOREACH(basic_block::msg_queue_map_t::value_type &i, block->msg_queue) {
- if(block->has_msg_handler(i.first)) {
- while((msg = block->delete_head_nowait(i.first))) {
- guard.unlock(); // release lock while processing msg
- block->dispatch_msg(i.first, msg);
- guard.lock();
- }
- }
- else {
- // leave msg in queue if no handler is defined
- // start dropping if we have too many
- if(block->nmsgs(i.first) > max_nmsgs){
- GR_LOG_WARN(LOG,"asynchronous message buffer overflowing, dropping message");
- msg = block->delete_head_nowait(i.first);
- }
- }
- }
- if (d->done()) {
- return;
- }
+ if(!d->d_tpb.input_changed) {
+ boost::system_time const timeout=boost::get_system_time()+ boost::posix_time::milliseconds(250);
+ d->d_tpb.input_cond.timed_wait(guard, timeout);
}
}
break;
- case block_executor::BLKD_OUT: // Wait for output buffer space.
+ case block_executor::BLKD_OUT: // Wait for output buffer space.
{
- gr::thread::scoped_lock guard(d->d_tpb.mutex);
- while(!d->d_tpb.output_changed) {
- // wait for output room or message
- while(!d->d_tpb.output_changed && block->empty_handled_p())
- d->d_tpb.output_cond.wait(guard);
-
- // handle all pending messages
- BOOST_FOREACH(basic_block::msg_queue_map_t::value_type &i, block->msg_queue) {
- if(block->has_msg_handler(i.first)) {
- while((msg = block->delete_head_nowait(i.first))) {
- guard.unlock(); // release lock while processing msg
- block->dispatch_msg(i.first, msg);
- guard.lock();
- }
- }
- else {
- // leave msg in queue if no handler is defined
- // start dropping if we have too many
- if(block->nmsgs(i.first) > max_nmsgs){
- GR_LOG_WARN(LOG,"asynchronous message buffer overflowing, dropping message");
- msg = block->delete_head_nowait(i.first);
- }
- }
- }
+ gr::thread::scoped_lock guard(d->d_tpb.mutex);
+ while(!d->d_tpb.output_changed) {
+ d->d_tpb.output_cond.wait(guard);
}
}
break;
diff --git a/gnuradio-runtime/python/build_utils.py b/gnuradio-runtime/python/build_utils.py
deleted file mode 100644
index cf58a97637..0000000000
--- a/gnuradio-runtime/python/build_utils.py
+++ /dev/null
@@ -1,226 +0,0 @@
-#
-# Copyright 2004,2009,2012 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.
-#
-
-"""Misc utilities used at build time
-"""
-
-import re, os, os.path
-from build_utils_codes import *
-
-
-# set srcdir to the directory that contains Makefile.am
-try:
- srcdir = os.environ['srcdir']
-except KeyError, e:
- srcdir = "."
-srcdir = srcdir + '/'
-
-# set do_makefile to either true or false dependeing on the environment
-try:
- if os.environ['do_makefile'] == '0':
- do_makefile = False
- else:
- do_makefile = True
-except KeyError, e:
- do_makefile = False
-
-# set do_sources to either true or false dependeing on the environment
-try:
- if os.environ['do_sources'] == '0':
- do_sources = False
- else:
- do_sources = True
-except KeyError, e:
- do_sources = True
-
-name_dict = {}
-
-def log_output_name (name):
- (base, ext) = os.path.splitext (name)
- ext = ext[1:] # drop the leading '.'
-
- entry = name_dict.setdefault (ext, [])
- entry.append (name)
-
-def open_and_log_name (name, dir):
- global do_sources
- if do_sources:
- f = open (name, dir)
- else:
- f = None
- log_output_name (name)
- return f
-
-def expand_template (d, template_filename, extra = ""):
- '''Given a dictionary D and a TEMPLATE_FILENAME, expand template into output file
- '''
- global do_sources
- output_extension = extract_extension (template_filename)
- template = open_src (template_filename, 'r')
- output_name = d['NAME'] + extra + '.' + output_extension
- log_output_name (output_name)
- if do_sources:
- output = open (output_name, 'w')
- do_substitution (d, template, output)
- output.close ()
- template.close ()
-
-def output_glue (dirname):
- output_makefile_fragment ()
- output_ifile_include (dirname)
-
-def output_makefile_fragment ():
- global do_makefile
- if not do_makefile:
- return
-# overwrite the source, which must be writable; this should have been
-# checked for beforehand in the top-level Makefile.gen.gen .
- f = open (os.path.join (os.environ.get('gendir', os.environ.get('srcdir', '.')), 'Makefile.gen'), 'w')
- f.write ('#\n# This file is machine generated. All edits will be overwritten\n#\n')
- output_subfrag (f, 'h')
- output_subfrag (f, 'i')
- output_subfrag (f, 'cc')
- f.close ()
-
-def output_ifile_include (dirname):
- global do_sources
- if do_sources:
- f = open ('%s_generated.i' % (dirname,), 'w')
- f.write ('//\n// This file is machine generated. All edits will be overwritten\n//\n')
- files = name_dict.setdefault ('i', [])
- files.sort ()
- f.write ('%{\n')
- for file in files:
- f.write ('#include <%s>\n' % (file[0:-1] + 'h',))
- f.write ('%}\n\n')
- for file in files:
- f.write ('%%include <%s>\n' % (file,))
-
-def output_subfrag (f, ext):
- files = name_dict.setdefault (ext, [])
- files.sort ()
- f.write ("GENERATED_%s =" % (ext.upper ()))
- for file in files:
- f.write (" \\\n\t%s" % (file,))
- f.write ("\n\n")
-
-def extract_extension (template_name):
- # template name is something like: GrFIRfilterXXX.h.t
- # we return everything between the penultimate . and .t
- mo = re.search (r'\.([a-z]+)\.t$', template_name)
- if not mo:
- raise ValueError, "Incorrectly formed template_name '%s'" % (template_name,)
- return mo.group (1)
-
-def open_src (name, mode):
- global srcdir
- return open (os.path.join (srcdir, name), mode)
-
-def do_substitution (d, in_file, out_file):
- def repl (match_obj):
- key = match_obj.group (1)
- # print key
- return d[key]
-
- inp = in_file.read ()
- out = re.sub (r"@([a-zA-Z0-9_]+)@", repl, inp)
- out_file.write (out)
-
-
-
-copyright = '''/* -*- c++ -*- */
-/*
- * Copyright 2003,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.
- */
-'''
-
-def is_complex (code3):
- if i_code (code3) == 'c' or o_code (code3) == 'c':
- return '1'
- else:
- return '0'
-
-
-def standard_dict (name, code3, package='gr'):
- d = {}
- d['NAME'] = name
- d['NAME_IMPL'] = name+'_impl'
- d['GUARD_NAME'] = 'INCLUDED_%s_%s_H' % (package.upper(), name.upper())
- d['GUARD_NAME_IMPL'] = 'INCLUDED_%s_%s_IMPL_H' % (package.upper(), name.upper())
- d['BASE_NAME'] = re.sub ('^' + package + '_', '', name)
- d['SPTR_NAME'] = '%s_sptr' % name
- d['WARNING'] = 'WARNING: this file is machine generated. Edits will be overwritten'
- d['COPYRIGHT'] = copyright
- d['TYPE'] = i_type (code3)
- d['I_TYPE'] = i_type (code3)
- d['O_TYPE'] = o_type (code3)
- d['TAP_TYPE'] = tap_type (code3)
- d['IS_COMPLEX'] = is_complex (code3)
- return d
-
-
-def standard_dict2 (name, code3, package):
- d = {}
- d['NAME'] = name
- d['BASE_NAME'] = name
- d['GUARD_NAME'] = 'INCLUDED_%s_%s_H' % (package.upper(), name.upper())
- d['WARNING'] = 'WARNING: this file is machine generated. Edits will be overwritten'
- d['COPYRIGHT'] = copyright
- d['TYPE'] = i_type (code3)
- d['I_TYPE'] = i_type (code3)
- d['O_TYPE'] = o_type (code3)
- d['TAP_TYPE'] = tap_type (code3)
- d['IS_COMPLEX'] = is_complex (code3)
- return d
-
-def standard_impl_dict2 (name, code3, package):
- d = {}
- d['NAME'] = name
- d['IMPL_NAME'] = name
- d['BASE_NAME'] = name.rstrip("impl").rstrip("_")
- d['GUARD_NAME'] = 'INCLUDED_%s_%s_H' % (package.upper(), name.upper())
- d['WARNING'] = 'WARNING: this file is machine generated. Edits will be overwritten'
- d['COPYRIGHT'] = copyright
- d['FIR_TYPE'] = "fir_filter_" + code3
- d['CFIR_TYPE'] = "fir_filter_" + code3[0:2] + 'c'
- d['TYPE'] = i_type (code3)
- d['I_TYPE'] = i_type (code3)
- d['O_TYPE'] = o_type (code3)
- d['TAP_TYPE'] = tap_type (code3)
- d['IS_COMPLEX'] = is_complex (code3)
- return d
diff --git a/gnuradio-runtime/python/build_utils_codes.py b/gnuradio-runtime/python/build_utils_codes.py
index 9ea96baae4..e69de29bb2 100644
--- a/gnuradio-runtime/python/build_utils_codes.py
+++ b/gnuradio-runtime/python/build_utils_codes.py
@@ -1,52 +0,0 @@
-#
-# 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.
-#
-
-def i_code (code3):
- return code3[0]
-
-def o_code (code3):
- if len (code3) >= 2:
- return code3[1]
- else:
- return code3[0]
-
-def tap_code (code3):
- if len (code3) >= 3:
- return code3[2]
- else:
- return code3[0]
-
-def i_type (code3):
- return char_to_type[i_code (code3)]
-
-def o_type (code3):
- return char_to_type[o_code (code3)]
-
-def tap_type (code3):
- return char_to_type[tap_code (code3)]
-
-
-char_to_type = {}
-char_to_type['s'] = 'short'
-char_to_type['i'] = 'int'
-char_to_type['f'] = 'float'
-char_to_type['c'] = 'gr_complex'
-char_to_type['b'] = 'unsigned char'
diff --git a/gnuradio-runtime/python/gnuradio/CMakeLists.txt b/gnuradio-runtime/python/gnuradio/CMakeLists.txt
index d29e6aa9d2..736db499dc 100644
--- a/gnuradio-runtime/python/gnuradio/CMakeLists.txt
+++ b/gnuradio-runtime/python/gnuradio/CMakeLists.txt
@@ -35,5 +35,4 @@ GR_PYTHON_INSTALL(FILES
gr_unittest.py
gr_xmlrunner.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio
- COMPONENT "runtime_python"
)
diff --git a/gnuradio-runtime/python/gnuradio/__init__.py b/gnuradio-runtime/python/gnuradio/__init__.py
index dd7b89650b..c1735c3d8b 100644
--- a/gnuradio-runtime/python/gnuradio/__init__.py
+++ b/gnuradio-runtime/python/gnuradio/__init__.py
@@ -7,6 +7,7 @@ While not primarily a simulation tool, GNU Radio does support development of sig
GNU Radio is licensed under the GNU General Public License (GPL) version 3. All of the code is copyright of the Free Software Foundation.
"""
+from __future__ import unicode_literals
# This file makes gnuradio a package
# The docstring will be associated with the top level of the package.
@@ -37,13 +38,8 @@ if path.endswith(path_ending):
__path__.append(os.path.join(build_path, 'gr-wavelet', 'python'))
__path__.append(os.path.join(build_path, 'gr-audio', 'python'))
__path__.append(os.path.join(build_path, 'gr-qtgui', 'python'))
- __path__.append(os.path.join(build_path, 'gr-wxgui', 'python'))
- __path__.append(os.path.join(build_path, 'gr-atsc', 'python'))
- __path__.append(os.path.join(build_path, 'gr-noaa', 'python'))
- __path__.append(os.path.join(build_path, 'gr-pager', 'python'))
__path__.append(os.path.join(build_path, 'gr-video-sdl', 'python'))
__path__.append(os.path.join(build_path, 'gr-vocoder', 'python'))
- __path__.append(os.path.join(build_path, 'gr-fcd', 'python'))
__path__.append(os.path.join(build_path, 'gr-comedi', 'python'))
__path__.append(os.path.join(build_path, 'gr-channels', 'python'))
__path__.append(os.path.join(build_path, 'gr-fec', 'python'))
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/CMakeLists.txt b/gnuradio-runtime/python/gnuradio/ctrlport/CMakeLists.txt
index be959467cf..4b0dbf7b8a 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/CMakeLists.txt
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/CMakeLists.txt
@@ -24,7 +24,6 @@ install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/icon.png
DESTINATION ${GR_PYTHON_DIR}/gnuradio/ctrlport
- COMPONENT "runtime_python"
)
@@ -36,7 +35,6 @@ GR_PYTHON_INSTALL(
${CMAKE_CURRENT_SOURCE_DIR}/GNURadioControlPortClient.py
${CMAKE_CURRENT_SOURCE_DIR}/RPCConnection.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio/ctrlport/
- COMPONENT "runtime_python"
)
GR_PYTHON_INSTALL(
@@ -45,7 +43,6 @@ GR_PYTHON_INSTALL(
${CMAKE_CURRENT_SOURCE_DIR}/gr-ctrlport-monitor
DESTINATION ${GR_RUNTIME_DIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
- COMPONENT "runtime_python"
)
if(THRIFT_FOUND)
@@ -58,25 +55,24 @@ if(THRIFT_FOUND)
${CMAKE_CURRENT_BINARY_DIR}/GNURadio/StreamReceiver.py
${CMAKE_CURRENT_BINARY_DIR}/GNURadio/StreamReceiver-remote
${CMAKE_CURRENT_BINARY_DIR}/GNURadio/ttypes.py
- )
+ )
+
add_custom_command(
DEPENDS ${CMAKE_SOURCE_DIR}/gnuradio-runtime/lib/controlport/thrift/gnuradio.thrift
OUTPUT ${thrift_targets}
COMMAND ${THRIFT_BIN} --gen py -out ${CMAKE_CURRENT_BINARY_DIR}/ ${CMAKE_SOURCE_DIR}/gnuradio-runtime/lib/controlport/thrift/gnuradio.thrift
- )
+ )
GR_PYTHON_INSTALL(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/RPCConnectionThrift.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio/ctrlport/
- COMPONENT "runtime_python"
- )
+ )
GR_PYTHON_INSTALL(
FILES
${thrift_targets}
DESTINATION ${GR_PYTHON_DIR}/gnuradio/ctrlport/GNURadio
- COMPONENT "runtime_python"
- )
+ )
endif(THRIFT_FOUND)
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py b/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py
index 87d2cf5658..8b811ab9d9 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py
@@ -27,8 +27,8 @@ Remote Procedure Call (RPC) transports, the Apache Thrift middle-ware RPC
is currently the only supported transport.
"""
-
-import exceptions
+from __future__ import print_function
+from __future__ import unicode_literals
"""
GNURadioControlPortClient is the main class for creating a GNU Radio
@@ -38,7 +38,7 @@ Two constructors are provided for creating a connection to ControlPort.
"""
-class GNURadioControlPortClient():
+class GNURadioControlPortClient(object):
"""
Constructor for creating a ControlPort connection to a specified host / port
@@ -113,7 +113,7 @@ class GNURadioControlPortClient():
self.client = None
from gnuradio.ctrlport.RPCConnection import RPCMethods
- if RPCMethods.has_key(rpcmethod):
+ if rpcmethod in RPCMethods:
from gnuradio.ctrlport.RPCConnectionThrift import RPCConnectionThrift
if rpcmethod == 'thrift':
#print("making RPCConnectionThrift")
@@ -128,5 +128,5 @@ class GNURadioControlPortClient():
if not blockingcallback is None:
blockingcallback()
else:
- print("Unsupported RPC method: ", rpcmethod)
- raise exceptions.ValueError()
+ print(("Unsupported RPC method: ", rpcmethod))
+ raise ValueError()
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py b/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
index e0499c5eba..cb66baebb9 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import unicode_literals
+
from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
@@ -31,7 +34,7 @@ try:
from PyQt4 import QtGui, QtCore
import sip
except ImportError:
- print "Error: Program requires PyQt4 and gr-qtgui."
+ print("Error: Program requires PyQt4 and gr-qtgui.")
sys.exit(1)
class GrDataPlotParent(gr.top_block, QtGui.QWidget):
@@ -62,7 +65,7 @@ class GrDataPlotParent(gr.top_block, QtGui.QWidget):
self.layout.removeWidget(self.py_window)
self.disconnect(self.thr, (self.snk, 0))
self.disconnect(self.src[0], self.thr)
- for n in xrange(1, self._ncons):
+ for n in range(1, self._ncons):
self.disconnect(self.src[n], (self.snk,n))
self._ncons = nconnections
@@ -75,7 +78,7 @@ class GrDataPlotParent(gr.top_block, QtGui.QWidget):
self._last_data = []
self.src = []
- for n in xrange(self._ncons):
+ for n in range(self._ncons):
self.set_line_label(n, self.knobnames[n])
self._last_data.append(int(self._npts)*[0,])
@@ -142,7 +145,7 @@ class GrDataPlotParent(gr.top_block, QtGui.QWidget):
if(self._npts != npts):
# Adjust buffers to accommodate new settings
- for n in xrange(self._ncons):
+ for n in range(self._ncons):
if(npts < self._npts):
if(self._data_len[n] < npts):
self._last_data[n] = self._last_data[n][0:npts]
@@ -156,7 +159,7 @@ class GrDataPlotParent(gr.top_block, QtGui.QWidget):
if(self._stripchart):
# Update the plot data depending on type
- for n in xrange(self._ncons):
+ for n in range(self._ncons):
if(type(data[n]) == list):
data[n] = self.data_to_complex(data[n])
if(len(data[n]) > self._npts):
@@ -179,7 +182,7 @@ class GrDataPlotParent(gr.top_block, QtGui.QWidget):
self._last_data[n].append(data[n])
self.src[n].set_data(self._last_data[n])
else:
- for n in xrange(self._ncons):
+ for n in range(self._ncons):
if(type(data[n]) != list):
data[n] = [data[n],]
data[n] = self.data_to_complex(data[n])
@@ -407,11 +410,11 @@ class GrTimeRasterB(GrDataPlotParent):
self.snk.set_line_label(n, self.knobnames[n])
-class GrDataPlotterValueTable:
+class GrDataPlotterValueTable(object):
def __init__(self, uid, parent, x, y, xsize, ysize,
headers=['Statistic Key ( Source Block :: Stat Name ) ',
'Curent Value', 'Units', 'Description']):
- # must encapsulate, cuz Qt's bases are not classes
+ # must encapsulate, cuz Qt's bases are not classes
self.uid = uid
self.treeWidget = QtGui.QTreeWidget(parent)
self.treeWidget.setColumnCount(len(headers))
@@ -434,7 +437,7 @@ class GrDataPlotterValueTable:
# itemKey is the text in the first column of a QTreeWidgetItem
itemKey = str(item.text(0))
- if itemKey in knobs.keys():
+ if itemKey in list(knobs.keys()):
# This key was found in the tree, update its values.
foundKeys.append(itemKey)
@@ -465,7 +468,7 @@ class GrDataPlotterValueTable:
deleteKeys.append(itemKey)
# Add items to tree that are not currently in the tree.
- for k in knobs.keys():
+ for k in list(knobs.keys()):
if k not in foundKeys:
v = knobs[k].value
if(type(v) == ControlPort.complex):
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnection.py b/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnection.py
index 1b129534c9..0f3f27710f 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnection.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnection.py
@@ -17,9 +17,6 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
-
-import exceptions
-
"""
RPCMethods is a dictionary listing RPC transports currently supported
by this client.
@@ -30,6 +27,8 @@ Args:
options: result of command argument parsing (optparse.Values)
"""
+from __future__ import unicode_literals
+
RPCMethods = {'thrift': 'Apache Thrift',
#'ice': 'Zeroc ICE'
}
@@ -94,25 +93,25 @@ class RPCConnection(object):
return self.port
def newConnection(self, host=None, port=None):
- raise exceptions.NotImplementedError()
+ raise NotImplementedError()
def properties(self, *args):
- raise exceptions.NotImplementedError()
+ raise NotImplementedError()
def getKnobs(self, *args):
- raise exceptions.NotImplementedError()
+ raise NotImplementedError()
def getRe(self,*args):
- raise exceptions.NotImplementedError()
+ raise NotImplementedError()
def postMessage(self,*args):
- raise exceptions.NotImplementedError()
+ raise NotImplementedError()
def setKnobs(self,*args):
- raise exceptions.NotImplementedError()
+ raise NotImplementedError()
def shutdown(self):
- raise exceptions.NotImplementedError()
+ raise NotImplementedError()
def printProperties(self, props):
- raise exceptions.NotImplementedError()
+ raise NotImplementedError()
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py b/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py
index 522c74117b..466fc9fc04 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py
@@ -20,6 +20,7 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import unicode_literals
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
@@ -30,7 +31,7 @@ from gnuradio import gr
import pmt
import sys
-class ThriftRadioClient:
+class ThriftRadioClient(object):
def __init__(self, host, port):
self.tsocket = TSocket.TSocket(host, port)
self.transport = TTransport.TBufferedTransport(self.tsocket)
@@ -55,7 +56,7 @@ Args:
"""
class RPCConnectionThrift(RPCConnection.RPCConnection):
- class Knob():
+ class Knob(object):
def __init__(self, key, value=None, ktype=0):
(self.key, self.value, self.ktype) = (key, value, ktype)
@@ -144,7 +145,7 @@ class RPCConnectionThrift(RPCConnection.RPCConnection):
def properties(self, *args):
knobprops = self.thriftclient.radio.properties(*args)
- for key, knobprop in knobprops.iteritems():
+ for key, knobprop in list(knobprops.items()):
#print("key:", key, "value:", knobprop, "type:", knobprop.type)
knobprops[key].min = self.unpackKnob(key, knobprop.min)
knobprops[key].max = self.unpackKnob(key, knobprop.max)
@@ -153,28 +154,28 @@ class RPCConnectionThrift(RPCConnection.RPCConnection):
def getKnobs(self, *args):
result = {}
- for key, knob in self.thriftclient.radio.getKnobs(*args).iteritems():
+ for key, knob in list(self.thriftclient.radio.getKnobs(*args).items()):
#print("key:", key, "value:", knob, "type:", knob.type)
result[key] = self.unpackKnob(key, knob)
# If complex, convert to Python complex
# FIXME: better list iterator way to handle this?
if(knob.type == self.BaseTypes.C32VECTOR):
- for i in xrange(len(result[key].value)):
+ for i in range(len(result[key].value)):
result[key].value[i] = complex(result[key].value[i].re,
result[key].value[i].im)
return result
def getKnobsRaw(self, *args):
result = {}
- for key, knob in self.thriftclient.radio.getKnobs(*args).iteritems():
+ for key, knob in list(self.thriftclient.radio.getKnobs(*args).items()):
#print("key:", key, "value:", knob, "type:", knob.type)
result[key] = knob
return result
def getRe(self,*args):
result = {}
- for key, knob in self.thriftclient.radio.getRe(*args).iteritems():
+ for key, knob in list(self.thriftclient.radio.getRe(*args).items()):
result[key] = self.unpackKnob(key, knob)
return result
@@ -182,7 +183,7 @@ class RPCConnectionThrift(RPCConnection.RPCConnection):
if(type(*args) == dict):
a = dict(*args)
result = {}
- for key, knob in a.iteritems():
+ for key, knob in list(a.items()):
result[key] = self.packKnob(knob)
self.thriftclient.radio.setKnobs(result)
elif(type(*args) == list or type(*args) == tuple):
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/__init__.py b/gnuradio-runtime/python/gnuradio/ctrlport/__init__.py
index 8f33d65bbc..363d42a68e 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/__init__.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/__init__.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+from __future__ import unicode_literals
#
# Copyright 2012 Free Software Foundation, Inc.
#
@@ -22,7 +24,7 @@
# import swig generated symbols into the ctrlport namespace
#from ctrlport_swig import *
-from monitor import *
+from .monitor import *
# import any pure python here
#import GNURadio
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx b/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
index 15a2153a0f..302275feb1 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
@@ -20,6 +20,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
import sys, time, re, pprint
import random,math,operator
try:
@@ -36,14 +38,14 @@ try:
try:
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
except ImportError:
- print sys.argv[0], "could not load QTAgg backend."
+ print(sys.argv[0], "could not load QTAgg backend.")
sys.exit(1)
from matplotlib.figure import Figure
except ImportError:
- print sys.argv[0], "requires networkx and matplotlib.", \
- "Please check that they are installed and try again."
+ print(sys.argv[0], "requires networkx and matplotlib.",
+ "Please check that they are installed and try again.")
sys.exit(1)
from PyQt4 import QtCore,Qt
@@ -282,7 +284,7 @@ class ConInfoDialog(QtGui.QDialog):
class DataTable(QtGui.QWidget):
def update(self):
- print "update"
+ print("update")
def closeEvent(self, event):
self.timer = None
@@ -498,7 +500,7 @@ class MForm(QtGui.QWidget):
self.clockSel.setCurrentIndex(self.clockSelIdx)
self.prevent_clock_change = False
except:
- print "WARNING: Failed to get current clock setting!"
+ print("WARNING: Failed to get current clock setting!")
nodes_stream = self.G_stream.nodes()
nodes_msg = self.G_msg.nodes()
@@ -571,7 +573,7 @@ class MForm(QtGui.QWidget):
self.parent.statusBar().showMessage("Current GNU Radio Control Port Query Latency: %f ms"%\
(latency*1000))
- except Exception, e:
+ except Exception as e:
sys.stderr.write("gr-perf-monitorx: radio.getKnobs threw exception ({0}).\n".format(e))
if(type(self.parent) is MAINWindow):
# Find window of connection
@@ -625,7 +627,7 @@ class MForm(QtGui.QWidget):
return;
idx = self.clockSel.currentIndex();
clk = self.clocks.values()[idx]
-# print "UPDATE CLOCK!!! %d -> %d"%(idx,clk);
+# print("UPDATE CLOCK!!! %d -> %d"%(idx,clk);)
k = self.radioclient.getKnobs([self.clockKey]);
k[self.clockKey].value = clk;
km = {};
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/monitor.py b/gnuradio-runtime/python/gnuradio/ctrlport/monitor.py
index f651be2449..49b66e9830 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/monitor.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/monitor.py
@@ -20,12 +20,15 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import unicode_literals
+
import sys, subprocess, re, signal, time, atexit, os
from gnuradio import gr
-class monitor:
+class monitor(object):
def __init__(self,tool="gr-ctrlport-monitor"):
- print "ControlPort Monitor running."
+ print("ControlPort Monitor running.")
self.started = False
self.tool = tool
atexit.register(self.shutdown)
@@ -38,35 +41,35 @@ class monitor:
gr.prefs().singleton().set_bool("PerfCounters","on",True);
gr.prefs().singleton().set_bool("PerfCounters","export",True);
except:
- print "no support for gr.prefs setting"
+ print("no support for gr.prefs setting")
def __del__(self):
if(self.started):
self.stop()
def start(self):
- print "monitor::endpoints() = %s" % (gr.rpcmanager_get().endpoints())
+ print("monitor::endpoints() = %s" % (gr.rpcmanager_get().endpoints()))
try:
cmd = map(lambda a: [self.tool,
re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)",a).group(1),
re.search("-p (\d+)",a).group(1)],
gr.rpcmanager_get().endpoints())[0]
- print "running: %s"%(str(cmd))
+ print("running: %s"%(str(cmd)))
self.proc = subprocess.Popen(cmd);
self.started = True
except:
self.proc = None
- print "failed to to start ControlPort Monitor on specified port"
+ print("failed to to start ControlPort Monitor on specified port")
def stop(self):
if(self.proc):
if(self.proc.returncode == None):
- print "\tcalling stop on shutdown"
+ print("\tcalling stop on shutdown")
self.proc.terminate()
else:
- print "\tno proc to shut down, exiting"
+ print("\tno proc to shut down, exiting")
def shutdown(self):
- print "ctrlport.monitor received shutdown signal"
+ print("ctrlport.monitor received shutdown signal")
if(self.started):
self.stop()
diff --git a/gnuradio-runtime/python/gnuradio/eng_arg.py b/gnuradio-runtime/python/gnuradio/eng_arg.py
index 05cd8a1f2a..5983352443 100644
--- a/gnuradio-runtime/python/gnuradio/eng_arg.py
+++ b/gnuradio-runtime/python/gnuradio/eng_arg.py
@@ -22,6 +22,7 @@
'''
Add support for engineering notation to argparse.ArgumentParser
'''
+from __future__ import unicode_literals
import argparse
from gnuradio import eng_notation
diff --git a/gnuradio-runtime/python/gnuradio/eng_notation.py b/gnuradio-runtime/python/gnuradio/eng_notation.py
index 12332aef7d..391dc5838f 100644
--- a/gnuradio-runtime/python/gnuradio/eng_notation.py
+++ b/gnuradio-runtime/python/gnuradio/eng_notation.py
@@ -21,6 +21,7 @@
"""
Display numbers as strings using engineering notation.
"""
+from __future__ import unicode_literals
scale_factor = {}
scale_factor['E'] = 1e18
@@ -67,7 +68,7 @@ def str_to_num (value):
try:
scale = 1.0
suffix = value[-1]
- if scale_factor.has_key (suffix):
+ if suffix in scale_factor:
return float (value[0:-1]) * scale_factor[suffix]
return float (value)
except:
diff --git a/gnuradio-runtime/python/gnuradio/eng_option.py b/gnuradio-runtime/python/gnuradio/eng_option.py
index 5d8660f0f2..565780be28 100644
--- a/gnuradio-runtime/python/gnuradio/eng_option.py
+++ b/gnuradio-runtime/python/gnuradio/eng_option.py
@@ -20,10 +20,12 @@
#
'''Add support for engineering notation to optparse.OptionParser'''
+from __future__ import absolute_import
+from __future__ import unicode_literals
from copy import copy
from optparse import Option, OptionValueError
-import eng_notation
+from . import eng_notation
def check_eng_float (option, opt, value):
try:
@@ -39,25 +41,9 @@ def check_intx (option, opt, value):
raise OptionValueError (
"option %s: invalid integer value: %r" % (opt, value))
-def check_subdev (option, opt, value):
- """
- Value has the form: (A|B)(:0|1)?
-
- Returns:
- a 2-tuple (0|1, 0|1)
- """
- d = { 'A' : (0, 0), 'A:0' : (0, 0), 'A:1' : (0, 1), 'A:2' : (0, 2),
- 'B' : (1, 0), 'B:0' : (1, 0), 'B:1' : (1, 1), 'B:2' : (1, 2) }
- try:
- return d[value.upper()]
- except:
- raise OptionValueError(
- "option %s: invalid subdev: '%r', must be one of %s" % (opt, value, ', '.join(sorted(d.keys()))))
-
class eng_option (Option):
TYPES = Option.TYPES + ("eng_float", "intx", "subdev")
TYPE_CHECKER = copy (Option.TYPE_CHECKER)
TYPE_CHECKER["eng_float"] = check_eng_float
TYPE_CHECKER["intx"] = check_intx
- TYPE_CHECKER["subdev"] = check_subdev
diff --git a/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt b/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt
index 30d3d88fd8..1b535ef997 100644
--- a/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt
+++ b/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt
@@ -22,6 +22,7 @@ include(GrPython)
GR_PYTHON_INSTALL(FILES
__init__.py
+ exceptions.py
tag_utils.py
packet_utils.py
gateway.py
@@ -32,7 +33,6 @@ GR_PYTHON_INSTALL(FILES
top_block.py
pubsub.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio/gr
- COMPONENT "runtime_python"
)
########################################################################
@@ -54,6 +54,6 @@ if(ENABLE_TESTING)
file(GLOB py_qa_test_files "qa_*.py")
foreach(py_qa_test_file ${py_qa_test_files})
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
- GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file})
+ GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
endforeach(py_qa_test_file)
endif(ENABLE_TESTING)
diff --git a/gnuradio-runtime/python/gnuradio/gr/__init__.py b/gnuradio-runtime/python/gnuradio/gr/__init__.py
index cdfa1a3157..6ec5074fff 100644
--- a/gnuradio-runtime/python/gnuradio/gr/__init__.py
+++ b/gnuradio-runtime/python/gnuradio/gr/__init__.py
@@ -24,6 +24,8 @@
"""
Core contents.
"""
+from __future__ import absolute_import
+from __future__ import unicode_literals
# This is the main GNU Radio python module.
# We pull the swig output and the other modules into the gnuradio.gr namespace
@@ -31,20 +33,20 @@ Core contents.
# If gnuradio is installed then the swig output will be in this directory.
# Otherwise it will reside in ../../../swig.
-import os
+import os, sys
try:
- from runtime_swig import *
+ from .runtime_swig import *
except ImportError:
dirname, filename = os.path.split(os.path.abspath(__file__))
__path__.append(os.path.join(dirname, "..", "..", "..", "swig"))
- from runtime_swig import *
+ from .runtime_swig import *
-from exceptions import *
-from top_block import *
-from hier_block2 import *
-from tag_utils import *
-from gateway import basic_block, sync_block, decim_block, interp_block, py_io_signature
+from .exceptions import *
+from .top_block import *
+from .hier_block2 import *
+from .tag_utils import *
+from .gateway import basic_block, sync_block, decim_block, interp_block, py_io_signature
# Force the preference database to be initialized
prefs = prefs.singleton
diff --git a/gnuradio-runtime/python/gnuradio/gr/exceptions.py b/gnuradio-runtime/python/gnuradio/gr/exceptions.py
index dba04750bc..1b7fd025b7 100644
--- a/gnuradio-runtime/python/gnuradio/gr/exceptions.py
+++ b/gnuradio-runtime/python/gnuradio/gr/exceptions.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
#
# Copyright 2004 Free Software Foundation, Inc.
#
diff --git a/gnuradio-runtime/python/gnuradio/gr/gateway.py b/gnuradio-runtime/python/gnuradio/gr/gateway.py
index 4498729825..4eaa8745ac 100644
--- a/gnuradio-runtime/python/gnuradio/gr/gateway.py
+++ b/gnuradio-runtime/python/gnuradio/gr/gateway.py
@@ -19,18 +19,23 @@
# Boston, MA 02110-1301, USA.
#
-import runtime_swig as gr
-from runtime_swig import io_signature, io_signaturev
-from runtime_swig import block_gw_message_type
-from runtime_swig import block_gateway
+from __future__ import print_function
+from __future__ import unicode_literals
+
+
import numpy
+from . import runtime_swig as gr
+from .runtime_swig import io_signature, io_signaturev
+from .runtime_swig import block_gw_message_type
+from .runtime_swig import block_gateway
+
########################################################################
# Magic to turn pointers into numpy arrays
# http://docs.scipy.org/doc/numpy/reference/arrays.interface.html
########################################################################
def pointer_to_ndarray(addr, dtype, nitems):
- class array_like:
+ class array_like(object):
__array_interface__ = {
'data' : (int(addr), False),
'typestr' : dtype.base.str,
diff --git a/gnuradio-runtime/python/gnuradio/gr/gr_threading.py b/gnuradio-runtime/python/gnuradio/gr/gr_threading.py
index 5d6f0fdaf9..cb0519f6f6 100644
--- a/gnuradio-runtime/python/gnuradio/gr/gr_threading.py
+++ b/gnuradio-runtime/python/gnuradio/gr/gr_threading.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+from __future__ import unicode_literals
#
# Copyright 2005 Free Software Foundation, Inc.
#
@@ -25,10 +27,10 @@ from sys import version_info as _version_info
if _version_info[0:2] == (2, 3):
#print "Importing gr_threading_23"
- from gr_threading_23 import *
+ from .gr_threading_23 import *
elif _version_info[0:2] == (2, 4):
#print "Importing gr_threading_24"
- from gr_threading_24 import *
+ from .gr_threading_24 import *
else:
# assume the patch was applied...
#print "Importing system provided threading"
diff --git a/gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py b/gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py
index 795c1593d4..f4f062f715 100644
--- a/gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py
+++ b/gnuradio-runtime/python/gnuradio/gr/gr_threading_23.py
@@ -4,15 +4,18 @@
# It's been patched to fix a problem with join, where a KeyboardInterrupt
# caused a lock to be left in the acquired state.
+from __future__ import print_function
+from __future__ import unicode_literals
+
import sys as _sys
try:
- import thread
+ import _thread
except ImportError:
del _sys.modules[__name__]
raise
-from StringIO import StringIO as _StringIO
+from io import StringIO as _StringIO
from time import time as _time, sleep as _sleep
from traceback import print_exc as _print_exc
@@ -21,11 +24,11 @@ __all__ = ['activeCount', 'Condition', 'currentThread', 'enumerate', 'Event',
'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread',
'Timer', 'setprofile', 'settrace']
-_start_new_thread = thread.start_new_thread
-_allocate_lock = thread.allocate_lock
-_get_ident = thread.get_ident
-ThreadError = thread.error
-del thread
+_start_new_thread = _thread.start_new_thread
+_allocate_lock = _thread.allocate_lock
+_get_ident = _thread.get_ident
+ThreadError = _thread.error
+del _thread
# Debug support (adapted from ihooks.py).
@@ -127,8 +130,9 @@ class _RLock(_Verbose):
# Internal methods used by condition variables
- def _acquire_restore(self, (count, owner)):
+ def _acquire_restore(self, lock):
self.__block.acquire()
+ count, owner = lock
self.__count = count
self.__owner = owner
if __debug__:
@@ -313,7 +317,7 @@ class _BoundedSemaphore(_Semaphore):
def release(self):
if self._Semaphore__value >= self._initial_value:
- raise ValueError, "Semaphore released too many times"
+ raise ValueError("Semaphore released too many times")
return _Semaphore.release(self)
@@ -627,7 +631,7 @@ def activeCount():
def enumerate():
_active_limbo_lock.acquire()
- active = _active.values() + _limbo.values()
+ active = list(_active.values()) + list(_limbo.values())
_active_limbo_lock.release()
return active
@@ -698,7 +702,7 @@ def _test():
def run(self):
while self.count > 0:
item = self.queue.get()
- print item
+ print(item)
self.count = self.count - 1
NP = 3
diff --git a/gnuradio-runtime/python/gnuradio/gr/gr_threading_24.py b/gnuradio-runtime/python/gnuradio/gr/gr_threading_24.py
index 8ad880b090..6dddce7e22 100644
--- a/gnuradio-runtime/python/gnuradio/gr/gr_threading_24.py
+++ b/gnuradio-runtime/python/gnuradio/gr/gr_threading_24.py
@@ -4,10 +4,13 @@
# It's been patched to fix a problem with join, where a KeyboardInterrupt
# caused a lock to be left in the acquired state.
+from __future__ import print_function
+from __future__ import unicode_literals
+
import sys as _sys
try:
- import thread
+ import _thread
except ImportError:
del _sys.modules[__name__]
raise
@@ -21,11 +24,11 @@ __all__ = ['activeCount', 'Condition', 'currentThread', 'enumerate', 'Event',
'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread',
'Timer', 'setprofile', 'settrace', 'local']
-_start_new_thread = thread.start_new_thread
-_allocate_lock = thread.allocate_lock
-_get_ident = thread.get_ident
-ThreadError = thread.error
-del thread
+_start_new_thread = _thread.start_new_thread
+_allocate_lock = _thread.allocate_lock
+_get_ident = _thread.get_ident
+ThreadError = _thread.error
+del _thread
# Debug support (adapted from ihooks.py).
@@ -127,8 +130,9 @@ class _RLock(_Verbose):
# Internal methods used by condition variables
- def _acquire_restore(self, (count, owner)):
+ def _acquire_restore(self, lock):
self.__block.acquire()
+ count, owner = lock
self.__count = count
self.__owner = owner
if __debug__:
@@ -311,7 +315,7 @@ class _BoundedSemaphore(_Semaphore):
def release(self):
if self._Semaphore__value >= self._initial_value:
- raise ValueError, "Semaphore released too many times"
+ raise ValueError("Semaphore released too many times")
return _Semaphore.release(self)
@@ -688,7 +692,7 @@ def activeCount():
def enumerate():
_active_limbo_lock.acquire()
- active = _active.values() + _limbo.values()
+ active = list(_active.values()) + list(_limbo.values())
_active_limbo_lock.release()
return active
@@ -700,7 +704,7 @@ _MainThread()
# module, or from the python fallback
try:
- from thread import _local as local
+ from _thread import _local as local
except ImportError:
from _threading_local import local
@@ -767,7 +771,7 @@ def _test():
def run(self):
while self.count > 0:
item = self.queue.get()
- print item
+ print(item)
self.count = self.count - 1
NP = 3
diff --git a/gnuradio-runtime/python/gnuradio/gr/hier_block2.py b/gnuradio-runtime/python/gnuradio/gr/hier_block2.py
index 3f4c6aa9c7..8d0533c71c 100644
--- a/gnuradio-runtime/python/gnuradio/gr/hier_block2.py
+++ b/gnuradio-runtime/python/gnuradio/gr/hier_block2.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
#
# Copyright 2006,2007,2014 Free Software Foundation, Inc.
#
@@ -21,7 +22,7 @@
import functools
-from runtime_swig import hier_block2_swig, dot_graph
+from .runtime_swig import hier_block2_swig, dot_graph
import pmt
diff --git a/gnuradio-runtime/python/gnuradio/gr/packet_utils.py b/gnuradio-runtime/python/gnuradio/gr/packet_utils.py
index 720cfd962f..770a5c0b36 100644
--- a/gnuradio-runtime/python/gnuradio/gr/packet_utils.py
+++ b/gnuradio-runtime/python/gnuradio/gr/packet_utils.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr
import pmt
@@ -28,9 +31,9 @@ def make_lengthtags(lengths, offsets, tagname='length', vlen=1):
assert(len(offsets) == len(lengths))
for offset, length in zip(offsets, lengths):
tag = gr.tag_t()
- tag.offset = offset/vlen
+ tag.offset = offset // vlen
tag.key = pmt.string_to_symbol(tagname)
- tag.value = pmt.from_long(length/vlen)
+ tag.value = pmt.from_long(length // vlen)
tags.append(tag)
return tags
@@ -73,7 +76,7 @@ def count_bursts(data, tags, tsb_tag_key, vlen=1):
if pos in lengths:
if in_packet:
print("Got tag at pos {0} current packet_pos is {1}".format(pos, packet_pos))
- raise StandardError("Received packet tag while in packet.")
+ raise Exception("Received packet tag while in packet.")
packet_pos = -1
packet_length = lengths[pos]
in_packet = True
@@ -128,9 +131,9 @@ def packets_to_vectors(packets, tsb_tag_key, vlen=1):
for packet in packets:
data.extend(packet)
tag = gr.tag_t()
- tag.offset = offset/vlen
+ tag.offset = offset // vlen
tag.key = pmt.string_to_symbol(tsb_tag_key)
- tag.value = pmt.from_long(len(packet)/vlen)
+ tag.value = pmt.from_long(len(packet) // vlen)
tags.append(tag)
offset = offset + len(packet)
return data, tags
diff --git a/gnuradio-runtime/python/gnuradio/gr/pubsub.py b/gnuradio-runtime/python/gnuradio/gr/pubsub.py
index 90568418fc..25108b8f70 100644
--- a/gnuradio-runtime/python/gnuradio/gr/pubsub.py
+++ b/gnuradio-runtime/python/gnuradio/gr/pubsub.py
@@ -26,43 +26,46 @@ Abstract GNU Radio publisher/subscriber interface
This is a proof of concept implementation, will likely change significantly.
"""
+from __future__ import print_function
+from __future__ import unicode_literals
+
class pubsub(dict):
def __init__(self):
- self._publishers = { }
- self._subscribers = { }
- self._proxies = { }
+ self._publishers = { }
+ self._subscribers = { }
+ self._proxies = { }
def __missing__(self, key, value=None):
- dict.__setitem__(self, key, value)
- self._publishers[key] = None
- self._subscribers[key] = []
- self._proxies[key] = None
+ dict.__setitem__(self, key, value)
+ self._publishers[key] = None
+ self._subscribers[key] = []
+ self._proxies[key] = None
def __setitem__(self, key, val):
- if not self.has_key(key):
- self.__missing__(key, val)
- elif self._proxies[key] is not None:
- (p, newkey) = self._proxies[key]
- p[newkey] = val
- else:
- dict.__setitem__(self, key, val)
- for sub in self._subscribers[key]:
- # Note this means subscribers will get called in the thread
- # context of the 'set' caller.
- sub(val)
+ if key not in self:
+ self.__missing__(key, val)
+ elif self._proxies[key] is not None:
+ (p, newkey) = self._proxies[key]
+ p[newkey] = val
+ else:
+ dict.__setitem__(self, key, val)
+ for sub in self._subscribers[key]:
+ # Note this means subscribers will get called in the thread
+ # context of the 'set' caller.
+ sub(val)
def __getitem__(self, key):
- if not self.has_key(key): self.__missing__(key)
- if self._proxies[key] is not None:
- (p, newkey) = self._proxies[key]
- return p[newkey]
- elif self._publishers[key] is not None:
- return self._publishers[key]()
- else:
- return dict.__getitem__(self, key)
+ if key not in self: self.__missing__(key)
+ if self._proxies[key] is not None:
+ (p, newkey) = self._proxies[key]
+ return p[newkey]
+ elif self._publishers[key] is not None:
+ return self._publishers[key]()
+ else:
+ return dict.__getitem__(self, key)
def publish(self, key, publisher):
- if not self.has_key(key): self.__missing__(key)
+ if key not in self: self.__missing__(key)
if self._proxies[key] is not None:
(p, newkey) = self._proxies[key]
p.publish(newkey, publisher)
@@ -70,7 +73,7 @@ class pubsub(dict):
self._publishers[key] = publisher
def subscribe(self, key, subscriber):
- if not self.has_key(key): self.__missing__(key)
+ if key not in self: self.__missing__(key)
if self._proxies[key] is not None:
(p, newkey) = self._proxies[key]
p.subscribe(newkey, subscriber)
@@ -92,9 +95,9 @@ class pubsub(dict):
self._subscribers[key].remove(subscriber)
def proxy(self, key, p, newkey=None):
- if not self.has_key(key): self.__missing__(key)
- if newkey is None: newkey = key
- self._proxies[key] = (p, newkey)
+ if key not in self: self.__missing__(key)
+ if newkey is None: newkey = key
+ self._proxies[key] = (p, newkey)
def unproxy(self, key):
self._proxies[key] = None
@@ -105,49 +108,49 @@ if __name__ == "__main__":
o = pubsub()
# Non-existent key gets auto-created with None value
- print "Auto-created key 'foo' value:", o['foo']
+ print("Auto-created key 'foo' value:", o['foo'])
# Add some subscribers
# First is a bare function
def print_len(x):
- print "len=%i" % (len(x), )
+ print("len=%i" % (len(x), ))
o.subscribe('foo', print_len)
# The second is a class member function
class subber(object):
- def __init__(self, param):
- self._param = param
- def printer(self, x):
- print self._param, `x`
+ def __init__(self, param):
+ self._param = param
+ def printer(self, x):
+ print(self._param, repr(x))
s = subber('param')
o.subscribe('foo', s.printer)
# The third is a lambda function
- o.subscribe('foo', lambda x: sys.stdout.write('val='+`x`+'\n'))
+ o.subscribe('foo', lambda x: sys.stdout.write('val='+repr(x)+'\n'))
# Update key 'foo', will notify subscribers
- print "Updating 'foo' with three subscribers:"
+ print("Updating 'foo' with three subscribers:")
o['foo'] = 'bar';
# Remove first subscriber
o.unsubscribe('foo', print_len)
# Update now will only trigger second and third subscriber
- print "Updating 'foo' after removing a subscriber:"
+ print("Updating 'foo' after removing a subscriber:")
o['foo'] = 'bar2';
# Publish a key as a function, in this case, a lambda function
o.publish('baz', lambda : 42)
- print "Published value of 'baz':", o['baz']
+ print("Published value of 'baz':", o['baz'])
# Unpublish the key
o.unpublish('baz')
# This will return None, as there is no publisher
- print "Value of 'baz' with no publisher:", o['baz']
+ print("Value of 'baz' with no publisher:", o['baz'])
# Set 'baz' key, it gets cached
o['baz'] = 'bazzz'
# Now will return cached value, since no provider
- print "Cached value of 'baz' after being set:", o['baz']
+ print("Cached value of 'baz' after being set:", o['baz'])
diff --git a/gnuradio-runtime/python/gnuradio/gr/qa_feval.py b/gnuradio-runtime/python/gnuradio/gr/qa_feval.py
index 9018e12f36..078e2bf789 100755..100644
--- a/gnuradio-runtime/python/gnuradio/gr/qa_feval.py
+++ b/gnuradio-runtime/python/gnuradio/gr/qa_feval.py
@@ -20,6 +20,7 @@
# Boston, MA 02110-1301, USA.
#
+
from gnuradio import gr, gr_unittest
class my_add2_dd(gr.feval_dd):
diff --git a/gnuradio-runtime/python/gnuradio/gr/qa_flowgraph.py b/gnuradio-runtime/python/gnuradio/gr/qa_flowgraph.py
index fa4fd4910e..f5802c51bc 100755..100644
--- a/gnuradio-runtime/python/gnuradio/gr/qa_flowgraph.py
+++ b/gnuradio-runtime/python/gnuradio/gr/qa_flowgraph.py
@@ -20,6 +20,7 @@
# Boston, MA 02110-1301, USA.
#
+
import time
import pmt
from gnuradio import gr, gr_unittest, blocks
diff --git a/gnuradio-runtime/python/gnuradio/gr/qa_hier_block2.py b/gnuradio-runtime/python/gnuradio/gr/qa_hier_block2.py
index 005331c2ec..c8f3d1a5f9 100644
--- a/gnuradio-runtime/python/gnuradio/gr/qa_hier_block2.py
+++ b/gnuradio-runtime/python/gnuradio/gr/qa_hier_block2.py
@@ -19,9 +19,12 @@
# Boston, MA 02110-1301, USA.
#
-import pmt, time
+import time
+
from gnuradio import gr_unittest, blocks, gr, analog
from gnuradio.gr.hier_block2 import _multiple_endpoints, _optional_endpoints
+import pmt
+
class test_hblk(gr.hier_block2):
def __init__(self, io_sig=1*[gr.sizeof_gr_complex], ndebug=2):
@@ -126,7 +129,7 @@ class test_hier_block2(gr_unittest.TestCase):
time.sleep(1)
tb.stop()
tb.wait()
-
+
def test_012(self):
s, st, h, k = analog.sig_source_c(44100, analog.GR_COS_WAVE, 440, 1.0, 0.0), blocks.message_strobe(pmt.PMT_NIL, 100), blocks.head(gr.sizeof_gr_complex, 1000), test_hblk([gr.sizeof_gr_complex], 16)
tb = gr.top_block()
@@ -139,4 +142,3 @@ class test_hier_block2(gr_unittest.TestCase):
if __name__ == '__main__':
gr_unittest.run(test_hier_block2, "test_hier_block2.xml")
-
diff --git a/gnuradio-runtime/python/gnuradio/gr/qa_kludged_imports.py b/gnuradio-runtime/python/gnuradio/gr/qa_kludged_imports.py
index f80188c9fc..e2e9047c9b 100755..100644
--- a/gnuradio-runtime/python/gnuradio/gr/qa_kludged_imports.py
+++ b/gnuradio-runtime/python/gnuradio/gr/qa_kludged_imports.py
@@ -20,6 +20,7 @@
# Boston, MA 02110-1301, USA.
#
+
from gnuradio import gr, gr_unittest
class test_kludged_imports (gr_unittest.TestCase):
diff --git a/gnuradio-runtime/python/gnuradio/gr/qa_random.py b/gnuradio-runtime/python/gnuradio/gr/qa_random.py
index d3e5410454..6fbf5e478a 100644
--- a/gnuradio-runtime/python/gnuradio/gr/qa_random.py
+++ b/gnuradio-runtime/python/gnuradio/gr/qa_random.py
@@ -20,6 +20,7 @@
# Boston, MA 02110-1301, USA.
#
+
from gnuradio import gr, gr_unittest
import numpy as np
diff --git a/gnuradio-runtime/python/gnuradio/gr/qa_tag_utils.py b/gnuradio-runtime/python/gnuradio/gr/qa_tag_utils.py
index 55b62a12ac..3d7b99d12c 100755..100644
--- a/gnuradio-runtime/python/gnuradio/gr/qa_tag_utils.py
+++ b/gnuradio-runtime/python/gnuradio/gr/qa_tag_utils.py
@@ -20,12 +20,12 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
+
from gnuradio import gr, gr_unittest
+import pmt
-try:
- import pmt_swig as pmt
-except ImportError:
- import pmt
class test_tag_utils (gr_unittest.TestCase):
@@ -111,6 +111,6 @@ class test_tag_utils (gr_unittest.TestCase):
if __name__ == '__main__':
- print 'hi'
+ print('hi')
gr_unittest.run(test_tag_utils, "test_tag_utils.xml")
diff --git a/gnuradio-runtime/python/gnuradio/gr/tag_utils.py b/gnuradio-runtime/python/gnuradio/gr/tag_utils.py
index 0d4805a8b8..d054865c22 100644
--- a/gnuradio-runtime/python/gnuradio/gr/tag_utils.py
+++ b/gnuradio-runtime/python/gnuradio/gr/tag_utils.py
@@ -1,6 +1,7 @@
+from __future__ import unicode_literals
import pmt
-import runtime_swig as gr
+from . import runtime_swig as gr
class PythonTag(object):
" Python container for tags "
@@ -51,29 +52,29 @@ def python_to_tag(tag_struct):
good = False
tag = gr.tag_t()
if(type(tag_struct) == dict):
- if(tag_struct.has_key('offset')):
- if(isinstance(tag_struct['offset'], (int,long))):
+ if('offset' in tag_struct):
+ if(isinstance(tag_struct['offset'], int)):
tag.offset = tag_struct['offset']
good = True
- if(tag_struct.has_key('key')):
+ if('key' in tag_struct):
if(isinstance(tag_struct['key'], pmt.swig_int_ptr)):
tag.key = tag_struct['key']
good = True
- if(tag_struct.has_key('value')):
+ if('value' in tag_struct):
if(isinstance(tag_struct['value'], pmt.swig_int_ptr)):
tag.value = tag_struct['value']
good = True
- if(tag_struct.has_key('srcid')):
+ if('srcid' in tag_struct):
if(isinstance(tag_struct['srcid'], pmt.swig_int_ptr)):
tag.srcid = tag_struct['srcid']
good = True
elif(type(tag_struct) == list or type(tag_struct) == tuple):
if(len(tag_struct) == 4):
- if(isinstance(tag_struct[0], (int,long))):
+ if(isinstance(tag_struct[0], int)):
tag.offset = tag_struct[0]
good = True
@@ -90,7 +91,7 @@ def python_to_tag(tag_struct):
good = True
elif(len(tag_struct) == 3):
- if(isinstance(tag_struct[0], (int,long))):
+ if(isinstance(tag_struct[0], int)):
tag.offset = tag_struct[0]
good = True
diff --git a/gnuradio-runtime/python/gnuradio/gr/top_block.py b/gnuradio-runtime/python/gnuradio/gr/top_block.py
index 2efcbd9aae..e7608bf5e9 100644
--- a/gnuradio-runtime/python/gnuradio/gr/top_block.py
+++ b/gnuradio-runtime/python/gnuradio/gr/top_block.py
@@ -19,15 +19,18 @@
# Boston, MA 02110-1301, USA.
#
-from runtime_swig import top_block_swig, \
- top_block_wait_unlocked, top_block_run_unlocked, \
- top_block_start_unlocked, top_block_stop_unlocked, \
- top_block_unlock_unlocked, dot_graph_tb
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
+from .runtime_swig import (top_block_swig,
+ top_block_wait_unlocked, top_block_run_unlocked,
+ top_block_start_unlocked, top_block_stop_unlocked,
+ top_block_unlock_unlocked, dot_graph_tb)
#import gnuradio.gr.gr_threading as _threading
-import gr_threading as _threading
+from . import gr_threading as _threading
-from hier_block2 import hier_block2
+from .hier_block2 import hier_block2
class _top_block_waiter(_threading.Thread):
"""
diff --git a/gnuradio-runtime/python/gnuradio/gr_unittest.py b/gnuradio-runtime/python/gnuradio/gr_unittest.py
index 49d1189635..190ea63354 100755..100644
--- a/gnuradio-runtime/python/gnuradio/gr_unittest.py
+++ b/gnuradio-runtime/python/gnuradio/gr_unittest.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004,2010 Free Software Foundation, Inc.
+# Copyright 2004,2010,2018 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -22,10 +22,16 @@
"""
GNU radio specific extension of unittest.
"""
+from __future__ import absolute_import
+from __future__ import unicode_literals
+from __future__ import division
+
+import os
+import stat
import unittest
-import gr_xmlrunner
-import sys, os, stat
+from . import gr_xmlrunner
+
class TestCase(unittest.TestCase):
@@ -44,11 +50,12 @@ class TestCase(unittest.TestCase):
as significant digits (measured from the most significant digit).
"""
if round(second.real-first.real, places) != 0:
- raise self.failureException, \
- (msg or '%s != %s within %s places' % (`first`, `second`, `places` ))
+ raise self.failureException(
+ msg or '%r != %r within %r places' % (first, second, places))
if round(second.imag-first.imag, places) != 0:
- raise self.failureException, \
- (msg or '%s != %s within %s places' % (`first`, `second`, `places` ))
+ raise self.failureException(
+ msg or '%r != %r within %r places' % (first, second, places)
+ )
def assertComplexAlmostEqual2 (self, ref, x, abs_eps=1e-12, rel_eps=1e-6, msg=None):
"""
@@ -58,48 +65,52 @@ class TestCase(unittest.TestCase):
return
if abs(ref) > abs_eps:
- if abs(ref-x)/abs(ref) > rel_eps:
- raise self.failureException, \
- (msg or '%s != %s rel_error = %s rel_limit = %s' % (
- `ref`, `x`, abs(ref-x)/abs(ref), `rel_eps` ))
+ if abs(ref-x) / abs(ref) > rel_eps:
+ raise self.failureException(
+ msg or '%r != %r rel_error = %r rel_limit = %r' % (
+ ref, x, abs(ref-x) / abs(ref), rel_eps
+ )
+ )
else:
- raise self.failureException, \
- (msg or '%s != %s rel_error = %s rel_limit = %s' % (
- `ref`, `x`, abs(ref-x)/abs(ref), `rel_eps` ))
+ raise self.failureException(
+ msg or '%r != %r rel_error = %r rel_limit = %r' % (
+ ref, x, abs(ref-x) / abs(ref), rel_eps
+ )
+ )
def assertComplexTuplesAlmostEqual (self, a, b, places=7, msg=None):
self.assertEqual (len(a), len(b))
- for i in xrange (len(a)):
+ for i in range (len(a)):
self.assertComplexAlmostEqual (a[i], b[i], places, msg)
def assertComplexTuplesAlmostEqual2 (self, ref, x,
abs_eps=1e-12, rel_eps=1e-6, msg=None):
self.assertEqual (len(ref), len(x))
- for i in xrange (len(ref)):
+ for i in range (len(ref)):
try:
self.assertComplexAlmostEqual2 (ref[i], x[i], abs_eps, rel_eps, msg)
- except self.failureException, e:
+ except self.failureException as e:
#sys.stderr.write("index = %d " % (i,))
- #sys.stderr.write("%s\n" % (e,))
+ #sys.stderr.write("%r\n" % (e,))
raise
def assertFloatTuplesAlmostEqual (self, a, b, places=7, msg=None):
self.assertEqual (len(a), len(b))
- for i in xrange (len(a)):
+ for i in range (len(a)):
self.assertAlmostEqual (a[i], b[i], places, msg)
def assertFloatTuplesAlmostEqual2 (self, ref, x,
abs_eps=1e-12, rel_eps=1e-6, msg=None):
self.assertEqual (len(ref), len(x))
- for i in xrange (len(ref)):
+ for i in range (len(ref)):
try:
self.assertComplexAlmostEqual2 (ref[i], x[i], abs_eps, rel_eps, msg)
- except self.failureException, e:
+ except self.failureException as e:
#sys.stderr.write("index = %d " % (i,))
- #sys.stderr.write("%s\n" % (e,))
+ #sys.stderr.write("%r\n" % (e,))
raise
@@ -126,7 +137,7 @@ def run(PUT, filename=None, verbosity=1):
path = basepath + "/python"
if not os.path.exists(basepath):
- os.makedirs(basepath, 0750)
+ os.makedirs(basepath, mode=0o750)
xmlrunner = None
# only proceed if .unittests is writable
@@ -134,13 +145,13 @@ def run(PUT, filename=None, verbosity=1):
if(st & stat.S_IWUSR > 0):
# Test if path exists; if not, build it
if not os.path.exists(path):
- os.makedirs(path, 0750)
+ os.makedirs(path, mode=0o750)
# Just for safety: make sure we can write here, too
st = os.stat(path)[stat.ST_MODE]
if(st & stat.S_IWUSR > 0):
# Create an XML runner to filename
- fout = file(path + "/" + filename, "w")
+ fout = open(path+"/"+filename, "w")
xmlrunner = gr_xmlrunner.XMLTestRunner(fout)
txtrunner = TextTestRunner(verbosity=verbosity)
@@ -150,7 +161,7 @@ def run(PUT, filename=None, verbosity=1):
suite = TestLoader().loadTestsFromTestCase(PUT)
# use the xmlrunner if we can write the the directory
- if(xmlrunner is not None):
+ if xmlrunner is not None:
xmlrunner.run(suite)
main(verbosity=verbosity)
diff --git a/gnuradio-runtime/python/gnuradio/gr_xmlrunner.py b/gnuradio-runtime/python/gnuradio/gr_xmlrunner.py
index 31298197ff..fccb1b76f0 100644
--- a/gnuradio-runtime/python/gnuradio/gr_xmlrunner.py
+++ b/gnuradio-runtime/python/gnuradio/gr_xmlrunner.py
@@ -1,25 +1,56 @@
"""
XML Test Runner for PyUnit
"""
-
# Written by Sebastian Rittau <srittau@jroger.in-berlin.de> and placed in
# the Public Domain. With contributions by Paolo Borelli and others.
# Added to GNU Radio Oct. 3, 2010
-__version__ = "0.1"
+from __future__ import unicode_literals
import os.path
import re
import sys
import time
-import traceback
import unittest
+import linecache
from xml.sax.saxutils import escape
+from io import StringIO
+
+
+__version__ = "0.1"
-try:
- from StringIO import StringIO
-except ImportError:
- from io import StringIO
+
+# inline trackeback.print_tb so that py2 uses unicode literals (py2/3 compat)
+def print_tb(tb, limit=None, out=None):
+ """Print up to 'limit' stack trace entries from the traceback 'tb'.
+
+ If 'limit' is omitted or None, all entries are printed. If 'file'
+ is omitted or None, the output goes to sys.stderr; otherwise
+ 'file' should be an open file or file-like object with a write()
+ method.
+ """
+ def _print(out, s='', terminator='\n'):
+ out.write(s+terminator)
+
+ if out is None:
+ out = sys.stderr
+ if limit is None:
+ if hasattr(sys, 'tracebacklimit'):
+ limit = sys.tracebacklimit
+ n = 0
+ while tb is not None and (limit is None or n < limit):
+ f = tb.tb_frame
+ lineno = tb.tb_lineno
+ co = f.f_code
+ filename = co.co_filename
+ name = co.co_name
+ _print(out, ' Out "%s", line %d, in %s' % (filename, lineno, name))
+ linecache.checkcache(filename)
+ line = linecache.getline(filename, lineno, f.f_globals)
+ if line:
+ _print(out, ' ' + line.strip())
+ tb = tb.tb_next
+ n = n+1
class _TestInfo(object):
@@ -60,12 +91,12 @@ class _TestInfo(object):
supplied stream.
"""
- stream.write(' <testcase classname="%(class)s" name="%(method)s" time="%(time).4f">' % \
- {
- "class": self._class,
- "method": self._method,
- "time": self._time,
- })
+ stream.write(' <testcase classname="%(class)s" name="%(method)s" time="%(time).4f">' %
+ {
+ 'class': self._class,
+ 'method': self._method,
+ 'time': self._time,
+ })
if self._failure is not None:
self._print_error(stream, 'failure', self._failure)
if self._error is not None:
@@ -76,10 +107,10 @@ class _TestInfo(object):
"""Print information from a failure or error to the supplied stream."""
text = escape(str(error[1]))
stream.write('\n')
- stream.write(' <%s type="%s">%s\n' \
- % (tagname, _clsname(error[0]), text))
+ stream.write(' <%s type="%s">%s\n'
+ % (tagname, _clsname(error[0]), text))
tb_stream = StringIO()
- traceback.print_tb(error[2], None, tb_stream)
+ print_tb(error[2], None, tb_stream)
stream.write(escape(tb_stream.getvalue()))
stream.write(' </%s>\n' % tagname)
stream.write(' ')
@@ -137,14 +168,17 @@ class _XMLTestResult(unittest.TestResult):
output and standard error streams must be passed in.a
"""
- stream.write('<testsuite errors="%(e)d" failures="%(f)d" ' % \
- { "e": len(self.errors), "f": len(self.failures) })
- stream.write('name="%(n)s" tests="%(t)d" time="%(time).3f">\n' % \
- {
- "n": self._test_name,
- "t": self.testsRun,
- "time": time_taken,
- })
+ stream.write('<testsuite errors="%(e)d" failures="%(f)d" ' %
+ {
+ "e": len(self.errors),
+ "f": len(self.failures)
+ })
+ stream.write('name="%(n)s" tests="%(t)d" time="%(time).3f">\n' %
+ {
+ "n": self._test_name,
+ "t": self.testsRun,
+ "time": time_taken
+ })
for info in self._tests:
info.print_report(stream)
stream.write(' <system-out><![CDATA[%s]]></system-out>\n' % out)
@@ -173,9 +207,9 @@ class XMLTestRunner(object):
"""Run the given test case or test suite."""
class_ = test.__class__
classname = class_.__module__ + "." + class_.__name__
- if self._stream == None:
+ if self._stream is None:
filename = "TEST-%s.xml" % classname
- stream = file(os.path.join(self._path, filename), "w")
+ stream = open(os.path.join(self._path, filename), "w")
stream.write('<?xml version="1.0" encoding="utf-8"?>\n')
else:
stream = self._stream
diff --git a/gnuradio-runtime/python/gnuradio/gru/CMakeLists.txt b/gnuradio-runtime/python/gnuradio/gru/CMakeLists.txt
index f0276a8d53..c1d7b701a9 100644
--- a/gnuradio-runtime/python/gnuradio/gru/CMakeLists.txt
+++ b/gnuradio-runtime/python/gnuradio/gru/CMakeLists.txt
@@ -32,5 +32,4 @@ GR_PYTHON_INSTALL(FILES
socket_stuff.py
daemon.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio/gru
- COMPONENT "runtime_python"
)
diff --git a/gnuradio-runtime/python/gnuradio/gru/__init__.py b/gnuradio-runtime/python/gnuradio/gru/__init__.py
index 4e41d03a74..0948edb17f 100644
--- a/gnuradio-runtime/python/gnuradio/gru/__init__.py
+++ b/gnuradio-runtime/python/gnuradio/gru/__init__.py
@@ -1,13 +1,15 @@
+from __future__ import absolute_import
+from __future__ import unicode_literals
# make this a package
# Import gru stuff
-from daemon import *
-from freqz import *
-from gnuplot_freqz import *
-from hexint import *
-from listmisc import *
-from mathmisc import *
-from msgq_runner import *
-from os_read_exactly import *
-from seq_with_cursor import *
-from socket_stuff import *
+from .daemon import *
+from .freqz import *
+from .gnuplot_freqz import *
+from .hexint import *
+from .listmisc import *
+from .mathmisc import *
+from .msgq_runner import *
+from .os_read_exactly import *
+from .seq_with_cursor import *
+from .socket_stuff import *
diff --git a/gnuradio-runtime/python/gnuradio/gru/daemon.py b/gnuradio-runtime/python/gnuradio/gru/daemon.py
index e04702152d..14138f9730 100644
--- a/gnuradio-runtime/python/gnuradio/gru/daemon.py
+++ b/gnuradio-runtime/python/gnuradio/gru/daemon.py
@@ -18,6 +18,10 @@
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
+
+from __future__ import print_function
+from __future__ import unicode_literals
+
import os, sys, signal
# Turn application into a background daemon process.
@@ -55,38 +59,38 @@ import os, sys, signal
def daemonize(pidfile=None, logfile=None):
# fork() into background
try:
- pid = os.fork()
- except OSError, e:
- raise Exception, "%s [%d]" % (e.strerror, e.errno)
+ pid = os.fork()
+ except OSError as e:
+ raise Exception("%s [%d]" % (e.strerror, e.errno))
if pid == 0: # First child of first fork()
- # Become session leader of new session
- os.setsid()
+ # Become session leader of new session
+ os.setsid()
- # fork() into background again
- try:
- pid = os.fork()
- except OSError, e:
- raise Exception, "%s [%d]" % (e.strerror, e.errno)
+ # fork() into background again
+ try:
+ pid = os.fork()
+ except OSError as e:
+ raise Exception("%s [%d]" % (e.strerror, e.errno))
- if pid != 0:
- os._exit(0) # Second child of second fork()
+ if pid != 0:
+ os._exit(0) # Second child of second fork()
- else: # Second child of first fork()
- os._exit(0)
+ else: # Second child of first fork()
+ os._exit(0)
- os.umask(0111)
+ os.umask(0o111)
# Write pid
pid = os.getpid()
if pidfile is not None:
- open(pidfile, 'w').write('%d\n'%pid)
+ open(pidfile, 'w').write('%d\n'%pid)
# Redirect streams
if logfile is not None:
- lf = open(logfile, 'a+')
- sys.stdout = lf
- sys.stderr = lf
+ lf = open(logfile, 'a+')
+ sys.stdout = lf
+ sys.stderr = lf
# Prevent pinning any filesystem mounts
os.chdir('/')
@@ -97,6 +101,6 @@ def daemonize(pidfile=None, logfile=None):
if __name__ == "__main__":
import time
daemonize()
- print "Hello, world, from daemon process."
+ print("Hello, world, from daemon process.")
time.sleep(20)
- print "Goodbye, world, from daemon process."
+ print("Goodbye, world, from daemon process.")
diff --git a/gnuradio-runtime/python/gnuradio/gru/freqz.py b/gnuradio-runtime/python/gnuradio/gru/freqz.py
index a24d13ddee..edea6113b6 100644
--- a/gnuradio-runtime/python/gnuradio/gru/freqz.py
+++ b/gnuradio-runtime/python/gnuradio/gru/freqz.py
@@ -52,6 +52,8 @@
# DAMAGE.
#
+from __future__ import division
+from __future__ import unicode_literals
__all__ = ['freqz']
import numpy
@@ -106,7 +108,7 @@ def polyval(p,x):
y = x * y + p[i]
return y
-class poly1d:
+class poly1d(object):
"""A one-dimensional polynomial class.
p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3
@@ -125,14 +127,14 @@ class poly1d:
"""
def __init__(self, c_or_r, r=0):
if isinstance(c_or_r,poly1d):
- for key in c_or_r.__dict__.keys():
+ for key in list(c_or_r.__dict__.keys()):
self.__dict__[key] = c_or_r.__dict__[key]
return
if r:
c_or_r = poly(c_or_r)
c_or_r = atleast_1d(c_or_r)
if len(c_or_r.shape) > 1:
- raise ValueError, "Polynomial must be 1d only."
+ raise ValueError("Polynomial must be 1d only.")
c_or_r = trim_zeros(c_or_r, trim='f')
if len(c_or_r) == 0:
c_or_r = numpy.array([0])
@@ -227,7 +229,7 @@ class poly1d:
def __pow__(self, val):
if not isscalar(val) or int(val) != val or val < 0:
- raise ValueError, "Power to non-negative integers only."
+ raise ValueError("Power to non-negative integers only.")
res = [1]
for k in range(val):
res = polymul(self.coeffs, res)
@@ -243,20 +245,20 @@ class poly1d:
def __div__(self, other):
if isscalar(other):
- return poly1d(self.coeffs/other)
+ return poly1d(self.coeffs / other)
else:
other = poly1d(other)
- return map(poly1d,polydiv(self.coeffs, other.coeffs))
+ return list(map(poly1d,polydiv(self.coeffs, other.coeffs)))
def __rdiv__(self, other):
if isscalar(other):
- return poly1d(other/self.coeffs)
+ return poly1d(other / self.coeffs)
else:
other = poly1d(other)
- return map(poly1d,polydiv(other.coeffs, self.coeffs))
+ return list(map(poly1d,polydiv(other.coeffs, self.coeffs)))
def __setattr__(self, key, val):
- raise ValueError, "Attributes cannot be changed this way."
+ raise ValueError("Attributes cannot be changed this way.")
def __getattr__(self, key):
if key in ['r','roots']:
@@ -279,7 +281,7 @@ class poly1d:
def __setitem__(self, key, val):
ind = self.order - key
if key < 0:
- raise ValueError, "Does not support negative powers."
+ raise ValueError("Does not support negative powers.")
if key > self.order:
zr = numpy.zeros(key-self.order,self.coeffs.typecode())
self.__dict__['coeffs'] = numpy.concatenate((zr,self.coeffs))
@@ -323,22 +325,22 @@ def freqz(b, a, worN=None, whole=0, plot=None):
h -- The frequency response.
w -- The frequencies at which h was computed.
"""
- b, a = map(atleast_1d, (b,a))
+ b, a = list(map(atleast_1d, (b,a)))
if whole:
lastpoint = 2*pi
else:
lastpoint = pi
if worN is None:
N = 512
- w = Num.arange(0,lastpoint,lastpoint/N)
- elif isinstance(worN, types.IntType):
+ w = Num.arange(0,lastpoint,lastpoint / N)
+ elif isinstance(worN, int):
N = worN
- w = Num.arange(0,lastpoint,lastpoint/N)
+ w = Num.arange(0,lastpoint,lastpoint / N)
else:
w = worN
w = atleast_1d(w)
zm1 = exp(-1j*w)
- h = polyval(b[::-1], zm1) / polyval(a[::-1], zm1)
+ h = polyval(b[::-1] / zm1, polyval(a[::-1], zm1))
# if not plot is None:
# plot(w, h)
return h, w
diff --git a/gnuradio-runtime/python/gnuradio/gru/gnuplot_freqz.py b/gnuradio-runtime/python/gnuradio/gru/gnuplot_freqz.py
index dd483e4277..71aee11f0b 100755..100644
--- a/gnuradio-runtime/python/gnuradio/gru/gnuplot_freqz.py
+++ b/gnuradio-runtime/python/gnuradio/gru/gnuplot_freqz.py
@@ -20,6 +20,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import division
+from __future__ import unicode_literals
__all__ = ['gnuplot_freqz']
import tempfile
@@ -46,10 +48,10 @@ def gnuplot_freqz (hw, Fs=None, logfreq=False):
h, w = hw
ampl = 20 * numpy.log10 (numpy.absolute (h) + 1e-9)
- phase = map (lambda x: math.atan2 (x.imag, x.real), h)
+ phase = [math.atan2 (x.imag, x.real) for x in h]
if Fs:
- w *= (Fs/(2*math.pi))
+ w *= (Fs / (2*math.pi))
for freq, a, ph in zip (w, ampl, phase):
data_file.write ("%g\t%g\t%g\n" % (freq, a, ph))
@@ -99,4 +101,4 @@ def test_plot ():
if __name__ == '__main__':
handle = test_plot ()
- raw_input ('Press Enter to continue: ')
+ input ('Press Enter to continue: ')
diff --git a/gnuradio-runtime/python/gnuradio/gru/hexint.py b/gnuradio-runtime/python/gnuradio/gru/hexint.py
index 0fb5ecde04..096b876701 100644
--- a/gnuradio-runtime/python/gnuradio/gru/hexint.py
+++ b/gnuradio-runtime/python/gnuradio/gru/hexint.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
#
# Copyright 2005 Free Software Foundation, Inc.
#
diff --git a/gnuradio-runtime/python/gnuradio/gru/listmisc.py b/gnuradio-runtime/python/gnuradio/gru/listmisc.py
index 9e70eb863c..a981147337 100644
--- a/gnuradio-runtime/python/gnuradio/gru/listmisc.py
+++ b/gnuradio-runtime/python/gnuradio/gru/listmisc.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
#
# Copyright 2005 Free Software Foundation, Inc.
#
diff --git a/gnuradio-runtime/python/gnuradio/gru/mathmisc.py b/gnuradio-runtime/python/gnuradio/gru/mathmisc.py
index 7e6f23a346..790d7c993c 100644
--- a/gnuradio-runtime/python/gnuradio/gru/mathmisc.py
+++ b/gnuradio-runtime/python/gnuradio/gru/mathmisc.py
@@ -1,3 +1,5 @@
+from __future__ import division
+from __future__ import unicode_literals
#
# Copyright 2005 Free Software Foundation, Inc.
#
@@ -30,4 +32,4 @@ def lcm(a,b):
return a * b / gcd(a, b)
def log2(x):
- return math.log(x)/math.log(2)
+ return math.log(x) / math.log(2)
diff --git a/gnuradio-runtime/python/gnuradio/gru/msgq_runner.py b/gnuradio-runtime/python/gnuradio/gru/msgq_runner.py
index 767a74a717..2d58480f5f 100644
--- a/gnuradio-runtime/python/gnuradio/gru/msgq_runner.py
+++ b/gnuradio-runtime/python/gnuradio/gru/msgq_runner.py
@@ -40,6 +40,7 @@ To manually stop the runner, call stop() on the object.
To determine if the runner has exited, call exited() on the object.
"""
+from __future__ import unicode_literals
from gnuradio import gr
import gnuradio.gr.gr_threading as _threading
@@ -66,7 +67,7 @@ class msgq_runner(_threading.Thread):
else:
try:
self._callback(msg)
- except Exception, e:
+ except Exception as e:
if self._exit_on_error:
self._exit_error = e
self.stop()
diff --git a/gnuradio-runtime/python/gnuradio/gru/os_read_exactly.py b/gnuradio-runtime/python/gnuradio/gru/os_read_exactly.py
index 40b053770e..c079fc4e11 100644
--- a/gnuradio-runtime/python/gnuradio/gru/os_read_exactly.py
+++ b/gnuradio-runtime/python/gnuradio/gru/os_read_exactly.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
#
# Copyright 2005 Free Software Foundation, Inc.
#
diff --git a/gnuradio-runtime/python/gnuradio/gru/seq_with_cursor.py b/gnuradio-runtime/python/gnuradio/gru/seq_with_cursor.py
index def3299b69..0aefbf83bb 100644
--- a/gnuradio-runtime/python/gnuradio/gru/seq_with_cursor.py
+++ b/gnuradio-runtime/python/gnuradio/gru/seq_with_cursor.py
@@ -21,8 +21,12 @@
# misc utilities
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import unicode_literals
+
import types
-import exceptions
+
class seq_with_cursor (object):
__slots__ = [ 'items', 'index' ]
@@ -40,7 +44,7 @@ class seq_with_cursor (object):
elif initial_index >= 0 and initial_index < len (self.items):
self.index = initial_index
else:
- raise exceptions.ValueError
+ raise ValueError
def set_index_by_value(self, v):
"""
@@ -51,9 +55,9 @@ class seq_with_cursor (object):
cv = self.current()
more = True
while cv < v and more:
- cv, more = self.next() # side effect!
+ cv, more = next(self) # side effect!
- def next (self):
+ def __next__ (self):
new_index = self.index + 1
if new_index < len (self.items):
self.index = new_index
@@ -74,4 +78,3 @@ class seq_with_cursor (object):
def get_seq (self):
return self.items[:] # copy of items
-
diff --git a/gnuradio-runtime/python/gnuradio/gru/socket_stuff.py b/gnuradio-runtime/python/gnuradio/gru/socket_stuff.py
index b7c5ac2fe1..ce08ce1e10 100644
--- a/gnuradio-runtime/python/gnuradio/gru/socket_stuff.py
+++ b/gnuradio-runtime/python/gnuradio/gru/socket_stuff.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
#
# Copyright 2005 Free Software Foundation, Inc.
#
@@ -37,7 +38,7 @@ def tcp_connect_or_die(sock_addr):
s = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect(sock_addr)
- except socket.error, err:
+ except socket.error as err:
sys.stderr.write('Failed to connect to %s: %s\n' %
(sock_addr, os.strerror (err.args[0]),))
sys.exit(1)
@@ -55,7 +56,7 @@ def udp_connect_or_die(sock_addr):
s = socket.socket (socket.AF_INET, socket.SOCK_DGRAM)
try:
s.connect(sock_addr)
- except socket.error, err:
+ except socket.error as err:
sys.stderr.write('Failed to connect to %s: %s\n' %
(sock_addr, os.strerror (err.args[0]),))
sys.exit(1)
diff --git a/gnuradio-runtime/python/pmt/CMakeLists.txt b/gnuradio-runtime/python/pmt/CMakeLists.txt
index ca7a4f147d..e635663924 100644
--- a/gnuradio-runtime/python/pmt/CMakeLists.txt
+++ b/gnuradio-runtime/python/pmt/CMakeLists.txt
@@ -26,7 +26,6 @@ GR_PYTHON_INSTALL(FILES
__init__.py
pmt_to_python.py
DESTINATION ${GR_PYTHON_DIR}/pmt
- COMPONENT "runtime_python"
)
########################################################################
@@ -43,6 +42,6 @@ foreach(py_qa_test_file ${py_qa_test_files})
${CMAKE_BINARY_DIR}/gnuradio-blocks/swig
)
set(GR_TEST_TARGET_DEPS gnuradio-runtime)
- GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file})
+ GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
endforeach(py_qa_test_file)
endif(ENABLE_TESTING)
diff --git a/gnuradio-runtime/python/pmt/__init__.py b/gnuradio-runtime/python/pmt/__init__.py
index 399fae8701..89eb555823 100644
--- a/gnuradio-runtime/python/pmt/__init__.py
+++ b/gnuradio-runtime/python/pmt/__init__.py
@@ -39,14 +39,17 @@ bool, symbol (string), integer, real, complex, null, pair, list,
vector, dict, uniform_vector, any (boost::any cast)
'''
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
import os
try:
- from pmt_swig import *
+ from .pmt_swig import *
except ImportError:
dirname, filename = os.path.split(os.path.abspath(__file__))
__path__.append(os.path.join(dirname, "..", "..", "swig"))
- from pmt_swig import *
+ from .pmt_swig import *
# due to changes in the PMT_NIL singleton for static builds, we force
# this into Python here.
@@ -55,5 +58,5 @@ PMT_T = get_PMT_T()
PMT_F = get_PMT_F()
PMT_EOF = get_PMT_EOF()
-from pmt_to_python import pmt_to_python as to_python
-from pmt_to_python import python_to_pmt as to_pmt
+from .pmt_to_python import pmt_to_python as to_python
+from .pmt_to_python import python_to_pmt as to_pmt
diff --git a/gnuradio-runtime/python/pmt/pmt_to_python.py b/gnuradio-runtime/python/pmt/pmt_to_python.py
index 2909c93c21..270a1dd9e9 100644
--- a/gnuradio-runtime/python/pmt/pmt_to_python.py
+++ b/gnuradio-runtime/python/pmt/pmt_to_python.py
@@ -17,8 +17,9 @@
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
-try: import pmt_swig as pmt
-except: import pmt
+from __future__ import unicode_literals
+
+from . import pmt_swig as pmt
import numpy
# SWIG isn't taking in the #define PMT_NIL;
@@ -34,7 +35,7 @@ def pmt_to_tuple(p):
return tuple(elems)
def pmt_from_tuple(p):
- args = map(python_to_pmt, p)
+ args = list(map(python_to_pmt, p))
return pmt.make_tuple(*args)
def pmt_to_vector(p):
@@ -62,7 +63,7 @@ def pmt_to_dict(p):
def pmt_from_dict(p):
d = pmt.make_dict()
- for k, v in p.iteritems():
+ for k, v in list(p.items()):
#dict is immutable -> therefore pmt_dict_add returns the new dict
d = pmt.dict_add(d, python_to_pmt(k), python_to_pmt(v))
return d
@@ -88,27 +89,27 @@ uvector_mappings = dict([ (numpy_mappings[key][3], (numpy_mappings[key][2], key)
def numpy_to_uvector(numpy_array):
try:
mapping = numpy_mappings[numpy_array.dtype]
- pc = map(mapping[1], numpy.ravel(numpy_array))
+ pc = list(map(mapping[1], numpy.ravel(numpy_array)))
return mapping[0](numpy_array.size, pc)
except KeyError:
raise ValueError("unsupported numpy array dtype for conversion to pmt %s"%(numpy_array.dtype))
def uvector_to_numpy(uvector):
- match = None
- for test_func in uvector_mappings.keys():
- if test_func(uvector):
- match = uvector_mappings[test_func]
- return numpy.array(match[0](uvector), dtype = match[1])
- else:
- raise ValueError("unsupported uvector data type for conversion to numpy array %s"%(uvector))
+ match = None
+ for test_func in list(uvector_mappings.keys()):
+ if test_func(uvector):
+ match = uvector_mappings[test_func]
+ return numpy.array(match[0](uvector), dtype = match[1])
+ else:
+ raise ValueError("unsupported uvector data type for conversion to numpy array %s"%(uvector))
type_mappings = ( #python type, check pmt type, to python, from python
(None, pmt.is_null, lambda x: None, lambda x: PMT_NIL),
(bool, pmt.is_bool, pmt.to_bool, pmt.from_bool),
(str, pmt.is_symbol, pmt.symbol_to_string, pmt.string_to_symbol),
- (unicode, lambda x: False, None, lambda x: pmt.string_to_symbol(x.encode('utf-8'))),
+ (str, lambda x: False, None, lambda x: pmt.string_to_symbol(x.encode('utf-8'))),
(int, pmt.is_integer, pmt.to_long, pmt.from_long),
- (long, pmt.is_uint64, lambda x: long(pmt.to_uint64(x)), pmt.from_uint64),
+ (int, pmt.is_uint64, lambda x: int(pmt.to_uint64(x)), pmt.from_uint64),
(float, pmt.is_real, pmt.to_double, pmt.from_double),
(complex, pmt.is_complex, pmt.to_complex, pmt.from_complex),
(tuple, pmt.is_tuple, pmt_to_tuple, pmt_from_tuple),
diff --git a/gnuradio-runtime/python/pmt/qa_pmt.py b/gnuradio-runtime/python/pmt/qa_pmt.py
index 32cff62f44..b6df648029 100755..100644
--- a/gnuradio-runtime/python/pmt/qa_pmt.py
+++ b/gnuradio-runtime/python/pmt/qa_pmt.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2018 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,6 +20,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
import unittest
import pmt
@@ -30,7 +32,7 @@ class test_pmt(unittest.TestCase):
b = pmt.from_double(123765)
d1 = pmt.make_dict()
d2 = pmt.dict_add(d1, a, b)
- print d2
+ print(d2)
def test02(self):
const = 123765
diff --git a/gnuradio-runtime/python/pmt/qa_pmt_to_python.py b/gnuradio-runtime/python/pmt/qa_pmt_to_python.py
index e63ade1843..18a8e2bcf5 100755..100644
--- a/gnuradio-runtime/python/pmt/qa_pmt_to_python.py
+++ b/gnuradio-runtime/python/pmt/qa_pmt_to_python.py
@@ -20,16 +20,19 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import absolute_import
+
+
import unittest
import pmt
-import pmt_to_python as pmt2py
+from pmt import pmt_to_python as pmt2py
class test_pmt_to_python(unittest.TestCase):
def test_pmt_from_double(self):
b = pmt.from_double(123765)
self.assertEqual(pmt.to_python(b), 123765)
- t = pmt.to_pmt(range(5))
+ t = pmt.to_pmt(list(range(5)))
def test_numpy_to_uvector_and_reverse(self):
import numpy as np
diff --git a/gnuradio-runtime/swig/CMakeLists.txt b/gnuradio-runtime/swig/CMakeLists.txt
index 3236bcee61..16cba615fa 100644
--- a/gnuradio-runtime/swig/CMakeLists.txt
+++ b/gnuradio-runtime/swig/CMakeLists.txt
@@ -45,13 +45,11 @@ set(GR_SWIG_LIBRARIES
set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/pmt_swig_doc.i)
set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include/pmt
${CMAKE_CURRENT_BINARY_DIR}/../include/pmt)
-list(APPEND GR_SWIG_TARGET_DEPS pmt_generated)
GR_SWIG_MAKE(pmt_swig pmt_swig.i)
GR_SWIG_INSTALL(
TARGETS pmt_swig
DESTINATION ${GR_PYTHON_DIR}/pmt
- COMPONENT "runtime_python"
)
add_custom_target(pmt_swig DEPENDS ${SWIG_MODULE_pmt_swig_REAL_NAME})
@@ -60,12 +58,6 @@ add_custom_target(pmt_swig DEPENDS ${SWIG_MODULE_pmt_swig_REAL_NAME})
# Build gnuradio-runtime swig
###############################################################
-# Only use if log4cpp is installed
-# Define ENABLE_GR_LOG for the .i file to ignore it.
-if(ENABLE_GR_LOG)
- SET(GR_SWIG_FLAGS "-DENABLE_GR_LOG")
-endif(ENABLE_GR_LOG)
-
if(ENABLE_GR_CTRLPORT)
ADD_DEFINITIONS(-DGR_CTRLPORT)
list(APPEND GR_SWIG_FLAGS -DGR_CTRLPORT)
@@ -81,7 +73,6 @@ GR_SWIG_MAKE(runtime_swig runtime_swig.i)
GR_SWIG_INSTALL(
TARGETS runtime_swig
DESTINATION ${GR_PYTHON_DIR}/gnuradio/gr
- COMPONENT "runtime_python"
)
install(
@@ -94,7 +85,6 @@ install(
block_detail.i
block_gateway.i
buffer.i
- complex_vec_test.i
constants.i
feval.i
gnuradio.i
@@ -112,8 +102,8 @@ install(
msg_queue.i
pmt_swig.i
prefs.i
+ py3compat.i
realtime.i
- single_threaded_scheduler.i
sync_block.i
sync_decimator.i
sync_interpolator.i
@@ -123,5 +113,4 @@ install(
${CMAKE_CURRENT_BINARY_DIR}/runtime_swig_doc.i
${CMAKE_CURRENT_BINARY_DIR}/pmt_swig_doc.i
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig
- COMPONENT "runtime_swig"
)
diff --git a/gnuradio-runtime/swig/basic_block.i b/gnuradio-runtime/swig/basic_block.i
index cf75479bb8..363e121bc6 100644
--- a/gnuradio-runtime/swig/basic_block.i
+++ b/gnuradio-runtime/swig/basic_block.i
@@ -31,6 +31,10 @@ namespace std {
%template(x_vector_basic_block_sptr) vector<gr::basic_block_sptr>;
};
+%begin %{
+#define SWIG_PYTHON_2_UNICODE
+%}
+
namespace gr {
class gr::basic_block
@@ -60,6 +64,8 @@ namespace gr {
}
#ifdef SWIGPYTHON
+%import py3compat.i
+
%pythoncode %{
basic_block_sptr.__repr__ = lambda self: "<basic_block %s (%d)>" % (self.name(), self.unique_id ())
%}
diff --git a/gnuradio-runtime/swig/block.i b/gnuradio-runtime/swig/block.i
index 96205296ef..808e62f9dd 100644
--- a/gnuradio-runtime/swig/block.i
+++ b/gnuradio-runtime/swig/block.i
@@ -60,6 +60,9 @@ class gr::block : public gr::basic_block
uint64_t nitems_read(unsigned int which_input);
uint64_t nitems_written(unsigned int which_output);
+ void set_log_level(std::string level);
+ std::string log_level();
+
// Methods to manage the block's max_noutput_items size.
int max_noutput_items();
void set_max_noutput_items(int m);
diff --git a/gnuradio-runtime/swig/complex_vec_test.i b/gnuradio-runtime/swig/complex_vec_test.i
deleted file mode 100644
index 4b95633be7..0000000000
--- a/gnuradio-runtime/swig/complex_vec_test.i
+++ /dev/null
@@ -1,25 +0,0 @@
-
-std::vector<std::complex<float> >
-complex_vec_test0();
-
-std::vector<std::complex<float> >
-complex_vec_test1(const std::vector<std::complex<float> > &input);
-
-std::complex<float>
-complex_scalar_test0();
-
-std::complex<float>
-complex_scalar_test1(std::complex<float> input);
-
-std::vector<int>
-int_vec_test0();
-
-std::vector<int>
-int_vec_test1(const std::vector<int> &input);
-
-std::vector<float>
-float_vec_test0();
-
-std::vector<float>
-float_vec_test1(const std::vector<float> &input);
-
diff --git a/gnuradio-runtime/swig/gnuradio.i b/gnuradio-runtime/swig/gnuradio.i
index 7056d28ff5..b616e81229 100644
--- a/gnuradio-runtime/swig/gnuradio.i
+++ b/gnuradio-runtime/swig/gnuradio.i
@@ -77,3 +77,15 @@
%}
%include <gnuradio/high_res_timer.h>
+
+////////////////////////////////////////////////////////////////////////
+// Python 2/3 compatibilty
+
+%begin %{
+#define SWIG_PYTHON_2_UNICODE
+#define SWIG_PYTHON_CAST_MODE
+%}
+
+#ifdef SWIGPYTHON
+%import py3compat.i
+#endif
diff --git a/gnuradio-runtime/swig/gr_swig_block_magic.i b/gnuradio-runtime/swig/gr_swig_block_magic.i
index 6d1af6136d..3a23487239 100644
--- a/gnuradio-runtime/swig/gr_swig_block_magic.i
+++ b/gnuradio-runtime/swig/gr_swig_block_magic.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2010,2012 Free Software Foundation, Inc.
+ * Copyright 2004,2010,2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -49,6 +49,16 @@ BASE_NAME = BASE_NAME.make;
%}
%enddef
+%define GR_SWIG_BLOCK_MAGIC2_TMPL(PKG, BASE_NAME, TARGET_NAME...)
+%template(BASE_NAME) gr:: ## PKG ## :: ## TARGET_NAME;
+%template(BASE_NAME ## _sptr) boost::shared_ptr<gr:: ## PKG ## :: ## TARGET_NAME ## >;
+%pythoncode %{
+BASE_NAME ## _sptr.__repr__ = lambda self: "<gr_block %s (%d)>" % (self.name(), self.unique_id())
+BASE_NAME = BASE_NAME.make
+%}
+%enddef
+
+
%define GR_SWIG_BLOCK_MAGIC_FACTORY(PKG, BASE_NAME, FACTORY)
%template(FACTORY ## _sptr) boost::shared_ptr<gr:: ## PKG ## :: ## BASE_NAME>;
%pythoncode %{
diff --git a/gnuradio-runtime/swig/hier_block2.i b/gnuradio-runtime/swig/hier_block2.i
index 12190d0452..9511471ebc 100644
--- a/gnuradio-runtime/swig/hier_block2.i
+++ b/gnuradio-runtime/swig/hier_block2.i
@@ -34,7 +34,7 @@ namespace gr {
make_hier_block2(const std::string name,
gr::io_signature::sptr input_signature,
gr::io_signature::sptr output_signature)
- throw (std::runtime_error);
+ noexcept(false);
}
// Rename connect and disconnect so that we can more easily build a
@@ -58,28 +58,28 @@ namespace gr {
~hier_block2 ();
void connect(gr::basic_block_sptr block)
- throw (std::invalid_argument);
+ noexcept(false);
void connect(gr::basic_block_sptr src, int src_port,
gr::basic_block_sptr dst, int dst_port)
- throw (std::invalid_argument);
+ noexcept(false);
void msg_connect(gr::basic_block_sptr src, pmt::pmt_t srcport,
gr::basic_block_sptr dst, pmt::pmt_t dstport)
- throw (std::runtime_error);
+ noexcept(false);
void msg_connect(gr::basic_block_sptr src, std::string srcport,
gr::basic_block_sptr dst, std::string dstport)
- throw (std::runtime_error);
+ noexcept(false);
void msg_disconnect(gr::basic_block_sptr src, pmt::pmt_t srcport,
gr::basic_block_sptr dst, pmt::pmt_t dstport)
- throw (std::runtime_error);
+ noexcept(false);
void msg_disconnect(gr::basic_block_sptr src, std::string srcport,
gr::basic_block_sptr dst, std::string dstport)
- throw (std::runtime_error);
+ noexcept(false);
void disconnect(gr::basic_block_sptr block)
- throw (std::invalid_argument);
+ noexcept(false);
void disconnect(gr::basic_block_sptr src, int src_port,
gr::basic_block_sptr dst, int dst_port)
- throw (std::invalid_argument);
+ noexcept(false);
void disconnect_all();
void lock();
void unlock();
@@ -91,6 +91,9 @@ namespace gr {
void unset_processor_affinity();
std::vector<int> processor_affinity();
+ void set_log_level(std::string level);
+ std::string log_level();
+
// Methods to manage block's min/max buffer sizes.
size_t max_output_buffer(int i);
void set_max_output_buffer(size_t max_output_buffer);
diff --git a/gnuradio-runtime/swig/message.i b/gnuradio-runtime/swig/message.i
index ac13c40641..063deebc1c 100644
--- a/gnuradio-runtime/swig/message.i
+++ b/gnuradio-runtime/swig/message.i
@@ -22,6 +22,12 @@
namespace gr {
+ %pythonappend message::to_string %{
+ import sys
+ if sys.version_info[0] > 2:
+ val = val.encode("utf8", errors="surrogateescape")
+ %}
+
/*!
* \brief Message.
*
@@ -63,6 +69,8 @@ namespace gr {
long message_ncurrently_allocated();
}
+
+
%template(message_sptr) boost::shared_ptr<gr::message>;
%pythoncode %{
message_from_string = message.make_from_string
diff --git a/gnuradio-runtime/swig/pmt_swig.i b/gnuradio-runtime/swig/pmt_swig.i
index 2063a5c972..f03ce1289a 100644
--- a/gnuradio-runtime/swig/pmt_swig.i
+++ b/gnuradio-runtime/swig/pmt_swig.i
@@ -25,6 +25,10 @@
%include "std_string.i"
%include "stdint.i"
+%begin %{
+#define SWIG_PYTHON_2_UNICODE
+%}
+
%{
#include <boost/intrusive_ptr.hpp>
#include <boost/shared_ptr.hpp>
@@ -36,6 +40,23 @@
#include <iosfwd>
#include <stdexcept>
#include <pmt/pmt.h>
+
+namespace pmt {
+ // Wrapper for serialize_str(), so we always have raw byte strings
+ std::vector<uint8_t> _serialize_str_u8(pmt_t obj)
+ {
+ std::string serialized_str(serialize_str(obj));
+ return std::vector<uint8_t>(serialized_str.begin(), serialized_str.end());
+ }
+
+ // Wrapper for deserialize_str(), so we always have raw byte strings
+ pmt_t _deserialize_str_u8(std::vector<uint8_t> py_str)
+ {
+ std::string cpp_str(py_str.begin(), py_str.end());
+ return deserialize_str(cpp_str);
+ }
+} /* namespace pmt */
+
%}
%feature("autodoc","1");
@@ -58,6 +79,8 @@
%template(pmt_vector_cfloat) std::vector< std::complex<float> >;
%template(pmt_vector_cdouble) std::vector< std::complex<double> >;
+%import py3compat.i
+
////////////////////////////////////////////////////////////////////////
// Language independent exception handler
////////////////////////////////////////////////////////////////////////
@@ -296,7 +319,31 @@ namespace pmt{
bool serialize(pmt_t obj, std::streambuf &sink);
pmt_t deserialize(std::streambuf &source);
void dump_sizeof();
+
+ std::vector<uint8_t> _serialize_str_u8(pmt_t obj);
+ pmt_t _deserialize_str_u8(std::vector<uint8_t> py_str);
+
+ %rename(_serialize_str) serialize_str;
std::string serialize_str(pmt_t obj);
+
+ %rename(_deserialize_str) deserialize_str;
pmt_t deserialize_str(std::string str);
} //namespace pmt
+
+%pythoncode %{
+ def serialize_str(pmt_obj):
+ import sys
+ if sys.version_info.major == 2:
+ return _serialize_str(pmt_obj)
+ import array
+ return array.array('B', _serialize_str_u8(pmt_obj)).tobytes()
+
+ def deserialize_str(pmt_str):
+ import sys
+ if sys.version_info.major == 2:
+ return _deserialize_str(pmt_str)
+ return _deserialize_str_u8(tuple(x for x in pmt_str))
+
+%}
+
diff --git a/gnuradio-runtime/swig/py3compat.i b/gnuradio-runtime/swig/py3compat.i
new file mode 100644
index 0000000000..6e726c294f
--- /dev/null
+++ b/gnuradio-runtime/swig/py3compat.i
@@ -0,0 +1,7 @@
+%begin %{
+#define SWIG_PYTHON_2_UNICODE
+%}
+
+%pythonbegin %{
+from __future__ import absolute_import
+%}
diff --git a/gnuradio-runtime/swig/single_threaded_scheduler.i b/gnuradio-runtime/swig/single_threaded_scheduler.i
deleted file mode 100644
index f4fbed075c..0000000000
--- a/gnuradio-runtime/swig/single_threaded_scheduler.i
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2013 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 <gnuradio/runtime.h>
-
-class gr::single_threaded_scheduler;
-typedef boost::shared_ptr<gr::single_threaded_scheduler> gr::single_threaded_scheduler_sptr;
-%template(single_threaded_scheduler_sptr) boost::shared_ptr<gr::single_threaded_scheduler>;
-%rename(single_threaded_scheduler) gr::make_single_threaded_scheduler;
-%ignore gr::single_threaded_scheduler;
-
-gr::single_threaded_scheduler_sptr
-gr::make_single_threaded_scheduler(const std::vector<gr::block_sptr> &modules);
-
-class gr::single_threaded_scheduler {
- public:
- ~single_threaded_scheduler ();
-
- // void run ();
- void stop ();
-
- private:
- single_threaded_scheduler (const std::vector<block_sptr> &modules);
-};
-
-#ifdef SWIGPYTHON
-%inline %{
- void sts_pyrun (gr::single_threaded_scheduler_sptr s) {
- Py_BEGIN_ALLOW_THREADS; // release global interpreter lock
- s->run ();
- Py_END_ALLOW_THREADS; // acquire global interpreter lock
- }
-%}
-#endif
-
diff --git a/gnuradio-runtime/swig/top_block.i b/gnuradio-runtime/swig/top_block.i
index c7ee0af941..6d0632a9a7 100644
--- a/gnuradio-runtime/swig/top_block.i
+++ b/gnuradio-runtime/swig/top_block.i
@@ -37,12 +37,12 @@ namespace gr {
public:
~top_block();
- void start(int max_noutput_items=100000000) throw (std::runtime_error);
+ void start(int max_noutput_items=100000000) noexcept(false);
void stop();
//void wait();
//void run() throw (std::runtime_error);
void lock();
- void unlock() throw (std::runtime_error);
+ void unlock() noexcept(false);
std::string edge_list();
std::string msg_edge_list();
void dump();
@@ -57,7 +57,7 @@ namespace gr {
#ifdef SWIGPYTHON
%inline %{
-void top_block_run_unlocked(gr::top_block_sptr r) throw (std::runtime_error)
+void top_block_run_unlocked(gr::top_block_sptr r) noexcept(false)
{
GR_PYTHON_BLOCKING_CODE
(
@@ -65,7 +65,7 @@ void top_block_run_unlocked(gr::top_block_sptr r) throw (std::runtime_error)
)
}
-void top_block_start_unlocked(gr::top_block_sptr r, int max_noutput_items) throw (std::runtime_error)
+void top_block_start_unlocked(gr::top_block_sptr r, int max_noutput_items) noexcept(false)
{
GR_PYTHON_BLOCKING_CODE
(
@@ -73,7 +73,7 @@ void top_block_start_unlocked(gr::top_block_sptr r, int max_noutput_items) throw
)
}
-void top_block_wait_unlocked(gr::top_block_sptr r) throw (std::runtime_error)
+void top_block_wait_unlocked(gr::top_block_sptr r) noexcept(false)
{
GR_PYTHON_BLOCKING_CODE
(
@@ -81,7 +81,7 @@ void top_block_wait_unlocked(gr::top_block_sptr r) throw (std::runtime_error)
)
}
-void top_block_stop_unlocked(gr::top_block_sptr r) throw (std::runtime_error)
+void top_block_stop_unlocked(gr::top_block_sptr r) noexcept(false)
{
GR_PYTHON_BLOCKING_CODE
(
@@ -89,7 +89,7 @@ void top_block_stop_unlocked(gr::top_block_sptr r) throw (std::runtime_error)
)
}
-void top_block_unlock_unlocked(gr::top_block_sptr r) throw (std::runtime_error)
+void top_block_unlock_unlocked(gr::top_block_sptr r) noexcept(false)
{
GR_PYTHON_BLOCKING_CODE
(