Skip to content

Commit

Permalink
Merge pull request #511 from jneuhauser/fix-elm-maxspeed
Browse files Browse the repository at this point in the history
Fix ELM maxspeed parameter handling
  • Loading branch information
cedricp authored Jan 1, 2021
2 parents dca6112 + e64c3bc commit 0fd5a90
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
13 changes: 7 additions & 6 deletions elm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -603,15 +599,20 @@ 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)
except:
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)
Expand Down

0 comments on commit 0fd5a90

Please sign in to comment.