PowerBroker2/ELMduino

How to change OBD protocol

reflexsa opened this issue · 5 comments

Firstly thanks for this, it was exactly what I was searching for.
I just wanted to ask how/where do I change the OBD protocol? I need to select "const char ISO_15765_11_BIT_500_KBAUD = '6';" to work reliably with my vehicle.
Apologies for the silly question!

The elm should automatically find and use the best protocol, but if you want to specify it yourself, you can do so in the begin() function:

/*
bool ELM327::begin(Stream &stream, const bool& debug, const uint16_t& timeout, const char& protocol, const uint16_t& payloadLen, const byte& dataTimeout)
Description:
------------
* Constructor for the ELM327 Class; initializes ELM327
Inputs:
-------
* Stream &stream - Reference to Serial port connected to ELM327
* bool debug - Specify whether or not to print debug statements to "Serial"
* uint16_t timeout - Time in ms to wait for a query response
* char protocol - Protocol ID to specify the ELM327 to communicate with the ECU over
* uint16_t payloadLen - Maximum number of bytes expected to be returned by the ELM327 after a query
* byte dataTimeout - Number of ms to wait after receiving data before the ELM327 will
return the data - see https://www.elmelectronics.com/help/obd/tips/#UnderstandingOBD
Return:
-------
* bool - Whether or not the ELM327 was properly initialized
*/
bool ELM327::begin(Stream &stream, const bool &debug, const uint16_t &timeout, const char &protocol, const uint16_t &payloadLen, const byte &dataTimeout)

Thank you. For some reason when using my adapter with Torque for example I will get an 'engine check light' unless I specify the protocol. The actual error is communication to the gearbox so it seems that is somehow interfered with.
So would I just change the "const char &protocol" to 6 in the below?
bool ELM327::begin(Stream &stream, const bool &debug, const uint16_t &timeout, const char &protocol, const uint16_t &payloadLen, const byte &dataTimeout)

to:
bool ELM327::begin(Stream &stream, const bool &debug, const uint16_t &timeout, 6, const uint16_t &payloadLen, const byte &dataTimeout)

You would have to add the argument in the sketch kind of like this:

myELM327.begin(ELM_PORT, true, 2000, ISO_15765_11_BIT_500_KBAUD);

Thank you. I see, that does make sense. I'm hoping this will resolve my other issue where I just have a recurring response after the initial AT commands #241