本文整理汇总了Python中arduino.Arduino.readAll方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.readAll方法的具体用法?Python Arduino.readAll怎么用?Python Arduino.readAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arduino.Arduino
的用法示例。
在下文中一共展示了Arduino.readAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: verify
# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import readAll [as 别名]
def verify():
global PATHS, DEVICES, SEM,SEM2,ALL
tiempo = 0
while 1:
data = {}
devices = Device.objects.all()
for device in devices:
if device.path not in PATHS:
PATHS.append(device.path)
arduino = Arduino(device.path)
DEVICES.append(arduino)
else:
for dev in DEVICES:
if dev.getLocation() == device.path:
arduino = dev
break
test = True
while test:
#print "while"
#print
try:
data[device.path] = ast.literal_eval(arduino.readAll())
test = False
except:
pass
controllersComplete = ControllerComplete.objects.all()
for controller in controllersComplete:
value = ""
try:
value = data[controller.sensor.device.path][controller.sensor.pin]
except Exception,e:
print e
try:
flag = eval(str(value)+controller.condition+controller.value)
if controller.actuator.ejecute and not flag:
P(SEM)
arduino = Arduino(controller.actuator.device.path)
ActuatorArduino.objects.filter(id = controller.actuator.id).update(ejecute = False)
arduino.digitalWriteDown(controller.actuator.pin)
V(SEM)
elif flag and not controller.actuator.ejecute:
P(SEM)
arduino = Arduino(controller.actuator.device.path)
ActuatorArduino.objects.filter(id = controller.actuator.id).update(ejecute = True)
arduino.digitalWriteUp(controller.actuator.pin)
V(SEM)
except Exception, e:
print e