lemberg / obd2-swift-lib

car onboard diagnostic swift library
MIT License
144 stars 39 forks source link

OBD reconnect issue #17

Closed jackangrybird closed 6 years ago

jackangrybird commented 6 years ago

Hi there,

Thanks so much for this awesome library, great work!

I think there is only one problem where the re-connection doesn't seem to work, every time after I done obd.disconnect() , I won't be able to connect back again unless unplugging the OBD dongle and put it back in.

By tracing the code found that the reconnect fail at InitScannerOperation where it return error "ELM error", I've tried different combination like pauseScan, stopScan, resumeScan doesn't seem to make any difference on this issue. Maybe I've missed something, could you help?

Thank you, Jack Roderick

jackangrybird commented 6 years ago

Quick update:

  1. Looks like the disconnect() isn't the culprit as the App still failing at InitScannerOperation even without disconnecting.
  2. I ran other OBD2 App in parallel and the other App was able to connect to the WiFi dongle without any problem at any given time.

something weird is going on that prevent the re-connection from happening, can anyone point me a direction to investigate ? after couple days work I'm totally lost :(

jackangrybird commented 6 years ago

Turns out the issue is causing by OBD2 command mix matching, changing the initial sequence to the following fix my problem:

  1. echo off
  2. linefeed off
  3. timeout set to 125
  4. set protocol