首页 > 解决方案 > OBD-Python 无法获取 VIN 号

问题描述

我正在使用 OBD-Python 库,当我尝试从我的车辆中获取 VIN 号时,即使遵循自定义命令文档,我也会收到以下消息:

[obd.obd] 'b'0902':不支持 VIN NUMBER 日期:2018-07-09 14:48:30.428588 -- VIN NUMBER:无。

def vin(messages):
""" decoder for RPM messages """
d = messages[0].data # only operate on a single message
d = d[2:] # chop off mode and PID bytes
v = bytes_to_int(d) / 4.0  # helper function for converting byte arrays to ints
return v * Unit.VIN # construct a Pint Quantity
c = OBDCommand("VIN",           # name
           "VIN NUMBER",    # description
           b"0902",         # command
           17,              # number of return bytes to expect
           vin,             # decoding function
           ECU.ENGINE,      # (optional) ECU filter
           True)            # (optional) allow a "01" to be added for speed
o = obd.OBD()
o.supported_commands.add(c)
o.query(c)
print('Data: ' + str(datetime.datetime.now()) + ' -- VIN NUMBER: '+str(connection.query(c)))

我做错了什么?

标签: pythonobd-iivin

解决方案


你没有做错什么。SAE J1979 定义的几乎所有命令都是可选的——供应商可以选择是否实现它们。就您的车辆而言,供应商似乎决定反对它。


推荐阅读