Skip to content

Commit f3aa467

Browse files
author
Brendan Whitfield
committed
handle CAN length fields, fixed protocol docs
1 parent 329f2f3 commit f3aa467

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎obd/protocols/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Notes
33

44
Each protocol object is callable, and accepts a list of raw input strings, and returns a list of parsed `Message` objects. The `data` field will contain a list of integers, corresponding to all relevant data returned by the command.
55

6-
*Note: `Message.data` does not refer to the full data field of a message, but rather a subset of this field. Things like Mode/PID/PCI bytes are removed. However, `Frame.data_bytes` DOES include the full data field (per-spec), for each frame.*
6+
*Note: `Message.data` does not refer to the full data field of a message. Things like PCI/Mode/PID bytes are removed. If you want to see these fields, use `Frame.data` for the full (per-spec) data field.*
77

88
For example, these are the resultant `Message.data` fields for some single frame messages:
99

‎obd/protocols/protocol_can.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,15 @@ def parse_message(self, message):
216216

217217

218218
# on the first frame, skip PCI byte AND length code
219-
message.data += ff[0].data[2:]
219+
message.data = ff[0].data[2:]
220220

221221
# now that they're in order, load/accumulate the data from each CF frame
222222
for f in cf:
223223
message.data += f.data[1:] # chop off the PCI byte
224224

225+
# chop to the correct size (as specified in the first frame)
226+
message.data = message.data[:ff[0].data_len]
227+
225228

226229
# chop off the Mode/PID bytes based on the mode number
227230
mode = message.data[0]

0 commit comments

Comments
 (0)