stanleyhuangyc / ArduinoOBD

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

getVin not getting answer #74

Open geetee24 opened 1 year ago

geetee24 commented 1 year 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 1 year 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;
            }