diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..67177193 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +### ddt4all specific +/ecu.zip +/ecus/ +/logs/ + +### Python generic ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +### IDE generic ### +/.vscode/ diff --git a/elm.py b/elm.py index 993482a2..472e674e 100644 --- a/elm.py +++ b/elm.py @@ -568,10 +568,6 @@ def __init__(self, portName, rate, adapter_type="STD", maxspeed="No"): self.sim_mode = options.simulation_mode self.portName = portName self.adapter_type = adapter_type - if maxspeed == "No": - maxspeed = 0 - else: - maxspeed = int(maxspeed) if not options.simulation_mode: self.port = Port(portName, speed, self.portTimeout) @@ -603,7 +599,12 @@ def __init__(self, portName, rate, adapter_type="STD", maxspeed="No"): rate = speed break - if adapter_type == "OBDLINK" and maxspeed and not options.elm_failed and rate != 2000000: + try: + maxspeed = int(maxspeed) + except: + maxspeed = 0 + + if adapter_type == "OBDLINK" and maxspeed > 0 and not options.elm_failed and rate != 2000000: print("OBDLink Connection OK, attempting full speed UART switch") try: self.raise_odb_speed(maxspeed) @@ -611,7 +612,7 @@ def __init__(self, portName, rate, adapter_type="STD", maxspeed="No"): options.elm_failed = True self.connectionStatus = False print("Failed to switch to change OBDLink to " + str(maxspeed)) - elif adapter_type == "STD_USB" and rate != 115200 and maxspeed: + elif adapter_type == "STD_USB" and rate != 115200 and maxspeed > 0: print("ELM Connection OK, attempting high speed UART switch") try: self.raise_elm_speed(maxspeed)