GNU Radio 3.6.4.1 C++ API
comedi_source_s.h
Go to the documentation of this file.
1
/* -*- c++ -*- */
2
/*
3
* Copyright 2005 Free Software Foundation, Inc.
4
*
5
* This file is part of GNU Radio
6
*
7
* GNU Radio is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 3, or (at your option)
10
* any later version.
11
*
12
* GNU Radio is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with GNU Radio; see the file COPYING. If not, write to
19
* the Free Software Foundation, Inc., 51 Franklin Street,
20
* Boston, MA 02110-1301, USA.
21
*/
22
#ifndef INCLUDED_COMEDI_SOURCE_S_H
23
#define INCLUDED_COMEDI_SOURCE_S_H
24
25
#include <
gr_sync_block.h
>
26
#include <string>
27
#include <comedilib.h>
28
#include <stdexcept>
29
30
class
comedi_source_s
;
31
typedef
boost::shared_ptr<comedi_source_s>
comedi_source_s_sptr
;
32
33
/*!
34
* \brief make a COMEDI source.
35
*
36
* \param sampling_freq sampling rate in Hz
37
* \param dev COMEDI device name, e.g., "/dev/comedi0"
38
*/
39
comedi_source_s_sptr
40
comedi_make_source_s
(
int
sampling_freq,
41
const
std::string dev =
"/dev/comedi0"
);
42
43
/*!
44
* \brief source using COMEDI
45
*
46
* The source has one to many input stream of signed short integers.
47
*
48
* Output samples will be in the range [-32768,32767].
49
*/
50
class
comedi_source_s
:
public
gr_sync_block
{
51
friend
comedi_source_s_sptr
52
comedi_make_source_s
(
int
sampling_freq,
const
std::string dev);
53
54
// typedef for pointer to class work method
55
typedef
int (
comedi_source_s
::*work_t)(
int
noutput_items,
56
gr_vector_const_void_star
&input_items,
57
gr_vector_void_star
&output_items);
58
59
unsigned
int
d_sampling_freq;
60
std::string d_device_name;
61
62
comedi_t *d_dev;
63
int
d_subdevice;
64
int
d_n_chan;
65
void
*d_map;
66
int
d_buffer_size;
67
unsigned
d_buf_front;
68
unsigned
d_buf_back;
69
70
// random stats
71
int
d_noverruns;
// count of overruns
72
73
void
output_error_msg (
const
char
*msg,
int
err);
74
void
bail (
const
char
*msg,
int
err)
throw
(std::runtime_error);
75
76
77
protected
:
78
comedi_source_s
(
int
sampling_freq,
const
std::string device_name);
79
80
public
:
81
~comedi_source_s
();
82
83
bool
check_topology
(
int
ninputs,
int
noutputs);
84
85
int
work
(
int
noutput_items,
86
gr_vector_const_void_star
&input_items,
87
gr_vector_void_star
&output_items);
88
};
89
90
#endif
/* INCLUDED_COMEDI_SOURCE_S_H */
gnuradio
gr-comedi
src
comedi_source_s.h
Generated by
1.8.1.2