artoo 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99300043a8e0ea0151c2e11e169e417c3f5695f8
4
- data.tar.gz: a9e775a2e51c7fc4ee9b2a3b0d6d55c24d2baae9
3
+ metadata.gz: 1e658b80b5b9aa14f41900900289cbd09888384b
4
+ data.tar.gz: a2613c23ca45cc5a48d93326d5da716c00df6f86
5
5
  SHA512:
6
- metadata.gz: 73914f51e137d73d0a16911469b89d8f614df51c2806aafd339a0a54a06a8268b01021b77529e9fa110d5dfa46b201dc838bd34f89834add8633bf5193ff8b07
7
- data.tar.gz: d3a6b329bd46dcd87e5ef586de3489e541064723a6961583d7c3a398b9aae8817cbdcb84d93ff50df59077a95eeb512c0f6a64b659f7316e6372a48138f00426
6
+ metadata.gz: d3199bf1714b0254bea7bd409c14441b33f077bacc6e05881257603f6a9982dd8acea58e02637f29b582c795e0c65d1b5146271086640f0a6132234274c89a48
7
+ data.tar.gz: 1825a2500d229156dfdd75cb59674b48e77815b8a053b891e8adcbca64262a059ff76f22d44ccdfb7879a6c0d23a08bd13cb3eae1ffd949884d315b8be235de2
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.1.0
1
+ ruby-2.1.1
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- artoo (1.6.1)
4
+ artoo (1.6.2)
5
5
  celluloid (~> 0.15.0)
6
6
  celluloid-io (~> 0.15.0)
7
7
  multi_json (~> 1.6)
8
8
  pry (~> 0.9)
9
9
  rake
10
10
  reel (~> 0.4.0)
11
- robeaux (~> 0.0.3)
11
+ robeaux (~> 0.0.4)
12
12
  thor (~> 0.18.1)
13
13
 
14
14
  GEM
@@ -21,6 +21,7 @@ GEM
21
21
  nio4r (>= 0.5.0)
22
22
  coderay (1.1.0)
23
23
  dotenv (0.9.0)
24
+ ffi (1.9.3-java)
24
25
  foreman (0.63.0)
25
26
  dotenv (>= 0.7)
26
27
  thor (>= 0.13.6)
@@ -30,6 +31,7 @@ GEM
30
31
  http (0.5.0)
31
32
  http_parser.rb
32
33
  http_parser.rb (0.6.0)
34
+ http_parser.rb (0.6.0-java)
33
35
  json (1.7.7)
34
36
  json (1.7.7-java)
35
37
  kramdown (1.2.0)
@@ -42,10 +44,16 @@ GEM
42
44
  metaclass (~> 0.0.1)
43
45
  multi_json (1.8.4)
44
46
  nio4r (1.0.0)
47
+ nio4r (1.0.0-java)
45
48
  pry (0.9.12.4)
46
49
  coderay (~> 1.0)
47
50
  method_source (~> 0.8)
48
51
  slop (~> 3.4)
52
+ pry (0.9.12.4-java)
53
+ coderay (~> 1.0)
54
+ method_source (~> 0.8)
55
+ slop (~> 3.4)
56
+ spoon (~> 0.0)
49
57
  rake (10.1.1)
50
58
  reel (0.4.0)
51
59
  celluloid (>= 0.15.1)
@@ -54,8 +62,10 @@ GEM
54
62
  http_parser.rb (>= 0.6.0.beta.2)
55
63
  websocket_parser (>= 0.1.4)
56
64
  ref (1.0.5)
57
- robeaux (0.0.3)
65
+ robeaux (0.0.4)
58
66
  slop (3.4.7)
67
+ spoon (0.0.4)
68
+ ffi
59
69
  therubyracer (0.12.0)
60
70
  libv8 (~> 3.16.14.0)
61
71
  ref
data/artoo.gemspec CHANGED
@@ -27,5 +27,5 @@ Gem::Specification.new do |s|
27
27
  s.add_runtime_dependency 'rake'
28
28
  s.add_runtime_dependency 'pry', '~> 0.9'
29
29
  s.add_runtime_dependency 'thor', '~> 0.18.1'
30
- s.add_runtime_dependency 'robeaux', '~> 0.0.3'
30
+ s.add_runtime_dependency 'robeaux', '~> 0.0.4'
31
31
  end
data/bin/artoo CHANGED
@@ -3,10 +3,12 @@ require 'rubygems'
3
3
  require 'thor'
4
4
  require 'thor/group'
5
5
  require 'artoo/robot'
6
- require 'artoo/commands/commands'
7
6
  require 'artoo/commands/generate'
8
- require 'artoo/commands/connect'
7
+ require 'artoo/commands/commands'
9
8
  require 'artoo/commands/install'
9
+ require 'artoo/commands/scan'
10
+ require 'artoo/commands/socket'
11
+ require 'artoo/commands/bluetooth'
10
12
 
11
13
  Celluloid.logger = nil
12
14
 
@@ -34,15 +36,17 @@ module CLI
34
36
  run("ruby #{robot}")
35
37
  end
36
38
 
37
- desc "generate SUBCOMMAND ...ARGS", "Generates a new robot or adaptor"
39
+ desc "generate <SUBCOMMAND> ...ARGS", "Generates a new robot or adaptor"
38
40
  subcommand "generate", Artoo::Commands::Generate
39
41
 
40
- desc "connect SUBCOMMAND ...ARGS", "Connects to device"
41
- subcommand "connect", Artoo::Commands::Connect
42
+ desc "bluetooth <SUBCOMMAND> ...ARGS", "Scans, pairs and Connects to a bluetooth device"
43
+ subcommand "bluetooth", Artoo::Commands::Bluetooth
42
44
 
43
- desc "install SUBCOMMAND ...ARGS", "Installs utility programs"
45
+ desc "install <SUBCOMMAND> ...ARGS", "Installs utility programs, like socat"
44
46
  subcommand "install", Artoo::Commands::Install
45
47
 
48
+ desc "scan <type> ...ARGS", "Installs utility programs"
49
+ subcommand "scan", Artoo::Commands::Scan
46
50
  end
47
51
  end
48
52
 
@@ -0,0 +1,74 @@
1
+ require 'thor'
2
+ require 'thor/group'
3
+
4
+ module Artoo
5
+ module Commands
6
+ class Bluetooth < Commands
7
+ package_name "bluetooth"
8
+
9
+ desc "scan", "Scan for bluetooth devices"
10
+ def scan
11
+ Artoo::Commands::Scan.new().bluetooth()
12
+ end
13
+
14
+ desc "bind [ADDRESS] [NAME]", "Binds a Bluetooth device to a serial port"
15
+ option :comm, :aliases => "-c", :default => 0, :desc => "Comm number"
16
+ option :radio, :aliases => "-r", :default => "hci0", :desc => "Bluetooth radio address"
17
+ def bind(address, name)
18
+ case os
19
+ when :linux
20
+ run("sudo rfcomm -i #{options[:radio]} bind /dev/rfcomm#{options[:comm]} #{address} 1")
21
+ run("sudo ln -s /dev/rfcomm#{options[:comm]} /dev/#{name}")
22
+ when :macosx
23
+ say "OSX binds devices on its own volition."
24
+ else
25
+ say "OS not yet supported..."
26
+ end
27
+ end
28
+
29
+ desc "unbind [ADDRESS] [NAME]", "Unbinds a Bluetooth device from a serial port"
30
+ def unbind(address, name)
31
+ case os
32
+ when :linux
33
+ run("sudo rfcomm unbind #{address}")
34
+ run("sudo rm /dev/#{name}")
35
+ when :macosx
36
+ say "OSX binds devices on its own volition."
37
+ else
38
+ say "OS not yet supported..."
39
+ end
40
+ end
41
+
42
+ desc "connect [NAME] [PORT]", "Connect a serial device to a TCP socket using socat"
43
+ option :retries, :aliases => "-r", :default => 0, :desc => "Number of times to retry connecting on failure"
44
+ option :baudrate, :aliases => "-b", :default => 57600, :desc => "Baud rate to use to connect to the serial device"
45
+ def connect(name, port)
46
+ Artoo::Commands::Socket.new().connect(name, port, options[:retries], options[:baudrate])
47
+ end
48
+
49
+ desc "pair [ADDRESS]", "Pairs a Bluetooth device"
50
+ def pair(address)
51
+ case os
52
+ when :linux
53
+ run("bluez-simple-agent hci0 #{ address }")
54
+ when :macosx
55
+ say "OS X manages Bluetooth pairing itself."
56
+ else
57
+ say "OS not yet supported..."
58
+ end
59
+ end
60
+
61
+ desc "unpair [ADDRESS]", "Unpairs a Bluetooth device"
62
+ def unpair(address)
63
+ case os
64
+ when :linux
65
+ run("bluez-simple-agent hci0 #{ address } remove")
66
+ when :macosx
67
+ say "OS X manages Bluetooth unpairing itself."
68
+ else
69
+ say "OS not yet supported..."
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -17,7 +17,7 @@ module Artoo
17
17
  end
18
18
 
19
19
  def self.install_path
20
- ENV["GEM_HOME"] || ENV["RBENV_ROOT"] || Dir.home(Etc.getlogin)
20
+ ENV["GEM_HOME"] || ENV["RBENV_ROOT"] || Dir.home(Etc.getlogin)
21
21
  end
22
22
  end
23
23
  end
@@ -0,0 +1,42 @@
1
+ require 'thor'
2
+ require 'thor/group'
3
+
4
+ module Artoo
5
+ module Commands
6
+ class Scan < Commands
7
+ package_name "scan"
8
+
9
+ desc "serial", "Scan for connected serial devices"
10
+ def serial
11
+ case os
12
+ when :linux
13
+ run("ls /dev/tty*")
14
+ when :macosx
15
+ run("ls /dev/{tty,cu}.*")
16
+ else
17
+ say("OS not yet supported...")
18
+ end
19
+ end
20
+
21
+ desc "usb", "Scan for connected usb devices"
22
+ def usb
23
+ case os
24
+ when :linux
25
+ run("lsusb")
26
+ else
27
+ say "OS not yet supported..."
28
+ end
29
+ end
30
+
31
+ desc "bluetooth", "Scan for bluetooth devices"
32
+ def bluetooth
33
+ case os
34
+ when :linux
35
+ run("hcitool scan")
36
+ else
37
+ say "OS not yet supported..."
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,43 @@
1
+ module Artoo
2
+ module Commands
3
+ class Socket < Commands
4
+
5
+ desc "connect [NAME] [PORT]", "Connect a serial device to a TCP socket using socat"
6
+ option :retries, :aliases => "-r", :default => 0, :desc => "Number of times to retry connecting on failure"
7
+ option :baudrate, :aliases => "-b", :default => 57600, :desc => "Baud rate to use to connect to the serial device"
8
+ def connect(name, port, retries = nil, baudrate = nil)
9
+ retries |= (1 + options[:retries].to_i)
10
+ baudrate |= options[:baudrate].to_i
11
+
12
+ # check that Socat is installed
13
+ system("socat -V &> /dev/null")
14
+ unless $?.success?
15
+ say "Socat not installed. Cannot bind serial to TCP."
16
+ say "Please install with 'artoo install socat' and try again."
17
+ return
18
+ end
19
+
20
+ case os
21
+ when :linux
22
+ run("sudo chmod a+rw /dev/#{name}")
23
+
24
+ while(retries > 0) do
25
+ run("socat -d -d FILE:/dev/#{name},nonblock,raw,b#{ baudrate },echo=0 TCP-LISTEN:#{port},fork")
26
+ break unless $? == 1
27
+ retries -= 1
28
+ end
29
+
30
+ when :macosx
31
+ while(retries > 0) do
32
+ run("socat -d -d -b#{ baudrate } FILE:/dev/#{name},nonblock,raw,echo=0 TCP-LISTEN:#{port},fork")
33
+ break unless $? == 1
34
+ retries -= 1
35
+ end
36
+
37
+ else
38
+ say "OS not yet supported..."
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
data/lib/artoo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Artoo
2
2
  unless const_defined?('VERSION')
3
- VERSION = "1.6.1"
3
+ VERSION = "1.6.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ron Evans
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-02-13 00:00:00.000000000 Z
15
+ date: 2014-04-04 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: celluloid
@@ -118,14 +118,14 @@ dependencies:
118
118
  requirements:
119
119
  - - "~>"
120
120
  - !ruby/object:Gem::Version
121
- version: 0.0.3
121
+ version: 0.0.4
122
122
  type: :runtime
123
123
  prerelease: false
124
124
  version_requirements: !ruby/object:Gem::Requirement
125
125
  requirements:
126
126
  - - "~>"
127
127
  - !ruby/object:Gem::Version
128
- version: 0.0.3
128
+ version: 0.0.4
129
129
  description: Ruby-based microframework for robotics
130
130
  email:
131
131
  - artoo@hybridgroup.com
@@ -192,10 +192,12 @@ files:
192
192
  - lib/artoo/api/device_event_client.rb
193
193
  - lib/artoo/api/route_helpers.rb
194
194
  - lib/artoo/basic.rb
195
+ - lib/artoo/commands/bluetooth.rb
195
196
  - lib/artoo/commands/commands.rb
196
- - lib/artoo/commands/connect.rb
197
197
  - lib/artoo/commands/generate.rb
198
198
  - lib/artoo/commands/install.rb
199
+ - lib/artoo/commands/scan.rb
200
+ - lib/artoo/commands/socket.rb
199
201
  - lib/artoo/connection.rb
200
202
  - lib/artoo/delegator.rb
201
203
  - lib/artoo/device.rb
@@ -266,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
268
  version: '0'
267
269
  requirements: []
268
270
  rubyforge_project: artoo
269
- rubygems_version: 2.2.1
271
+ rubygems_version: 2.2.2
270
272
  signing_key:
271
273
  specification_version: 4
272
274
  summary: Ruby-based microframework for robotics
@@ -1,83 +0,0 @@
1
- require 'thor'
2
- require 'thor/group'
3
-
4
- module Artoo
5
- module Commands
6
- class Connect < Commands
7
- package_name "connect"
8
-
9
- desc "scan", "Scan for connected devices"
10
- option :type, :aliases => "-t", :default => "bluetooth", :desc => "type of scan [bluetooth, serial]"
11
- def scan
12
- case os
13
- when :linux
14
- case options[:type]
15
- when 'bluetooth'
16
- run("hcitool scan")
17
- when 'serial'
18
- run("ls /dev/tty*")
19
- when 'usb'
20
- run("lsusb")
21
- else
22
- say "ERROR: scan type '#{options[:type]}' not supported!"
23
- end
24
- when :macosx
25
- run("ls /dev/tty*")
26
- else
27
- say "OS not yet supported..."
28
- end
29
- end
30
-
31
- desc "bind [ADDRESS] [NAME]", "Binds a Bluetooth device to some connected hardware"
32
- option :comm, :aliases => "-c", :default => 0, :desc => "Comm number"
33
- option :radio, :aliases => "-r", :default => "hci0", :desc => "Bluetooth radio address"
34
- def bind(address, name)
35
- case os
36
- when :linux
37
- run("sudo rfcomm -i #{options[:radio]} bind /dev/rfcomm#{options[:comm]} #{address} 1")
38
- run("sudo ln -s /dev/rfcomm#{options[:comm]} /dev/#{name}")
39
- when :macosx
40
- say "OSX binds devices on its own volition."
41
- else
42
- say "OS not yet supported..."
43
- end
44
- end
45
-
46
- desc "serial [NAME] [PORT]", "Connect a serial device to a TCP socket using socat"
47
- option :retries, :aliases => "-r", :default => 0, :desc => "Number of times to retry connecting on failure"
48
- option :baudrate, :aliases => "-b", :default => 57600, :desc => "Baud rate to use to connect to the serial device"
49
- def serial(name, port)
50
- attempts = 1 + options[:retries].to_i
51
-
52
- # check that Socat is installed
53
- system("socat -V &> /dev/null")
54
- unless $?.success?
55
- say "Socat not installed. Cannot bind serial to TCP."
56
- say "Please install with 'artoo install socat' and try again."
57
- return
58
- end
59
-
60
- case os
61
- when :linux
62
- run("sudo chmod a+rw /dev/#{name}")
63
-
64
- while(attempts > 0) do
65
- run("socat -d -d FILE:/dev/#{name},nonblock,raw,b#{options[:baudrate]},echo=0 TCP-LISTEN:#{port},fork")
66
- break unless $? == 1
67
- attempts -= 1
68
- end
69
-
70
- when :macosx
71
- while(attempts > 0) do
72
- run("socat -d -d -b#{options[:baudrate]} FILE:/dev/#{name},nonblock,raw,echo=0 TCP-LISTEN:#{port},fork")
73
- break unless $? == 1
74
- attempts -= 1
75
- end
76
-
77
- else
78
- say "OS not yet supported..."
79
- end
80
- end
81
- end
82
- end
83
- end