Mercurial > code > home > repos > homeauto
annotate service/arduinoNode/arduinoNode.py @ 293:fc0e42933baa
save data to influxdb, not graphite
Ignore-this: ebf07e54d1949bdf3c2e9a81c5fc7292
author | drewp@bigasterisk.com |
---|---|
date | Mon, 01 Aug 2016 02:26:38 -0700 |
parents | d2c60552fb13 |
children | 6614416dd2c3 |
rev | line source |
---|---|
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
1 """ |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
2 depends on packages: |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
3 arduino-mk |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
4 indent |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
5 """ |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
6 from __future__ import division |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
7 import glob, sys, logging, subprocess, socket, os, hashlib, time, tempfile |
170
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
8 import shutil, json |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
9 import serial |
164 | 10 import cyclone.web |
251
254df9f881a6
start sending oneshot events from some devices
drewp@bigasterisk.com
parents:
243
diff
changeset
|
11 from cyclone.httpclient import fetch |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
12 from rdflib import Graph, Namespace, URIRef, Literal, RDF, ConjunctiveGraph |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
13 from rdflib.parser import StringInputSource |
164 | 14 from twisted.internet import reactor, task |
176
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
15 from docopt import docopt |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
16 |
164 | 17 import devices |
229 | 18 import write_arduino_code |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
19 import dotrender |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
20 import rdflib_patch |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
21 rdflib_patch.fixQnameOfUriWithTrailingSlash() |
164 | 22 |
23 logging.basicConfig(level=logging.DEBUG) | |
24 | |
25 from loggingserial import LoggingSerial | |
26 | |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
27 sys.path.append("../../lib") |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
28 from patchablegraph import PatchableGraph, CycloneGraphHandler, CycloneGraphEventsHandler |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
29 |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
30 sys.path.append("/my/proj/light9") |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
31 from light9.rdfdb.patch import Patch |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
32 from light9.rdfdb.rdflibpatch import inContext |
164 | 33 |
293 | 34 sys.path.append("../piNode") |
35 from export_to_influxdb import InfluxExporter | |
213
9c8674329a13
write some values to carbon/graphite upon polling
drewp@bigasterisk.com
parents:
192
diff
changeset
|
36 |
164 | 37 log = logging.getLogger() |
38 logging.getLogger('serial').setLevel(logging.WARN) | |
39 | |
40 ROOM = Namespace('http://projects.bigasterisk.com/room/') | |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
41 HOST = Namespace('http://bigasterisk.com/ruler/host/') |
164 | 42 |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
43 ACTION_BASE = 10 # higher than any of the fixed command numbers |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
44 |
233
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
45 hostname = socket.gethostname() |
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
46 CTX = ROOM['arduinosOn%s' % hostname] |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
47 |
164 | 48 class Config(object): |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
49 def __init__(self, masterGraph): |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
50 self.graph = ConjunctiveGraph() |
164 | 51 log.info('read config') |
214 | 52 for f in os.listdir('config'): |
53 if f.startswith('.'): continue | |
54 self.graph.parse('config/%s' % f, format='n3') | |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
55 self.graph.bind('', ROOM) # not working |
164 | 56 self.graph.bind('rdf', RDF) |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
57 # config graph is too noisy; maybe make it a separate resource |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
58 #masterGraph.patch(Patch(addGraph=self.graph)) |
164 | 59 |
60 def serialDevices(self): | |
61 return dict([(row.dev, row.board) for row in self.graph.query( | |
62 """SELECT ?board ?dev WHERE { | |
63 ?board :device ?dev; | |
64 a :ArduinoBoard . | |
65 }""", initNs={'': ROOM})]) | |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
66 |
164 | 67 class Board(object): |
68 """an arduino connected to this computer""" | |
69 baudrate = 115200 | |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
70 def __init__(self, dev, configGraph, masterGraph, uri): |
164 | 71 """ |
72 each connected thing has some pins. | |
73 """ | |
74 self.uri = uri | |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
75 self.configGraph = configGraph |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
76 self.masterGraph = masterGraph |
164 | 77 self.dev = dev |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
78 |
233
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
79 self.masterGraph.patch(Patch(addQuads=self.staticStmts())) |
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
80 |
164 | 81 # The order of this list needs to be consistent between the |
82 # deployToArduino call and the poll call. | |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
83 self._devs = devices.makeDevices(configGraph, self.uri) |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
84 self._devCommandNum = dict((dev.uri, ACTION_BASE + devIndex) |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
85 for devIndex, dev in enumerate(self._devs)) |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
86 self._polledDevs = [d for d in self._devs if d.generatePollCode()] |
164 | 87 |
185
2161c71c7b02
support for device code in the idle loop
drewp@bigasterisk.com
parents:
176
diff
changeset
|
88 self._statementsFromInputs = {} # input device uri: latest statements |
243
141079644c45
piNode poll switches much faster. mirror the logic in arduinoNode though vari-rate poll is not supported yet
drewp@bigasterisk.com
parents:
233
diff
changeset
|
89 self._lastPollTime = {} # input device uri: time() |
293 | 90 self._influx = InfluxExporter(self.configGraph) |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
91 self.open() |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
92 for d in self._devs: |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
93 self.syncMasterGraphToHostStatements(d) |
164 | 94 |
170
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
95 def description(self): |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
96 """for web page""" |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
97 return { |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
98 'uri': self.uri, |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
99 'dev': self.dev, |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
100 'baudrate': self.baudrate, |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
101 'devices': [d.description() for d in self._devs], |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
102 } |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
103 |
164 | 104 def open(self): |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
105 self.ser = LoggingSerial(port=self.dev, baudrate=self.baudrate, |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
106 timeout=2) |
164 | 107 |
256 | 108 def startPolling(self, period=.5): |
109 task.LoopingCall(self._poll).start(period) | |
164 | 110 |
111 def _poll(self): | |
112 """ | |
113 even boards with no inputs need some polling to see if they're | |
114 still ok | |
115 """ | |
116 try: | |
117 self._pollWork() | |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
118 except serial.SerialException: |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
119 reactor.crash() |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
120 raise |
164 | 121 except Exception as e: |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
122 import traceback; traceback.print_exc() |
164 | 123 log.warn("poll: %r" % e) |
124 | |
125 def _pollWork(self): | |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
126 t1 = time.time() |
243
141079644c45
piNode poll switches much faster. mirror the logic in arduinoNode though vari-rate poll is not supported yet
drewp@bigasterisk.com
parents:
233
diff
changeset
|
127 self.ser.write("\x60\x00") # "poll everything" |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
128 for i in self._polledDevs: |
256 | 129 try: |
130 now = time.time() | |
131 new = i.readFromPoll(self.ser.read) | |
132 if isinstance(new, dict): # new style | |
133 oneshot = new['oneshot'] | |
134 new = new['latest'] | |
135 else: | |
136 oneshot = None | |
137 prev = self._statementsFromInputs.get(i.uri, []) | |
138 if new or prev: | |
139 self._statementsFromInputs[i.uri] = new | |
140 # it's important that quads from different devices | |
141 # don't clash, since that can lead to inconsistent | |
142 # patches (e.g. | |
143 # dev1 changes value from 1 to 2; | |
144 # dev2 changes value from 2 to 3; | |
145 # dev1 changes from 2 to 4 but this patch will | |
146 # fail since the '2' statement is gone) | |
147 self.masterGraph.patch(Patch.fromDiff(inContext(prev, i.uri), | |
148 inContext(new, i.uri))) | |
149 if oneshot: | |
150 self._sendOneshot(oneshot) | |
151 self._lastPollTime[i.uri] = now | |
152 except: | |
153 log.warn('while polling %r:', i.uri) | |
154 raise | |
164 | 155 #plus statements about succeeding or erroring on the last poll |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
156 byte = self.ser.read(1) |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
157 if byte != 'x': |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
158 raise ValueError("after poll, got %x instead of 'x'" % byte) |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
159 elapsed = time.time() - t1 |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
160 if elapsed > 1.0: |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
161 log.warn('poll took %.1f seconds' % elapsed) |
293 | 162 |
163 self._influx.exportToInflux( | |
164 set.union([set(v) for v in self._statementsFromInputs.values()])) | |
213
9c8674329a13
write some values to carbon/graphite upon polling
drewp@bigasterisk.com
parents:
192
diff
changeset
|
165 |
251
254df9f881a6
start sending oneshot events from some devices
drewp@bigasterisk.com
parents:
243
diff
changeset
|
166 def _sendOneshot(self, oneshot): |
254df9f881a6
start sending oneshot events from some devices
drewp@bigasterisk.com
parents:
243
diff
changeset
|
167 body = (' '.join('%s %s %s .' % (s.n3(), p.n3(), o.n3()) |
254df9f881a6
start sending oneshot events from some devices
drewp@bigasterisk.com
parents:
243
diff
changeset
|
168 for s,p,o in oneshot)).encode('utf8') |
254df9f881a6
start sending oneshot events from some devices
drewp@bigasterisk.com
parents:
243
diff
changeset
|
169 bang6 = 'fcb8:4119:fb46:96f8:8b07:1260:0f50:fcfa' |
254df9f881a6
start sending oneshot events from some devices
drewp@bigasterisk.com
parents:
243
diff
changeset
|
170 fetch(method='POST', |
254df9f881a6
start sending oneshot events from some devices
drewp@bigasterisk.com
parents:
243
diff
changeset
|
171 url='http://[%s]:9071/oneShot' % bang6, |
254df9f881a6
start sending oneshot events from some devices
drewp@bigasterisk.com
parents:
243
diff
changeset
|
172 headers={'Content-Type': ['text/n3']}, postdata=body, |
254df9f881a6
start sending oneshot events from some devices
drewp@bigasterisk.com
parents:
243
diff
changeset
|
173 timeout=5) |
254df9f881a6
start sending oneshot events from some devices
drewp@bigasterisk.com
parents:
243
diff
changeset
|
174 |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
175 def outputStatements(self, stmts): |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
176 unused = set(stmts) |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
177 for dev in self._devs: |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
178 stmtsForDev = [] |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
179 for pat in dev.outputPatterns(): |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
180 if [term is None for term in pat] != [False, False, True]: |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
181 raise NotImplementedError |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
182 for stmt in stmts: |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
183 if stmt[:2] == pat[:2]: |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
184 stmtsForDev.append(stmt) |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
185 unused.discard(stmt) |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
186 if stmtsForDev: |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
187 log.info("output goes to action handler for %s" % dev.uri) |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
188 self.ser.write("\x60" + chr(self._devCommandNum[dev.uri])) |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
189 dev.sendOutput(stmtsForDev, self.ser.write, self.ser.read) |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
190 if self.ser.read(1) != 'k': |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
191 raise ValueError( |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
192 "%s sendOutput/generateActionCode didn't use " |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
193 "matching output bytes" % dev.__class__) |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
194 # Dev *could* change hostStatements at any time, and |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
195 # we're not currently tracking that, but the usual is |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
196 # to change them in response to sendOutput so this |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
197 # should be good enough. The right answer is to give |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
198 # each dev the masterGraph for it to write to. |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
199 self.syncMasterGraphToHostStatements(dev) |
233
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
200 log.info("output and masterGraph sync complete") |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
201 if unused: |
218
f8ffb9d8d982
multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents:
214
diff
changeset
|
202 log.info("Board %s doesn't care about these statements:", self.uri) |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
203 for s in unused: |
233
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
204 log.warn("%r", s) |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
205 |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
206 def syncMasterGraphToHostStatements(self, dev): |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
207 hostStmtCtx = URIRef(dev.uri + '/host') |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
208 newQuads = inContext(dev.hostStatements(), hostStmtCtx) |
233
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
209 p = self.masterGraph.patchSubgraph(hostStmtCtx, newQuads) |
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
210 log.debug("patch master with these host stmts %s", p) |
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
211 |
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
212 def staticStmts(self): |
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
213 return [(HOST[hostname], ROOM['connectedTo'], self.uri, CTX)] |
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
214 |
164 | 215 def generateArduinoCode(self): |
233
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
216 code = write_arduino_code.writeCode(self.baudrate, self._devs, |
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
217 self._devCommandNum) |
229 | 218 code = write_arduino_code.indent(code) |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
219 cksum = hashlib.sha1(code).hexdigest() |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
220 code = code.replace('CODE_CHECKSUM', cksum) |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
221 return code, cksum |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
222 |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
223 def _readBoardChecksum(self, length): |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
224 # this is likely right after reset, so it might take 2 seconds |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
225 for tries in range(6): |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
226 self.ser.write("\x60\x01") |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
227 try: |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
228 return self.ser.read(length) |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
229 except ValueError: |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
230 if tries == 5: |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
231 raise |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
232 time.sleep(.5) |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
233 raise ValueError |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
234 |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
235 def _boardIsCurrent(self, currentChecksum): |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
236 try: |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
237 boardCksum = self._readBoardChecksum(len(currentChecksum)) |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
238 if boardCksum == currentChecksum: |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
239 log.info("board has current code (%s)" % currentChecksum) |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
240 return True |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
241 else: |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
242 log.info("board responds with incorrect code version") |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
243 except Exception as e: |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
244 log.info("can't get code version from board: %r" % e) |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
245 return False |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
246 |
164 | 247 def deployToArduino(self): |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
248 code, cksum = self.generateArduinoCode() |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
249 |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
250 if self._boardIsCurrent(cksum): |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
251 return |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
252 |
164 | 253 try: |
254 if hasattr(self, 'ser'): | |
255 self.ser.close() | |
256 workDir = tempfile.mkdtemp(prefix='arduinoNode_board_deploy') | |
257 try: | |
258 self._arduinoMake(workDir, code) | |
259 finally: | |
260 shutil.rmtree(workDir) | |
261 finally: | |
262 self.open() | |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
263 |
164 | 264 def _arduinoMake(self, workDir, code): |
265 with open(workDir + '/makefile', 'w') as makefile: | |
229 | 266 makefile.write(write_arduino_code.writeMakefile( |
267 dev=self.dev, | |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
268 tag=self.configGraph.value(self.uri, ROOM['boardTag']), |
229 | 269 allLibs=sum((d.generateArduinoLibs() for d in self._devs), []))) |
164 | 270 |
271 with open(workDir + '/main.ino', 'w') as main: | |
272 main.write(code) | |
273 | |
274 subprocess.check_call(['make', 'upload'], cwd=workDir) | |
275 | |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
276 |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
277 def currentGraph(self): |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
278 g = Graph() |
164 | 279 |
280 | |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
281 for dev in self._devs: |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
282 for stmt in dev.hostStatements(): |
164 | 283 g.add(stmt) |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
284 return g |
164 | 285 |
286 class Dot(cyclone.web.RequestHandler): | |
287 def get(self): | |
166
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
288 configGraph = self.settings.config.graph |
c0180bd2b33a
only recompile if the C code is new. redo Device class api. single temperature sensor is working
drewp@bigasterisk.com
parents:
164
diff
changeset
|
289 dot = dotrender.render(configGraph, self.settings.boards) |
164 | 290 self.write(dot) |
291 | |
292 class ArduinoCode(cyclone.web.RequestHandler): | |
293 def get(self): | |
294 board = [b for b in self.settings.boards if | |
295 b.uri == URIRef(self.get_argument('board'))][0] | |
218
f8ffb9d8d982
multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents:
214
diff
changeset
|
296 self.set_header('Content-Type', 'text/plain') |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
297 code, cksum = board.generateArduinoCode() |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
298 self.write(code) |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
299 |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
300 def rdfGraphBody(body, headers): |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
301 g = Graph() |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
302 g.parse(StringInputSource(body), format='nt') |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
303 return g |
176
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
304 |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
305 class OutputPage(cyclone.web.RequestHandler): |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
306 def post(self): |
176
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
307 # for old ui; use PUT instead |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
308 stmts = list(rdfGraphBody(self.request.body, self.request.headers)) |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
309 for b in self.settings.boards: |
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
310 b.outputStatements(stmts) |
176
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
311 |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
312 def put(self): |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
313 subj = URIRef(self.get_argument('s')) |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
314 pred = URIRef(self.get_argument('p')) |
170
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
315 |
176
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
316 turtleLiteral = self.request.body |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
317 try: |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
318 obj = Literal(float(turtleLiteral)) |
185
2161c71c7b02
support for device code in the idle loop
drewp@bigasterisk.com
parents:
176
diff
changeset
|
319 except ValueError: |
176
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
320 obj = Literal(turtleLiteral) |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
321 |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
322 stmt = (subj, pred, obj) |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
323 for b in self.settings.boards: |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
324 b.outputStatements([stmt]) |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
325 |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
326 |
170
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
327 class Boards(cyclone.web.RequestHandler): |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
328 def get(self): |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
329 self.set_header('Content-type', 'application/json') |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
330 self.write(json.dumps({ |
233
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
331 'host': hostname, |
170
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
332 'boards': [b.description() for b in self.settings.boards] |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
333 }, indent=2)) |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
334 |
164 | 335 def currentSerialDevices(): |
336 log.info('find connected boards') | |
337 return glob.glob('/dev/serial/by-id/*') | |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
338 |
164 | 339 def main(): |
176
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
340 arg = docopt(""" |
218
f8ffb9d8d982
multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents:
214
diff
changeset
|
341 Usage: arduinoNode.py [options] |
176
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
342 |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
343 -v Verbose |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
344 """) |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
345 log.setLevel(logging.WARN) |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
346 if arg['-v']: |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
347 from twisted.python import log as twlog |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
348 twlog.startLogging(sys.stdout) |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
349 |
f81c4d3d774b
arduinoNode: use -v for logging; support a PUT with subj+pred in query, obj in body
drewp@bigasterisk.com
parents:
170
diff
changeset
|
350 log.setLevel(logging.DEBUG) |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
351 |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
352 masterGraph = PatchableGraph() |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
353 config = Config(masterGraph) |
164 | 354 current = currentSerialDevices() |
355 | |
356 boards = [] | |
357 for dev, board in config.serialDevices().items(): | |
358 if str(dev) not in current: | |
359 continue | |
360 log.info("we have board %s connected at %s" % (board, dev)) | |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
361 b = Board(dev, config.graph, masterGraph, board) |
164 | 362 boards.append(b) |
363 | |
218
f8ffb9d8d982
multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents:
214
diff
changeset
|
364 for b in boards: |
f8ffb9d8d982
multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents:
214
diff
changeset
|
365 b.deployToArduino() |
164 | 366 |
367 log.info('open boards') | |
368 for b in boards: | |
256 | 369 b.startPolling(period=.1 if not arg['-v'] else 10) |
164 | 370 |
190
ad20e5cb4feb
serve ipv6 and use localhost's ipv6 name for getting updates
drewp@bigasterisk.com
parents:
185
diff
changeset
|
371 |
233
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
372 reactor.listenTCP(9059, cyclone.web.Application([ |
170
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
373 (r"/()", cyclone.web.StaticFileHandler, { |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
374 "path": "static", "default_filename": "index.html"}), |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
375 (r'/static/(.*)', cyclone.web.StaticFileHandler, {"path": "static"}), |
376599552a4c
polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
169
diff
changeset
|
376 (r'/boards', Boards), |
230
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
377 (r"/graph", CycloneGraphHandler, {'masterGraph': masterGraph}), |
0aa54404df19
update arduinoNode to support streamed graph output
drewp@bigasterisk.com
parents:
229
diff
changeset
|
378 (r"/graph/events", CycloneGraphEventsHandler, {'masterGraph': masterGraph}), |
169
d228105749ac
new /output to post statements which devices can handle. led and lcd output working
drewp@bigasterisk.com
parents:
166
diff
changeset
|
379 (r'/output', OutputPage), |
164 | 380 (r'/arduinoCode', ArduinoCode), |
381 (r'/dot', Dot), | |
233
4ebb5cc30002
server/browser graph sync. cut dependency on the WS version. merge some changes between arduino/pi code.
drewp@bigasterisk.com
parents:
230
diff
changeset
|
382 ], config=config, boards=boards), interface='::') |
164 | 383 reactor.run() |
384 | |
385 main() |