if int(lista[2]) == 0: IndexError: list index out of range

import serial import time import smtplib from email.mime.text import MIMEText

#nombre del dispositivo serial : dmesg | grep -v disconnect | grep -Eo "tty(ACM|USB)." | tail -1 ser = serial.Serial('/dev/ttyACM0',9600) ser.flushInput()

def iluminacion (lista): #movimiento del robot dato = '5' #envio de las cordenadas gmail if int(lista[2]) == 0:

    correo_origen = '**********'
    contraseƱa = '******'
    correo_destino = '*********'
   
    a = "https://www.google.com/maps?q="
    b = lista[3]
    texto = a  + str(b)
   
    msg = MIMEText(texto)
    msg['Subject'] = 'COORDENADAS DE LA PERSONA '
    msg['From'] = correo_origen
    msg['To'] = correo_destino

    server = smtplib.SMTP('smtp.gmail.com',587)
    server.starttls()
    server.login(correo_origen,contraseƱa)
    server.sendmail(correo_origen,correo_destino,msg.as_string())

    print(texto)

    server.quit()
   
   
return dato
return lista

while True:

try:

    lineBytes = ser.readline()
    line  = lineBytes.decode('latin-1').strip()
    lista = line.split(',')
    print(lista)

    mensaje = iluminacion(lista).encode('latin-1')
    ser.write(mensaje)
    time.sleep(0.5)

except KeyboardInterrupt:
    break


from Recent Questions - Stack Overflow https://ift.tt/38CiOyE
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation