urix-util 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/urix/urix.rb +24 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4eed6302afb3c5e6a605b32635cc53cab47fb801
|
4
|
+
data.tar.gz: 48998e0941c8eaf0ec9a87cf9e8394200525008b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eef2006b79653a1845ebc53edfe13618ed3e1cd4e5e6e0e3141c32d6a33ac0c844f30e4ab459fa18be6cafbad4e5d311ec4f1c53aa0498f938144bc8fc49fc79
|
7
|
+
data.tar.gz: 9b32964c7dfcf4d9a6b95ff0788d5a9b81ae84f9c2af162eb2f1e34fa2808cc831085d34b6b4374fdb654e66565bfe7636511316f5042d89828f969222d65990
|
data/lib/urix/urix.rb
CHANGED
@@ -9,6 +9,8 @@ module URIx
|
|
9
9
|
attr :usb, :device, :handle
|
10
10
|
attr_reader :pin_states, :pin_modes, :claimed
|
11
11
|
|
12
|
+
|
13
|
+
# Creates a new URIx interface.
|
12
14
|
def initialize
|
13
15
|
@usb = LIBUSB::Context.new
|
14
16
|
@pin_states = 0x0
|
@@ -18,6 +20,9 @@ module URIx
|
|
18
20
|
set_pin_mode( PTT_PIN, :output )
|
19
21
|
end
|
20
22
|
|
23
|
+
|
24
|
+
# Claim the USB interface for this program. Must be
|
25
|
+
# called to begin using the interface.
|
21
26
|
def claim_interface
|
22
27
|
devices = usb.devices(:idVendor => VENDOR_ID, :idProduct => PRODUCT_ID)
|
23
28
|
|
@@ -32,12 +37,20 @@ module URIx
|
|
32
37
|
@handle.claim_interface( HID_INTERFACE )
|
33
38
|
end
|
34
39
|
|
40
|
+
|
41
|
+
# Closes the interface and frees it to be used by something
|
42
|
+
# else. Important to call at the end of program.
|
35
43
|
def close_interface
|
36
44
|
@handle.release_interface( HID_INTERFACE )
|
37
45
|
@handle.attach_kernel_driver(HID_INTERFACE)
|
38
46
|
@handle.close
|
39
47
|
end
|
40
48
|
|
49
|
+
|
50
|
+
# Sets the state of a GPIO pin.
|
51
|
+
#
|
52
|
+
# @param pin [Integer] ID of GPIO pin.
|
53
|
+
# @param state [Boolean] State to set pin to. True == :high
|
41
54
|
def set_output pin, state
|
42
55
|
state = false if state == :low
|
43
56
|
state = true if state == :high
|
@@ -52,6 +65,11 @@ module URIx
|
|
52
65
|
write_output
|
53
66
|
end
|
54
67
|
|
68
|
+
|
69
|
+
# Sets the mode of a GPIO pin to input or output.
|
70
|
+
#
|
71
|
+
# @param pin [Integer] ID of GPIO pin.
|
72
|
+
# @param mode [Symbol] :input or :output
|
55
73
|
def set_pin_mode pin, mode
|
56
74
|
if ( @pin_modes >> ( pin - 1 )).odd? && ( mode == :input ) or
|
57
75
|
( @pin_modes >> ( pin - 1 )).even? && ( mode == :output ) then
|
@@ -61,10 +79,16 @@ module URIx
|
|
61
79
|
end
|
62
80
|
end
|
63
81
|
|
82
|
+
|
83
|
+
# Shortcut for `set_output( PTT_PIN, state )`
|
84
|
+
#
|
85
|
+
# @param state [Boolean] State to set PTT pin to. True == :high
|
64
86
|
def set_ptt state
|
65
87
|
set_output PTT_PIN, state
|
66
88
|
end
|
67
89
|
|
90
|
+
|
91
|
+
|
68
92
|
private
|
69
93
|
def write_output
|
70
94
|
type = LIBUSB::ENDPOINT_OUT
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: urix-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Herting
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libusb
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.4'
|
27
27
|
description: A library to talk to a URIx radio interface.
|
@@ -43,12 +43,12 @@ require_paths:
|
|
43
43
|
- lib
|
44
44
|
required_ruby_version: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
@@ -58,3 +58,4 @@ signing_key:
|
|
58
58
|
specification_version: 4
|
59
59
|
summary: A library to talk to a URIx radio interface.
|
60
60
|
test_files: []
|
61
|
+
has_rdoc:
|