subduino 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +26 -0
- data/Rakefile +76 -0
- data/Readme.textile +46 -0
- data/VERSION +1 -0
- data/bin/subduino +34 -0
- data/bin/subduino-cli +65 -0
- data/duino/.gitignore +2 -0
- data/duino/Makefile +401 -0
- data/duino/duino.pde +17 -0
- data/duino/duino.rb +16 -0
- data/duino/methods.pde +5 -0
- data/lib/subduino/ard_io.rb +60 -0
- data/lib/subduino/ard_ps.rb +38 -0
- data/lib/subduino/arduino.rb +30 -0
- data/lib/subduino/parse.rb +61 -0
- data/lib/subduino/scaffold/Makefile +401 -0
- data/lib/subduino/scaffold/Makefile2 +247 -0
- data/lib/subduino/scaffold/generator.rb +29 -0
- data/lib/subduino/scaffold/scaffold.pde +17 -0
- data/lib/subduino/scaffold/scaffold.rb +16 -0
- data/lib/subduino/store.rb +65 -0
- data/lib/subduino.rb +48 -0
- data/node/arduinode.js +68 -0
- data/node/server.js +45 -0
- data/node/vendor/faye.js +1925 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/subduino/ard_io_spec.rb +9 -0
- data/spec/subduino/parse_spec.rb +21 -0
- data/spec/subduino/store_spec.rb +17 -0
- data/spec/subduino_spec.rb +20 -0
- data/subduino.gemspec +239 -0
- data/webapp/Gemfile +8 -0
- data/webapp/Gemfile.lock +14 -0
- data/webapp/Rakefile +49 -0
- data/webapp/Readme.textile +45 -0
- data/webapp/VERSION +1 -0
- data/webapp/lib/app.rb +103 -0
- data/webapp/lib/duino.rb +213 -0
- data/webapp/lib/environment.rb +36 -0
- data/webapp/lib/messenger.rb +16 -0
- data/webapp/public/app.css +119 -0
- data/webapp/public/app.js +34 -0
- data/webapp/public/faye.js +1 -0
- data/webapp/public/icons/alarm-clock-blue.png +0 -0
- data/webapp/public/icons/alarm-clock.png +0 -0
- data/webapp/public/icons/balloon-left.png +0 -0
- data/webapp/public/icons/bandaid.png +0 -0
- data/webapp/public/icons/bell-disable.png +0 -0
- data/webapp/public/icons/bell.png +0 -0
- data/webapp/public/icons/big_icon.png +0 -0
- data/webapp/public/icons/bomb.png +0 -0
- data/webapp/public/icons/bookmark.png +0 -0
- data/webapp/public/icons/box-label.png +0 -0
- data/webapp/public/icons/brightness-control-up.png +0 -0
- data/webapp/public/icons/brightness-control.png +0 -0
- data/webapp/public/icons/brightness-small.png +0 -0
- data/webapp/public/icons/broom.png +0 -0
- data/webapp/public/icons/bug.png +0 -0
- data/webapp/public/icons/calculator.png +0 -0
- data/webapp/public/icons/calendar-day.png +0 -0
- data/webapp/public/icons/camera.png +0 -0
- data/webapp/public/icons/cards-address.png +0 -0
- data/webapp/public/icons/chart.png +0 -0
- data/webapp/public/icons/clock-select.png +0 -0
- data/webapp/public/icons/color.png +0 -0
- data/webapp/public/icons/compass.png +0 -0
- data/webapp/public/icons/control-power-small.png +0 -0
- data/webapp/public/icons/control-power.png +0 -0
- data/webapp/public/icons/control-record-small.png +0 -0
- data/webapp/public/icons/cpus.png +0 -0
- data/webapp/public/icons/credit-card.png +0 -0
- data/webapp/public/icons/cross-small.png +0 -0
- data/webapp/public/icons/dashboard.png +0 -0
- data/webapp/public/icons/database.png +0 -0
- data/webapp/public/icons/databases.png +0 -0
- data/webapp/public/icons/door-open-in.png +0 -0
- data/webapp/public/icons/door-open-out.png +0 -0
- data/webapp/public/icons/door-open.png +0 -0
- data/webapp/public/icons/door.png +0 -0
- data/webapp/public/icons/drive-globe.png +0 -0
- data/webapp/public/icons/equalizer.png +0 -0
- data/webapp/public/icons/exclamation-diamond.png +0 -0
- data/webapp/public/icons/exclamation.png +0 -0
- data/webapp/public/icons/eye-disable.png +0 -0
- data/webapp/public/icons/eye.png +0 -0
- data/webapp/public/icons/false.png +0 -0
- data/webapp/public/icons/gear-small.png +0 -0
- data/webapp/public/icons/gear.png +0 -0
- data/webapp/public/icons/groups.png +0 -0
- data/webapp/public/icons/heart.png +0 -0
- data/webapp/public/icons/heart_empty.png +0 -0
- data/webapp/public/icons/info.png +0 -0
- data/webapp/public/icons/key.png +0 -0
- data/webapp/public/icons/lightbulb.png +0 -0
- data/webapp/public/icons/lightbulb_off.png +0 -0
- data/webapp/public/icons/lightning-disable.png +0 -0
- data/webapp/public/icons/lightning-small.png +0 -0
- data/webapp/public/icons/lightning.png +0 -0
- data/webapp/public/icons/lock-unlock.png +0 -0
- data/webapp/public/icons/lock.png +0 -0
- data/webapp/public/icons/marker.png +0 -0
- data/webapp/public/icons/media-player-phone.png +0 -0
- data/webapp/public/icons/megaphone.png +0 -0
- data/webapp/public/icons/mem.png +0 -0
- data/webapp/public/icons/microphone.png +0 -0
- data/webapp/public/icons/monitor.png +0 -0
- data/webapp/public/icons/navigation.png +0 -0
- data/webapp/public/icons/off.png +0 -0
- data/webapp/public/icons/on.png +0 -0
- data/webapp/public/icons/pin.png +0 -0
- data/webapp/public/icons/plug--exclamation.png +0 -0
- data/webapp/public/icons/plug-disable.png +0 -0
- data/webapp/public/icons/plug.png +0 -0
- data/webapp/public/icons/restart.png +0 -0
- data/webapp/public/icons/ruby.png +0 -0
- data/webapp/public/icons/server.png +0 -0
- data/webapp/public/icons/shield-disable.png +0 -0
- data/webapp/public/icons/shield.png +0 -0
- data/webapp/public/icons/socket--exclamation.png +0 -0
- data/webapp/public/icons/socket-disable.png +0 -0
- data/webapp/public/icons/socket.png +0 -0
- data/webapp/public/icons/start.png +0 -0
- data/webapp/public/icons/stop.png +0 -0
- data/webapp/public/icons/switch--exclamation.png +0 -0
- data/webapp/public/icons/switch-disable.png +0 -0
- data/webapp/public/icons/switch-small.png +0 -0
- data/webapp/public/icons/switch.png +0 -0
- data/webapp/public/icons/target.png +0 -0
- data/webapp/public/icons/television-off.png +0 -0
- data/webapp/public/icons/television.png +0 -0
- data/webapp/public/icons/terminal.png +0 -0
- data/webapp/public/icons/tick-small.png +0 -0
- data/webapp/public/icons/traffic-light-off.png +0 -0
- data/webapp/public/icons/traffic-light.png +0 -0
- data/webapp/public/icons/traffic.png +0 -0
- data/webapp/public/icons/true.png +0 -0
- data/webapp/public/icons/umbrella.png +0 -0
- data/webapp/public/icons/unmonitor.png +0 -0
- data/webapp/public/icons/unmonitored.png +0 -0
- data/webapp/public/icons/users.png +0 -0
- data/webapp/public/icons/vcard.png +0 -0
- data/webapp/public/icons/wall.png +0 -0
- data/webapp/public/icons/wall_brick.png +0 -0
- data/webapp/public/icons/wall_disable.png +0 -0
- data/webapp/public/icons/wand-disable.png +0 -0
- data/webapp/public/icons/wand.png +0 -0
- data/webapp/public/icons/warn.png +0 -0
- data/webapp/public/icons/weather_clouds.png +0 -0
- data/webapp/public/icons/weather_cloudy.png +0 -0
- data/webapp/public/icons/weather_lightning.png +0 -0
- data/webapp/public/icons/weather_rain.png +0 -0
- data/webapp/public/icons/weather_snow.png +0 -0
- data/webapp/public/icons/weather_sun.png +0 -0
- data/webapp/public/icons/wrench-screwdriver.png +0 -0
- data/webapp/public/icons/wrench.png +0 -0
- data/webapp/public/iui/backButton.png +0 -0
- data/webapp/public/iui/blueButton.png +0 -0
- data/webapp/public/iui/cancel.png +0 -0
- data/webapp/public/iui/grayButton.png +0 -0
- data/webapp/public/iui/greenButton.png +0 -0
- data/webapp/public/iui/iui-logo-touch-icon.png +0 -0
- data/webapp/public/iui/iui.css +396 -0
- data/webapp/public/iui/iui.js +511 -0
- data/webapp/public/iui/iuix.css +1 -0
- data/webapp/public/iui/iuix.js +1 -0
- data/webapp/public/iui/listArrow.png +0 -0
- data/webapp/public/iui/listArrowSel.png +0 -0
- data/webapp/public/iui/listGroup.png +0 -0
- data/webapp/public/iui/loading.gif +0 -0
- data/webapp/public/iui/pinstripes.png +0 -0
- data/webapp/public/iui/redButton.png +0 -0
- data/webapp/public/iui/selection.png +0 -0
- data/webapp/public/iui/thumb.png +0 -0
- data/webapp/public/iui/toggle.png +0 -0
- data/webapp/public/iui/toggleOn.png +0 -0
- data/webapp/public/iui/toolButton.png +0 -0
- data/webapp/public/iui/toolbar.png +0 -0
- data/webapp/public/iui/whiteButton.png +0 -0
- data/webapp/public/iui/yellowButton.png +0 -0
- data/webapp/public/jquery.js +154 -0
- data/webapp/public/layout.css +33 -0
- data/webapp/public/right.js +9 -0
- data/webapp/public/rt.js +7 -0
- data/webapp/public/sparkline.js +85 -0
- data/webapp/spec/duino_spec.rb +8 -0
- data/webapp/spec/spec_helper.rb +10 -0
- data/webapp/views/command.haml +4 -0
- data/webapp/views/icon.haml +6 -0
- data/webapp/views/index.haml +51 -0
- data/webapp/views/layout.haml +17 -0
- data/webapp/views/mobile.haml +21 -0
- data/webapp/views/switch.haml +56 -0
- data/webapp/views/top.haml +4 -0
- data/webapp/views/watch.haml +26 -0
- metadata +277 -0
@@ -0,0 +1,247 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2010 Alan Burlison. All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
8
|
+
# this list of conditions and the following disclaimer.
|
9
|
+
#
|
10
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
#
|
14
|
+
# THIS SOFTWARE IS PROVIDED BY ALAN BURLISON "AS IS" AND ANY EXPRESS OR IMPLIED
|
15
|
+
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
16
|
+
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
17
|
+
# EVENT SHALL ALAN BURLISON OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
18
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
19
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
20
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
21
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
22
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
23
|
+
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
24
|
+
#
|
25
|
+
# Makefile for building Arduino projects outside of the Arduino environment
|
26
|
+
#
|
27
|
+
# This makefile should be included into a per-project Makefile of the following
|
28
|
+
# form:
|
29
|
+
#
|
30
|
+
# ----------
|
31
|
+
# BOARD = mega
|
32
|
+
# PORT = /dev/term/0
|
33
|
+
# INC_DIRS = ../common
|
34
|
+
# LIB_DIRS = ../libraries/Task ../../libraries/VirtualWire
|
35
|
+
# include ../../Makefile.master
|
36
|
+
# ----------
|
37
|
+
#
|
38
|
+
# Where:
|
39
|
+
# BOARD : Arduino board type, from $(ARD_HOME)/hardware/boards.txt
|
40
|
+
# PORT : USB port
|
41
|
+
# INC_DIRS : List pf directories containing header files
|
42
|
+
# LIB_DIRS : List of directories containing library source
|
43
|
+
#
|
44
|
+
# Before using this Makefile you should adjust the following macros to suit
|
45
|
+
# your environment, either by editing this file directly or by defining them in
|
46
|
+
# the Makefile that includes this one:
|
47
|
+
# ARD_REV : Arduino software revision, e.g. 0017, 0018
|
48
|
+
# ARD_HOME : Installation directory of the Arduino software.
|
49
|
+
# MON_TERM : terminal command for serial monitor
|
50
|
+
# MON_CMD : serial monitor command
|
51
|
+
# MON_SPEED : serial monitor speed
|
52
|
+
#
|
53
|
+
|
54
|
+
# Global configuration.
|
55
|
+
ARD_REV ?= 0018
|
56
|
+
ARD_HOME ?= /usr/share/arduino
|
57
|
+
MON_TERM ?= gnome-terminal
|
58
|
+
MON_SPEED ?= 9600
|
59
|
+
MON_CMD ?= tip
|
60
|
+
|
61
|
+
### Nothing below here should require editing. ###
|
62
|
+
|
63
|
+
# Check for the required definitions.
|
64
|
+
|
65
|
+
ifndef BOARD
|
66
|
+
$(error $$(BOARD) not defined)
|
67
|
+
endif
|
68
|
+
ifndef PORT
|
69
|
+
$(error $$(PORT) not defined)
|
70
|
+
endif
|
71
|
+
|
72
|
+
# Version-specific settings
|
73
|
+
ifeq ($(ARD_REV),0018)
|
74
|
+
ARD_BOARDS = $(ARD_HOME)/hardware/arduino/boards.txt
|
75
|
+
ARD_SRC_DIR = $(ARD_HOME)/hardware/arduino/cores/arduino
|
76
|
+
ARD_MAIN = $(ARD_SRC_DIR)/main.cpp
|
77
|
+
else
|
78
|
+
ARD_BOARDS = $(ARD_HOME)/hardware/boards.txt
|
79
|
+
ARD_SRC_DIR = $(ARD_HOME)/hardware/cores/arduino
|
80
|
+
ARD_MAIN = $(ARD_SRC_DIR)/main.cxx
|
81
|
+
endif
|
82
|
+
|
83
|
+
# Standard macros.
|
84
|
+
PROGRAMMER ?= arduino
|
85
|
+
SKETCH = $(notdir $(CURDIR))
|
86
|
+
ARD_BIN = $(ARD_HOME)/hardware/tools/gcc-avr/bin
|
87
|
+
BUILD_DIR = build
|
88
|
+
VPATH = $(LIB_DIRS)
|
89
|
+
|
90
|
+
# Macros derived from boards.txt
|
91
|
+
MCU := $(shell sed -n 's/$(BOARD)\.build\.mcu=\(.*\)/\1/p' < $(ARD_BOARDS))
|
92
|
+
F_CPU := $(shell sed -n 's/$(BOARD)\.build\.f_cpu=\(.*\)/\1/p' < $(ARD_BOARDS))
|
93
|
+
UPLOAD_SPEED := \
|
94
|
+
$(shell sed -n 's/$(BOARD)\.upload\.speed=\(.*\)/\1/p' < $(ARD_BOARDS))
|
95
|
+
|
96
|
+
# Build tools.
|
97
|
+
CC = $(ARD_BIN)/avr-gcc
|
98
|
+
CXX = $(ARD_BIN)/avr-g++
|
99
|
+
CXXFILT = $(ARD_BIN)/avr-c++filt
|
100
|
+
OBJCOPY = $(ARD_BIN)/avr-objcopy
|
101
|
+
OBJDUMP = $(ARD_BIN)/avr-objdump
|
102
|
+
AR = $(ARD_BIN)/avr-ar
|
103
|
+
SIZE = $(ARD_BIN)/avr-size
|
104
|
+
NM = $(ARD_BIN)/avr-nm
|
105
|
+
AVRDUDE = $(ARD_HOME)/hardware/tools/avrdude
|
106
|
+
AVRDUDE_CONF = $(ARD_HOME)/hardware/tools/avrdude.conf
|
107
|
+
MKDIR = mkdir -p
|
108
|
+
RM = rm -rf
|
109
|
+
MV = mv -f
|
110
|
+
|
111
|
+
# Compiler flags.
|
112
|
+
INC_FLAGS = \
|
113
|
+
$(addprefix -I,$(INC_DIRS)) $(addprefix -I,$(LIB_DIRS)) -I$(ARD_SRC_DIR)
|
114
|
+
ARD_FLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARD_REV)
|
115
|
+
C_CXX_FLAGS = \
|
116
|
+
-Wall -Wextra -Wundef -Werror -Wno-unused-parameter \
|
117
|
+
-Wno-attributes -fdiagnostics-show-option -g -Wa,-adhlns=$(BUILD_DIR)/$*.lst
|
118
|
+
C_FLAGS = \
|
119
|
+
$(C_CXX_FLAGS) -std=gnu99 -Wstrict-prototypes -Wno-old-style-declaration
|
120
|
+
CXX_FLAGS = $(C_CXX_FLAGS)
|
121
|
+
|
122
|
+
# Optimiser flags.
|
123
|
+
# optimise for size, unsigned by default, pack data.
|
124
|
+
# separate sections, drop unused ones, shorten branches, jumps.
|
125
|
+
# don't inline, vectorise loops. no exceptions.
|
126
|
+
# no os preamble, use function calls in prologues.
|
127
|
+
# http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc.html
|
128
|
+
# http://www.tty1.net/blog/2008-04-29-avr-gcc-optimisations_en.html
|
129
|
+
# XXX does it really cause it to fail?
|
130
|
+
# NB would like to add -fno-split-wide-types but that makes upload verify fail
|
131
|
+
OPT_FLAGS = \
|
132
|
+
-Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
|
133
|
+
-ffunction-sections -fdata-sections -Wl,--gc-sections,--relax \
|
134
|
+
-fno-inline-small-functions -fno-tree-scev-cprop -fno-exceptions \
|
135
|
+
-ffreestanding -mcall-prologues -fno-split-wide-types
|
136
|
+
|
137
|
+
# Build parameters.
|
138
|
+
IMAGE = $(BUILD_DIR)/$(SKETCH)
|
139
|
+
ARD_C_SRC = $(wildcard $(ARD_SRC_DIR)/*.c)
|
140
|
+
ARD_CXX_SRC = $(filter-out %/main.cpp,$(wildcard $(ARD_SRC_DIR)/*.cpp))
|
141
|
+
ARD_C_OBJ = $(patsubst %.c,%.o,$(notdir $(ARD_C_SRC)))
|
142
|
+
ARD_CXX_OBJ = $(patsubst %.cpp,%.o,$(notdir $(ARD_CXX_SRC)))
|
143
|
+
ARD_LIB = arduino
|
144
|
+
ARD_AR = $(BUILD_DIR)/lib$(ARD_LIB).a
|
145
|
+
ARD_AR_OBJ = $(ARD_AR)($(ARD_C_OBJ) $(ARD_CXX_OBJ))
|
146
|
+
ARD_LD_FLAG = -l$(ARD_LIB)
|
147
|
+
|
148
|
+
# Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734
|
149
|
+
$(ARD_AR)(Tone.o) : CXX_FLAGS += -w
|
150
|
+
|
151
|
+
# Sketch libraries.
|
152
|
+
LIB_C_SRC = $(foreach ld,$(LIB_DIRS),$(wildcard $(ld)/*.c))
|
153
|
+
LIB_CXX_SRC = $(foreach ld,$(LIB_DIRS),$(wildcard $(ld)/*.cpp))
|
154
|
+
LIB_SRC = $(LIB_C_SRC) $(LIB_CXX_SRC)
|
155
|
+
ifneq "$(strip $(LIB_C_SRC) $(LIB_CXX_SRC))" ""
|
156
|
+
LIB_C_OBJ = $(patsubst %.c,%.o,$(notdir $(LIB_C_SRC)))
|
157
|
+
LIB_CXX_OBJ = $(patsubst %.cpp,%.o,$(notdir $(LIB_CXX_SRC)))
|
158
|
+
LIB_LIB = library
|
159
|
+
LIB_AR = $(BUILD_DIR)/lib$(LIB_LIB).a
|
160
|
+
LIB_AR_OBJ = $(LIB_AR)($(LIB_C_OBJ) $(LIB_CXX_OBJ))
|
161
|
+
LIB_LD_FLAG = -l$(LIB_LIB)
|
162
|
+
endif
|
163
|
+
|
164
|
+
# Sketch PDE, C and C++ source.
|
165
|
+
SKT_PDE_SRC = $(wildcard *.pde)
|
166
|
+
SKT_C_SRC = $(wildcard *.c)
|
167
|
+
SKT_CXX_SRC = $(wildcard *.cpp)
|
168
|
+
ifneq "$(strip $(SKT_C_SRC) $(SKT_CXX_SRC))" ""
|
169
|
+
ifneq "$(strip $(SKT_PDE_SRC))" ""
|
170
|
+
SKT_PDE_OBJ = $(BUILD_DIR)/$(SKETCH)_pde.o
|
171
|
+
endif
|
172
|
+
SKT_C_OBJ = $(patsubst %.c,%.o,$(SKT_C_SRC))
|
173
|
+
SKT_CXX_OBJ = $(patsubst %.cpp,%.o,$(SKT_CXX_SRC))
|
174
|
+
SKT_LIB = sketch
|
175
|
+
SKT_AR = $(BUILD_DIR)/lib$(SKT_LIB).a
|
176
|
+
SKT_AR_OBJ = $(SKT_AR)/($(SKT_C_OBJ) $(SKT_CXX_OBJ))
|
177
|
+
SKT_LD_FLAG = -l$(SKT_LIB)
|
178
|
+
endif
|
179
|
+
|
180
|
+
# Definitions.
|
181
|
+
define run-cc
|
182
|
+
$(CC) -c $(C_FLAGS) $(OPT_FLAGS) $(ARD_FLAGS) $(INC_FLAGS) \
|
183
|
+
$< -o $(BUILD_DIR)/$*.o
|
184
|
+
@ $(AR) rc $@ $(BUILD_DIR)/$*.o
|
185
|
+
@ $(RM) $(BUILD_DIR)/$*.o
|
186
|
+
@ $(CXXFILT) < $(BUILD_DIR)/$*.lst > $(BUILD_DIR)/$*.lst.tmp
|
187
|
+
@ $(MV) $(BUILD_DIR)/$*.lst.tmp $(BUILD_DIR)/$*.lst
|
188
|
+
endef
|
189
|
+
|
190
|
+
define run-cxx
|
191
|
+
$(CXX) -c $(CXX_FLAGS) $(OPT_FLAGS) $(ARD_FLAGS) $(INC_FLAGS) \
|
192
|
+
$< -o $(BUILD_DIR)/$*.o
|
193
|
+
@ $(AR) rc $@ $(BUILD_DIR)/$*.o
|
194
|
+
@ $(RM) $(BUILD_DIR)/$*.o
|
195
|
+
@ $(CXXFILT) < $(BUILD_DIR)/$*.lst > $(BUILD_DIR)/$*.lst.tmp
|
196
|
+
@ $(MV) $(BUILD_DIR)/$*.lst.tmp $(BUILD_DIR)/$*.lst
|
197
|
+
endef
|
198
|
+
|
199
|
+
# Rules.
|
200
|
+
.PHONY : all clean upload monitor upload_monitor
|
201
|
+
|
202
|
+
all : $(BUILD_DIR) $(IMAGE).hex
|
203
|
+
|
204
|
+
clean : $(RM) $(BUILD_DIR)
|
205
|
+
|
206
|
+
$(BUILD_DIR) : $(MKDIR) $@
|
207
|
+
|
208
|
+
$(SKT_PDE_OBJ) : $(SKT_PDE_SRC)
|
209
|
+
echo '#include <WProgram.h>' > $(BUILD_DIR)/$(SKETCH)_pde.cpp
|
210
|
+
cat $^ $(ARD_MAIN) >> $(BUILD_DIR)/$(SKETCH)_pde.cpp
|
211
|
+
cd $(BUILD_DIR) && $(CXX) -c $(subst build/,,$(CXX_FLAGS)) \
|
212
|
+
$(OPT_FLAGS) $(ARD_FLAGS) -I.. \
|
213
|
+
$(subst -I../,-I../../,$(INC_FLAGS)) $(SKETCH)_pde.cpp -o $(@F)
|
214
|
+
|
215
|
+
(%.o) : $(ARD_SRC_DIR)/%.c
|
216
|
+
$(run-cc)
|
217
|
+
|
218
|
+
(%.o) : $(ARD_SRC_DIR)/%.cpp
|
219
|
+
$(run-cxx)
|
220
|
+
|
221
|
+
(%.o) : %.c
|
222
|
+
$(run-cc)
|
223
|
+
|
224
|
+
(%.o) : %.cpp
|
225
|
+
$(run-cxx)
|
226
|
+
|
227
|
+
$(IMAGE).hex : $(ARD_AR_OBJ) $(LIB_AR_OBJ) $(SKT_AR_OBJ) $(SKT_PDE_OBJ)
|
228
|
+
$(CXX) $(CXX_FLAGS) $(OPT_FLAGS) $(ARD_FLAGS) -L$(BUILD_DIR) \
|
229
|
+
$(SKT_PDE_OBJ) $(SKT_LD_FLAG) $(LIB_LD_FLAG) $(ARD_LD_FLAG) \
|
230
|
+
-o $(IMAGE).elf
|
231
|
+
$(OBJCOPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load \
|
232
|
+
--no-change-warnings --change-section-lma .eeprom=0 $(IMAGE).elf \
|
233
|
+
$(IMAGE).eep
|
234
|
+
$(OBJCOPY) -O ihex -R .eeprom $(IMAGE).elf $(IMAGE).hex
|
235
|
+
$(SIZE) $(IMAGE).hex
|
236
|
+
|
237
|
+
upload : all
|
238
|
+
- pkill -f $(MON_CMD).*$(PORT)
|
239
|
+
- $(AVRDUDE) -C$(AVRDUDE_CONF) -p$(MCU) -c$(PROGRAMMER) -P$(PORT) \
|
240
|
+
-b$(UPLOAD_SPEED) -D -Uflash:w:$(IMAGE).hex:i -q
|
241
|
+
|
242
|
+
monitor :
|
243
|
+
LD_LIBRARY_PATH= LD_PRELOAD= \
|
244
|
+
$(MON_TERM) -t '$(BOARD) $(PORT)' \
|
245
|
+
-e '$(MON_CMD) -$(MON_SPEED) $(PORT)' &
|
246
|
+
|
247
|
+
upload_monitor : upload monitor
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
module Subduino
|
3
|
+
class Generator
|
4
|
+
|
5
|
+
Files = %w{ Makefile scaffold.rb scaffold.pde}
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def copy_files(dir)
|
9
|
+
name = dir.split("/").last
|
10
|
+
Files.each do |file|
|
11
|
+
puts "Working on #{file}"
|
12
|
+
dump = File.open(File.dirname(__FILE__) + "/#{file}").readlines
|
13
|
+
file.gsub!(/scaffold/, name)
|
14
|
+
File.open(dir + "/#{file}", 'w') do |f|
|
15
|
+
f.write(dump.join.gsub(/!!SCAFFOLD!!/, name))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def os_detect
|
21
|
+
case RUBY_PLATFORM
|
22
|
+
when /linux/ then ""
|
23
|
+
when /darwin/ then ""
|
24
|
+
else raise "Dunno how to play with #{RUBY_PLATFORM}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#
|
2
|
+
# Subduino Persistent Store
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# Uses redis to store.
|
6
|
+
# Maybe Tokyo/PG support in the future...
|
7
|
+
#
|
8
|
+
module Subduino
|
9
|
+
class Store
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def redis
|
13
|
+
@redis ||= Redis.new(:timeout => 0) rescue false
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def read(key)
|
18
|
+
redis.get key
|
19
|
+
end
|
20
|
+
|
21
|
+
def write(key, val=nil)
|
22
|
+
if val
|
23
|
+
add_to_store key, val
|
24
|
+
else
|
25
|
+
key.each do |k,v|
|
26
|
+
add_to_store k, v
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_to_store(k, v)
|
32
|
+
return unless redis.connected?
|
33
|
+
redis.set k, v
|
34
|
+
redis.rpush "#{k}_log", v
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_csv_to_store(csv)
|
38
|
+
Log.info "[STORE] CSV #{Time.now.to_i}"
|
39
|
+
csv.split(",").each do |d|
|
40
|
+
comm, value = d.split(":")
|
41
|
+
write(comm, value)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def count
|
46
|
+
redis.dbsize
|
47
|
+
end
|
48
|
+
|
49
|
+
def flush
|
50
|
+
redis.flushdb
|
51
|
+
#redis.flushall
|
52
|
+
end
|
53
|
+
|
54
|
+
def all
|
55
|
+
redis.keys
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
# def method_missing(*args)
|
60
|
+
# read(args[0])
|
61
|
+
# end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/subduino.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#
|
2
|
+
#
|
3
|
+
# Arduino PubSub Hub
|
4
|
+
#
|
5
|
+
#
|
6
|
+
#
|
7
|
+
require 'serialport'
|
8
|
+
require 'eventmachine'
|
9
|
+
require 'stringio'
|
10
|
+
require 'readline'
|
11
|
+
require 'logger'
|
12
|
+
require 'redis'
|
13
|
+
|
14
|
+
require 'subduino/ard_io'
|
15
|
+
require 'subduino/ard_ps'
|
16
|
+
require 'subduino/parse'
|
17
|
+
require 'subduino/store'
|
18
|
+
require 'subduino/arduino'
|
19
|
+
|
20
|
+
Thread.current.abort_on_exception = false
|
21
|
+
|
22
|
+
module Subduino
|
23
|
+
Log = Logger.new("out.log")
|
24
|
+
BAUDS = 115200 #BAUDS = 9600
|
25
|
+
# BAUDS = [300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200]
|
26
|
+
Sensors = [:temp, :lux]
|
27
|
+
# DATA_BITS = 8
|
28
|
+
# DATA_STOP = 1
|
29
|
+
|
30
|
+
|
31
|
+
def self.start(&proc)
|
32
|
+
trap(:TERM) { stop! }
|
33
|
+
trap(:INT) { stop! }
|
34
|
+
# Start some threads...
|
35
|
+
ArdIO.read &proc
|
36
|
+
ArdPS.read
|
37
|
+
|
38
|
+
# Be a daemon. Should be a better way..
|
39
|
+
# EM.run do; end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.stop!
|
43
|
+
ArdIO.stop!
|
44
|
+
ArdPS.stop!
|
45
|
+
exit 0
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
data/node/arduinode.js
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
// Arduino Node.js
|
2
|
+
|
3
|
+
|
4
|
+
var sys = require('sys'),
|
5
|
+
fs = require('fs'),
|
6
|
+
faye = require('./vendor/faye');
|
7
|
+
|
8
|
+
var dpath = "/dev/ttyUSB1";
|
9
|
+
|
10
|
+
var client = new faye.Client('http://localhost:8000/faye');
|
11
|
+
|
12
|
+
var subscription = client.subscribe('/foo', function(message) {
|
13
|
+
sys.puts("SUB!!!"); // handle message
|
14
|
+
});
|
15
|
+
|
16
|
+
var log = function(txt) {
|
17
|
+
sys.puts(txt)
|
18
|
+
}
|
19
|
+
|
20
|
+
var find_arduino = function(err, stats) {
|
21
|
+
if(err)
|
22
|
+
return log("Arduino not found...");
|
23
|
+
|
24
|
+
log("DUIN!");
|
25
|
+
log(sys.inspect(stats));
|
26
|
+
}
|
27
|
+
|
28
|
+
fs.stat("/dev/ttyUSB1", find_arduino);
|
29
|
+
|
30
|
+
|
31
|
+
var spawn = require('child_process').spawn,
|
32
|
+
stty = spawn('stty -F /dev/ttyUSB1 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts'); //, ['-lh', '/usr']);
|
33
|
+
|
34
|
+
stty.stdout.on('data', function (data) {
|
35
|
+
sys.print('stdout: ' + data);
|
36
|
+
});
|
37
|
+
|
38
|
+
stty.stderr.on('data', function (data) {
|
39
|
+
log("Could not stty " + dpath);
|
40
|
+
log('stderr: ' + data);
|
41
|
+
});
|
42
|
+
|
43
|
+
stty.on('exit', function (code) {
|
44
|
+
if (code == 0)
|
45
|
+
console.log('Done modding stty ' + dpath);
|
46
|
+
});
|
47
|
+
|
48
|
+
|
49
|
+
// stty -F /dev/ttyUSB1 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
|
50
|
+
var rr = fs.createReadStream(dpath, {
|
51
|
+
'flags': 'r',
|
52
|
+
'encoding': 'ascii', // binary, utf8
|
53
|
+
// 'mode': 0666,
|
54
|
+
// 'bufferSize': 4 * 1024
|
55
|
+
});
|
56
|
+
|
57
|
+
|
58
|
+
rr.addListener('data', function (chunk) {
|
59
|
+
log('data: ' + chunk);
|
60
|
+
log(sys.inspect(chunk));
|
61
|
+
});
|
62
|
+
|
63
|
+
rr.on('end', function () {
|
64
|
+
log('end, closed fs');
|
65
|
+
});
|
66
|
+
|
67
|
+
|
68
|
+
|
data/node/server.js
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
// Arduino <> Subduino/Node <> WWW
|
2
|
+
|
3
|
+
var sys = require('sys'),
|
4
|
+
http = require('http'),
|
5
|
+
faye = require('./vendor/faye');
|
6
|
+
|
7
|
+
var bayeux = new faye.NodeAdapter({
|
8
|
+
mount: '/faye',
|
9
|
+
timeout: 45
|
10
|
+
});
|
11
|
+
|
12
|
+
sys.puts("Starting server...");
|
13
|
+
|
14
|
+
// process.on('SIGHUP', function () {
|
15
|
+
// sys.puts('Got SIGHUP signal.');
|
16
|
+
// });
|
17
|
+
// process.on('SIGKILL', function () {
|
18
|
+
// sys.puts('Got SIGHUP signal.');
|
19
|
+
// });
|
20
|
+
|
21
|
+
// Handle non-Bayeux requests
|
22
|
+
var server = http.createServer(function(request, response) {
|
23
|
+
response.writeHead(200, {'Content-Type': 'text/plain'});
|
24
|
+
response.write('Nothing to see here...');
|
25
|
+
response.end();
|
26
|
+
});
|
27
|
+
|
28
|
+
server.on('stream', function(stream) {
|
29
|
+
sys.puts("Stream!");
|
30
|
+
sys.puts(stream);
|
31
|
+
})
|
32
|
+
|
33
|
+
var listen_callback = function() {
|
34
|
+
sys.log("Server started...");
|
35
|
+
}
|
36
|
+
|
37
|
+
bayeux.attach(server);
|
38
|
+
server.listen(8000, listen_callback);
|
39
|
+
|
40
|
+
|
41
|
+
// var client = new faye.Client('http://localhost:8000/faye');
|
42
|
+
// bayeux.getClient().publish('/email/new', {
|
43
|
+
// text: 'New email has arrived!',
|
44
|
+
// inboxSize: 34
|
45
|
+
// });
|