brendan-w / python-OBD

OBD-II serial module for reading engine data
GNU General Public License v2.0
1.02k stars 360 forks source link

Fix truncation of last character of VIN by modifying decode_encoded_string() #275

Closed gwillgues closed 1 month ago

gwillgues commented 1 month ago

When retrieving VIN via the following example code, I received 16 characters instead of the proper 17, and the trailing "0" in my VIN was truncated.

connection = obd.OBD()

cmd = obd.commands.VIN
response = connection.query(cmd)
print(response.value)

I modified decode_encoded_string() in decoders.py to use the .replace() function instead of .strip() to remove '\x00', '\x01', and '\x02', which resolved the issue in my testing.