@@ -265,39 +265,20 @@ def parse_message(self, message):
265265 # chop to the correct size (as specified in the first frame)
266266 message .data = message .data [:ff [0 ].data_len ]
267267
268- """
269- # chop off the Mode/PID bytes based on the mode number
270- mode = message.data[0]
271- if mode == 0x43:
272268
269+ # trim DTC requests based on DTC count
270+ # this ISN'T in the decoder because the legacy protocols
271+ # don't provide a DTC_count bytes, and instead, insert a 0x00
272+ # for consistency
273+
274+ if message .data [0 ] == 0x43 :
273275 # []
274276 # 43 03 11 11 22 22 33 33
275277 # [DTC] [DTC] [DTC]
276278
277- # fetch the DTC count, and use it as a length code
278- num_dtc_bytes = message.data[1] * 2
279-
280- # skip the PID byte and the DTC count,
281- message.data = message.data[2:][:num_dtc_bytes]
279+ num_dtc_bytes = message .data [1 ] * 2 # each DTC is 2 bytes
280+ message .data = message .data [:(num_dtc_bytes + 2 )] # add 2 to account for mode/DTC_count bytes
282281
283- elif mode == 0x46:
284- # the monitor test mode only has a mode number
285- # the MID (mode 6's version of a PID) is needed,
286- # and handled in the decoder
287- message.data = message.data[1:]
288-
289- else:
290- # skip the Mode and PID bytes
291- #
292- # single line response:
293- # [ Data ]
294- # 00 00 07 E8 06 41 00 BE 7F B8 13
295- #
296- # OR, the data from a multiline response:
297- # [ Data ]
298- # 49 04 01 35 36 30 32 38 39 34 39 41 43 00 00 00 00 00 00
299- message.data = message.data[2:]
300- """
301282 return True
302283
303284
0 commit comments