本文整理汇总了Python中arduino.Arduino.isconnected方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.isconnected方法的具体用法?Python Arduino.isconnected怎么用?Python Arduino.isconnected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arduino.Arduino
的用法示例。
在下文中一共展示了Arduino.isconnected方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CloudSensor
# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import isconnected [as 别名]
#.........这里部分代码省略.........
self.mutebutton.config(text='Unmute')
else:
self.mute = False
self.mutebutton.config(text='Mute')
def updatetmp(self):
''' Update the temperatures and gui.
Also check if we need to raise alarm.
'''
if self.stop:
self.frame.after(polldelay, self.updatetmp)
return
if 'Client' in self.csmode.get():
try:
if self.socket is not None:
self.socket.close()
self.socket = None
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.connect((socket.gethostname(), 8001))
mesg = self.socket.recv(32).strip('\0')
self.socket.close()
except Exception as msg:
log.error("client exception: " + str(msg))
if mesg is None:
log.warning("Didn't get a response from the server...")
self.frame.after(polldelay, self.updatetmp)
return
else:
[a, b, c] = mesg.split(';')
self.timearray.append(datetime.datetime.strptime(a.split('.')[0], '%Y-%m-%d %H:%M:%S'))
self.skytmphist.append(int(b))
self.ambtmphist.append(int(c))
else:
log.debug("Arduino is connected? " + str(self.uno.isconnected()))
if self.uno.isconnected() == True:
# Add workaround for 1037.55
newtmp, anewtmp = self.uno.get_temperatures()
if newtmp == '1037.55':
try:
self.skytmphist.append(self.skytmphist[-1])
except IndexError:
self.skytmphist.append('0')
else:
self.skytmphist.append(newtmp)
if anewtmp == '1037.55':
try:
self.ambtmphist.append(self.ambtmphist[-1])
except IndexError:
self.ambtmphist.append('0')
else:
self.ambtmphist.append(anewtmp)
templog.debug("sky=" + str(newtmp) + ":ambient=" + str(anewtmp))
else:
newtmp = randint(0, 100)
anewtmp = randint(0, 100)
templog.debug("sky=" + str(newtmp) + ":ambient=" + str(anewtmp))
self.skytmphist.append(newtmp)
self.ambtmphist.append(anewtmp)
tnow = datetime.datetime.now()
self.timearray.append(tnow)
self.skytemp.config(text=str(self.skytmphist[-1]))
self.ambtemp.config(text=str(self.ambtmphist[-1]))
self.__updateplot()
if (float(self.skytmphist[-1]) > float((self.threshold.get()))) and not self.mute:
log.debug("BEEEEEEEPPPPPP")