forked from lbenthins/ecu-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecu_config.py
65 lines (34 loc) · 1.18 KB
/
ecu_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import json
import os
CONFIG_FILE = os.path.join(os.path.dirname(__file__), "ecu_config.json")
CONFIG = json.load(open(CONFIG_FILE, "r"))
def get_vin():
return CONFIG["vin"].get("value")
def get_ecu_name():
return CONFIG["ecu_name"].get("value")
def get_fuel_level():
return CONFIG["fuel_level"].get("value")
def get_fuel_type():
return CONFIG["fuel_type"].get("value")
def get_dtcs():
return CONFIG["dtcs"].get("value")
def get_obd_broadcast_address():
return create_address(CONFIG["obd_broadcast_address"].get("value"))
def get_obd_ecu_address():
return create_address(CONFIG["obd_ecu_address"].get("value"))
def get_uds_ecu_address():
return create_address(CONFIG["uds_ecu_address"].get("value"))
def create_address(address):
try:
return int(address, 16)
except ValueError as error:
print(error)
exit(1)
def get_can_interface():
return CONFIG["can_interface"].get("value")
def get_can_interface_type():
return CONFIG["can_interface_type"].get("value")
def get_can_bitrate():
return CONFIG["can_bitrate"].get("value")
def get_isotp_ko_file_path():
return CONFIG["isotp_ko_file_path"].get("value")