OBD-II постоянно отправляет «7F 01 12».Python

Программы на Python
Anonymous
OBD-II постоянно отправляет «7F 01 12».

Сообщение Anonymous »

Я пишу программу, которая получает скорость и расход топлива автомобиля от компьютера OBD-II. Скорость работает нормально, но при запросе расхода топлива я всегда получаю «7F 01 12». Как я могу это исправить?
Я использую это для получения данных из интерфейса OBD-II, и вот мой код:
Файл main.py
from OBD import OBD
import datetime

f = open('log.txt', 'w')
obd = OBD()

while True:
# Put the current data and time at the beginning of each section
f.write(str(datetime.datetime.now()))

# Print the received data to the console and save it to the file
data = obd.get(obd.SPEED)
print(data)
f.write(str(data) + "\n")

data = obd.get(obd.FUEL_RATE)
print(data)
f.write(str(data) + "\n")

f.flush() # Call flush to finish writing to the file

Файл OBD.py
import socket
import time

class OBD:
def __init__(self):

# Create the variables to deal with the PIDs
self._PIDs = [b"010D\r", b"015E\r"]
self.SPEED = 0
self.FUEL_RATE = 1

# Create the socket and connect to the OBD device
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect(("192.168.0.10", 35000))

def get(self, pid):
if pid < 0 or pid > 1:
return 0

# Send the request for the data
if self.sock.send(self._PIDs[pid])

Подробнее здесь: https://stackoverflow.com/questions/228 ... g-7f-01-12

Вернуться в «Python»