Fix README instructions
Hi,
I would first like to thank you for this very useful library.
I started using it with my simulated ECU: https://github.com/spoonieau/OBD2-ECU-Simulator but I was not getting out the right data, while Torque or other ODB apps were able to get them.
I found that the readme lacked some PID configuration for the command to parse the data.
So before I got this data:
2023-12-27 14:15:43.998 29171-30361 PID io.xxx.xxx D : 0.0
2023-12-27 14:15:43.998 29171-30361 PID Formatted Result io.xxx.xxx D 0.0 null
2023-12-27 14:15:45.103 29171-30361 PID io.xxx.xxx D : 0.0
2023-12-27 14:15:45.103 29171-30361 PID Formatted Result io.xxx.xxx D 0.0 null
Then after passing the right parameters to the PID I got ( I configured the simulator to 2000RPM):
2023-12-27 15:14:04.268 29162-30222 PID io.xxx.xxx D : 2000.0
2023-12-27 15:14:04.268 29162-30222 PID Formatted Result io.xxx.xxx D 2000.0 null
2023-12-27 15:14:05.376 29162-30222 PID io.xxx.xxx D : 2000.0
2023-12-27 15:14:05.377 29162-30222 PID Formatted Result io.xxx.xxx D 2000.0 null
2023-12-27 15:14:06.483 29162-30222 PID io.xxx.xxx D : 2000.0
I hope this will be helpful to other developers using this library.
As a side note, I guess some more commands needs to be sent into the socket to properly configure the device.
As if I open torque and then my app everything works just fine, while if I connect the ODB device and open directly my app I get a bunch of garbage data.
Any help in that direction will be more than appreciated, so that I can include it in this PR.
There are some init commands that you need to send over to setup the connection.
Here is a snippet from an app I have connecting to the ELM327 device and right after this block it sends a normal request for a pid and they work.
val MODE_AT = "AT"
//set defaults
initPid.mode = MODE_AT
initPid.PID = "D"
var cmd = OBDCommand(initPid).setIgnoreResult(true).run(inputStream, outputStream)
Log.d(TAG, "Set defaults sent (" + initPid.mode + " " + initPid.PID + ") Received: " + cmd.rawResult)
//resets the ELM327
initPid.mode = MODE_AT
initPid.PID = "Z"
cmd = OBDCommand(initPid).setIgnoreResult(true).run(inputStream, outputStream)
Log.d(TAG, "Reset command sent (" + initPid.mode + " " + initPid.PID + ") Received: " + cmd.rawResult)
//extended responses off
initPid.mode = MODE_AT
initPid.PID = "E0"
cmd = OBDCommand(initPid).setIgnoreResult(true).run(inputStream, outputStream)
Log.d(TAG, "Extended Responses Off (" + initPid.mode + " " + initPid.PID + ") Received: " + cmd.rawResult)
//line feeds off
initPid.mode = MODE_AT
initPid.PID = "L0"
cmd = OBDCommand(initPid).setIgnoreResult(true).run(inputStream, outputStream)
Log.d(TAG, "Turn Off Line Feeds (" + initPid.mode + " " + initPid.PID + ") Received: " + cmd.rawResult)
//printing of spaces off
initPid.mode = MODE_AT
initPid.PID = "S0"
cmd = OBDCommand(initPid).setIgnoreResult(true).run(inputStream, outputStream)
Log.d(TAG, "Printing Spaces Off (" + initPid.mode + " " + initPid.PID + ") Received: " + cmd.rawResult)
//headers off
initPid.mode = MODE_AT
initPid.PID = "H0"
cmd = OBDCommand(initPid).setIgnoreResult(true).run(inputStream, outputStream)
Log.d(TAG, "Headers Off (" + initPid.mode + " " + initPid.PID + ") Received: " + cmd.rawResult)
//set protocol
initPid.mode = "$MODE_AT SP"
initPid.PID = ObdProtocols.AUTO.value.toString()
cmd = OBDCommand(initPid).setIgnoreResult(true).run(inputStream, outputStream)
Log.d(TAG, "Select Protocol (" + initPid.mode + " " + initPid.PID + ") Received: " + cmd.rawResult)
//set timeout for response from the ECU
initPid.mode = "$MODE_AT ST"
initPid.PID = Integer.toHexString(0xFF and ECU_RESPONSE_TIMEOUT)
cmd = OBDCommand(initPid).setIgnoreResult(true).run(inputStream, outputStream)
Im sure this code can be cut down from instructions