comparison service/starArduino/starArduino.py @ 895:84d415fd454e

fix broken request paths Ignore-this: dbfef5f7358cf2b89dc58dd3c377041c darcs-hash:20130817055453-312f9-f1d8488b7434048cecc73f8ee2b4e80e6483e627
author drewp <drewp@bigasterisk.com>
date Fri, 16 Aug 2013 22:54:53 -0700
parents 78a418407eb9
children ca380454d176
comparison
equal deleted inserted replaced
894:3ad6b7bcdaff 895:84d415fd454e
4 """ 4 """
5 from __future__ import division 5 from __future__ import division
6 6
7 import sys,json 7 import sys,json
8 from twisted.internet import reactor, task 8 from twisted.internet import reactor, task
9 from twisted.internet.task import LoopingCall
10 import cyclone.web, restkit 9 import cyclone.web, restkit
11 10
12 sys.path.append("/my/proj/pixel/shiftweb") 11 sys.path.append("/my/proj/pixel/shiftweb")
13 from drvarduino import ShiftbriteArduino 12 from drvarduino import ShiftbriteArduino
14 from shiftweb import hexFromRgb, rgbFromHex 13 from shiftweb import hexFromRgb, rgbFromHex
47 self.write("updated %r" % colors) 46 self.write("updated %r" % colors)
48 47
49 class Barcode(PrettyErrorHandler, cyclone.web.RequestHandler): 48 class Barcode(PrettyErrorHandler, cyclone.web.RequestHandler):
50 def get(self): 49 def get(self):
51 self.set_header("Content-Type", "text/plain") 50 self.set_header("Content-Type", "text/plain")
52 ser = self.settings.arduino.ser 51 ard = self.settings.arduino
53 ser.write("\x60\x02") 52 ard.ser.write("\x60\x02")
54 self.write(str(ser.readJson())) 53 self.write(str(ard.readJson()))
55 54
56 class BarcodeBeep(PrettyErrorHandler, cyclone.web.RequestHandler): 55 class BarcodeBeep(PrettyErrorHandler, cyclone.web.RequestHandler):
57 def put(self): 56 def put(self):
58 self.set_header("Content-Type", "text/plain") 57 self.set_header("Content-Type", "text/plain")
59 ser = self.settings.arduino.ser 58 ard = self.settings.arduino
60 ser.write("\x60\x03") 59 ard.ser.write("\x60\x03")
61 self.write(str(ser.readJson())) 60 self.write(str(ard.readJson()))
62 61
63 def barcodeWatch(arduino, postBarcode): 62 def barcodeWatch(arduino, postBarcode):
64 arduino.ser.write("\xff\xfb") 63 arduino.ser.write("\xff\xfb")
65 ret = arduino.readJson() 64 ret = arduino.readJson()
66 if not ret['barcode']: 65 if not ret['barcode']: