add dtc codes, wip
This commit is contained in:
+23
-1
@@ -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:
|
class Account:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.name = "quoije"
|
self.name = "quoije"
|
||||||
self.pp_image = None
|
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
-2
@@ -1,4 +1,3 @@
|
|||||||
class Car:
|
class Car:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.model = None
|
self.model = None
|
||||||
self.obd = None
|
|
||||||
+15
@@ -95,6 +95,21 @@ def obd_rpm():
|
|||||||
socketio.emit('obd_speed', response.value.to("kph"))
|
socketio.emit('obd_speed', response.value.to("kph"))
|
||||||
finally:
|
finally:
|
||||||
obd_rpm_lock.release()
|
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):
|
def kill_obd(obd_type):
|
||||||
if obd_type == "speed":
|
if obd_type == "speed":
|
||||||
|
|||||||
@@ -38,6 +38,14 @@ socket.on('connect', function(data) {
|
|||||||
console.log('socket.io is connected')
|
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) {
|
socket.on('obd_status', function(data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
const status = document.getElementById('obd-status');
|
const status = document.getElementById('obd-status');
|
||||||
@@ -75,6 +83,12 @@ socket.on('obd_rpm', function(data) {
|
|||||||
status.innerHTML = 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) {
|
socket.on('obd_error', function(data) {
|
||||||
console.log("obd errors "+data);
|
console.log("obd errors "+data);
|
||||||
const status = document.getElementById('obd-error');
|
const status = document.getElementById('obd-error');
|
||||||
|
|||||||
+3
-1
@@ -58,7 +58,9 @@
|
|||||||
<div class="card-header py-3">
|
<div class="card-header py-3">
|
||||||
<p class="text-primary m-0 fw-bold">Output</p>
|
<p class="text-primary m-0 fw-bold">Output</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body"></div>
|
<div class="card-body">
|
||||||
|
<p id="obd-dtc"></p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user