hid_api 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hid_api/device.rb +11 -4
- data/lib/hid_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bec3d023bb6aff34ad5546a6d3d251c09ac8843
|
4
|
+
data.tar.gz: 7274f344c0fbc04263e5df8173448f1024753c44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9702dd5834be34f41318d4f7bc16884cc527fe86822b5d3ce2e516ae0a42df0dc500a3bff1b91024568833c9f3738528aba9c4e1395a2ab928407928d4ad88b
|
7
|
+
data.tar.gz: db3451def500983a7516cee86fba247a2ae8fbc9c71c68d93b5dcdfe0fdb45d99e841953fa7c00da60ab8c48f6b4c1fbc4de3fc1dcb68795835303ad7205415e
|
data/lib/hid_api/device.rb
CHANGED
@@ -30,7 +30,7 @@ module HidApi
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def read(length)
|
33
|
-
buffer =
|
33
|
+
buffer = clear_buffer length
|
34
34
|
with_hid_error_handling do
|
35
35
|
HidApi.hid_read self, buffer, buffer.length
|
36
36
|
end
|
@@ -38,7 +38,7 @@ module HidApi
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def read_timeout(length, timeout)
|
41
|
-
buffer =
|
41
|
+
buffer = clear_buffer length
|
42
42
|
with_hid_error_handling do
|
43
43
|
HidApi.hid_read_timeout self, buffer, buffer.length, timeout
|
44
44
|
end
|
@@ -46,7 +46,7 @@ module HidApi
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def write(data)
|
49
|
-
buffer =
|
49
|
+
buffer = clear_buffer data.length
|
50
50
|
case data
|
51
51
|
when String then buffer.put_bytes 0, data
|
52
52
|
when Array then buffer.put_array_of_char 0, data
|
@@ -72,8 +72,15 @@ module HidApi
|
|
72
72
|
end
|
73
73
|
|
74
74
|
private
|
75
|
+
def clear_buffer length
|
76
|
+
b = FFI::Buffer.new(1, length)
|
77
|
+
# FFI::Buffer doesn't clear the first byte if length < 8
|
78
|
+
b.put_char 0, 0
|
79
|
+
b
|
80
|
+
end
|
81
|
+
|
75
82
|
def get_buffered_string field
|
76
|
-
buffer =
|
83
|
+
buffer = clear_buffer 255
|
77
84
|
HidApi.send "hid_get_#{field}_string", self, buffer, buffer.length
|
78
85
|
buffer.read_wchar_string
|
79
86
|
end
|
data/lib/hid_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hid_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gareth Adams
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|