+ global d
+ global l
+ data=str(ser.readline())
+ d=data[4]
+ l=data[2]
+ return d,l
+
+def check():
+ global d
+ global l
+ global dstate
+ global lstate
+ with open('/var/www/html/index.html') as fp:
+ soup=BeautifulSoup((fp),features='html.parser')
+ dstate=soup.find(id='dstate')
+ lstate=soup.find(id='lstate')
+ fp.close()
+ if int(l)==0:
+ lstate.string='OFF'
+ if int(l)==1:
+ lstate.string='ON'
+ if int(d)==1:
+ dstate=soup.find(id='dstate')
+ dstate.string='OPEN'
+ with open('/var/www/html/index.html','w') as writer:
+ writer.write(str(soup))
+ fp.close()
+ writer.close()
+ return dstate
+ elif int(d)==0:
+ dstate.string='CLOSED'
+ with open('/var/www/html/index.html','w') as writer:
+ writer.write(str(soup))
+ fp.close()
+ writer.close()
+ return dstate