Hello Guys
i need help with creating a bash script which connect over an obd2 cable to my car.
The bash script must open a Termial connection to /dev/ttyUSB0 (baud rate 9600 8N1).
After that you can write "010C" at the promt, and you get an HEX dump of the RPM signal.
i found with google a way to decode hex numbers with the follow command:
Code:
linux:~ echo $((0x7B))
it gives me
123 back
A short example what i mean:
i write "
010C" at the termial and get this:
Code:
010C
41 0C 00 00
Note: The echo function is on.
For me are the last 4 numbers important:
Quote:
Mode(hex) = 01
PID(hex) = 0C
Data bytes returned = 2
Description = Engine RPM
Min value = 0
Max value = 16,383.75
Units = rpm
Formula = ((A*256)+B)/4
wikipedia says i must calculate the first "00 = A" with the second "00 = B".
This is the formula what i need to get the right "((A*256)+B)/4" RPM Speed.
Note: i know it is 00 my engine was not running.
Another Example:
Quote:
Mode (hex) = 01
PID (hex) = 05
Data bytes returned = 1
Description = Engine coolant temperature
Min value = -40
Max value = 215
Units = °C
Formula = A-40
ok i write the OBD2 Pid "0105" to the Terminal and get this:
Code:
0105
41 05 39
wikipedia says i must subtract my hex encoded answer with 40.
Code:
linux:~# echo $((0x39))
57
57-40 = 17
OBD2 tells me my current Engine coolant temperature is: 17 °C.
i dont know how can i open a terminal session and grab the output.
Thanks for help
Robert
Links:
Wikipedia OBD2 PID List