[Python] Undefined variable: SerialException

Discussão em 'Python' iniciado por Stack, Junho 6, 2025.

  1. Stack

    Stack Membro Participativo

    I am using the pySerial library to have a Python script log data from an Arduino. I am trying to handle the SerialException when the script cannot connect to the port you provided, and Eclipse says "Undefined variable: SerialException". Is there something I forgot to import?

    Code:

    try:
    ser = serial.Serial(port, 9600)
    connected = 1
    except SerialException:
    print "No connection to the device could be established"

    Continue reading...

Compartilhe esta Página