-
Notifications
You must be signed in to change notification settings - Fork 3
/
my_scan.py
281 lines (251 loc) · 8.12 KB
/
my_scan.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
import logging
from timeit import default_timer as timer
log = logging.getLogger(__name__)
def known():
"""
OBD scan of known pids
"""
log.info ("SALT: "+str(__salt__))
"""
args = ['7E4#220101']
kwargs = {
'auto_format': True,
'expect_response': True,
'raw_response': True,
'baudrate': 500000,
'protocol': '6'
}
res = __salt__['obd.send'](*args, **kwargs)
values = res['values']
log.info ("TEST: auto_format: True raw_response: True "+str(values))
line = values[0]
log.info ("TEST: auto_format: True raw_response: True "+str(line))
char = line[0:1]
log.info ("TEST: auto_format: True raw_response: True "+str(char))
int = bytes_to_int(line[0:1])
log.info ("TEST: auto_format: True raw_response: True "+str(int))
"""
# 7A0 / 7A8 - BCM / TPMS
for mode in ['22']:
for pid in ['B00C','B00E','C002','C00B']:
args = ['scan '+mode+pid]
kwargs = {
'mode': mode,
'pid': pid,
'header': '7A0',
'baudrate': 500000,
'protocol': '6',
'verify': False,
'force': True,
}
log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))
# 7E4/7EC = BMC
for mode in ['220']:
for pid in ['101','102','103','104','105','106']:
args = ['scan '+mode+pid]
kwargs = {
'mode': mode,
'pid': pid,
'header': '7E4',
'baudrate': 500000,
'protocol': '6',
'verify': False,
'force': True,
}
log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))
# 7E3 / 7EB = MCU
for mode in ['21']:
for pid in ['01','02','03','04','05','06','12']:
args = ['scan '+mode+pid]
kwargs = {
'mode': mode,
'pid': pid,
'header': '7E3',
'baudrate': 500000,
'protocol': '6',
'verify': False,
'force': True,
}
log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))
# 7E5/7ED = OBC
for mode in ['21']:
for pid in ['01','03']:
args = ['scan '+mode+pid]
kwargs = {
'mode': mode,
'pid': pid,
'header': '7E5',
'baudrate': 500000,
'protocol': '6',
'verify': False,
'force': True,
}
log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))
# 7E2/7EA = VMCU
for mode in ['21']:
for pid in ['01','02']:
args = ['scan '+mode+pid]
kwargs = {
'mode': mode,
'pid': pid,
'header': '7E2',
'baudrate': 500000,
'protocol': '6',
'verify': False,
'force': True,
}
log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))
# 7C6/7CE Cluster odometer
for mode in ['22']:
for pid in ['B002']:
args = ['scan '+mode+pid]
kwargs = {
'mode': mode,
'pid': pid,
'header': '7C6',
'baudrate': 500000,
'protocol': '6',
'verify': False,
'force': True,
}
log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))
# 770/778 IGMP
for mode in ['22']:
for pid in ['BC03','BC04','BC07']:
args = ['scan '+mode+pid]
kwargs = {
'mode': mode,
'pid': pid,
'header': '770',
'baudrate': 500000,
'protocol': '6',
'verify': False,
'force': True,
}
log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))
# 7B3/7BB AirCon
for mode in ['220']:
for pid in ['100','102']:
args = ['scan '+mode+pid]
kwargs = {
'mode': mode,
'pid': pid,
'header': '7B3',
'baudrate': 500000,
'protocol': '6',
'verify': False,
'force': True,
}
log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))
# 7D1/7D9 ABS ESP
for mode in ['22']:
for pid in ['C101']:
args = ['scan '+mode+pid]
kwargs = {
'mode': mode,
'pid': pid,
'header': '7D1',
'baudrate': 500000,
'protocol': '6',
'verify': False,
'force': True,
}
log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))
# 7E6/7EE ??
for mode in ['21']:
for pid in ['0805','0806','0807','0808','0809','080a','080b','080c','080d','080e','080f']:
args = ['scan '+mode+pid]
kwargs = {
'mode': mode,
'pid': pid,
'header': '7E6',
'baudrate': 500000,
'protocol': '6',
'verify': False,
'force': True,
}
log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))
return {"msg": "Scan finished"}
def test():
"""
OBD scan
torque scan does :
24 plus [ 0 to 1F in hex ] plus FFFF
21 plus [ 0 to 110 in hex ] basic scan
21 plus [ 0 to 255 in hex ] full scan
22 plus [ 0 to 255 in hex ] plus [ 0 to 15 in hex ] plus 01 basic scan
22 plus [ 0 to 255 in hex ] plus [ 0 to 255 in hex ] plus 01 full scan
"""
"""
for mode in [ '24']:
count = 0
while count < 32:
pid = "{:02X}FFFF".format(count)
count += 1
args = ['scan '+mode+pid]
kwargs = {
'mode': mode,
'pid': pid,
'baudrate': 500000,
'protocol': '6',
'verify': False,
'force': True,
}
log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))
"""
for mode in [ '220', '221']:
count = 0
while count <= 4095:
pid = "{:02X}".format(count)
count += 1
args = ['scan '+mode+pid]
kwargs = {
'mode': mode,
'pid': pid,
'baudrate': 500000,
'protocol': '6',
'verify': False,
'force': True,
}
log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))
"""
for mode in [ '21', '22']:
a = 0
while a <= 255:
b = 0
while b <= 15:
pid = "{:02X}".format(a)+"{:02X}".format(b)
b += 1
args = ['scan '+mode+pid]
kwargs = {
'mode': mode,
'pid': pid,
'baudrate': 500000,
'protocol': '6',
'verify': False,
'force': True,
}
log.info ("SCAN: "+mode+" "+pid+" "+str(__salt__['obd.query'](*args, **kwargs)))
a += 1
"""
return {"msg": "Scan finished"}
def send():
"""
OBD scan via obd.send
"""
args = ['7E4#220101']
kwargs = {
'auto_format': True,
'raw_response': True,
'expect_response': True,
'baudrate': 500000,
'protocol': '6'
}
start = timer()
res = __salt__['obd.send'](*args, **kwargs)
end = timer()
log.info ("TIME: "+str(end-start))
#values = res['values'][0][0:1]
log.info ("SEND: "+str(res))
#log.info ("SEND: "+str(values))
return {"msg": str(res)}