add dtc codes, wip

This commit is contained in:
Mathieu Moran
2023-11-06 17:46:54 -05:00
parent 86e6de5bab
commit 37f7d99883
5 changed files with 56 additions and 4 deletions
+23 -1
View File
@@ -1,5 +1,27 @@
import app_car as Car
account_car = Car()
account_car.model = "YARIS"
account_pp_image = "static\img\image.png"
account_info = ["name","pp_image", "car_model"]
class Account:
def __init__(self):
self.name = "quoije"
self.pp_image = None
self.car = None
self.car = account_car.model
def account_info():
obd_speed_lock.acquire()
cmd = obd.commands.GET_DTC # select an OBD command (sensor)
response = connection.query(cmd) # send the command and parse the response
try:
if response.is_null():
error_txt = "No data received."
print(error_txt)
socketio.emit('obd_dtc', error_txt)
else:
print(response.value)
socketio.emit('obd_dtc', response.value)
finally:
obd_rpm_lock.release()
-1
View File
@@ -1,4 +1,3 @@
class Car:
def __init__(self):
self.model = None
self.obd = None
+15
View File
@@ -96,6 +96,21 @@ def obd_rpm():
finally:
obd_rpm_lock.release()
def obd_dtc():
obd_speed_lock.acquire()
cmd = obd.commands.GET_DTC # select an OBD command (sensor)
response = connection.query(cmd) # send the command and parse the response
try:
if response.is_null():
error_txt = "No data received."
print(error_txt)
socketio.emit('obd_dtc', error_txt)
else:
print(response.value)
socketio.emit('obd_dtc', response.value)
finally:
obd_rpm_lock.release()
def kill_obd(obd_type):
if obd_type == "speed":
obd_speed.loop = False
+14
View File
@@ -38,6 +38,14 @@ socket.on('connect', function(data) {
console.log('socket.io is connected')
});
socket.on('account_info', function(data) {
console.log(data);
// car model
const car_model = document.getElementById('index-car-model');
car_model.innerHTML = data;
});
socket.on('obd_status', function(data) {
console.log(data);
const status = document.getElementById('obd-status');
@@ -75,6 +83,12 @@ socket.on('obd_rpm', function(data) {
status.innerHTML = data;
});
socket.on('obd_dtc', function(data) {
console.log("obd dtc "+data);
const status = document.getElementById('obd-dtc');
status.innerHTML = data;
});
socket.on('obd_error', function(data) {
console.log("obd errors "+data);
const status = document.getElementById('obd-error');
+3 -1
View File
@@ -58,7 +58,9 @@
<div class="card-header py-3">
<p class="text-primary m-0 fw-bold">Output</p>
</div>
<div class="card-body"></div>
<div class="card-body">
<p id="obd-dtc"></p>
</div>
</div>
</div>
</div>