mickeyl / LTSupportAutomotive

An iOS / watchOS / macOS support library for OBD2, VIN-Decoding, and more.
MIT License
212 stars 59 forks source link

OBDLink MX+ via BT Stuck on initializing, Received Data: Error\r #52

Closed dennislysenko closed 3 months ago

dennislysenko commented 3 months ago

Tried by cloning repo, running Demo.xcodeproj and testing with the OBDLink MX+ Model MX201 (3.1) connected via Bluetooth. The OBDLink is connected to Freematics OBD-II emulator (KWP2000, ISO9141-2, CAN BUS & J1850).

In sendInitializationSequence, the responseHandler in transmitRawString is never called. I see in the logs "Received Data: Error\r"

Full log: https://hastebin.com/share/ivobiqulad.xml

Sending ATD command alone causes the same error. Sending ATZ alone gives some sort of output that is not an error:

-[LTOBD2AdapterELM327 receivedData:receiveBuffer:] (LTOBD2AdapterELM327.m:154) Received data: OBD-II EMULATOR V1.2
-[LTOBD2AdapterELM327 receivedData:receiveBuffer:] (LTOBD2AdapterELM327.m:154) Received data: \r\n
-[LTOBD2AdapterELM327 receivedData:receiveBuffer:] (LTOBD2AdapterELM327.m:154) Received data: -[LTOBD2AdapterELM327 receivedData:receiveBuffer:] (LTOBD2AdapterELM327.m:169) Warning: Skipping invalid character 0x00 in response...
-[LTOBD2AdapterELM327 receivedData:receiveBuffer:] (LTOBD2AdapterELM327.m:154) Received data: OBD-II EMULATOR V1.2
-[LTOBD2AdapterELM327 receivedData:receiveBuffer:] (LTOBD2AdapterELM327.m:154) Received data: \r\n00.00.02,00.01.05,
-[LTOBD2AdapterELM327 receivedData:receiveBuffer:] (LTOBD2AdapterELM327.m:154) Received data: 202311,GH202311B****
-[LTOBD2AdapterELM327 receivedData:receiveBuffer:] (LTOBD2AdapterELM327.m:154) Received data: 15,LSGGG************
-[LTOBD2AdapterELM327 receivedData:receiveBuffer:] (LTOBD2AdapterELM327.m:154) Received data: \r\n

(*-ed out some stuff like VIN).

Full log: https://hastebin.com/share/urezewawij.xml

Is there a way to make this work? The adapter is meant to be ELM327 compatible and lists many supported ELM327 commands:

stn1100-frpm (1).pdf

mickeyl commented 3 months ago

It looks like this OBD-II EMULATOR is putting more stuff out on initialization than usually.

Can you please post the full communication log in here? (The file on hastebin did vanish)

dennislysenko commented 3 months ago

I think it was an issue with the adapter I was using--we tried the UniCarScan in the list of supported BLE devices and it started to work. Not sure how MFi works.

On Sun, Mar 31, 2024 at 7:24 AM Dr. Mickey Lauer @.***> wrote:

It looks like this OBD-II EMULATOR is putting more stuff out on initialization than usually.

Can you please post the full communication log in here? (The file on hastebin did vanish)

— Reply to this email directly, view it on GitHub https://github.com/mickeyl/LTSupportAutomotive/issues/52#issuecomment-2028768929, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHAR77ZUWWTY4EOAFNDKADY3AMCHAVCNFSM6AAAAABE6ETHBSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRYG43DQOJSHE . You are receiving this because you authored the thread.Message ID: @.***>

-- Dennis Lysenko

mickeyl commented 3 months ago

Alright. The issue may actually be that LTOBD2AdapterELM327 does not do a full drain of the input buffer before sending the first AT command. The OBD-II EMULATOR dumps a bunch of initialization lines on startup which seem to confuse our class. Upon the next initialization it will work then until you power-cycle the emulator.

While this is a bit unfortunate, I think it's not a showstopper, since "normal" ELM327-derivatives don't do this.