phidgets 0.0.1 → 0.0.2
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.
- data/History.txt +4 -2
- data/README.rdoc +2 -3
- data/Rakefile +13 -21
- data/lib/phidgets.rb +2 -2
- data/lib/phidgets/common.rb +256 -250
- data/lib/phidgets/interfacekit.rb +76 -32
- data/lib/phidgets/rfid.rb +64 -37
- data/test/test_interfacekit.rb +2 -3
- data/test/test_phidgets.rb +15 -2
- metadata +13 -10
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -14,8 +14,7 @@ This gem provides a ruby interface to the phidgets library.
|
|
14
14
|
* Not all the devices have been implemented, and not all of the devices that have been implemented have been fully tested.
|
15
15
|
* The callback functionality of the Phidgets library is not working very well. Making multiple calls to the phidgets library from
|
16
16
|
within a callback will cause an exception.
|
17
|
-
* The gem will attempt to guess the name of the phidgets library based on the platform it is run on (Linux or Windows).
|
18
|
-
incorrectly, the library name can be set manually with Phidgets::setLibName(lib)
|
17
|
+
* The gem will attempt to guess the name of the phidgets library based on the platform it is run on (Linux or Windows).
|
19
18
|
|
20
19
|
== SYNOPSIS:
|
21
20
|
|
@@ -47,7 +46,7 @@ end
|
|
47
46
|
|
48
47
|
== LICENSE:
|
49
48
|
|
50
|
-
Copyright (C) 2009 Craig DeHaan
|
49
|
+
Copyright (C) 2009-2010 Craig DeHaan
|
51
50
|
|
52
51
|
This program is free software; you can redistribute it and/or
|
53
52
|
modify it under the terms of the GNU General Public License
|
data/Rakefile
CHANGED
@@ -1,28 +1,20 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/phidgets'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
3
8
|
|
4
9
|
# Generate all the Rake tasks
|
5
10
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
-
$hoe = Hoe.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# p.extra_deps = [
|
12
|
-
# ['activesupport','>= 2.0.2'],
|
13
|
-
# ]
|
14
|
-
p.extra_dev_deps = [
|
15
|
-
['newgem', ">= #{::Newgem::VERSION}"]
|
16
|
-
]
|
17
|
-
|
18
|
-
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
19
|
-
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
20
|
-
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
21
|
-
p.rsync_args = '-av --delete --ignore-errors'
|
11
|
+
$hoe = Hoe.spec 'phidgets' do
|
12
|
+
self.developer 'Craig DeHaan', 'craig.s.dehaan@gmail.com'
|
13
|
+
self.post_install_message = 'PostInstall.txt'
|
14
|
+
self.rubyforge_name = self.name
|
15
|
+
|
22
16
|
end
|
23
17
|
|
24
|
-
require 'newgem/tasks'
|
18
|
+
require 'newgem/tasks'
|
25
19
|
Dir['tasks/**/*.rake'].each { |t| load t }
|
26
20
|
|
27
|
-
# TODO - want other tests/tasks run by default? Add them to the list
|
28
|
-
# task :default => [:spec, :features]
|
data/lib/phidgets.rb
CHANGED
data/lib/phidgets/common.rb
CHANGED
@@ -1,97 +1,156 @@
|
|
1
1
|
|
2
2
|
require 'dl'
|
3
|
+
require 'dl/import'
|
3
4
|
require 'rbconfig'
|
4
5
|
|
5
|
-
module Phidgets
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
7
|
+
module Phidgets
|
8
|
+
extend DL::Importable
|
9
|
+
|
10
|
+
NOTATTACHED = 0
|
11
|
+
ATTACHED = 1
|
12
|
+
|
13
|
+
CLASS_NOTHING = 1
|
14
|
+
CLASS_ACCELEROMETER = 2
|
15
|
+
CLASS_ADVANCEDSERVO = 3
|
16
|
+
CLASS_ENCODER = 4
|
17
|
+
CLASS_GPS = 5
|
18
|
+
CLASS_GYROSCOPE = 6
|
19
|
+
CLASS_INTERFACEKIT = 7
|
20
|
+
CLASS_LED = 8
|
21
|
+
CLASS_MOTORCONTROL = 9
|
22
|
+
CLASS_PHSENSOR = 10
|
23
|
+
CLASS_RFID = 11
|
24
|
+
CLASS_SERVO = 12
|
25
|
+
CLASS_STEPPER = 13
|
26
|
+
CLASS_TEMPERATURESENSOR = 14
|
27
|
+
CLASS_TEXTLCD = 15
|
28
|
+
CLASS_TEXTLED = 16
|
29
|
+
CLASS_WEIGHTSENSOR = 17
|
30
|
+
|
31
|
+
ID_ACCELEROMETER_2AXIS = 0x071
|
32
|
+
ID_ACCELEROMETER_3AXIS = 0x07E
|
33
|
+
ID_ADVANCEDSERVO_8MOTOR = 0x03A
|
34
|
+
ID_BIPOLAR_STEPPER_1MOTOR = 0x07B
|
35
|
+
ID_ENCODER_1ENCODER_1INPUT = 0x04B
|
36
|
+
ID_ENCODER_HS_1ENCODER = 0x080
|
37
|
+
ID_INTERFACEKIT_0_0_4 = 0x040
|
38
|
+
ID_INTERFACEKIT_0_0_8 = 0x081
|
39
|
+
ID_INTERFACEKIT_0_16_16 = 0x044
|
40
|
+
ID_INTERFACEKIT_8_8_8 = 0x045
|
41
|
+
ID_INTERFACEKIT_8_8_8_w_LCD = 0x07D
|
42
|
+
ID_LED_64 = 0x04A
|
43
|
+
ID_LINEAR_TOUCH = 0x076
|
44
|
+
ID_MOTORCONTROL_HC_2MOTOR = 0x059
|
42
45
|
ID_MOTORCONTROL_LV_2MOTOR_4INPUT = 0x058
|
43
|
-
ID_PHSENSOR
|
44
|
-
ID_RFID_2OUTPUT
|
45
|
-
ID_ROTARY_TOUCH
|
46
|
-
ID_SERVO_1MOTOR
|
47
|
-
ID_TEMPERATURESENSOR
|
48
|
-
ID_TEXTLCD_2x20_w_8_8_8
|
49
|
-
ID_UNIPOLAR_STEPPER_4MOTOR
|
50
|
-
ID_INTERFACEKIT_0_8_8_w_LCD
|
51
|
-
ID_INTERFACEKIT_4_8_8
|
52
|
-
ID_RFID
|
53
|
-
ID_SERVO_1MOTOR_OLD
|
54
|
-
ID_SERVO_4MOTOR
|
55
|
-
ID_SERVO_4MOTOR_OLD
|
56
|
-
ID_TEXTLCD_2x20
|
57
|
-
ID_TEXTLCD_2x20_w_0_8_8
|
58
|
-
ID_TEXTLED_1x8
|
59
|
-
ID_TEXTLED_4x8
|
60
|
-
ID_WEIGHTSENSOR
|
61
|
-
|
62
|
-
|
63
|
-
|
46
|
+
ID_PHSENSOR = 0x074
|
47
|
+
ID_RFID_2OUTPUT = 0x031
|
48
|
+
ID_ROTARY_TOUCH = 0x077
|
49
|
+
ID_SERVO_1MOTOR = 0x039
|
50
|
+
ID_TEMPERATURESENSOR = 0x070
|
51
|
+
ID_TEXTLCD_2x20_w_8_8_8 = 0x17D
|
52
|
+
ID_UNIPOLAR_STEPPER_4MOTOR = 0x07A
|
53
|
+
ID_INTERFACEKIT_0_8_8_w_LCD = 0x053
|
54
|
+
ID_INTERFACEKIT_4_8_8 = 0x004
|
55
|
+
ID_RFID = 0x030
|
56
|
+
ID_SERVO_1MOTOR_OLD = 0x002
|
57
|
+
ID_SERVO_4MOTOR = 0x038
|
58
|
+
ID_SERVO_4MOTOR_OLD = 0x003
|
59
|
+
ID_TEXTLCD_2x20 = 0x052
|
60
|
+
ID_TEXTLCD_2x20_w_0_8_8 = 0x153
|
61
|
+
ID_TEXTLED_1x8 = 0x049
|
62
|
+
ID_TEXTLED_4x8 = 0x048
|
63
|
+
ID_WEIGHTSENSOR = 0x072
|
64
|
+
|
65
|
+
begin
|
66
|
+
case Config::CONFIG['target_os']
|
67
|
+
when 'linux'
|
68
|
+
dlload 'libphidget21.so'
|
69
|
+
when 'mswin32'
|
70
|
+
dlload 'phidget21.dll'
|
71
|
+
else
|
72
|
+
raise Phidgets::Exception.new(Exception::EPHIDGET_LIBNAME)
|
73
|
+
end
|
74
|
+
rescue
|
75
|
+
raise Phidgets::Exception.new(Exception::EPHIDGET_LOAD_LIB_FAIL)
|
76
|
+
end
|
77
|
+
|
78
|
+
extern "int CPhidget_openRemote(void *, int, void *, void *)"
|
79
|
+
extern "int CPhidget_openRemoteIP(void *, int, void *, int, void *)"
|
80
|
+
extern "int CPhidget_open(void *, int)"
|
81
|
+
extern "int CPhidget_close(void *)"
|
82
|
+
extern "int CPhidget_delete(void *)"
|
83
|
+
extern "int CPhidget_set_OnDetach_Handler(void *, void *, void *)"
|
84
|
+
extern "int CPhidget_set_OnAttach_Handler(void *, void *, void *)"
|
85
|
+
extern "int CPhidget_set_OnServerConnect_Handler(void *, void *, void *)"
|
86
|
+
extern "int CPhidget_set_OnServerDisconnect_Handler(void *, void *, void *)"
|
87
|
+
extern "int CPhidget_set_OnError_Handler(void *, void *, void *)"
|
88
|
+
extern "int CPhidget_getDeviceName(void *, void *)"
|
89
|
+
extern "int CPhidget_getSerialNumber(void *, int *)"
|
90
|
+
extern "int CPhidget_getDeviceVersion(void *, int *)"
|
91
|
+
extern "int CPhidget_getDeviceStatus(void *, int *)"
|
92
|
+
extern "int CPhidget_getLibraryVersion(void *)"
|
93
|
+
extern "int CPhidget_getDeviceType(void *, void *)"
|
94
|
+
extern "int CPhidget_getDeviceLabel(void *, void *)"
|
95
|
+
extern "int CPhidget_setDeviceLabel(void *, void *)"
|
96
|
+
extern "int CPhidget_getErrorDescription(int, void *)"
|
97
|
+
extern "int CPhidget_waitForAttachment(void *, int)"
|
98
|
+
extern "int CPhidget_getServerID(void *, void *)"
|
99
|
+
extern "int CPhidget_getServerAddress(void *, void *, int *)"
|
100
|
+
extern "int CPhidget_getServerStatus(void *, int *)"
|
101
|
+
extern "int CPhidget_getDeviceID(void *, int *)"
|
102
|
+
extern "int CPhidget_getDeviceClass(void *, int *)"
|
103
|
+
|
104
|
+
# Gets the library version. This contains a version number and a build date.
|
105
|
+
def Phidgets.getLibraryVersion
|
106
|
+
ptr = DL.malloc(DL.sizeof('P'))
|
107
|
+
r = cPhidget_getLibraryVersion(ptr.ref)
|
108
|
+
raise Phidgets::Exception.new(r) if r != 0
|
109
|
+
ptr.free = nil
|
110
|
+
ptr.to_s
|
64
111
|
end
|
65
112
|
|
113
|
+
# Gets the description for an error code.
|
114
|
+
def Phidgets.getErrorDescription(error_code)
|
115
|
+
ptr = DL.malloc(DL.sizeof('P'))
|
116
|
+
r = cPhidget_getErrorDescription(error_code, ptr.ref)
|
117
|
+
raise Phidgets::Exception.new(r) if r != 0
|
118
|
+
ptr.free = nil
|
119
|
+
ptr.to_s
|
120
|
+
end
|
121
|
+
|
122
|
+
|
66
123
|
class Exception < RuntimeError
|
67
124
|
attr_reader :code
|
68
125
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
126
|
+
EPHIDGET_LOAD_LIB_FAIL = -2
|
127
|
+
EPHIDGET_LIBNAME = -1
|
128
|
+
EPHIDGET_NOTFOUND = 1
|
129
|
+
EPHIDGET_NOMEMORY = 2
|
130
|
+
EPHIDGET_UNEXPECTED = 3
|
131
|
+
EPHIDGET_INVALIDARG = 4
|
132
|
+
EPHIDGET_NOTATTACHED = 5
|
133
|
+
EPHIDGET_INTERRUPTED = 6
|
134
|
+
EPHIDGET_INVALID = 7
|
135
|
+
EPHIDGET_NETWORK = 8
|
136
|
+
EPHIDGET_UNKNOWNVAL = 9
|
137
|
+
EPHIDGET_BADPASSWORD = 10
|
138
|
+
EPHIDGET_UNSUPPORTED = 11
|
139
|
+
EPHIDGET_DUPLICATE = 12
|
140
|
+
EPHIDGET_TIMEOUT = 13
|
141
|
+
EPHIDGET_OUTOFBOUNDS = 14
|
142
|
+
EPHIDGET_EVENT = 15
|
143
|
+
EPHIDGET_NETWORK_NOTCONNECTED = 16
|
144
|
+
EPHIDGET_WRONGDEVICE = 17
|
145
|
+
EPHIDGET_CLOSED = 18
|
146
|
+
EPHIDGET_BADVERSION = 19
|
88
147
|
|
89
148
|
def initialize(code)
|
90
149
|
@code = code
|
91
150
|
case code
|
92
|
-
when
|
151
|
+
when EPHIDGET_LOAD_LIB_FAIL
|
93
152
|
super('Failed to load Phidgets Library')
|
94
|
-
when
|
153
|
+
when EPHIDGET_LIBNAME
|
95
154
|
super('Unable to determine Phidgets Library name.')
|
96
155
|
when EPHIDGET_NOTFOUND
|
97
156
|
super('A Phidget matching the type and or serial number could not be found.')
|
@@ -136,257 +195,204 @@ module Phidgets
|
|
136
195
|
|
137
196
|
end
|
138
197
|
|
139
|
-
class Common
|
140
|
-
@@libname = nil
|
141
|
-
@@lib = nil
|
142
|
-
@@open_remote = nil
|
143
|
-
@@open_remote_ip = nil
|
144
|
-
@@open = nil
|
145
|
-
@@close = nil
|
146
|
-
@@delete = nil
|
147
|
-
@@detach_handler = nil
|
148
|
-
@@attach_handler = nil
|
149
|
-
@@connect_handler = nil
|
150
|
-
@@disconnect_handler = nil
|
151
|
-
@@error_handler = nil
|
152
|
-
@@name = nil
|
153
|
-
@@serial = nil
|
154
|
-
@@version = nil
|
155
|
-
@@status = nil
|
156
|
-
@@lib_version = nil
|
157
|
-
@@type = nil
|
158
|
-
@@get_label = nil
|
159
|
-
@@set_label = nil
|
160
|
-
@@error_description = nil
|
161
|
-
@@wait = nil
|
162
|
-
@@server_id = nil
|
163
|
-
@@server_addr = nil
|
164
|
-
@@server_status = nil
|
165
|
-
@@device_id = nil
|
166
|
-
@@device_class = nil
|
167
198
|
|
199
|
+
class Common
|
168
200
|
def initialize
|
169
|
-
if @@libname == nil
|
170
|
-
case Config::CONFIG['target_os']
|
171
|
-
when 'linux'
|
172
|
-
@@libname = 'libphidget21.so'
|
173
|
-
when 'mswin32'
|
174
|
-
@@libname = 'phidget21.dll'
|
175
|
-
else
|
176
|
-
raise Phidgets::Exception.new(-1)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
begin
|
181
|
-
@@lib = DL.dlopen(@@libname)
|
182
|
-
rescue
|
183
|
-
raise Phidgets::Exception.new(-2)
|
184
|
-
end
|
185
|
-
|
186
201
|
@handle = DL.malloc(DL.sizeof('P'))
|
187
|
-
|
188
|
-
end
|
189
|
-
|
190
|
-
private
|
191
|
-
|
192
|
-
def sym(name, interface)
|
193
|
-
@@lib[name, interface]
|
194
|
-
end
|
195
|
-
|
196
|
-
def call_IX(sym_name, func_name, format, arg1)
|
197
|
-
sym_name = sym(func_name, format) if sym_name == nil
|
198
|
-
r,rs = sym_name.call(arg1)
|
199
|
-
raise Phidgets::Exception.new(r) if r != 0
|
200
|
-
end
|
201
|
-
|
202
|
-
def call_IXX(sym_name, func_name, format, arg1, arg2)
|
203
|
-
sym_name = sym(func_name, format) if sym_name == nil
|
204
|
-
r,rs = sym_name.call(arg1, arg2)
|
205
|
-
raise Phidgets::Exception.new(r) if r != 0
|
206
|
-
end
|
207
|
-
|
208
|
-
def call_IXXX(sym_name, func_name, format, arg1, arg2, arg3)
|
209
|
-
sym_name = sym(func_name, format) if sym_name == nil
|
210
|
-
r,rs = sym_name.call(arg1, arg2, arg3)
|
211
|
-
raise Phidgets::Exception.new(r) if r != 0
|
212
|
-
end
|
213
|
-
|
214
|
-
def call_IXXXX(sym_name, func_name, format, arg1, arg2, arg3, arg4)
|
215
|
-
sym_name = sym(func_name, format) if sym_name == nil
|
216
|
-
r,rs = sym_name.call(arg1, arg2, arg3, arg4)
|
217
|
-
raise Phidgets::Exception.new(r) if r != 0
|
218
|
-
end
|
219
|
-
|
220
|
-
def call_IXXXXX(sym_name, func_name, format, arg1, arg2, arg3, arg4, arg5)
|
221
|
-
sym_name = sym(func_name, format) if sym_name == nil
|
222
|
-
r,rs = sym_name.call(arg1, arg2, arg3, arg4, arg5)
|
223
|
-
raise Phidgets::Exception.new(r) if r != 0
|
224
|
-
end
|
225
|
-
|
226
|
-
def call_IPi(sym_name, func_name, arg1)
|
227
|
-
sym_name = sym(func_name, 'IPi') if sym_name == nil
|
228
|
-
return_arg = 0
|
229
|
-
r,rs = sym_name.call(arg1, return_arg)
|
230
|
-
raise Phidgets::Exception.new(r) if r != 0
|
231
|
-
rs[1]
|
232
|
-
end
|
233
|
-
|
234
|
-
def call_IPIi(sym_name, func_name, arg1, arg2)
|
235
|
-
sym_name = sym(func_name, 'IPIi') if sym_name == nil
|
236
|
-
return_arg = 0
|
237
|
-
r,rs = sym_name.call(arg1, arg2, return_arg)
|
238
|
-
raise Phidgets::Exception.new(r) if r != 0
|
239
|
-
rs[2]
|
240
|
-
end
|
241
|
-
|
242
|
-
def call_IPs(sym_name, func_name, arg1)
|
243
|
-
sym_name = sym(func_name, 'IPp') if sym_name == nil
|
244
|
-
arg_ptr = DL.malloc(DL.sizeof('P'))
|
245
|
-
r,rs = sym_name.call(arg1, arg_ptr.ref)
|
246
|
-
raise Phidgets::Exception.new(r) if r != 0
|
247
|
-
arg_ptr.free = nil
|
248
|
-
arg_ptr.to_s
|
249
|
-
end
|
250
|
-
|
251
|
-
def createCallback(callback)
|
252
|
-
DL.callback('IPP') {|handle,data|
|
253
|
-
data = ObjectSpace._id2ref(data.to_i)
|
254
|
-
eval("#{callback}(data)")
|
255
|
-
}
|
256
|
-
end
|
257
|
-
|
258
|
-
def createErrorCallback(callback)
|
259
|
-
DL.callback('IPPIS') {|handle,data,error_code,error_string|
|
260
|
-
data = ObjectSpace._id2ref(data.to_i)
|
261
|
-
eval("#{callback}(data,error_code,error_string)")
|
262
|
-
}
|
263
|
-
end
|
264
|
-
|
265
|
-
public
|
266
|
-
|
267
|
-
def Common.setLibName(name)
|
268
|
-
@@libname = name
|
269
202
|
end
|
270
203
|
|
204
|
+
# Opens a Phidget remotely by ServerID. Note that this requires Bonjour (mDNS) to be running on both the host and the server.
|
271
205
|
def openRemote(serial_number=-1, server=nil, password=nil, timeout=0)
|
272
|
-
|
206
|
+
r = cPhidget_openRemote(@handle, serial_number, server, password)
|
207
|
+
raise Phidgets::Exception.new(r) if r != 0
|
273
208
|
waitForAttachment(timeout) if timeout > 0
|
274
209
|
end
|
275
210
|
|
211
|
+
# Opens a Phidget remotely by address and port.
|
276
212
|
def openRemoteIP(serial_number, address, port=5001, password=nil, timeout=0)
|
277
|
-
|
213
|
+
r = cPhidget_openRemoteIP(@handle, serial_number, address, port, password)
|
214
|
+
raise Phidgets::Exception.new(r) if r != 0
|
278
215
|
waitForAttachment(timeout) if timeout > 0
|
279
216
|
end
|
280
217
|
|
218
|
+
# Opens a Phidget.
|
281
219
|
def open(serial_number=-1, timeout=0)
|
282
|
-
|
220
|
+
r = Phidgets.cPhidget_open(@handle, serial_number)
|
221
|
+
raise Phidgets::Exception.new(r) if r != 0
|
283
222
|
waitForAttachment(timeout) if timeout > 0
|
284
223
|
end
|
285
224
|
|
225
|
+
# Closes a Phidget.
|
286
226
|
def close
|
287
|
-
|
227
|
+
r = Phidgets.cPhidget_close(@handle)
|
228
|
+
raise Phidgets::Exception.new(r) if r != 0
|
288
229
|
end
|
289
230
|
|
231
|
+
# Frees a Phidget handle.
|
290
232
|
def delete
|
291
233
|
@handle.free = nil
|
292
|
-
|
234
|
+
r = Phidgets.cPhidget_delete(@handle)
|
235
|
+
raise Phidgets::Exception.new(r) if r != 0
|
293
236
|
end
|
294
237
|
|
238
|
+
# Sets a detach handler callback function. This is called when this Phidget is unplugged from the system.
|
295
239
|
def setOnDetachHandler(callback, data)
|
296
|
-
|
240
|
+
r = Phidgets.cPhidget_set_OnDetach_Handler(@handle, createCallback(callback), DL::PtrData.new(data.object_id))
|
241
|
+
raise Phidgets::Exception.new(r) if r != 0
|
297
242
|
end
|
298
243
|
|
244
|
+
# Sets an attach handler callback function. This is called when this Phidget is plugged into the system, and is ready for use.
|
299
245
|
def setOnAttachHandler(callback, data)
|
300
|
-
|
246
|
+
r = Phidgets.cPhidget_set_OnAttach_Handler(@handle, createCallback(callback), DL::PtrData.new(data.object_id))
|
247
|
+
raise Phidgets::Exception.new(r) if r != 0
|
301
248
|
end
|
302
249
|
|
250
|
+
# Sets a server connect handler callback function. This is used for opening Phidgets remotely, and is called when a connection to the sever has been made.
|
303
251
|
def setOnConnectHandler(callback, data)
|
304
|
-
|
252
|
+
r = Phidgets.cPhidget_set_OnServerConnect_Handler(@handle, createCallback(callback), DL::PtrData.new(data.object_id))
|
253
|
+
raise Phidgets::Exception.new(r) if r != 0
|
305
254
|
end
|
306
255
|
|
256
|
+
# Sets a server disconnect handler callback function. This is used for opening Phidgets remotely, and is called when a connection to the server has been lost.
|
307
257
|
def setOnDisconnectHandler(callback, data)
|
308
|
-
|
258
|
+
r = Phidgets.cPhidget_set_OnServerDisconnect_Handler(@handle, createCallback(callback), DL::PtrData.new(data.object_id))
|
259
|
+
raise Phidgets::Exception.new(r) if r != 0
|
309
260
|
end
|
310
261
|
|
262
|
+
# Sets the error handler callback function. This is called when an asynchronous error occurs.
|
311
263
|
def setOnErrorHandler(callback, data)
|
312
|
-
|
264
|
+
r = Phidgets.cPhidget_set_OnError_Handler(@handle, createErrorCallback(callback), DL::PtrData.new(data.object_id))
|
265
|
+
raise Phidgets::Exception.new(r) if r != 0
|
313
266
|
end
|
314
267
|
|
268
|
+
# Gets the specific name of a Phidget.
|
315
269
|
def getDeviceName
|
316
|
-
|
270
|
+
ptr = DL.malloc(DL.sizeof('P'))
|
271
|
+
r = Phidgets.cPhidget_getDeviceName(@handle, ptr.ref)
|
272
|
+
raise Phidgets::Exception.new(r) if r != 0
|
273
|
+
ptr.free = nil
|
274
|
+
ptr.to_s
|
317
275
|
end
|
318
276
|
|
277
|
+
# Gets the serial number of a Phidget.
|
319
278
|
def getSerialNumber
|
320
|
-
|
279
|
+
sn = DL.malloc(DL.sizeof('I'))
|
280
|
+
r = Phidgets.cPhidget_getSerialNumber(@handle, sn.ref)
|
281
|
+
raise Phidgets::Exception.new(r) if r != 0
|
282
|
+
sn.free = nil
|
283
|
+
sn.to_i
|
321
284
|
end
|
322
285
|
|
286
|
+
# Gets the firmware version of a Phidget.
|
323
287
|
def getDeviceVersion
|
324
|
-
|
288
|
+
ver = DL.malloc(DL.sizeof('I'))
|
289
|
+
r = Phidgets.cPhidget_getDeviceVersion(@handle, ver.ref)
|
290
|
+
raise Phidgets::Exception.new(r) if r != 0
|
291
|
+
ver.free = nil
|
292
|
+
ver.to_i
|
325
293
|
end
|
326
294
|
|
295
|
+
# Gets the attached status of a Phidget.
|
327
296
|
def getDeviceStatus
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
def getLibraryVersion
|
332
|
-
@@lib_version = sym('CPhidget_getLibraryVersion', 'Ip') if @@lib_version == nil
|
333
|
-
lib_version_ptr = DL.malloc(DL.sizeof('P'))
|
334
|
-
r,rs = @@lib_version.call(lib_version_ptr.ref)
|
297
|
+
stat = DL.malloc(DL.sizeof('I'))
|
298
|
+
r = Phidgets.cPhidget_getDeviceStatus(@handle, stat.ref)
|
335
299
|
raise Phidgets::Exception.new(r) if r != 0
|
336
|
-
|
337
|
-
|
300
|
+
stat.free = nil
|
301
|
+
stat.to_i
|
338
302
|
end
|
339
303
|
|
304
|
+
# Gets the type (class) of a Phidget.
|
340
305
|
def getDeviceType
|
341
|
-
|
306
|
+
ptr = DL.malloc(DL.sizeof('P'))
|
307
|
+
r = Phidgets.cPhidget_getDeviceType(@handle, ptr.ref)
|
308
|
+
raise Phidgets::Exception.new(r) if r != 0
|
309
|
+
ptr.free = nil
|
310
|
+
ptr.to_s
|
342
311
|
end
|
343
312
|
|
313
|
+
# Gets the label of a Phidget.
|
344
314
|
def getDeviceLabel
|
345
|
-
|
315
|
+
ptr = DL.malloc(DL.sizeof('P'))
|
316
|
+
r = Phidgets.cPhidget_getDeviceLabel(@handle, ptr.ref)
|
317
|
+
raise Phidgets::Exception.new(r) if r != 0
|
318
|
+
ptr.free = nil
|
319
|
+
ptr.to_s
|
346
320
|
end
|
347
321
|
|
322
|
+
# Sets the label of a Phidget. Note that this is nut supported on very old Phidgets, and not yet supported in Windows.
|
348
323
|
def setDeviceLabel(label)
|
349
|
-
|
350
|
-
end
|
351
|
-
|
352
|
-
def getErrorDescription(error_code)
|
353
|
-
@@error_description = sym('CPhidget_getErrorDescription', 'IIp') if @@error_description == nil
|
354
|
-
error_description_ptr = DL.malloc(DL.sizeof('P'))
|
355
|
-
r,rs = @@error_description.call(error_code, error_description_ptr.ref)
|
324
|
+
r = Phidgets.cPhidget_setDeviceLabel(@handle, label)
|
356
325
|
raise Phidgets::Exception.new(r) if r != 0
|
357
|
-
error_description_ptr.free = nil
|
358
|
-
error_description_ptr.to_s
|
359
326
|
end
|
360
327
|
|
328
|
+
# Waits for attachment to happen. This can be called wirght after calling CPhidget_open, as an alternative to using the attach handler.
|
361
329
|
def waitForAttachment(timeout)
|
362
|
-
|
330
|
+
r = Phidgets.cPhidget_waitForAttachment(@handle, timeout)
|
331
|
+
raise Phidgets::Exception.new(r) if r != 0
|
363
332
|
end
|
364
333
|
|
334
|
+
# Gets the server ID of a remotely opened Phidget. This will fail if the Phidget was opened locally.
|
365
335
|
def getServerID
|
366
|
-
|
336
|
+
ptr = DL.malloc(DL.sizeof('P'))
|
337
|
+
r = Phidgets.cPhidget_getServerID(@handle, ptr.ref)
|
338
|
+
raise Phidgets::Exception.new(r) if r != 0
|
339
|
+
ptr.free = nil
|
340
|
+
ptr.to_s
|
367
341
|
end
|
368
342
|
|
343
|
+
# Gets the address and port of a remotely opened Phidget. This will fail if the Phidget was opened locally.
|
369
344
|
def getServerAddress
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
r,rs = @@server_addr.call(@handle, server_addr_ptr.ref, server_port)
|
345
|
+
ptr = DL.malloc(DL.sizeof('P'))
|
346
|
+
port = DL.malloc(DL.sizeof('I'))
|
347
|
+
r = Phidgets.cPhidget_getServerAddress(@handle, ptr.ref, port.ref)
|
374
348
|
raise Phidgets::Exception.new(r) if r != 0
|
375
|
-
|
376
|
-
|
377
|
-
|
349
|
+
ptr.free = nil
|
350
|
+
port.free = nil
|
351
|
+
[ptr.to_s, port.to_i]
|
378
352
|
end
|
379
353
|
|
354
|
+
# Gets the connected to server status of a remotely opened Phidget. This will fail if the Phidget was opened locally.
|
380
355
|
def getServerStatus
|
381
|
-
|
356
|
+
stat = DL.malloc(DL.sizeof('I'))
|
357
|
+
r = Phidgets.cPhidget_getServerStatus(@handle, stat.ref)
|
358
|
+
raise Phidgets::Exception.new(r) if r != 0
|
359
|
+
stat.free = nil
|
360
|
+
stat.to_i
|
382
361
|
end
|
383
362
|
|
363
|
+
# Gets the device ID of a Phidget.
|
384
364
|
def getDeviceID
|
385
|
-
|
365
|
+
dev = DL.malloc(DL.sizeof('I'))
|
366
|
+
r = Phidgets.cPhidget_getDeviceID(@handle, dev.ref)
|
367
|
+
raise Phidgets::Exception.new(r) if r != 0
|
368
|
+
dev.free = nil
|
369
|
+
dev.to_i
|
386
370
|
end
|
387
371
|
|
372
|
+
# Gets the class of a Phidget.
|
388
373
|
def getDeviceClass
|
389
|
-
|
374
|
+
dev = DL.malloc(DL.sizeof('I'))
|
375
|
+
r = Phidgets.cPhidget_getDeviceClass(@handle, dev.ref)
|
376
|
+
raise Phidgets::Exception.new(r) if r != 0
|
377
|
+
dev.free = nil
|
378
|
+
dev.to_i
|
379
|
+
end
|
380
|
+
|
381
|
+
|
382
|
+
private
|
383
|
+
|
384
|
+
def createCallback(callback)
|
385
|
+
DL.callback('IPP') {|handle,data|
|
386
|
+
data = ObjectSpace._id2ref(data.to_i)
|
387
|
+
eval("#{callback}(data)")
|
388
|
+
}
|
389
|
+
end
|
390
|
+
|
391
|
+
def createErrorCallback(callback)
|
392
|
+
DL.callback('IPPIS') {|handle,data,error_code,error_string|
|
393
|
+
data = ObjectSpace._id2ref(data.to_i)
|
394
|
+
eval("#{callback}(data,error_code,error_string)")
|
395
|
+
}
|
390
396
|
end
|
391
397
|
|
392
398
|
end
|
@@ -1,20 +1,21 @@
|
|
1
1
|
|
2
|
-
#require 'phidgets/common'
|
3
2
|
|
4
3
|
module Phidgets
|
5
4
|
|
5
|
+
extern "int CPhidgetInterfaceKit_create(void *)"
|
6
|
+
extern "int CPhidgetInterfaceKit_getInputCount(void *, int *)"
|
7
|
+
extern "int CPhidgetInterfaceKit_getInputState(void *, int, int *)"
|
8
|
+
extern "int CPhidgetInterfaceKit_getOutputCount(void *, int *)"
|
9
|
+
extern "int CPhidgetInterfaceKit_getOutputState(void *, int, int *)"
|
10
|
+
extern "int CPhidgetInterfaceKit_setOutputState(void *, int, int)"
|
11
|
+
extern "int CPhidgetInterfaceKit_getSensorCount(void *, int *)"
|
12
|
+
extern "int CPhidgetInterfaceKit_getSensorValue(void *, int, int *)"
|
13
|
+
extern "int CPhidgetInterfaceKit_getSensorRawValue(void *, int, int *)"
|
14
|
+
extern "int CPhidgetInterfaceKit_getRatiometric(void *, int *)"
|
15
|
+
extern "int CPhidgetInterfaceKit_setRatiometric(void *, int)"
|
16
|
+
|
17
|
+
|
6
18
|
class InterfaceKit < Common
|
7
|
-
@@create = nil
|
8
|
-
@@input_count = nil
|
9
|
-
@@input_state = nil
|
10
|
-
@@output_count = nil
|
11
|
-
@@get_output_state = nil
|
12
|
-
@@set_output_state = nil
|
13
|
-
@@sensor_count = nil
|
14
|
-
@@sensor_value = nil
|
15
|
-
@@sensor_raw_value = nil
|
16
|
-
@@get_ratiometric = nil
|
17
|
-
@@set_ratiometric = nil
|
18
19
|
|
19
20
|
def initialize(serial_number=-1, timeout=0)
|
20
21
|
super()
|
@@ -22,54 +23,97 @@ module Phidgets
|
|
22
23
|
open(serial_number, timeout) if timeout > 0
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
def create
|
28
|
-
@@create = sym('CPhidgetInterfaceKit_create', 'Ip') if @@create == nil
|
29
|
-
r,rs = @@create.call(@handle.ref)
|
30
|
-
raise Phidgets::Exception.new(r) if r != 0
|
31
|
-
end
|
32
|
-
|
33
|
-
public
|
34
|
-
|
26
|
+
# Gets the number of digital inputs supported by this board.
|
35
27
|
def getInputCount
|
36
|
-
|
28
|
+
cnt = DL.malloc(DL.sizeof('I'))
|
29
|
+
r = Phidgets.cPhidgetInterfaceKit_getInputCount(@handle, cnt.ref)
|
30
|
+
raise Phidgets::Exception.new(r) if r != 0
|
31
|
+
cnt.free = nil
|
32
|
+
cnt.to_i
|
37
33
|
end
|
38
34
|
|
35
|
+
# Gets the state of a digital input.
|
39
36
|
def getInputState(index)
|
40
|
-
|
37
|
+
state = DL.malloc(DL.sizeof('I'))
|
38
|
+
r = Phidgets.cPhidgetInterfaceKit_getInputState(@handle, index, state.ref)
|
39
|
+
raise Phidgets::Exception.new(r) if r != 0
|
40
|
+
state.free = nil
|
41
|
+
state.to_i
|
41
42
|
end
|
42
43
|
|
44
|
+
# Gets the number of digital outputs supported by this board.
|
43
45
|
def getOutputCount
|
44
|
-
|
46
|
+
cnt = DL.malloc(DL.sizeof('I'))
|
47
|
+
r = Phidgets.cPhidgetInterfaceKit_getOutputCount(@handle, cnt.ref)
|
48
|
+
raise Phidgets::Exception.new(r) if r != 0
|
49
|
+
cnt.free = nil
|
50
|
+
cnt.to_i
|
45
51
|
end
|
46
52
|
|
53
|
+
# Gets the state of a digital output.
|
47
54
|
def getOutputState(index)
|
48
|
-
|
55
|
+
state = DL.malloc(DL.sizeof('I'))
|
56
|
+
r = Phidgets.cPhidgetInterfaceKit_getOutputState(@handle, index, state.ref)
|
57
|
+
raise Phidgets::Exception.new(r) if r != 0
|
58
|
+
state.free = nil
|
59
|
+
state.to_i
|
49
60
|
end
|
50
61
|
|
62
|
+
# Sets the state of a digital output.
|
51
63
|
def setOutputState(index, state)
|
52
|
-
|
64
|
+
r = Phidgets.cPhidgetInterfaceKit_setOutputState(@handle, index, state)
|
65
|
+
raise Phidgets::Exception.new(r) if r != 0
|
53
66
|
end
|
54
67
|
|
68
|
+
# Gets the number of sensor (analog) inputs supported by this board.
|
55
69
|
def getSensorCount
|
56
|
-
|
70
|
+
cnt = DL.malloc(DL.sizeof('I'))
|
71
|
+
r = Phidgets.cPhidgetInterfaceKit_getSensorCount(@handle, cnt.ref)
|
72
|
+
raise Phidgets::Exception.new(r) if r != 0
|
73
|
+
cnt.free = nil
|
74
|
+
cnt.to_i
|
57
75
|
end
|
58
76
|
|
77
|
+
# Gets a sensor value (0-1000).
|
59
78
|
def getSensorValue(index)
|
60
|
-
|
79
|
+
state = DL.malloc(DL.sizeof('I'))
|
80
|
+
r = Phidgets.cPhidgetInterfaceKit_getSensorValue(@handle, index, state.ref)
|
81
|
+
raise Phidgets::Exception.new(r) if r != 0
|
82
|
+
state.free = nil
|
83
|
+
state.to_i
|
61
84
|
end
|
62
85
|
|
86
|
+
# Gets a sensor raw value (12-bit).
|
63
87
|
def getSensorRawValue(index)
|
64
|
-
|
88
|
+
state = DL.malloc(DL.sizeof('I'))
|
89
|
+
r = Phidgets.cPhidgetInterfaceKit_getSensorRawValue(@handle, index, state.ref)
|
90
|
+
raise Phidgets::Exception.new(r) if r != 0
|
91
|
+
state.free = nil
|
92
|
+
state.to_i
|
65
93
|
end
|
66
94
|
|
95
|
+
# Gets the ratiometric state for this board.
|
67
96
|
def getRatiometric
|
68
|
-
|
97
|
+
ratio = DL.malloc(DL.sizeof('I'))
|
98
|
+
r = Phidgets.cPhidgetInterfaceKit_getRatiometric(@handle, ratio.ref)
|
99
|
+
raise Phidgets::Exception.new(r) if r != 0
|
100
|
+
ratio.free = nil
|
101
|
+
ratio.to_i
|
69
102
|
end
|
70
103
|
|
104
|
+
# Sets the ratiometric state for this board.
|
71
105
|
def setRatiometric(ratiometric)
|
72
|
-
|
106
|
+
r = Phidgets.cPhidgetInterfaceKit_setRatiometric(@handle, ratiometric)
|
107
|
+
raise Phidgets::Exception.new(r) if r != 0
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
# Creates a Phidget InterfaceKit handle.
|
114
|
+
def create
|
115
|
+
r = Phidgets.cPhidgetInterfaceKit_create(@handle.ref)
|
116
|
+
raise Phidgets::Exception.new(r) if r != 0
|
73
117
|
end
|
74
118
|
|
75
119
|
end
|
data/lib/phidgets/rfid.rb
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
|
2
|
-
#require 'phidgets/common'
|
3
2
|
|
4
3
|
module Phidgets
|
5
4
|
|
5
|
+
extern "int CPhidgetRFID_create(void *)"
|
6
|
+
extern "int CPhidgetRFID_getOutputCount(void *, int *)"
|
7
|
+
extern "int CPhidgetRFID_getOutputState(void *, int, int *)"
|
8
|
+
extern "int CPhidgetRFID_setOutputState(void *, int *)"
|
9
|
+
extern "int CPhidgetRFID_getAntennaOn(void *, int, int *)"
|
10
|
+
extern "int CPhidgetRFID_setAntennaOn(void *, int, int)"
|
11
|
+
extern "int CPhidgetRFID_getLEDOn(void *, int *)"
|
12
|
+
extern "int CPhidgetRFID_setLEDOn(void *, int, int *)"
|
13
|
+
extern "int CPhidgetRFID_getLastTag(void *, int, int *)"
|
14
|
+
extern "int CPhidgetRFID_getTagStatus(void *, int *)"
|
15
|
+
extern "int CPhidgetRFID_set_OnTag_Handler(void *, int)"
|
16
|
+
extern "int CPhidgetRFID_set_OnTagLost_Handler(void *, int)"
|
17
|
+
|
18
|
+
|
6
19
|
class RFID < Common
|
7
|
-
@@create = nil
|
8
|
-
@@output_count = nil
|
9
|
-
@@get_output_state = nil
|
10
|
-
@@set_output_state = nil
|
11
|
-
@@get_antenna_on = nil
|
12
|
-
@@set_antenna_on = nil
|
13
|
-
@@get_led_on = nil
|
14
|
-
@@set_led_on = nil
|
15
|
-
@@get_last_tag = nil
|
16
|
-
@@get_tag_status = nil
|
17
|
-
@@on_tag_handler = nil
|
18
|
-
@@tag_lost_handler = nil
|
19
20
|
|
20
21
|
def initialize(serial_number=-1, timeout=0)
|
21
22
|
super()
|
@@ -23,58 +24,84 @@ module Phidgets
|
|
23
24
|
open(serial_number, timeout) if timeout > 0
|
24
25
|
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
def create
|
29
|
-
@@create = sym('CPhidgetRFID_create', 'Ip') if @@create == nil
|
30
|
-
r,rs = @@create.call(@handle.ref)
|
31
|
-
raise Phidgets::Exception.new(r) if r != 0
|
32
|
-
end
|
33
|
-
|
34
|
-
public
|
35
|
-
|
27
|
+
# Gets the number of outputs supported by this board.
|
36
28
|
def getOutputCount
|
37
|
-
|
29
|
+
cnt = DL.malloc(DL.sizeof('I'))
|
30
|
+
r = Phidgets.cPhidgetRFID_getOutputCount(@handle, cnt.ref)
|
31
|
+
raise Phidgets::Exception.new(r) if r != 0
|
32
|
+
cnt.free = nil
|
33
|
+
cnt.to_i
|
38
34
|
end
|
39
35
|
|
36
|
+
# Gets the state of an output.
|
40
37
|
def getOutputState(index)
|
41
|
-
|
38
|
+
state = DL.malloc(DL.sizeof('I'))
|
39
|
+
r = Phidgets.cPhidgetRFID_getOutputState(@handle, index, state.ref)
|
40
|
+
raise Phidgets::Exception.new(r) if r != 0
|
41
|
+
state.free = nil
|
42
|
+
state.to_i
|
42
43
|
end
|
43
44
|
|
45
|
+
# Sets the state of an output.
|
44
46
|
def setOutputState(index, state)
|
45
|
-
|
47
|
+
r = Phidgets.cPhidgetRFID_setOutputState(@handle, index, state)
|
48
|
+
raise Phidgets::Exception.new(r) if r != 0
|
46
49
|
end
|
47
50
|
|
51
|
+
# Gets the state of the antenna.
|
48
52
|
def getAntennaOn
|
49
|
-
|
53
|
+
state = DL.malloc(DL.sizeof('I'))
|
54
|
+
r = Phidgets.cPhidgetRFID_getAntennaOn(@handle, state.ref)
|
55
|
+
raise Phidgets::Exception.new(r) if r != 0
|
56
|
+
state.free = nil
|
57
|
+
state.to_i
|
50
58
|
end
|
51
59
|
|
60
|
+
# Sets the state of the antenna. Note that the antenna must be enabled before tags will be read.
|
52
61
|
def setAntennaOn(state)
|
53
|
-
|
62
|
+
r = Phidgets.cPhidgetRFID_setAntennaOn(@handle, state)
|
63
|
+
raise Phidgets::Exception.new(r) if r != 0
|
54
64
|
end
|
55
65
|
|
66
|
+
# Gets the state of the onboard LED.
|
56
67
|
def getLedOn
|
57
|
-
|
68
|
+
state = DL.malloc(DL.sizeof('I'))
|
69
|
+
r = Phidgets.cPhidgetRFID_getLEDOn(@handle, state.ref)
|
70
|
+
raise Phidgets::Exception.new(r) if r != 0
|
71
|
+
state.free = nil
|
72
|
+
state.to_i
|
58
73
|
end
|
59
74
|
|
75
|
+
# Sets the state of the onboard LED.
|
60
76
|
def setLedOn(state)
|
61
|
-
|
77
|
+
r = Phidgets.cPhidgetRFID_setLEDOn(@handle, state)
|
78
|
+
raise Phidgets::Exception.new(r) if r != 0
|
62
79
|
end
|
63
80
|
|
81
|
+
# Gets the last tag read by the reader. This tag may or may not still be on the reader.
|
64
82
|
def getLastTag
|
65
|
-
|
83
|
+
tag = DL.malloc(5)
|
84
|
+
r = Phidgets.cPhidgetRFID_getLastTag(@handle, tag)
|
85
|
+
raise Phidgets::Exception.new(r) if r != 0
|
86
|
+
tag
|
66
87
|
end
|
67
88
|
|
89
|
+
# Gets the tag present status. This is whether or not a tag is being read by the reader.
|
68
90
|
def getTagStatus
|
69
|
-
|
91
|
+
stat = DL.malloc(DL.sizeof('I'))
|
92
|
+
r = Phidgets.cPhidgetRFID_getTagStatus(@handle, stat.ref)
|
93
|
+
raise Phidgets::Exception.new(r) if r != 0
|
94
|
+
stat.free = nil
|
95
|
+
stat.to_i
|
70
96
|
end
|
71
97
|
|
72
|
-
def setOnTagHandler(callback, data)
|
73
|
-
call_IXXX(@@on_tag_handler, 'CPhidgetRFID_set_OnTag_Handler', 'IPPP', @handle, createCallback(callback), DL::PtrData.new(data.object_id))
|
74
|
-
end
|
75
98
|
|
76
|
-
|
77
|
-
|
99
|
+
private
|
100
|
+
|
101
|
+
# Creates a Phidget RFID handle.
|
102
|
+
def create
|
103
|
+
r = Phidgets.cPhidgetRFID_create(@handle.ref)
|
104
|
+
raise Phidgets::Exception.new(r) if r != 0
|
78
105
|
end
|
79
106
|
|
80
107
|
end
|
data/test/test_interfacekit.rb
CHANGED
@@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
3
3
|
class TestPhidgetsInterfaceKit < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
sleep 1
|
7
6
|
end
|
8
7
|
|
9
8
|
def test_001_create
|
@@ -22,10 +21,10 @@ class TestPhidgetsInterfaceKit < Test::Unit::TestCase
|
|
22
21
|
end
|
23
22
|
|
24
23
|
def test_003_fail_attach
|
25
|
-
|
24
|
+
assert_raise Phidgets::Exception do
|
26
25
|
ik = Phidgets::InterfaceKit.new(1, 2000)
|
27
26
|
ik.delete
|
28
|
-
|
27
|
+
end
|
29
28
|
end
|
30
29
|
|
31
30
|
def test_004_get_device_name
|
data/test/test_phidgets.rb
CHANGED
@@ -1,2 +1,15 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestPhidgets < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_library_version
|
9
|
+
lib_ver = ""
|
10
|
+
assert_nothing_raised {
|
11
|
+
lib_ver = Phidgets.getLibraryVersion
|
12
|
+
}
|
13
|
+
assert lib_ver.split[0] == "Phidget21"
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phidgets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig DeHaan
|
@@ -9,18 +9,18 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-06-02 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: rubyforge
|
17
17
|
type: :development
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: 2.0.4
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hoe
|
@@ -30,9 +30,11 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.6.0
|
34
34
|
version:
|
35
|
-
description:
|
35
|
+
description: |-
|
36
|
+
Phidgets are a set of "plug and play" building blocks for low cost USB sensing and control from your PC.
|
37
|
+
This gem provides a ruby interface to the phidgets library.
|
36
38
|
email:
|
37
39
|
- craig.s.dehaan@gmail.com
|
38
40
|
executables: []
|
@@ -44,7 +46,6 @@ extra_rdoc_files:
|
|
44
46
|
- History.txt
|
45
47
|
- Manifest.txt
|
46
48
|
- PostInstall.txt
|
47
|
-
- README.rdoc
|
48
49
|
files:
|
49
50
|
- GNU_GPL.txt
|
50
51
|
- History.txt
|
@@ -64,6 +65,8 @@ files:
|
|
64
65
|
- test/test_interfacekit.rb
|
65
66
|
has_rdoc: true
|
66
67
|
homepage: http://phidgets.rubyforge.org
|
68
|
+
licenses: []
|
69
|
+
|
67
70
|
post_install_message: PostInstall.txt
|
68
71
|
rdoc_options:
|
69
72
|
- --main
|
@@ -85,11 +88,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
88
|
requirements: []
|
86
89
|
|
87
90
|
rubyforge_project: phidgets
|
88
|
-
rubygems_version: 1.3.
|
91
|
+
rubygems_version: 1.3.5
|
89
92
|
signing_key:
|
90
|
-
specification_version:
|
93
|
+
specification_version: 3
|
91
94
|
summary: Phidgets are a set of "plug and play" building blocks for low cost USB sensing and control from your PC
|
92
95
|
test_files:
|
93
|
-
- test/test_interfacekit.rb
|
94
96
|
- test/test_phidgets.rb
|
95
97
|
- test/test_helper.rb
|
98
|
+
- test/test_interfacekit.rb
|