go_easy_btn 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/go_easy_btn +17 -6
- data/lib/go_easy_btn.rb +3 -4
- metadata +2 -2
data/bin/go_easy_btn
CHANGED
@@ -1,12 +1,23 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
def usage
|
4
|
+
<<-USAGE
|
5
|
+
Usage:
|
6
|
+
|
7
|
+
go_easy_btn <cmd> <device> <baud>"
|
8
|
+
|
9
|
+
Example:
|
10
|
+
go_easy_btn "say 'Im a shell script called from $(pwd)'" /dev/tty.usbmodem12341 115200
|
11
|
+
|
12
|
+
USAGE
|
13
|
+
end
|
14
|
+
|
15
|
+
if ARGV[0].nil? || ARGV[0] == ''
|
16
|
+
puts usage
|
17
|
+
exit false
|
18
|
+
end
|
8
19
|
|
9
20
|
require 'go_easy_btn'
|
10
21
|
|
11
|
-
btn =
|
22
|
+
btn = GoEasyButton.new :cmd => ARGV[0], :dev => (ARGV[1] || '/dev/tty.usbmodem12341'), :baud => ARGV[2]
|
12
23
|
btn.make_it_easy
|
data/lib/go_easy_btn.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'serialport'
|
3
|
-
require
|
3
|
+
require 'alerter'
|
4
4
|
|
5
|
-
class
|
5
|
+
class GoEasyButton
|
6
6
|
BTN_COMMAND = 'PRESSED'
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
9
|
raise 'not found serial port has been' unless File.exists? options[:dev]
|
10
|
-
raise ':cmd must be something!' if options[:cmd].nil? || options[:cmd] == ''
|
11
10
|
@cmd = options[:cmd]
|
12
11
|
@device = options[:dev]
|
13
|
-
@port = options[:
|
12
|
+
@port = options[:baud] || 115200
|
14
13
|
@count = 0
|
15
14
|
@start_time = Time.now
|
16
15
|
end
|