doorbell: USB Symlink
This commit is contained in:
@@ -18,12 +18,15 @@ logger.addHandler(logHandler)
|
|||||||
logger.info('Initializing')
|
logger.info('Initializing')
|
||||||
|
|
||||||
|
|
||||||
arduino = serial.Serial('/dev/ttyUSB0', 9600, timeout=.1)
|
arduino = serial.Serial('/dev/Doorbell', 9600, timeout=.1)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
data = arduino.readline()[:-2] #the last bit gets rid of the new-line chars
|
data = arduino.readline()[:-2] #the last bit gets rid of the new-line chars
|
||||||
if data:
|
if data:
|
||||||
|
try:
|
||||||
data = data.decode('utf8')
|
data = data.decode('utf8')
|
||||||
|
except (UnicodeDecodeError) as ude:
|
||||||
|
logger.error(ude)
|
||||||
if (data == 'RING'):
|
if (data == 'RING'):
|
||||||
try:
|
try:
|
||||||
response = urllib.request.urlopen('http://192.168.178.51/bell/on', timeout=5).read().decode('utf-8')
|
response = urllib.request.urlopen('http://192.168.178.51/bell/on', timeout=5).read().decode('utf-8')
|
||||||
|
|||||||
Reference in New Issue
Block a user