diff options
author | Marcus Müller <mmueller@gnuradio.org> | 2019-07-17 21:51:56 +0200 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2019-07-17 22:31:50 +0200 |
commit | 29a50db640a3fe56f26a60f3a9cceb6e2b34fa9f (patch) | |
tree | 5560bd581a17ba71ee63b5349ecce8a44622e3c3 /gr-comedi | |
parent | f6273f1f01ef6aa0e6f101372bab275a3dc24be0 (diff) |
Purge gr-comedi and all references to it from mainline GNU Radio
This includes the gr-comedi/ subdirectory, the build infrastructure and
CMake modules referencing Comedi, and the documentation.
Diffstat (limited to 'gr-comedi')
-rw-r--r-- | gr-comedi/CMakeLists.txt | 68 | ||||
-rw-r--r-- | gr-comedi/gnuradio-comedi.pc.in | 11 | ||||
-rw-r--r-- | gr-comedi/include/gnuradio/comedi/CMakeLists.txt | 29 | ||||
-rw-r--r-- | gr-comedi/include/gnuradio/comedi/api.h | 33 | ||||
-rw-r--r-- | gr-comedi/include/gnuradio/comedi/sink_s.h | 58 | ||||
-rw-r--r-- | gr-comedi/include/gnuradio/comedi/source_s.h | 58 | ||||
-rw-r--r-- | gr-comedi/lib/CMakeLists.txt | 41 | ||||
-rw-r--r-- | gr-comedi/lib/sink_s_impl.cc | 239 | ||||
-rw-r--r-- | gr-comedi/lib/sink_s_impl.h | 73 | ||||
-rw-r--r-- | gr-comedi/lib/source_s_impl.cc | 236 | ||||
-rw-r--r-- | gr-comedi/lib/source_s_impl.h | 73 | ||||
-rw-r--r-- | gr-comedi/python/comedi/CMakeLists.txt | 49 | ||||
-rw-r--r-- | gr-comedi/python/comedi/__init__.py | 34 | ||||
-rw-r--r-- | gr-comedi/python/comedi/qa_comedi.py | 40 | ||||
-rw-r--r-- | gr-comedi/swig/CMakeLists.txt | 49 | ||||
-rw-r--r-- | gr-comedi/swig/comedi_swig.i | 39 |
16 files changed, 0 insertions, 1130 deletions
diff --git a/gr-comedi/CMakeLists.txt b/gr-comedi/CMakeLists.txt deleted file mode 100644 index be0b17dad2..0000000000 --- a/gr-comedi/CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright 2012,2019 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -######################################################################## -# Setup dependencies -######################################################################## -include(GrBoost) -include(FindPkgConfig) - -PKG_CHECK_MODULES(COMEDI comedilib) - -######################################################################## -# Register component -######################################################################## -include(GrComponent) -GR_REGISTER_COMPONENT("gr-comedi" ENABLE_GR_COMEDI - COMEDI_FOUND - Boost_FOUND - ENABLE_GNURADIO_RUNTIME -) - -SET(GR_PKG_COMEDI_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/comedi) - -######################################################################## -# Begin conditional configuration -######################################################################## -if(ENABLE_GR_COMEDI) - -######################################################################## -# Add subdirectories -######################################################################## -add_subdirectory(include/gnuradio/comedi) -add_subdirectory(lib) -if(ENABLE_PYTHON) - add_subdirectory(swig) - add_subdirectory(python/comedi) -endif(ENABLE_PYTHON) - -######################################################################## -# Create Pkg Config File -######################################################################## -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-comedi.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-comedi.pc -@ONLY) - -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-comedi.pc - DESTINATION ${GR_LIBRARY_DIR}/pkgconfig -) - -endif(ENABLE_GR_COMEDI) diff --git a/gr-comedi/gnuradio-comedi.pc.in b/gr-comedi/gnuradio-comedi.pc.in deleted file mode 100644 index 0f3ac4cae4..0000000000 --- a/gr-comedi/gnuradio-comedi.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: gnuradio-comedi -Description: GNU Radio blocks for the comedi library -Requires: gnuradio-runtime -Version: @LIBVER@ -Libs: -L${libdir} -lgnuradio-comedi -Cflags: -I${includedir} diff --git a/gr-comedi/include/gnuradio/comedi/CMakeLists.txt b/gr-comedi/include/gnuradio/comedi/CMakeLists.txt deleted file mode 100644 index 601c1fb91d..0000000000 --- a/gr-comedi/include/gnuradio/comedi/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 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. - -######################################################################## -# Install header files -######################################################################## -install(FILES - api.h - sink_s.h - source_s.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/comedi -) - diff --git a/gr-comedi/include/gnuradio/comedi/api.h b/gr-comedi/include/gnuradio/comedi/api.h deleted file mode 100644 index 1afaf0d18c..0000000000 --- a/gr-comedi/include/gnuradio/comedi/api.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 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. - */ - -#ifndef INCLUDED_COMEDI_API_H -#define INCLUDED_COMEDI_API_H - -#include <gnuradio/attributes.h> - -#ifdef gnuradio_comedi_EXPORTS -# define COMEDI_API __GR_ATTR_EXPORT -#else -# define COMEDI_API __GR_ATTR_IMPORT -#endif - -#endif /* INCLUDED_COMEDI_API_H */ diff --git a/gr-comedi/include/gnuradio/comedi/sink_s.h b/gr-comedi/include/gnuradio/comedi/sink_s.h deleted file mode 100644 index 6d60b76069..0000000000 --- a/gr-comedi/include/gnuradio/comedi/sink_s.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,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. - */ - -#ifndef INCLUDED_COMEDI_SINK_H -#define INCLUDED_COMEDI_SINK_H - -#include <gnuradio/comedi/api.h> -#include <gnuradio/sync_block.h> - -namespace gr { - namespace comedi { - - /*! - * \brief sink using COMEDI - * - * The sink has one input stream of signed short integers. - * - * Input samples must be in the range [-32768,32767]. - */ - class COMEDI_API sink_s : virtual public sync_block - { - public: - // gr::comedi::sink_s::sptr - typedef boost::shared_ptr<sink_s> sptr; - - /*! - * \brief make a COMEDI sink. - * - * \param sampling_freq sampling rate in Hz - * \param dev COMEDI device name, e.g., "/dev/comedi0" - */ - static sptr make(int sampling_freq, - const std::string dev = "/dev/comedi0"); - }; - - } /* namespace comedi */ -} /* namespace gr */ - -#endif /* INCLUDED_COMEDI_SINK_H */ diff --git a/gr-comedi/include/gnuradio/comedi/source_s.h b/gr-comedi/include/gnuradio/comedi/source_s.h deleted file mode 100644 index cab6f82018..0000000000 --- a/gr-comedi/include/gnuradio/comedi/source_s.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,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. - */ - -#ifndef INCLUDED_COMEDI_SOURCE_S_H -#define INCLUDED_COMEDI_SOURCE_S_H - -#include <gnuradio/comedi/api.h> -#include <gnuradio/sync_block.h> - -namespace gr { - namespace comedi { - - /*! - * \brief source using COMEDI - * - * The source has one to many input stream of signed short integers. - * - * Output samples will be in the range [-32768,32767]. - */ - class COMEDI_API source_s : virtual public sync_block - { - public: - // gr::comedi::source_s::sptr - typedef boost::shared_ptr<source_s> sptr; - - /*! - * \brief make a COMEDI source. - * - * \param sampling_freq sampling rate in Hz - * \param dev COMEDI device name, e.g., "/dev/comedi0" - */ - static sptr make(int sampling_freq, - const std::string dev = "/dev/comedi0"); - }; - - } /* namespace comedi */ -} /* namespace gr */ - -#endif /* INCLUDED_COMEDI_SOURCE_S_H */ diff --git a/gr-comedi/lib/CMakeLists.txt b/gr-comedi/lib/CMakeLists.txt deleted file mode 100644 index 43054ef9d6..0000000000 --- a/gr-comedi/lib/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2011,2012,2019 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -######################################################################## -# Setup library -######################################################################## -add_library(gnuradio-comedi - sink_s_impl.cc - source_s_impl.cc -) - -target_link_libraries(gnuradio-comedi - gnuradio-runtime - ${COMEDI_LIBRARIES} -) - -target_include_directories(gnuradio-comedi - PUBLIC - $<INSTALL_INTERFACE:include> - $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include> - ) - -if(BUILD_SHARED_LIBS) - GR_LIBRARY_FOO(gnuradio-comedi) -endif() diff --git a/gr-comedi/lib/sink_s_impl.cc b/gr-comedi/lib/sink_s_impl.cc deleted file mode 100644 index df2040adf9..0000000000 --- a/gr-comedi/lib/sink_s_impl.cc +++ /dev/null @@ -1,239 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010,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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <sys/mman.h> - -#include "sink_s_impl.h" -#include <gnuradio/io_signature.h> -#include <stdio.h> -#include <errno.h> -#include <iostream> -#include <stdexcept> - -namespace gr { - namespace comedi { - - /* - * comedi_sink_s is untested because I don't own appropriate hardware. - * Feedback is welcome! --SF - */ - - static std::string - default_device_name() - { - return "/dev/comedi0"; - } - - // ---------------------------------------------------------------- - - sink_s::sptr - sink_s::make(int sampling_freq, const std::string dev) - { - return gnuradio::get_initial_sptr - (new sink_s_impl(sampling_freq, dev)); - } - - sink_s_impl::sink_s_impl(int sampling_freq, - const std::string device_name) - : sync_block("comedi_sink_s", - io_signature::make(0, 0, 0), - io_signature::make(0, 0, 0)), - d_sampling_freq(sampling_freq), - d_device_name(device_name.empty() ? default_device_name() : device_name), - d_dev(0), - d_subdevice(COMEDI_SUBD_AO), - d_n_chan(1), // number of input channels - d_map(0), - d_buffer_size(0), - d_buf_front(0), - d_buf_back(0) - { - int aref=AREF_GROUND; - int range=0; - - d_dev = comedi_open(d_device_name.c_str()); - if(d_dev == 0) { - comedi_perror(d_device_name.c_str()); - throw std::runtime_error("sink_s_impl"); - } - - unsigned int chanlist[256]; - - for(int i=0; i<d_n_chan; i++) { - chanlist[i] = CR_PACK(i,range,aref); - } - - comedi_cmd cmd; - int ret; - - ret = comedi_get_cmd_generic_timed(d_dev,d_subdevice, - &cmd, d_n_chan, - (unsigned int)(1e9/sampling_freq)); - if(ret < 0) - bail("comedi_get_cmd_generic_timed", comedi_errno()); - - // TODO: check period_ns is not to far off sampling_freq - - d_buffer_size = comedi_get_buffer_size(d_dev, d_subdevice); - if(d_buffer_size <= 0) - bail("comedi_get_buffer_size", comedi_errno()); - - d_map = mmap(NULL, d_buffer_size, PROT_WRITE, - MAP_SHARED, comedi_fileno(d_dev), 0); - if(d_map == MAP_FAILED) - bail("mmap", errno); - - cmd.chanlist = chanlist; - cmd.chanlist_len = d_n_chan; - cmd.scan_end_arg = d_n_chan; - - cmd.stop_src = TRIG_NONE; - cmd.stop_arg = 0; - - /* comedi_command_test() tests a command to see if the trigger - * sources and arguments are valid for the subdevice. If a - * trigger source is invalid, it will be logically ANDed with - * valid values (trigger sources are actually bitmasks), which - * may or may not result in a valid trigger source. If an - * argument is invalid, it will be adjusted to the nearest valid - * value. In this way, for many commands, you can test it - * multiple times until it passes. Typically, if you can't get - * a valid command in two tests, the original command wasn't - * specified very well. */ - ret = comedi_command_test(d_dev,&cmd); - - if(ret < 0) - bail("comedi_command_test", comedi_errno()); - - ret = comedi_command_test(d_dev,&cmd); - - if(ret < 0) - bail("comedi_command_test", comedi_errno()); - - /* start the command */ - ret = comedi_command(d_dev,&cmd); - - if(ret < 0) - bail("comedi_command", comedi_errno()); - - set_output_multiple(d_n_chan*sizeof(sampl_t)); - - assert(sizeof(sampl_t) == sizeof(short)); - set_output_signature(io_signature::make(1, 1, sizeof(sampl_t))); - } - - bool - sink_s_impl::check_topology(int ninputs, int noutputs) - { - if(ninputs > d_n_chan) - throw std::runtime_error("sink_s_impl"); - - return true; - } - - sink_s_impl::~sink_s_impl() - { - if(d_map) { - munmap(d_map, d_buffer_size); - d_map = 0; - } - - comedi_close(d_dev); - } - - int - sink_s_impl::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) - { - int ret; - - int work_left = noutput_items * sizeof(sampl_t) * d_n_chan; - sampl_t *pbuf = (sampl_t*)d_map; - - do { - do { - ret = comedi_get_buffer_contents(d_dev, d_subdevice); - if(ret < 0) - bail("comedi_get_buffer_contents", comedi_errno()); - - assert(ret % sizeof(sampl_t) == 0); - assert(work_left % sizeof(sampl_t) == 0); - - ret = std::min(ret, work_left); - d_buf_front += ret; - - assert(d_buffer_size%d_n_chan == 0); - if(d_buf_front-d_buf_back > (unsigned)d_buffer_size) { - d_buf_front+=d_buffer_size; - d_buf_back +=d_buffer_size; - } - - if(d_buf_front==d_buf_back){ - usleep(1000000*std::min(work_left, - d_buffer_size/2)/(d_sampling_freq*sizeof(sampl_t)*d_n_chan)); - continue; - } - } while(d_buf_front==d_buf_back); - - for(unsigned i = d_buf_back/sizeof(sampl_t); i < d_buf_front/sizeof(sampl_t); i++) { - int chan = i%d_n_chan; - int i_idx = noutput_items-work_left/d_n_chan/sizeof(sampl_t) + \ - (i-d_buf_back/sizeof(sampl_t))/d_n_chan; - - pbuf[i%(d_buffer_size/sizeof(sampl_t))] = input_items[chan]==0 ? 0 : - (int)((short*)(input_items[chan]))[i_idx] + 32767; - } - - // FIXME: how to tell comedi the buffer is *written* ? - ret = comedi_mark_buffer_read(d_dev, d_subdevice, d_buf_front-d_buf_back); - if(ret < 0) - bail("comedi_mark_buffer_read", comedi_errno()); - - work_left -= d_buf_front-d_buf_back; - - d_buf_back = d_buf_front; - } while(work_left > 0); - - return noutput_items; - } - - void - sink_s_impl::output_error_msg(const char *msg, int err) - { - fprintf(stderr, "sink_s_impl[%s]: %s: %s\n", - d_device_name.c_str(), msg, comedi_strerror(err)); - } - - void - sink_s_impl::bail(const char *msg, int err) throw (std::runtime_error) - { - output_error_msg(msg, err); - throw std::runtime_error("sink_s_impl"); - } - - } /* namespace comedi */ -} /* namespace gr */ diff --git a/gr-comedi/lib/sink_s_impl.h b/gr-comedi/lib/sink_s_impl.h deleted file mode 100644 index 738664c28c..0000000000 --- a/gr-comedi/lib/sink_s_impl.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,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. - */ - -#ifndef INCLUDED_COMEDI_SINK_IMPL_H -#define INCLUDED_COMEDI_SINK_IMPL_H - -#include <gnuradio/comedi/sink_s.h> -#include <string> -#include <comedilib.h> -#include <stdexcept> - -namespace gr { - namespace comedi { - - class sink_s_impl : public sink_s - { - private: - // typedef for pointer to class work method - typedef int (sink_s::*work_t)(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - unsigned int d_sampling_freq; - std::string d_device_name; - - comedi_t *d_dev; - int d_subdevice; - int d_n_chan; - void *d_map; - int d_buffer_size; - unsigned d_buf_front; - unsigned d_buf_back; - - // random stats - int d_nunderuns; // count of underruns - - void output_error_msg(const char *msg, int err); - void bail(const char *msg, int err) throw (std::runtime_error); - - public: - sink_s_impl(int sampling_freq, const std::string device_name); - ~sink_s_impl(); - - bool check_topology(int ninputs, int noutputs); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - }; - - } /* namespace comedi */ -} /* namespace gr */ - -#endif /* INCLUDED_COMEDI_SINK_IMPL_H */ diff --git a/gr-comedi/lib/source_s_impl.cc b/gr-comedi/lib/source_s_impl.cc deleted file mode 100644 index 4e3d9e1c08..0000000000 --- a/gr-comedi/lib/source_s_impl.cc +++ /dev/null @@ -1,236 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <sys/mman.h> - -#include "source_s_impl.h" -#include <gnuradio/io_signature.h> -#include <stdio.h> -#include <errno.h> -#include <iostream> -#include <stdexcept> - -// FIXME these should query some kind of user preference - -namespace gr { - namespace comedi { - - static std::string - default_device_name() - { - return "/dev/comedi0"; - } - - // ---------------------------------------------------------------- - - source_s::sptr - source_s::make(int sampling_freq, const std::string dev) - { - return gnuradio::get_initial_sptr - (new source_s_impl(sampling_freq, dev)); - } - - source_s_impl::source_s_impl(int sampling_freq, - const std::string device_name) - : sync_block("comedi_source_s", - io_signature::make(0, 0, 0), - io_signature::make(0, 0, 0)), - d_sampling_freq(sampling_freq), - d_device_name(device_name.empty() ? default_device_name() : device_name), - d_dev(0), - d_subdevice(0/*COMEDI_SUBD_AI*/), - d_n_chan(1), // number of input channels - d_map(0), - d_buffer_size(0), - d_buf_front(0), - d_buf_back(0) - { - int aref = AREF_GROUND; - int range = 0; - - d_dev = comedi_open(d_device_name.c_str()); - if(d_dev == 0) { - comedi_perror(d_device_name.c_str()); - throw std::runtime_error("source_s_impl"); - } - - unsigned int chanlist[256]; - - for(int i=0; i<d_n_chan; i++) { - chanlist[i] = CR_PACK(i,range,aref); - } - - comedi_cmd cmd; - int ret; - - ret = comedi_get_cmd_generic_timed(d_dev, d_subdevice, - &cmd, d_n_chan, - (unsigned int)(1e9/sampling_freq)); - if(ret < 0) - bail("comedi_get_cmd_generic_timed", comedi_errno()); - - // TODO: check period_ns is not to far off sampling_freq - - d_buffer_size = comedi_get_buffer_size(d_dev, d_subdevice); - if(d_buffer_size <= 0) - bail("comedi_get_buffer_size", comedi_errno()); - - d_map = mmap(NULL, d_buffer_size, PROT_READ, - MAP_SHARED, comedi_fileno(d_dev),0); - if(d_map == MAP_FAILED) - bail("mmap", errno); - - cmd.chanlist = chanlist; - cmd.chanlist_len = d_n_chan; - cmd.scan_end_arg = d_n_chan; - - cmd.stop_src = TRIG_NONE; - cmd.stop_arg = 0; - - /* comedi_command_test() tests a command to see if the trigger - * sources and arguments are valid for the subdevice. If a - * trigger source is invalid, it will be logically ANDed with - * valid values (trigger sources are actually bitmasks), which - * may or may not result in a valid trigger source. If an - * argument is invalid, it will be adjusted to the nearest valid - * value. In this way, for many commands, you can test it - * multiple times until it passes. Typically, if you can't get - * a valid command in two tests, the original command wasn't - * specified very well. */ - ret = comedi_command_test(d_dev,&cmd); - - if(ret < 0) - bail("comedi_command_test", comedi_errno()); - - ret = comedi_command_test(d_dev,&cmd); - - if(ret < 0) - bail("comedi_command_test", comedi_errno()); - - /* start the command */ - ret = comedi_command(d_dev,&cmd); - - if(ret < 0) - bail("comedi_command", comedi_errno()); - - set_output_multiple(d_n_chan*sizeof(sampl_t)); - - assert(sizeof(sampl_t) == sizeof(short)); - set_output_signature(io_signature::make(1, 1, sizeof(sampl_t))); - } - - bool - source_s_impl::check_topology(int ninputs, int noutputs) - { - if(noutputs > d_n_chan) - throw std::runtime_error("source_s_impl"); - - return true; - } - - source_s_impl::~source_s_impl() - { - if(d_map) { - munmap(d_map, d_buffer_size); - d_map = 0; - } - - comedi_close(d_dev); - } - - int - source_s_impl::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) - { - int ret; - - int work_left = noutput_items * sizeof(sampl_t) * d_n_chan; - sampl_t *pbuf = (sampl_t*)d_map; - - do { - do { - ret = comedi_get_buffer_contents(d_dev, d_subdevice); - if(ret < 0) - bail("comedi_get_buffer_contents", comedi_errno()); - - assert(ret % sizeof(sampl_t) == 0); - assert(work_left % sizeof(sampl_t) == 0); - - ret = std::min(ret, work_left); - d_buf_front += ret; - - assert(d_buffer_size%d_n_chan == 0); - if(d_buf_front-d_buf_back > (unsigned)d_buffer_size) { - d_buf_front+=d_buffer_size; - d_buf_back +=d_buffer_size; - } - - if(d_buf_front==d_buf_back) { - usleep(1000000*std::min(work_left, - d_buffer_size/2)/(d_sampling_freq*sizeof(sampl_t)*d_n_chan)); - continue; - } - } while(d_buf_front == d_buf_back); - - for(unsigned i=d_buf_back/sizeof(sampl_t); i < d_buf_front/sizeof(sampl_t); i++) { - int chan = i%d_n_chan; - int o_idx = noutput_items-work_left/d_n_chan/sizeof(sampl_t) + \ - (i-d_buf_back/sizeof(sampl_t))/d_n_chan; - - if(output_items[chan]) - ((short*)(output_items[chan]))[o_idx] = - (int)pbuf[i%(d_buffer_size/sizeof(sampl_t))] - 32767; - } - - ret = comedi_mark_buffer_read(d_dev,d_subdevice, d_buf_front-d_buf_back); - if(ret < 0) - bail("comedi_mark_buffer_read", comedi_errno()); - - work_left -= d_buf_front-d_buf_back; - - d_buf_back = d_buf_front; - } while(work_left > 0); - - return noutput_items; - } - - void - source_s_impl::output_error_msg(const char *msg, int err) - { - fprintf(stderr, "source_s_impl[%s]: %s: %s\n", - d_device_name.c_str(), msg, comedi_strerror(err)); - } - - void - source_s_impl::bail(const char *msg, int err) throw (std::runtime_error) - { - output_error_msg(msg, err); - throw std::runtime_error("source_s_impl"); - } - - } /* namespace comedi */ -} /* namespace gr */ diff --git a/gr-comedi/lib/source_s_impl.h b/gr-comedi/lib/source_s_impl.h deleted file mode 100644 index d3ba10d231..0000000000 --- a/gr-comedi/lib/source_s_impl.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,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. - */ - -#ifndef INCLUDED_COMEDI_SOURCE_S_IMPL_H -#define INCLUDED_COMEDI_SOURCE_S_IMPL_H - -#include <gnuradio/comedi/source_s.h> -#include <string> -#include <comedilib.h> -#include <stdexcept> - -namespace gr { - namespace comedi { - - class source_s_impl : public source_s - { - private: - // typedef for pointer to class work method - typedef int(source_s::*work_t)(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - unsigned int d_sampling_freq; - std::string d_device_name; - - comedi_t *d_dev; - int d_subdevice; - int d_n_chan; - void *d_map; - int d_buffer_size; - unsigned d_buf_front; - unsigned d_buf_back; - - // random stats - int d_noverruns; // count of overruns - - void output_error_msg(const char *msg, int err); - void bail(const char *msg, int err) throw (std::runtime_error); - - public: - source_s_impl(int sampling_freq, const std::string device_name); - ~source_s_impl(); - - bool check_topology(int ninputs, int noutputs); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - }; - - } /* namespace comedi */ -} /* namespace gr */ - -#endif /* INCLUDED_COMEDI_SOURCE_S_IMPL_H */ diff --git a/gr-comedi/python/comedi/CMakeLists.txt b/gr-comedi/python/comedi/CMakeLists.txt deleted file mode 100644 index 01a917807d..0000000000 --- a/gr-comedi/python/comedi/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 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. - -######################################################################## -# Setup python install -######################################################################## -include(GrPython) - -GR_PYTHON_INSTALL( - FILES - __init__.py - DESTINATION ${GR_PYTHON_DIR}/gnuradio/comedi -) - -######################################################################## -# Handle the unit tests -######################################################################## -if(ENABLE_TESTING) - - set(GR_TEST_TARGET_DEPS "") - set(GR_TEST_LIBRARY_DIRS "") - set(GR_TEST_PYTHON_DIRS - ${CMAKE_BINARY_DIR}/gnuradio-runtime/python - ${CMAKE_BINARY_DIR}/gnuradio-runtime/swig - ) - - include(GrTest) - 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} -B ${py_qa_test_file}) - endforeach(py_qa_test_file) -endif(ENABLE_TESTING) diff --git a/gr-comedi/python/comedi/__init__.py b/gr-comedi/python/comedi/__init__.py deleted file mode 100644 index f9f1124e5a..0000000000 --- a/gr-comedi/python/comedi/__init__.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 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. -# - -''' -Blocks and utilities for COMEDI devices -''' -from __future__ import unicode_literals - -# The presence of this file turns this directory into a Python package -import os - -try: - from .comedi_swig import * -except ImportError: - dirname, filename = os.path.split(os.path.abspath(__file__)) - __path__.append(os.path.join(dirname, "..", "..", "swig")) - from .comedi_swig import * diff --git a/gr-comedi/python/comedi/qa_comedi.py b/gr-comedi/python/comedi/qa_comedi.py deleted file mode 100644 index f4dc7b7778..0000000000 --- a/gr-comedi/python/comedi/qa_comedi.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2007,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. -# - - -from gnuradio import gr, gr_unittest, comedi - -class test_comedi(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def test_000_nop(self): - """Just see if we can import the module... - They may not have COMEDI library, etc. Don't try to run anything""" - pass - -if __name__ == '__main__': - gr_unittest.run(test_comedi, "test_comedi.xml") diff --git a/gr-comedi/swig/CMakeLists.txt b/gr-comedi/swig/CMakeLists.txt deleted file mode 100644 index 77edb0ca89..0000000000 --- a/gr-comedi/swig/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2012,2019 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -######################################################################## -# Setup swig generation -######################################################################## -include(GrPython) -include(GrSwig) - -set(GR_SWIG_INCLUDE_DIRS $<TARGET_PROPERTY:runtime_swig,INCLUDE_DIRECTORIES>) -set(GR_SWIG_TARGET_DEPS runtime_swig) - -set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/analog_swig_doc.i) -# Setup swig docs to depend on includes and pull in from build directory -set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/comedi_swig_doc.i) -set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include/gnuradio/comedi) -set(GR_SWIG_DOCS_TARGET_DEPS runtime_swig_swig_doc) - -set(GR_SWIG_LIBRARIES gnuradio-comedi) - -GR_SWIG_MAKE(comedi_swig comedi_swig.i) - -GR_SWIG_INSTALL( - TARGETS comedi_swig - DESTINATION ${GR_PYTHON_DIR}/gnuradio/comedi -) - -install( - FILES - comedi_swig.i - ${CMAKE_CURRENT_BINARY_DIR}/comedi_swig_doc.i - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig -) diff --git a/gr-comedi/swig/comedi_swig.i b/gr-comedi/swig/comedi_swig.i deleted file mode 100644 index 57f8dec5b9..0000000000 --- a/gr-comedi/swig/comedi_swig.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,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. - */ - -#define COMEDI_API - -%include "gnuradio.i" - -//load generated python docstrings -%include "comedi_swig_doc.i" - -%{ -#include "gnuradio/comedi/sink_s.h" -#include "gnuradio/comedi/source_s.h" -%} - -%include "gnuradio/comedi/sink_s.h" -%include "gnuradio/comedi/source_s.h" - -GR_SWIG_BLOCK_MAGIC2(comedi, sink_s); -GR_SWIG_BLOCK_MAGIC2(comedi, source_s); |