Revision 08f3f99f

/dev/null
1
Johnathan Corgan <[email protected]>
/dev/null
1
#
2
# Copyright 2006 Free Software Foundation, Inc.
3
# 
4
# This file is part of GNU Radio
5
# 
6
# GNU Radio is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2, or (at your option)
9
# any later version.
10
# 
11
# GNU Radio is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
# 
16
# You should have received a copy of the GNU General Public License
17
# along with GNU Radio; see the file COPYING.  If not, write to
18
# the Free Software Foundation, Inc., 51 Franklin Street,
19
# Boston, MA 02110-1301, USA.
20
# 
21

22
include $(top_srcdir)/Makefile.common
23

24
SUBDIRS = src
/dev/null
1
#
2
# Copyright 2006 Free Software Foundation, Inc.
3
# 
4
# This file is part of GNU Radio
5
# 
6
# GNU Radio is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2, or (at your option)
9
# any later version.
10
# 
11
# GNU Radio is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
# 
16
# You should have received a copy of the GNU General Public License
17
# along with GNU Radio; see the file COPYING.  If not, write to
18
# the Free Software Foundation, Inc., 51 Franklin Street,
19
# Boston, MA 02110-1301, USA.
20
# 
21

22
SUBDIRS = lib python
/dev/null
1
#
2
# Copyright 2004,2005,2006,2007 Free Software Foundation, Inc.
3
# 
4
# This file is part of GNU Radio
5
# 
6
# GNU Radio is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2, or (at your option)
9
# any later version.
10
# 
11
# GNU Radio is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
# 
16
# You should have received a copy of the GNU General Public License
17
# along with GNU Radio; see the file COPYING.  If not, write to
18
# the Free Software Foundation, Inc., 51 Franklin Street,
19
# Boston, MA 02110-1301, USA.
20
# 
21

22
include $(top_srcdir)/Makefile.common
23

24
# Install this stuff so that it ends up as the gnuradio.ezdop module
25
# This usually ends up at:
26
#   ${prefix}/lib/python${python_version}/site-packages/gnuradio
27

28
ourpythondir = $(grpythondir)
29
ourlibdir    = $(grpyexecdir)
30

31
EZDOP_INCLUDES = \
32
    -I$(top_srcdir)/ezdop/src/firmware \
33
    -I$(top_srcdir)/ezdop/src/host/ezdop
34

35
EZDOP_LA = $(top_builddir)/ezdop/src/host/ezdop/libezdop.la
36

37
INCLUDES = \
38
    $(STD_DEFINES_AND_INCLUDES) \
39
    $(PYTHON_CPPFLAGS) \
40
    $(EZDOP_INCLUDES)
41

42
SWIGPYTHONARGS = $(SWIGPYTHONFLAGS) $(STD_DEFINES_AND_INCLUDES)
43

44
ALL_IFILES = 				\
45
	$(LOCAL_IFILES)			\
46
	$(NON_LOCAL_IFILES)		
47

48
NON_LOCAL_IFILES =			\
49
	$(GNURADIO_I)
50

51

52
LOCAL_IFILES = 				\
53
	$(top_srcdir)/gr-ezdop/src/lib/ezdop.i				
54

55
# These files are built by SWIG.  The first is the C++ glue.
56
# The second is the python wrapper that loads the _ezdop shared library
57
# and knows how to call our extensions.
58

59
BUILT_SOURCES = 			\
60
	ezdop.cc			\
61
	ezdop.py				
62

63
# This gets ezdop.py installed in the right place
64
ourpython_PYTHON =			\
65
	ezdop.py
66

67
ourlib_LTLIBRARIES = _ezdop.la
68

69
# These are the source files that go into the shared library
70
_ezdop_la_SOURCES = 			\
71
	ezdop.cc			\
72
	ezdop_source_c.cc		
73

74
# magic flags
75
_ezdop_la_LDFLAGS = $(NO_UNDEFINED) -module -avoid-version
76

77
# link the library against some comon swig runtime code and the 
78
# c++ standard library
79
_ezdop_la_LIBADD = 			\
80
	$(PYTHON_LDFLAGS)		\
81
	$(GNURADIO_CORE_LA)		\
82
	$(EZDOP_LA)			\
83
	-lstdc++			
84

85
ezdop.cc ezdop.py: $(ALL_IFILES)
86
	$(SWIG) $(SWIGPYTHONARGS) -module ezdop -o ezdop.cc $(LOCAL_IFILES)
87

88
# These headers get installed in ${prefix}/include/gnuradio
89
grinclude_HEADERS =			\
90
	ezdop_source_c.h
91

92
# These swig headers get installed in ${prefix}/include/gnuradio/swig
93
swiginclude_HEADERS = 			\
94
	$(LOCAL_IFILES)
95

96
MOSTLYCLEANFILES = $(BUILT_SOURCES) *.pyc
97

98
# Don't distribute output of swig
99
dist-hook:
100
	@for file in $(BUILT_SOURCES); do echo $(RM) $(distdir)/$$file; done
101
	@for file in $(BUILT_SOURCES); do $(RM) $(distdir)/$$file; done
/dev/null
1
/*
2
 * Copyright 2004,2006 Free Software Foundation, Inc.
3
 * 
4
 * This file is part of GNU Radio
5
 * 
6
 * GNU Radio is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2, or (at your option)
9
 * any later version.
10
 * 
11
 * GNU Radio is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with GNU Radio; see the file COPYING.  If not, write to
18
 * the Free Software Foundation, Inc., 51 Franklin Street,
19
 * Boston, MA 02110-1301, USA.
20
 */
21

22
//%feature("autodoc", "1");		// generate python docstrings
23

24
%include "exception.i"
25
%import "gnuradio.i"				// the common stuff
26

27
%{
28
#include "gnuradio_swig_bug_workaround.h"	// mandatory bug fix
29
#include "ezdop_source_c.h"
30
%}
31

32
GR_SWIG_BLOCK_MAGIC(ezdop,source_c);
33

34
ezdop_source_c_sptr ezdop_make_source_c();
35

36
class ezdop_source_c : public gr_sync_block 
37
{
38
private:
39
    ezdop_source_c() throw (std::runtime_error);
40

41
public:
42
    int  rate();
43
    bool set_rate(int rate);
44
    bool rotate();
45
    bool stop_rotating();
46
};
/dev/null
1
/*
2
 * Copyright 2004,2006 Free Software Foundation, Inc.
3
 * 
4
 * This file is part of GNU Radio
5
 * 
6
 * GNU Radio is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2, or (at your option)
9
 * any later version.
10
 * 
11
 * GNU Radio is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with GNU Radio; see the file COPYING.  If not, write to
18
 * the Free Software Foundation, Inc., 51 Franklin Street,
19
 * Boston, MA 02110-1301, USA.
20
 */
21

22
#ifdef HAVE_CONFIG_H
23
#include "config.h"
24
#endif
25

26
#include <ezdop_source_c.h>
27
#include <gr_io_signature.h>
28

29
ezdop_source_c_sptr ezdop_make_source_c()
30
{
31
    return ezdop_source_c_sptr(new ezdop_source_c());
32
}
33

34
ezdop_source_c::ezdop_source_c() throw (std::runtime_error) :
35
    gr_sync_block("ezdop_source_c",
36
	          gr_make_io_signature(0, 0, 0),
37
                  gr_make_io_signature(1, 1, sizeof (gr_complex))
38
    )
39
{
40
    d_ezdop = new ezdop();
41

42
    if (!d_ezdop->init())
43
	throw std::runtime_error("unable to init ezdop hardware");
44
    if (!d_ezdop->reset())
45
	throw std::runtime_error("unable to reset ezdop hardware");
46
}
47

48
ezdop_source_c::~ezdop_source_c()
49
{
50
    assert(d_ezdop);
51
    d_ezdop->finish();
52
    delete d_ezdop;
53
}
54

55
bool ezdop_source_c::start()
56
{
57
    assert(d_ezdop);
58
    bool success = d_ezdop->stream();
59
    if (!success)
60
	fprintf(stderr, "ezdop_source_c::start(): unable to start streaming\n");
61
    return success;
62
}
63

64
bool ezdop_source_c::stop()
65
{
66
    assert(d_ezdop);
67
    bool success = d_ezdop->stop_streaming();
68
    if (!success)
69
	fprintf(stderr, "ezdop_source_c::start(): unable to stop streaming\n");
70
    return success;
71
}
72

73
int ezdop_source_c::rate()
74
{
75
    assert(d_ezdop);
76
    return d_ezdop->rate();
77
}
78

79
bool ezdop_source_c::set_rate(int rate)
80
{
81
    assert(d_ezdop);
82
    if (rate <= 0 || rate > 2000)
83
	return false;
84
    bool success = d_ezdop->set_rate(rate);    
85
    return success;
86
}
87

88
bool ezdop_source_c::rotate()
89
{
90
    assert(d_ezdop);
91
    bool success = d_ezdop->rotate();
92
    if (!success)
93
	fprintf(stderr, "ezdop_source_c::rotate(): unable to start rotating\n");
94
    return success;
95
}
96

97
bool ezdop_source_c::stop_rotating()
98
{
99
    assert(d_ezdop);
100
    bool success = d_ezdop->stop_rotating();
101
    if (!success)
102
	fprintf(stderr, "ezdop_source_c::stop_rotating(): unable to stop rotating\n");
103
    return success;
104
}
105

106
int ezdop_source_c::work(int noutput_items,
107
	gr_vector_const_void_star &input_items,
108
	gr_vector_void_star &output_items)
109
{
110
    assert(d_ezdop);
111
    float volume = 0.0; // Dummy for now
112

113
    gr_complex *out = (gr_complex *)output_items[0];
114
    return d_ezdop->read_iq(out, noutput_items, volume);
115
}
/dev/null
1
/*
2
 * Copyright 2004,2006 Free Software Foundation, Inc.
3
 * 
4
 * This file is part of GNU Radio
5
 * 
6
 * GNU Radio is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2, or (at your option)
9
 * any later version.
10
 * 
11
 * GNU Radio is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with GNU Radio; see the file COPYING.  If not, write to
18
 * the Free Software Foundation, Inc., 51 Franklin Street,
19
 * Boston, MA 02110-1301, USA.
20
 */
21

22
#ifndef INCLUDED_EZDOP_SOURCE_C_H
23
#define INCLUDED_EZDOP_SOURCE_C_H
24

25
#include <gr_sync_block.h>
26
#include <ezdop.h>
27
#include <stdexcept>
28

29
class ezdop_source_c;
30
typedef boost::shared_ptr<ezdop_source_c> ezdop_source_c_sptr;
31

32
ezdop_source_c_sptr ezdop_make_source_c();
33

34
class ezdop_source_c : public gr_sync_block {
35
private:
36
    friend ezdop_source_c_sptr ezdop_make_source_c();
37
    ezdop_source_c() throw (std::runtime_error);
38

39
    ezdop *d_ezdop;
40

41
public:
42
    virtual bool start();  // Called by runtime 
43
    virtual bool stop();   // Called by runtime
44

45
    int rate();
46
    bool set_rate(int rate); // Any integer divisor of 2000 Hz
47

48
    bool rotate();
49
    bool stop_rotating();
50

51
    ~ezdop_source_c();
52

53
    int work(int noutput_items,
54
	gr_vector_const_void_star &input_items,
55
	gr_vector_void_star &output_items);
56
};
57

58
#endif /* INCLUDED_EZDOP_SOURCE_C_H */
/dev/null
1
#
2
# Copyright 2004 Free Software Foundation, Inc.
3
# 
4
# This file is part of GNU Radio
5
# 
6
# GNU Radio is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2, or (at your option)
9
# any later version.
10
# 
11
# GNU Radio is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
# 
16
# You should have received a copy of the GNU General Public License
17
# along with GNU Radio; see the file COPYING.  If not, write to
18
# the Free Software Foundation, Inc., 51 Franklin Street,
19
# Boston, MA 02110-1301, USA.
20
# 
21

22
include $(top_srcdir)/Makefile.common
23

24
EXTRA_DIST = run_tests.in
25

26

27
TESTS = 				\
28
	run_tests
29

30

31
noinst_PYTHON = 			\
32
	qa_ezdop.py			
/dev/null
1
#!/usr/bin/env python
2
#
3
# Copyright 2004 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 2, 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

23
from gnuradio import gr, gr_unittest
24
import ezdop
25

26
class qa_ezdop(gr_unittest.TestCase):
27

28
    def setUp (self):
29
        self.fg = gr.flow_graph ()
30

31
    def tearDown (self):
32
        self.fg = None
33
"""
34
    def test_001_installed(self):
35
	DOP = ezdop.source_c();
36

37
    def test_002_start_stop(self):
38
	DOP = ezdop.source_c();
39
	DOP.set_rate(1000);
40
	print "rate =", DOP.rate()
41
	DOP.rotate();
42

43
	self.fg.connect(DOP, gr.null_sink(gr.sizeof_gr_complex))
44
	try:
45
	    self.fg.run()
46
	except KeyboardInterrupt:
47
	    pass
48
	DOP.stop_rotating();
49
"""
50

51
if __name__ == '__main__':
52
    gr_unittest.main ()
/dev/null
1
#!/bin/sh
2

3
# 1st parameter is absolute path to component source directory
4
# 2nd parameter is absolute path to component build directory
5
# 3rd parameter is path to Python QA directory
6

7
@top_builddir@/run_tests.sh \
8
    @abs_top_srcdir@/gr-ezdop \
9
    @abs_top_builddir@/gr-ezdop \
10
    @srcdir@

Also available in: Unified diff