subduino 0.3.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +66 -0
- data/Rakefile +25 -39
- data/bin/subduino +16 -28
- data/lib/subduino.rb +10 -2
- data/lib/subduino/ard_io.rb +34 -37
- data/lib/subduino/scaffold/semantic.cache +13 -0
- data/lib/subduino/serial.rb +44 -0
- data/lib/subduino/version.rb +4 -0
- data/spec/subduino/#cubduino_spec.rb# +12 -0
- data/spec/subduino/ard_io_spec.rb +2 -2
- metadata +79 -100
- data/.document +0 -5
- data/Readme.textile +0 -92
- data/VERSION +0 -1
- data/duino/.gitignore +0 -2
- data/duino/Makefile +0 -403
- data/duino/duino.pde +0 -323
- data/duino/duino.rb +0 -16
- data/duino/methods.pde +0 -5
- data/examples/duin +0 -45
- data/ext/subduino/Makefile +0 -187
- data/ext/subduino/cubduino.c +0 -242
- data/ext/subduino/cubduino.h +0 -12
- data/ext/subduino/cubduino.o +0 -0
- data/ext/subduino/cubduino.so +0 -0
- data/lib/subduino/arduino.rb +0 -30
- data/node/arduinode.js +0 -68
- data/node/server.js +0 -45
- data/node/vendor/faye.js +0 -1925
- data/subduino.gemspec +0 -92
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
Subduino
|
2
|
+
========
|
3
|
+
|
4
|
+
AVR/Arduino Serial Tools on Ruby
|
5
|
+
|
6
|
+
http://github.com/nofxx/subduino
|
7
|
+
|
8
|
+
|
9
|
+
Install
|
10
|
+
-------
|
11
|
+
|
12
|
+
gem install subduino
|
13
|
+
|
14
|
+
|
15
|
+
Requirements
|
16
|
+
------------
|
17
|
+
|
18
|
+
Gems:
|
19
|
+
|
20
|
+
* serialport http://github.com/hparra/ruby-serialport
|
21
|
+
|
22
|
+
If you want:
|
23
|
+
|
24
|
+
PubSub:
|
25
|
+
|
26
|
+
* redis
|
27
|
+
|
28
|
+
WebApp:
|
29
|
+
|
30
|
+
* sinatra
|
31
|
+
* haml
|
32
|
+
|
33
|
+
|
34
|
+
Use
|
35
|
+
---
|
36
|
+
|
37
|
+
subduino -p <PORT> -b <BAUDS>
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
PubSub
|
42
|
+
------
|
43
|
+
|
44
|
+
|
45
|
+
Subduino.start do |reading|
|
46
|
+
puts "Received from mcu: #{reading}"
|
47
|
+
# Mail.send("foo@bla.com") if reading && reading.digital?
|
48
|
+
# Postgre.remember(:sensor => reading)
|
49
|
+
# Mongoid.insert(:sensor => reading)
|
50
|
+
# ...
|
51
|
+
end
|
52
|
+
|
53
|
+
Subduino.write(TXT)
|
54
|
+
|
55
|
+
|
56
|
+
Webapp
|
57
|
+
------
|
58
|
+
|
59
|
+
Need some love...
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
License
|
64
|
+
-------
|
65
|
+
|
66
|
+
"WTFPL":http://sam.zoy.org/wtfpl/
|
data/Rakefile
CHANGED
@@ -1,51 +1,37 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "subduino"
|
8
|
-
gem.summary = "Arduino Ruby Helpers"
|
9
|
-
gem.description = "Interface, compile, upload... Play with arduino on ruby!"
|
10
|
-
gem.email = "x@nofxx.com"
|
11
|
-
gem.homepage = "http://github.com/nofxx/subduino"
|
12
|
-
gem.authors = ["Marcos Piccinini"]
|
13
|
-
gem.add_dependency "redis"
|
14
|
-
gem.add_dependency "eventmachine"
|
15
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
16
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
-
end
|
18
|
-
Jeweler::GemcutterTasks.new
|
19
|
-
rescue LoadError
|
20
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
-
end
|
4
|
+
require "rspec"
|
5
|
+
require "rspec/core/rake_task"
|
22
6
|
|
23
|
-
|
24
|
-
|
25
|
-
# spec.libs << 'lib' << 'spec'
|
26
|
-
# spec.spec_files = FileList['spec/**/*_spec.rb']
|
27
|
-
# end
|
7
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
8
|
+
require "subduino/version"
|
28
9
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
10
|
+
desc "Builds the gem"
|
11
|
+
task :gem => :build
|
12
|
+
task :build do
|
13
|
+
system "gem build subduino.gemspec"
|
14
|
+
Dir.mkdir("pkg") unless Dir.exists?("pkg")
|
15
|
+
system "mv subduino-#{Subduino::VERSION}.gem pkg/"
|
16
|
+
end
|
34
17
|
|
35
|
-
|
18
|
+
task :install => :build do
|
19
|
+
system "sudo gem install pkg/subduino-#{Subduino::VERSION}.gem"
|
20
|
+
end
|
36
21
|
|
37
|
-
|
22
|
+
task :release => :build do
|
23
|
+
system "git tag -a v#{Subduino::VERSION} -m 'Tagging #{Subduino::VERSION}'"
|
24
|
+
system "git push --tags"
|
25
|
+
system "gem push pkg/subduino-#{Subduino::VERSION}.gem"
|
26
|
+
end
|
38
27
|
|
39
|
-
require 'rake/rdoctask'
|
40
|
-
Rake::RDocTask.new do |rdoc|
|
41
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
42
28
|
|
43
|
-
|
44
|
-
|
45
|
-
rdoc.rdoc_files.include('README*')
|
46
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
29
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
30
|
+
spec.pattern = "spec/**/*_spec.rb"
|
47
31
|
end
|
48
32
|
|
33
|
+
task :default => [:spec]
|
34
|
+
|
49
35
|
desc "Download and install arduino libraries"
|
50
36
|
task :clibs do |t|
|
51
37
|
puts "Starting...."
|
data/bin/subduino
CHANGED
@@ -1,56 +1,44 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
#require 'pry'
|
4
|
+
#require 'faye'
|
3
5
|
require 'rubygems'
|
4
6
|
require 'optparse'
|
5
|
-
|
7
|
+
require 'subduino'
|
8
|
+
require 'subduino/os'
|
6
9
|
|
7
10
|
Debug = false
|
8
11
|
|
9
|
-
|
10
|
-
# return unless f =~ /\.yml$/
|
11
|
-
puts "Using config file #{f}"
|
12
|
-
AppConfig = YAML.load(File.read(f))["opts"]
|
13
|
-
else
|
14
|
-
AppConfig = { :log_interval => 30 }
|
15
|
-
end
|
16
|
-
|
17
|
-
OptionParser.new { |op|
|
12
|
+
op = OptionParser.new { |op|
|
18
13
|
op.on('-d', '--debug') { |d| Debug = true }
|
19
|
-
op.on('-b', '--bauds=BAUDS', Integer) { |b|
|
20
|
-
op.on('-
|
21
|
-
op.on('-
|
22
|
-
op.on('-
|
14
|
+
op.on('-b', '--bauds=BAUDS', Integer) { |b| Subduino::Opts[:bauds] = b }
|
15
|
+
op.on('-p', '--port=/dev/port') { |p| Subduino::Opts[:port] = p }
|
16
|
+
# op.on('-e env') { |val| set :environment, val.to_sym }
|
17
|
+
# op.on('-s server') { |val| set :server, val }
|
23
18
|
op.parse!(ARGV)
|
24
19
|
}
|
25
20
|
|
26
|
-
require 'subduino'
|
27
|
-
require 'subduino/os'
|
28
|
-
require 'faye'
|
29
21
|
# Cubduino.write("hahah")
|
30
22
|
# puts Cubduino.read
|
31
23
|
|
32
|
-
# set :run, true
|
33
|
-
|
34
|
-
|
35
24
|
if ARGV.empty? || ARGV.join =~ /yml/
|
36
25
|
LastRun = {:all => 0}
|
37
26
|
|
38
|
-
client = Faye::Client.new('http://localhost:8000/faye')
|
27
|
+
# client = Faye::Client.new('http://localhost:8000/faye')
|
39
28
|
|
40
29
|
EM.run do
|
41
30
|
if Debug
|
42
31
|
puts "Starting on #{OS}"
|
32
|
+
puts "--------------------- #{Time.now}"
|
43
33
|
end
|
44
34
|
|
45
35
|
Subduino.start do |read|
|
46
|
-
|
47
|
-
if Debug
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
if LastRun[:all] < (Time.now.to_i - AppConfig[:log_interval])
|
36
|
+
|
37
|
+
print read if Debug
|
38
|
+
|
39
|
+
if LastRun[:all] < (Time.now.to_i - Subduino::Opts[:log_interval])
|
52
40
|
LastRun[:all] = Time.now.to_i
|
53
|
-
client.publish('/stats', 'data' => read)
|
41
|
+
# client.publish('/stats', 'data' => read)
|
54
42
|
Subduino::Store.add_csv_to_store(read, true)
|
55
43
|
else
|
56
44
|
Subduino::Store.add_csv_to_store(read)
|
data/lib/subduino.rb
CHANGED
@@ -17,14 +17,22 @@ require 'subduino/ard_io'
|
|
17
17
|
require 'subduino/ard_ps'
|
18
18
|
require 'subduino/parse'
|
19
19
|
require 'subduino/store'
|
20
|
-
require 'subduino/
|
20
|
+
require 'subduino/serial'
|
21
21
|
|
22
22
|
#Thread.current.abort_on_exception = false
|
23
23
|
|
24
24
|
module Subduino
|
25
|
+
if File.exists?(f = ARGV.join)
|
26
|
+
# return unless f =~ /\.yml$/
|
27
|
+
puts "Using config file #{f}"
|
28
|
+
Opts = YAML.load(File.read(f))["opts"]
|
29
|
+
else
|
30
|
+
Opts = { :log_interval => 30 }
|
31
|
+
end
|
32
|
+
|
33
|
+
|
25
34
|
Log = Logger.new(const_defined?("DEBUG") ? STDOUT : "subduino-debug.log")
|
26
35
|
# BAUDS = [300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200]
|
27
|
-
Sensors = [:temp, :lux]
|
28
36
|
# DATA_BITS = 8
|
29
37
|
# DATA_STOP = 1
|
30
38
|
|
data/lib/subduino/ard_io.rb
CHANGED
@@ -8,9 +8,8 @@ module Subduino
|
|
8
8
|
#
|
9
9
|
# Direct access to the SerialPort instance.
|
10
10
|
#
|
11
|
-
def
|
12
|
-
@
|
13
|
-
# @sp.read_timeout = 10;# @sp.write_timeout = 10
|
11
|
+
def serial
|
12
|
+
@serial ||= Serial.new(Opts[:bauds])
|
14
13
|
end
|
15
14
|
|
16
15
|
#
|
@@ -21,42 +20,43 @@ module Subduino
|
|
21
20
|
# Feed it with a block to read the text.
|
22
21
|
#
|
23
22
|
def read(&proc)
|
24
|
-
Log.info "[USB] Found Device...#{
|
25
|
-
Log.info "[USB] Starting Connect..." + sp.get_modem_params.map { |k,v| "#{k}: #{v}" }.join(" ")
|
26
|
-
Log.info "[USB] Read Timeout #{sp.read_timeout}" # {sp.write_timeout}"
|
23
|
+
Log.info "[USB] Found Device...#{serial.port}"
|
24
|
+
Log.info "[USB] Starting Connect..." + serial.sp.get_modem_params.map { |k,v| "#{k}: #{v}" }.join(" ")
|
25
|
+
# Log.info "[USB] Read Timeout #{sp.read_timeout}" # {sp.write_timeout}"
|
27
26
|
|
28
|
-
if
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
# print char if Debug
|
41
|
-
icache << char
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
27
|
+
if serial.up?
|
28
|
+
@iothread ||= Thread.new do
|
29
|
+
# Thread.current.abort_on_exception = false
|
30
|
+
icache = []
|
31
|
+
loop do
|
32
|
+
begin
|
33
|
+
while char = @serial.read
|
34
|
+
if !char.valid_encoding?
|
35
|
+
bytes = char.bytes.to_a
|
36
|
+
hexes = bytes.map { |b| b.to_s(16) }
|
37
|
+
puts " - Bad char #{char} - (Hex: #{char.unpack('H')} | Byte(s) #{bytes} | Hexe(s) #{hexes}"
|
38
|
+
# elsif char !~ /\n|\r/
|
39
|
+
# # print char if Debug
|
40
|
+
# icache << char
|
41
|
+
else
|
42
|
+
#data = icache.join(""); icache = []
|
43
|
+
data = char
|
44
|
+
unless data.empty?
|
45
|
+
Log.info "[IO RX] #{data}"
|
46
|
+
proc.call(data)
|
47
|
+
end
|
47
48
|
end
|
49
|
+
# sleep 1
|
48
50
|
end
|
49
|
-
|
51
|
+
rescue => e
|
52
|
+
Log.error "[USB] Error #{e}"
|
53
|
+
Log.error e.backtrace.join("\n")
|
54
|
+
stop!
|
55
|
+
exit 1
|
50
56
|
end
|
51
|
-
rescue => e
|
52
|
-
Log.error "[USB] Error #{e}"
|
53
|
-
Log.error e.backtrace.join("\n")
|
54
|
-
stop!
|
55
|
-
exit 1
|
56
57
|
end
|
57
58
|
end
|
58
59
|
end
|
59
|
-
end
|
60
60
|
|
61
61
|
end
|
62
62
|
|
@@ -69,10 +69,7 @@ module Subduino
|
|
69
69
|
#
|
70
70
|
def write(msg)
|
71
71
|
Log.info "[IO TX] #{msg}"
|
72
|
-
|
73
|
-
# txt += "\n" unless txt =~ /^\\n/
|
74
|
-
puts "=> Sending #{txt.inspect}" if Debug
|
75
|
-
sp.puts(msg)
|
72
|
+
serial.write(msg)
|
76
73
|
end
|
77
74
|
|
78
75
|
|
@@ -80,7 +77,7 @@ module Subduino
|
|
80
77
|
# Finish Him!
|
81
78
|
#
|
82
79
|
def stop!
|
83
|
-
|
80
|
+
serial.kill
|
84
81
|
Thread.kill @iothread
|
85
82
|
Log.info "[IO] K.I.A"
|
86
83
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
;; Object semantic.cache
|
2
|
+
;; SEMANTICDB Tags save file
|
3
|
+
(semanticdb-project-database "semantic.cache"
|
4
|
+
:file "semantic.cache"
|
5
|
+
:tables (list
|
6
|
+
(semanticdb-table "Makefile"
|
7
|
+
:file "Makefile"
|
8
|
+
:pointmax 11514
|
9
|
+
:major-mode 'makefile-gmake-mode
|
10
|
+
:tokens '(("TARGET" variable nil (("!!SCAFFOLD!!")) nil nil nil [274 302]) ("ARDUINO_DIR" variable nil (("/usr/share/arduino")) nil nil nil [302 336]) ("ARDUINO_LIBS" variable nil (("Messenger")) nil nil ((dirty . t)) [336 361]) ("MCU" variable nil (("atmega328p")) nil nil nil [370 396]) ("F_CPU" variable nil (("16000000")) nil nil nil [396 420]) ("ARDUINO_PORT" variable nil (("/dev/ttyUSB*")) nil nil nil [420 448]) ("AVR_TOOLS_PATH" variable nil (("/usr/bin")) nil nil nil [457 483]) ("AVRDUDE_CONF" variable nil (("/usr/share/arduino/hardware/tools/avrdude.conf")) nil nil nil [483 547]) ("AVRDUDE_ARD_PROGRAMMER" variable nil (("stk500v1")) nil nil nil [558 592]) ("AVRDUDE_ARD_BAUDRATE" variable nil (("57600")) nil nil nil [592 623]) ("AVR_TOOLS_PATH" variable nil (("$(ARDUINO_DIR)/hardware/tools/avr/bin")) nil nil nil [2902 2960]) ("ARDUINO_ETC_PATH" variable nil (("$(ARDUINO_DIR)/hardware/tools/avr/etc")) nil nil nil [2991 3049]) ("AVRDUDE_CONF" variable nil (("$(ARDUINO_ETC_PATH)/avrdude.conf")) nil nil nil [3076 3128]) ("ARDUINO_LIB_PATH" variable nil (("$(ARDUINO_DIR)/libraries")) nil nil nil [3135 3180]) ("ARDUINO_CORE_PATH" variable nil (("$(ARDUINO_DIR)/hardware/arduino/cores/arduino")) nil nil nil [3180 3246]) ("OBJDIR" variable nil (("build-cli")) nil nil nil [3286 3310]) ("LOCAL_C_SRCS" variable nil (("$(wildcard *.c)")) nil nil nil [3402 3436]) ("LOCAL_CPP_SRCS" variable nil (("$(wildcard *.cpp)")) nil nil nil [3436 3472]) ("LOCAL_CC_SRCS" variable nil (("$(wildcard *.cc)")) nil nil nil [3472 3507]) ("LOCAL_PDE_SRCS" variable nil (("$(wildcard *.pde)")) nil nil nil [3507 3543]) ("LOCAL_AS_SRCS" variable nil (("$(wildcard *.S)")) nil nil nil [3543 3577]) ("LOCAL_OBJ_FILES" variable nil (("$(LOCAL_C_SRCS:.c=.o)") ("$(LOCAL_CPP_SRCS:.cpp=.o)") nil ("$(LOCAL_CC_SRCS:.cc=.o)") ("$(LOCAL_PDE_SRCS:.pde=.o)") nil ("$(LOCAL_AS_SRCS:.S=.o)")) nil nil nil [3577 3728]) ("LOCAL_OBJS" variable nil (("$(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES))")) nil nil nil [3728 3791]) ("DEPS" variable nil (("$(LOCAL_OBJS:.o=.d)")) nil nil nil [3811 3849]) ("CORE_C_SRCS" variable nil (("$(wildcard $(ARDUINO_CORE_PATH)/*.c)")) nil nil nil [3917 3972]) ("CORE_CPP_SRCS" variable nil (("$(wildcard $(ARDUINO_CORE_PATH)/*.cpp)")) nil nil nil [3972 4029]) ("EXTRA_CPP_SRCS" variable nil (("$(wildcard $(ARDUINO_LIB_PATH)/Messenger/*.cpp)")) nil nil nil [4029 4096]) ("CORE_OBJ_FILES" variable nil (("$(CORE_C_SRCS:.c=.o)") ("$(CORE_CPP_SRCS:.cpp=.o)") ("$(EXTRA_CPP_SRCS:.cpp=.o)")) nil nil nil [4096 4186]) ("CORE_OBJS" variable nil (("$(patsubst $(ARDUINO_CORE_PATH)/%, $(OBJDIR)/%,$(CORE_OBJ_FILES))")) nil nil nil [4186 4270]) ("OBJS" variable nil (("$(LOCAL_OBJS)") ("$(CORE_OBJS)")) nil nil nil [4302 4347]) ("TARGET_HEX" variable nil (("$(OBJDIR)/$(TARGET).hex")) nil nil nil [4480 4517]) ("TARGET_ELF" variable nil (("$(OBJDIR)/$(TARGET).elf")) nil nil nil [4517 4554]) ("TARGETS" variable nil (("$(OBJDIR)/$(TARGET).*")) nil nil nil [4554 4589]) ("DEP_FILE" variable nil (("$(OBJDIR)/depends.mk")) nil nil nil [4615 4649]) ("CC" variable nil (("$(AVR_TOOLS_PATH)/avr-gcc")) nil nil nil [4673 4709]) ("CXX" variable nil (("$(AVR_TOOLS_PATH)/avr-g++")) nil nil nil [4709 4745]) ("OBJCOPY" variable nil (("$(AVR_TOOLS_PATH)/avr-objcopy")) nil nil nil [4745 4785]) ("OBJDUMP" variable nil (("$(AVR_TOOLS_PATH)/avr-objdump")) nil nil nil [4785 4825]) ("AR" variable nil (("$(AVR_TOOLS_PATH)/avr-ar")) nil nil nil [4825 4860]) ("SIZE" variable nil (("$(AVR_TOOLS_PATH)/avr-size")) nil nil nil [4860 4897]) ("NM" variable nil (("$(AVR_TOOLS_PATH)/avr-nm")) nil nil nil [4897 4932]) ("REMOVE" variable nil (("rm") ("-f")) nil nil nil [4932 4948]) ("MV" variable nil (("mv") ("-f")) nil nil nil [4948 4964]) ("CAT" variable nil (("cat")) nil nil nil [4964 4978]) ("ECHO" variable nil (("echo")) nil nil nil [4978 4993]) ("SYS_LIBS" variable nil (("$(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS))")) nil nil nil [5014 5082]) ("SYS_INCLUDES" variable nil (("$(patsubst %,-I%,$(SYS_LIBS))")) nil nil nil [5082 5128]) ("SYS_OBJS" variable nil (("$(wildcard $(patsubst %,%/*.o,$(SYS_LIBS)))")) nil nil nil [5128 5188]) ("CPPFLAGS" variable nil (("-mmcu=$(MCU)") ("-DF_CPU=$(F_CPU)") nil ("-I.") ("-I$(ARDUINO_CORE_PATH)") nil ("$(SYS_INCLUDES)") ("-g") ("-Os") ("-w") ("-Wall") nil ("-ffunction-sections") ("-fdata-sections")) nil nil nil [5189 5354]) ("CFLAGS" variable nil (("-std=gnu99")) nil nil nil [5354 5381]) ("CXXFLAGS" variable nil (("-fno-exceptions")) nil nil nil [5381 5413]) ("ASFLAGS" variable nil (("-mmcu=$(MCU)") ("-I.") ("-x") ("assembler-with-cpp")) nil nil nil [5413 5468]) ("LDFLAGS" variable nil (("-mmcu=$(MCU)") ("-lm") ("-Wl,--gc-sections") ("-Os")) nil nil nil [5468 5523]) ("ARD_PORT" variable nil (("$(firstword $(wildcard $(ARDUINO_PORT)))")) nil nil nil [5659 5716]) ("$(OBJDIR)" function nil (("%.c")) nil nil nil [6187 6249]) ("$(OBJDIR)" function nil (("%.cc")) nil nil nil [6249 6315]) ("$(OBJDIR)" function nil (("%.cpp")) nil nil nil [6315 6382]) ("$(OBJDIR)" function nil (("%.S")) nil nil nil [6382 6445]) ("$(OBJDIR)" function nil (("%.s")) nil nil nil [6445 6508]) ("$(OBJDIR)" function nil (("%.c")) nil nil nil [6508 6587]) ("$(OBJDIR)" function nil (("%.cc")) nil nil nil [6587 6670]) ("$(OBJDIR)" function nil (("%.cpp")) nil nil nil [6670 6754]) ("$(OBJDIR)" function nil (("%.S")) nil nil nil [6754 6834]) ("$(OBJDIR)" function nil (("%.s")) nil nil nil [6834 6914]) ("$(OBJDIR)" function nil (("%.pde")) nil nil nil [6941 7012]) ("$(OBJDIR)" function nil (("$(OBJDIR)/%.cpp")) nil nil nil [7012 7089]) ("$(OBJDIR)" function nil (("$(OBJDIR)/%.cpp")) nil nil nil [7089 7183]) ("$(OBJDIR)" function nil (("$(ARDUINO_CORE_PATH)/%.c")) nil nil nil [7196 7279]) ("$(OBJDIR)" function nil (("$(ARDUINO_CORE_PATH)/%.cpp")) nil nil nil [7279 7367]) ("$(OBJDIR)" function nil (("$(OBJDIR)/%.elf")) nil nil nil [7396 7468]) ("$(OBJDIR)" function nil (("$(OBJDIR)/%.elf")) nil nil nil [7468 7619]) ("$(OBJDIR)" function nil (("$(OBJDIR)/%.elf")) nil nil nil [7619 7680]) ("$(OBJDIR)" function nil (("$(OBJDIR)/%.elf")) nil nil nil [7680 7733]) ("AVRDUDE" variable nil (("$(AVR_TOOLS_PATH)/avrdude")) nil nil nil [7835 7880]) ("AVRDUDE_COM_OPTS" variable nil (("-q") ("-V") ("-p") ("$(MCU)")) nil nil nil [7887 7922]) ("+" variable nil (("-C") ("$(AVRDUDE_CONF)")) nil nil nil [7958 7980]) ("AVRDUDE_ARD_PROGRAMMER" variable nil (("stk500v1")) nil nil nil [8017 8051]) ("AVRDUDE_ARD_BAUDRATE" variable nil (("57600") nil) nil nil nil [8086 8125]) ("AVRDUDE_ARD_OPTS" variable nil (("-c") ("$(AVRDUDE_ARD_PROGRAMMER)") ("-b") ("$(AVRDUDE_ARD_BAUDRATE)") ("-P") ("$(ARD_PORT)")) nil nil nil [8132 8222]) ("ISP_LOCK_FUSE_PRE" variable nil (("0x3f")) nil nil nil [8248 8274]) ("ISP_LOCK_FUSE_POST" variable nil (("0xcf")) nil nil nil [8307 8333]) ("ISP_HIGH_FUSE" variable nil (("0xdf")) nil nil nil [8361 8387]) ("ISP_LOW_FUSE" variable nil (("0xff")) nil nil nil [8414 8440]) ("ISP_EXT_FUSE" variable nil (("0x01")) nil nil nil [8467 8493]) ("ISP_PROG" variable nil (("-c") ("stk500v2")) nil nil nil [8516 8543]) ("AVRDUDE_ISP_OPTS" variable nil (("-P") ("$(ISP_PORT)") ("$(ISP_PROG)")) nil nil nil [8550 8596]) ("all" function nil (("$(OBJDIR)") ("$(TARGET_HEX)")) nil nil nil [8706 8739]) ("$(OBJDIR)" function nil (nil) nil nil nil [8739 8771]) ("$(TARGET_ELF)" function nil (("$(OBJS)")) nil nil nil [8771 8843]) ("$(DEP_FILE)" function nil (("$(OBJDIR)") ("$(DEPS)")) nil nil nil [8843 8906]) ("upload" function nil (("reset") ("raw_upload")) nil nil nil [8906 8934]) ("raw_upload" function nil (("$(TARGET_HEX)")) nil nil nil [8934 9051]) ("reset" function nil (nil) nil nil nil [9246 9481]) ("ispload" function nil (("$(TARGET_HEX)")) nil nil nil [9481 9907]) ("clean" function nil (nil) nil nil nil [9907 9968]) ("depends" function nil (("$(DEPS)")) nil nil nil [9968 10017]) (".PHONY" function nil (("all") ("clean") ("depends") ("upload") ("raw_upload") ("reset")) nil nil nil [10017 10068]) ("$(DEP_FILE)" include nil nil nil [10068 10088]))
|
11
|
+
)
|
12
|
+
)
|
13
|
+
)
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Subduino
|
2
|
+
|
3
|
+
class Serial
|
4
|
+
attr_reader :sp, :port, :bauds
|
5
|
+
|
6
|
+
def initialize(bauds = 57600)
|
7
|
+
@bauds = bauds
|
8
|
+
@port = find_port
|
9
|
+
@sp ||= SerialPort.new(@port, bauds) #, DATA_BITS, DATA_STOP, parity)
|
10
|
+
# @sp.read_timeout = 10
|
11
|
+
# @sp.write_timeout = 10
|
12
|
+
end
|
13
|
+
|
14
|
+
def find_port
|
15
|
+
prefix = RUBY_PLATFORM =~ /darwin/ ? ".usbmodem" : "USB"
|
16
|
+
port = Dir.glob("/dev/tty#{prefix}*").first
|
17
|
+
raise "Can't find serial port" unless port
|
18
|
+
port
|
19
|
+
end
|
20
|
+
|
21
|
+
def read
|
22
|
+
sp.getc
|
23
|
+
end
|
24
|
+
|
25
|
+
def write msg
|
26
|
+
# txt += "\n" unless txt =~ /^\\n/
|
27
|
+
txt = msg.gsub("\r|\n", "")
|
28
|
+
Log.debug "=> Sending #{txt.inspect}"
|
29
|
+
sp.puts txt
|
30
|
+
# msg.to_s.chomp.split("").each do |char|
|
31
|
+
# @sp.putc char
|
32
|
+
end
|
33
|
+
|
34
|
+
def up?
|
35
|
+
sp
|
36
|
+
end
|
37
|
+
|
38
|
+
def kill
|
39
|
+
sp.close
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -3,8 +3,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe ArdIO do
|
4
4
|
|
5
5
|
it "should start serial port" do
|
6
|
-
|
6
|
+
Serial.stub!(:find_usb).and_return("/dev/ttyUSB0")
|
7
7
|
SerialPort.should_receive(:new).with("/dev/ttyUSB0", 115200)
|
8
|
-
ArdIO.
|
8
|
+
ArdIO.serial
|
9
9
|
end
|
10
10
|
end
|
metadata
CHANGED
@@ -1,151 +1,130 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: subduino
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 3
|
8
|
-
- 1
|
9
|
-
version: 0.3.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Marcos Piccinini
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-01-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: redis
|
16
|
+
requirement: &11141820 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
22
23
|
prerelease: false
|
23
|
-
|
24
|
+
version_requirements: *11141820
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: serialport
|
27
|
+
requirement: &11141120 !ruby/object:Gem::Requirement
|
24
28
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
31
33
|
type: :runtime
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: eventmachine
|
35
34
|
prerelease: false
|
36
|
-
|
35
|
+
version_requirements: *11141120
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: eventmachine
|
38
|
+
requirement: &11140640 !ruby/object:Gem::Requirement
|
37
39
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
- 0
|
43
|
-
version: "0"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
44
|
type: :runtime
|
45
|
-
version_requirements: *id002
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
45
|
prerelease: false
|
49
|
-
|
46
|
+
version_requirements: *11140640
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: &11161880 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
segments:
|
55
|
-
- 1
|
56
|
-
- 2
|
57
|
-
- 9
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
58
54
|
version: 1.2.9
|
59
55
|
type: :development
|
60
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *11161880
|
61
58
|
description: Interface, compile, upload... Play with arduino on ruby!
|
62
59
|
email: x@nofxx.com
|
63
|
-
executables:
|
60
|
+
executables:
|
64
61
|
- subduino
|
65
62
|
- subduino-cli
|
66
|
-
extensions:
|
63
|
+
extensions:
|
67
64
|
- ext/subduino/extconf.rb
|
68
65
|
extra_rdoc_files: []
|
69
|
-
|
70
|
-
files:
|
71
|
-
- .document
|
72
|
-
- Rakefile
|
73
|
-
- Readme.textile
|
74
|
-
- VERSION
|
75
|
-
- bin/subduino
|
76
|
-
- bin/subduino-cli
|
77
|
-
- duino/.gitignore
|
78
|
-
- duino/Makefile
|
79
|
-
- duino/duino.pde
|
80
|
-
- duino/duino.rb
|
81
|
-
- duino/methods.pde
|
82
|
-
- examples/duin
|
83
|
-
- ext/subduino/Makefile
|
84
|
-
- ext/subduino/cubduino.c
|
85
|
-
- ext/subduino/cubduino.h
|
86
|
-
- ext/subduino/cubduino.o
|
87
|
-
- ext/subduino/cubduino.so
|
88
|
-
- ext/subduino/extconf.rb
|
66
|
+
files:
|
89
67
|
- lib/subduino.rb
|
90
|
-
- lib/subduino/
|
91
|
-
- lib/subduino/ard_ps.rb
|
92
|
-
- lib/subduino/arduino.rb
|
93
|
-
- lib/subduino/os.rb
|
94
|
-
- lib/subduino/parse.rb
|
68
|
+
- lib/subduino/parse/temp.rb
|
95
69
|
- lib/subduino/parse/bool.rb
|
70
|
+
- lib/subduino/parse/pressure.rb
|
96
71
|
- lib/subduino/parse/energy.rb
|
97
72
|
- lib/subduino/parse/flow.rb
|
98
73
|
- lib/subduino/parse/lux.rb
|
99
74
|
- lib/subduino/parse/presence.rb
|
100
|
-
- lib/subduino/parse
|
101
|
-
- lib/subduino/
|
102
|
-
- lib/subduino/
|
75
|
+
- lib/subduino/parse.rb
|
76
|
+
- lib/subduino/os.rb
|
77
|
+
- lib/subduino/ard_ps.rb
|
78
|
+
- lib/subduino/ard_io.rb
|
79
|
+
- lib/subduino/version.rb
|
80
|
+
- lib/subduino/scaffold/scaffold.pde
|
81
|
+
- lib/subduino/scaffold/semantic.cache
|
103
82
|
- lib/subduino/scaffold/Makefile2
|
83
|
+
- lib/subduino/scaffold/Makefile
|
104
84
|
- lib/subduino/scaffold/generator.rb
|
105
|
-
- lib/subduino/scaffold/scaffold.pde
|
106
85
|
- lib/subduino/scaffold/scaffold.rb
|
86
|
+
- lib/subduino/serial.rb
|
107
87
|
- lib/subduino/store.rb
|
108
|
-
-
|
109
|
-
- node/server.js
|
110
|
-
- node/vendor/faye.js
|
88
|
+
- spec/subduino_spec.rb
|
111
89
|
- spec/spec_helper.rb
|
112
|
-
- spec/subduino/ard_io_spec.rb
|
113
90
|
- spec/subduino/cubduino_spec.rb
|
114
|
-
- spec/subduino/parse_spec.rb
|
115
91
|
- spec/subduino/store_spec.rb
|
116
|
-
- spec/
|
117
|
-
- subduino.
|
118
|
-
|
92
|
+
- spec/subduino/ard_io_spec.rb
|
93
|
+
- spec/subduino/#cubduino_spec.rb#
|
94
|
+
- spec/subduino/parse_spec.rb
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/subduino
|
98
|
+
- bin/subduino-cli
|
99
|
+
- ext/subduino/extconf.rb
|
119
100
|
homepage: http://github.com/nofxx/subduino
|
120
101
|
licenses: []
|
121
|
-
|
122
102
|
post_install_message:
|
123
103
|
rdoc_options: []
|
124
|
-
|
125
|
-
require_paths:
|
104
|
+
require_paths:
|
126
105
|
- lib
|
127
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
107
|
none: false
|
129
|
-
requirements:
|
130
|
-
- -
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
segments:
|
133
113
|
- 0
|
134
|
-
|
135
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
hash: 330229238283923974
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
116
|
none: false
|
137
|
-
requirements:
|
138
|
-
- -
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
segments:
|
141
122
|
- 0
|
142
|
-
|
123
|
+
hash: 330229238283923974
|
143
124
|
requirements: []
|
144
|
-
|
145
125
|
rubyforge_project:
|
146
|
-
rubygems_version: 1.
|
126
|
+
rubygems_version: 1.8.11
|
147
127
|
signing_key:
|
148
128
|
specification_version: 3
|
149
129
|
summary: Arduino Ruby Helpers
|
150
130
|
test_files: []
|
151
|
-
|