comedi_source_s.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef INCLUDED_COMEDI_SOURCE_S_H
00023 #define INCLUDED_COMEDI_SOURCE_S_H
00024
00025 #include <gr_sync_block.h>
00026 #include <string>
00027 #include <comedilib.h>
00028 #include <stdexcept>
00029
00030 class comedi_source_s;
00031 typedef boost::shared_ptr<comedi_source_s> comedi_source_s_sptr;
00032
00039 comedi_source_s_sptr
00040 comedi_make_source_s (int sampling_freq,
00041 const std::string dev = "/dev/comedi0");
00042
00050 class comedi_source_s : public gr_sync_block {
00051 friend comedi_source_s_sptr
00052 comedi_make_source_s (int sampling_freq, const std::string device_name);
00053
00054
00055 typedef int (comedi_source_s::*work_t)(int noutput_items,
00056 gr_vector_const_void_star &input_items,
00057 gr_vector_void_star &output_items);
00058
00059 unsigned int d_sampling_freq;
00060 std::string d_device_name;
00061
00062 comedi_t *d_dev;
00063 int d_subdevice;
00064 int d_n_chan;
00065 void *d_map;
00066 int d_buffer_size;
00067 unsigned d_buf_front;
00068 unsigned d_buf_back;
00069
00070
00071 int d_noverruns;
00072
00073 void output_error_msg (const char *msg, int err);
00074 void bail (const char *msg, int err) throw (std::runtime_error);
00075
00076
00077 protected:
00078 comedi_source_s (int sampling_freq, const std::string device_name);
00079
00080 public:
00081 ~comedi_source_s ();
00082
00083 bool check_topology (int ninputs, int noutputs);
00084
00085 int work (int noutput_items,
00086 gr_vector_const_void_star &input_items,
00087 gr_vector_void_star &output_items);
00088 };
00089
00090 #endif