This repository was archived by the owner on Nov 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstubs.py
More file actions
73 lines (52 loc) · 1.26 KB
/
stubs.py
File metadata and controls
73 lines (52 loc) · 1.26 KB
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
63
64
65
66
67
68
69
70
71
72
73
from random import randint
from obd import OBDStatus, OBD
from obd.protocols import ISO_15765_4_11bit_500k
from obd.protocols.protocol import Frame, Message, ECU
class ObdStub(OBD):
def status(self):
return OBDStatus.CAR_CONNECTED
@property
def interface(self):
if not hasattr(self, '__interface'):
self.__interface = ELMStub()
return self.__interface
@interface.setter
def interface(self, _):
pass
class ELMStub:
def set_protocol(self, protocol_):
return True
def manual_protocol(self, protocol_):
return False
def auto_protocol(self):
return True
def set_baudrate(self, baud):
return True
def auto_baudrate(self):
return False
def port_name(self):
return ""
def status(self):
return OBDStatus.CAR_CONNECTED
def ecus(self):
return True
def protocol_name(self):
return ISO_15765_4_11bit_500k
def protocol_id(self):
return "8"
def low_power(self):
return self.__read()
def normal_power(self):
return self.__read()
def close(self):
pass
def send_and_parse(self, cmd):
return self.__read()
def __read(self):
result = []
for _ in range(1):
message = Message([Frame("1" * 256)])
message.ecu = ECU.ALL
message.data = bytearray([randint(0, 255) for _ in range(6)])
result.append(message)
return result