stanleyhuangyc / ArduinoOBD

OBD-II library and sketches for Arduino
http://freematics.com
986 stars 518 forks source link

getVin not getting answer #74

Open geetee24 opened 2 years ago

geetee24 commented 2 years ago

used your example code but it gets NO vin.

raw data is:

VIN: 014 0: 49 02 01 32 54 32 1: 5A 4B 31 42 41 39 41 2: 43 30 32 014 0: 49 02 01 32 54 32 1: 5A 4B 31 42 41 39 41 2: 43 30 32 014 0: 49 02 01 32 54 32 1: 5A 4B 31 42 41 39 41 2: 43 30 32 014 0: 49 02 01 32 54 32 1: 5A 4B 31 42 41 39 41 2: 43 30 32 014 0: 49 02 01 32 54 32 1: 5A 4B 31 42 41 39 41 2: 43 30 32

why not working? My handheld ODB2 gets the vin.

geetee24 commented 2 years ago

i found the issue.

your lib asssume USA 17 digit VINs.

for foreign cars its 14 digit VINs.

so your code needs to be changed to

            if (
                ( q - buffer == len - 3 ) ||
                ( q - buffer == len - 7 ) ) {

                return true;
            }