turtleshell 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0866f748e24f3efdb6c4a1bb490f5664de5f97b1
4
- data.tar.gz: 1882e6475159941b9cf423d3c54c8d30d2419d50
3
+ metadata.gz: eb5dc6ce3ad0ddb16c72026c295a72640f360a83
4
+ data.tar.gz: 405f2ef9cccaf7630b4e3f83eea7b274b500f093
5
5
  SHA512:
6
- metadata.gz: 9647e4773ebabe4517600c124f06815ea3e1cb6029f35a7a63d5b314d2976072af8f9c435eb4346d9b69c40765b716fe6560453dfb491a2cae3120b6860b4183
7
- data.tar.gz: 645b2dd39e02d7440996f41d8313a8cb6ff48f3953d2ad84b0bc6eda5d4a86cd325651be61409cca1bbc91b2a1dca7450b4871a3a4e90ae1d360cc82b7c929f6
6
+ metadata.gz: c3fc4a7d00175527c3871df711600a7e78ccf1cc9baa09c437cc5aad5672003fc65b547ae0c5e2cb7dee32a77779cb0254594e3551ff4f53fa8aac92dff19fa7
7
+ data.tar.gz: 84e8c8563f2df9041ccfa56cd155924b813f0676bbde4ec095093a7e1de32e2399bad996a5fc7a7a1a44ac557ecc52dd98a24fdd94aa59c7bb6b142cd1b47c8f
data/.gitignore CHANGED
@@ -4,3 +4,4 @@
4
4
  tmp
5
5
  Gemfile.lock
6
6
  .rvmrc
7
+ ext/librtlsdr/Makefile
@@ -3,6 +3,25 @@ require 'mkmf'
3
3
 
4
4
  have_library('rtlsdr')
5
5
  extension_name = 'librtlsdr'
6
-
7
6
  dir_config('librtlsdr')
7
+
8
+ search_paths = ENV['C_INCLUDE_PATH']
9
+ standard_include_path = '/usr/local/include'
10
+ search_paths = search_paths.nil? ? standard_include_path : search_paths
11
+
12
+ unless search_paths.include?(standard_include_path) || !File.exists?(standard_include_path)
13
+ search_paths = [search_paths, standard_include_path].join(':')
14
+ end
15
+
16
+ unless find_header('rtl-sdr.h', search_paths)
17
+ puts "\n\n***************************************"
18
+ puts "Error: could not find rtl-sdr.h"
19
+ puts "Either rtl-sdr.h is not in your include path, or we couldn't find it"
20
+ puts "This is either a bug in Turtleshell or you haven't installed this dependency yet. Please consider reporting this as a bug!"
21
+ puts "https://github.com/tjarratt/turtleshell/issues"
22
+ puts "***************************************\n\n"
23
+ exit 1
24
+ end
25
+
26
+
8
27
  create_makefile('librtlsdr/librtlsdr')
@@ -224,7 +224,28 @@ static VALUE turtleshell_get_gains(VALUE self, VALUE wrapped_device) {
224
224
  return buffer;
225
225
  }
226
226
 
227
+ static VALUE turtleshell_get_tuner_type(VALUE self, VALUE wrapped_device) {
228
+ VALUE hash;
229
+ int tuner_type;
230
+ rtlsdr_dev_t *device;
231
+ Data_Get_Struct(wrapped_device, rtlsdr_dev_t, device);
232
+
233
+ hash = rb_const_get(m_rtlsdr, rb_intern("TunerTypes"));
234
+ tuner_type = rtlsdr_get_tuner_type(device);
235
+ return rb_hash_aref(hash, tuner_type);
236
+ }
237
+
238
+ static VALUE turtleshell_set_manual_gain(VALUE self, VALUE wrapped_device, VALUE enabled) {
239
+ int result;
240
+ rtlsdr_dev_t *device;
241
+ Data_Get_Struct(wrapped_device, rtlsdr_dev_t, device);
242
+
243
+ result = rtlsdr_set_tuner_gain_mode(device, RTEST(enabled));
244
+ return INT2NUM(result);
245
+ }
246
+
227
247
  void Init_librtlsdr() {
248
+ VALUE tuner_hash;
228
249
  m_turtleshell = rb_define_module("TurtleShell");
229
250
  m_rtlsdr = rb_define_module_under(m_turtleshell, "RTLSDR");
230
251
  c_device = rb_define_class_under(m_rtlsdr, "Device", rb_cObject);
@@ -250,4 +271,15 @@ void Init_librtlsdr() {
250
271
  rb_define_module_function(m_rtlsdr, "get_gain", turtleshell_get_gain, 1);
251
272
  rb_define_module_function(m_rtlsdr, "set_gain", turtleshell_set_gain, 2);
252
273
  rb_define_module_function(m_rtlsdr, "get_tuner_gains", turtleshell_get_gains, 1);
274
+ rb_define_module_function(m_rtlsdr, "get_tuner_type", turtleshell_get_tuner_type, 1);
275
+ rb_define_module_function(m_rtlsdr, "set_manual_gain", turtleshell_set_manual_gain, 2);
276
+
277
+ tuner_hash = rb_hash_new();
278
+ rb_hash_aset(tuner_hash, RTLSDR_TUNER_UNKNOWN, ID2SYM(rb_intern("unknown")));
279
+ rb_hash_aset(tuner_hash, RTLSDR_TUNER_E4000, ID2SYM(rb_intern("e4000")));
280
+ rb_hash_aset(tuner_hash, RTLSDR_TUNER_FC0012, ID2SYM(rb_intern("fc0012")));
281
+ rb_hash_aset(tuner_hash, RTLSDR_TUNER_FC0013, ID2SYM(rb_intern("fc0013")));
282
+ rb_hash_aset(tuner_hash, RTLSDR_TUNER_R820T, ID2SYM(rb_intern("r820t")));
283
+ rb_hash_aset(tuner_hash, RTLSDR_TUNER_R828D, ID2SYM(rb_intern("r828d")));
284
+ rb_define_const(m_rtlsdr, "TunerTypes", tuner_hash);
253
285
  }
@@ -53,6 +53,18 @@ module TurtleShell
53
53
  TurtleShell::RTLSDR.get_tuner_gains(@device)
54
54
  end
55
55
 
56
+ def get_tuner_type
57
+ TurtleShell::RTLSDR.get_tuner_type(@device)
58
+ end
59
+
60
+ def set_manual_gain_mode
61
+ TurtleShell::RTLSDR.set_manual_gain(@device, true)
62
+ end
63
+
64
+ def disable_manual_gain_mode
65
+ TurtleShell::RTLSDR.set_manual_gain(@device, false)
66
+ end
67
+
56
68
  # read specified number of complex samples from tuner
57
69
  # real and imaginary parts are normalized between [-1, 1]
58
70
  def read_samples(number_of_samples = 1024)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'turtleshell'
3
- s.version = '1.0.5'
3
+ s.version = '1.0.7'
4
4
  s.date = '2013-11-05'
5
5
  s.summary = 'A ruby wrapper for librtlsdr'
6
6
  s.description = 'ruby bindings for librtlsdr -- realtek USB software defined radio devices'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turtleshell
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Jarratt
@@ -68,7 +68,6 @@ files:
68
68
  - examples/async_read_from_device.rb
69
69
  - examples/listing_devices.rb
70
70
  - examples/simple_read_from_device.rb
71
- - ext/librtlsdr/Makefile
72
71
  - ext/librtlsdr/extconf.rb
73
72
  - ext/librtlsdr/librtlsdr.c
74
73
  - lib/turtleshell.rb
@@ -1,217 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- # V=0 quiet, V=1 verbose. other values don't work.
5
- V = 0
6
- Q1 = $(V:1=)
7
- Q = $(Q1:0=@)
8
- n=$(NULLCMD)
9
- ECHO1 = $(V:1=@$n)
10
- ECHO = $(ECHO1:0=@echo)
11
-
12
- #### Start of system configuration section. ####
13
-
14
- srcdir = .
15
- topdir = /Users/tjarratt/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1
16
- hdrdir = /Users/tjarratt/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1
17
- arch_hdrdir = /Users/tjarratt/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/$(arch)
18
- VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
19
- prefix = $(DESTDIR)/Users/tjarratt/.rvm/rubies/ruby-1.9.3-p327
20
- rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
21
- exec_prefix = $(prefix)
22
- vendorhdrdir = $(rubyhdrdir)/vendor_ruby
23
- sitehdrdir = $(rubyhdrdir)/site_ruby
24
- rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
25
- vendordir = $(rubylibprefix)/vendor_ruby
26
- sitedir = $(rubylibprefix)/site_ruby
27
- ridir = $(datarootdir)/$(RI_BASE_NAME)
28
- mandir = $(datarootdir)/man
29
- localedir = $(datarootdir)/locale
30
- libdir = $(exec_prefix)/lib
31
- psdir = $(docdir)
32
- pdfdir = $(docdir)
33
- dvidir = $(docdir)
34
- htmldir = $(docdir)
35
- infodir = $(datarootdir)/info
36
- docdir = $(datarootdir)/doc/$(PACKAGE)
37
- oldincludedir = $(DESTDIR)/usr/include
38
- includedir = $(prefix)/include
39
- localstatedir = $(prefix)/var
40
- sharedstatedir = $(prefix)/com
41
- sysconfdir = $(DESTDIR)/etc
42
- datadir = $(datarootdir)
43
- datarootdir = $(prefix)/share
44
- libexecdir = $(exec_prefix)/libexec
45
- sbindir = $(exec_prefix)/sbin
46
- bindir = $(exec_prefix)/bin
47
- rubylibdir = $(rubylibprefix)/$(ruby_version)
48
- archdir = $(rubylibdir)/$(arch)
49
- sitelibdir = $(sitedir)/$(ruby_version)
50
- sitearchdir = $(sitelibdir)/$(sitearch)
51
- vendorlibdir = $(vendordir)/$(ruby_version)
52
- vendorarchdir = $(vendorlibdir)/$(sitearch)
53
-
54
- NULLCMD = :
55
-
56
- CC = /usr/bin/gcc-4.2
57
- CXX = g++
58
- LIBRUBY = $(LIBRUBY_A)
59
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
60
- LIBRUBYARG_SHARED =
61
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
62
- empty =
63
- OUTFLAG = -o $(empty)
64
- COUTFLAG = -o $(empty)
65
-
66
- RUBY_EXTCONF_H =
67
- cflags = $(optflags) $(debugflags) $(warnflags)
68
- optflags = -O3
69
- debugflags = -ggdb
70
- warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration
71
- CFLAGS = -fno-common -I/Users/mpapis/.sm/pkg/active/include -pipe $(ARCH_FLAG)
72
- INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
73
- DEFS =
74
- CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
75
- CXXFLAGS = $(CFLAGS) $(cxxflags)
76
- ldflags = -L. -Bstatic -L/Users/mpapis/.sm/pkg/active/lib
77
- dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace
78
- ARCH_FLAG = -arch x86_64
79
- DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
80
- LDSHARED = $(CC) -dynamic -bundle
81
- LDSHAREDXX = $(CXX) -dynamic -bundle
82
- AR = ar
83
- EXEEXT =
84
-
85
- RUBY_BASE_NAME = ruby
86
- RUBY_INSTALL_NAME = ruby
87
- RUBY_SO_NAME = ruby
88
- arch = x86_64-darwin12.2.0
89
- sitearch = $(arch)
90
- ruby_version = 1.9.1
91
- ruby = /Users/tjarratt/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
92
- RUBY = $(ruby)
93
- RM = rm -f
94
- RM_RF = $(RUBY) -run -e rm -- -rf
95
- RMDIRS = rmdir -p
96
- MAKEDIRS = mkdir -p
97
- INSTALL = /usr/bin/install -c
98
- INSTALL_PROG = $(INSTALL) -m 0755
99
- INSTALL_DATA = $(INSTALL) -m 644
100
- COPY = cp
101
- TOUCH = exit >
102
-
103
- #### End of system configuration section. ####
104
-
105
- preload =
106
-
107
- libpath = . $(libdir)
108
- LIBPATH = -L. -L$(libdir)
109
- DEFFILE =
110
-
111
- CLEANFILES = mkmf.log
112
- DISTCLEANFILES =
113
- DISTCLEANDIRS =
114
-
115
- extout =
116
- extout_prefix =
117
- target_prefix =
118
- LOCAL_LIBS =
119
- LIBS = -lpthread -ldl -lobjc
120
- SRCS = librtlsdr.c
121
- OBJS = librtlsdr.o
122
- TARGET = librtlsdr
123
- DLLIB = $(TARGET).bundle
124
- EXTSTATIC =
125
- STATIC_LIB =
126
-
127
- BINDIR = $(bindir)
128
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
129
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
130
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
131
- HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
132
- ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
133
-
134
- TARGET_SO = $(DLLIB)
135
- CLEANLIBS = $(TARGET).bundle
136
- CLEANOBJS = *.o *.bak
137
-
138
- all: $(DLLIB)
139
- static: $(STATIC_LIB)
140
- .PHONY: all install static install-so install-rb
141
- .PHONY: clean clean-so clean-rb
142
-
143
- clean-rb-default::
144
- clean-rb::
145
- clean-so::
146
- clean: clean-so clean-rb-default clean-rb
147
- @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
148
-
149
- distclean-rb-default::
150
- distclean-rb::
151
- distclean-so::
152
- distclean: clean distclean-so distclean-rb-default distclean-rb
153
- @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
154
- @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
155
- @-$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
156
-
157
- realclean: distclean
158
- install: install-so install-rb
159
-
160
- install-so: $(RUBYARCHDIR)/$(DLLIB)
161
- $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
162
- -$(Q)$(MAKEDIRS) $(@D)
163
- $(INSTALL_PROG) $(DLLIB) $(@D)
164
- clean-static::
165
- -$(Q)$(RM) $(STATIC_LIB)
166
- install-rb: pre-install-rb install-rb-default
167
- install-rb-default: pre-install-rb-default
168
- pre-install-rb: Makefile
169
- pre-install-rb-default: Makefile
170
- pre-install-rb-default:
171
- $(ECHO) installing default librtlsdr libraries
172
- ./.RUBYARCHDIR.time:
173
- $(Q) $(MAKEDIRS) $(RUBYARCHDIR)
174
- $(Q) $(TOUCH) $@
175
-
176
- site-install: site-install-so site-install-rb
177
- site-install-so: install-so
178
- site-install-rb: install-rb
179
-
180
- .SUFFIXES: .c .m .cc .mm .cxx .cpp .C .o
181
-
182
- .cc.o:
183
- $(ECHO) compiling $(<)
184
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
185
-
186
- .mm.o:
187
- $(ECHO) compiling $(<)
188
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
189
-
190
- .cxx.o:
191
- $(ECHO) compiling $(<)
192
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
193
-
194
- .cpp.o:
195
- $(ECHO) compiling $(<)
196
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
197
-
198
- .C.o:
199
- $(ECHO) compiling $(<)
200
- $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
201
-
202
- .c.o:
203
- $(ECHO) compiling $(<)
204
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
205
-
206
- .m.o:
207
- $(ECHO) compiling $(<)
208
- $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
209
-
210
- $(DLLIB): $(OBJS) Makefile
211
- $(ECHO) linking shared-object $(DLLIB)
212
- -$(Q)$(RM) $(@)
213
- $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
214
-
215
-
216
-
217
- $(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h