Skip to content

Commit f69b162

Browse files
bessmanhardbyte
authored andcommitted
Backport fix to ASCReader #701
Skip J1939TP messages
1 parent f8c6086 commit f69b162

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

can/io/asc.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929
class ASCReader(BaseIOHandler):
3030
"""
31-
Iterator of CAN messages from a ASC logging file.
31+
Iterator of CAN messages from a ASC logging file. Meta data (comments,
32+
bus statistics, J1939 Transport Protocol messages) is ignored.
3233
3334
TODO: turn relative timestamps back to absolute form
3435
"""
@@ -77,7 +78,10 @@ def __iter__(self):
7778
channel=channel)
7879
yield msg
7980

80-
elif not isinstance(channel, int) or dummy.strip()[0:10].lower() == 'statistic:':
81+
elif (not isinstance(channel, int)
82+
or dummy.strip()[0:10].lower() == 'statistic:'
83+
or dummy.split(None, 1)[0] == "J1939TP"
84+
):
8185
pass
8286

8387
elif dummy[-1:].lower() == 'r':

test/data/logfile.asc

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
1-
date Sam Sep 30 15:06:13.191 2017
2-
base hex timestamps absolute
3-
internal events logged
4-
// version 9.0.0
5-
Begin Triggerblock Sam Sep 30 15:06:13.191 2017
6-
0.000000 Start of measurement
7-
0.015991 CAN 1 Status:chip status error passive - TxErr: 132 RxErr: 0
8-
0.015991 CAN 2 Status:chip status error active
9-
1.015991 1 Statistic: D 0 R 0 XD 0 XR 0 E 0 O 0 B 0.00%
10-
1.015991 2 Statistic: D 0 R 0 XD 0 XR 0 E 0 O 0 B 0.00%
11-
2.015992 1 Statistic: D 0 R 0 XD 0 XR 0 E 0 O 0 B 0.00%
12-
17.876707 CAN 1 Status:chip status error passive - TxErr: 131 RxErr: 0
13-
17.876708 1 6F9 Rx d 8 05 0C 00 00 00 00 00 00 Length = 240015 BitCount = 124 ID = 1785
14-
17.876976 1 6F8 Rx d 8 FF 00 0C FE 00 00 00 00 Length = 239910 BitCount = 124 ID = 1784
15-
18.015997 1 Statistic: D 2 R 0 XD 0 XR 0 E 0 O 0 B 0.04%
16-
113.016026 1 Statistic: D 0 R 0 XD 0 XR 0 E 0 O 0 B 0.00%
17-
113.016026 2 Statistic: D 0 R 0 XD 0 XR 0 E 0 O 0 B 0.00%
18-
End TriggerBlock
1+
date Sam Sep 30 15:06:13.191 2017
2+
base hex timestamps absolute
3+
internal events logged
4+
// version 9.0.0
5+
Begin Triggerblock Sam Sep 30 15:06:13.191 2017
6+
0.000000 Start of measurement
7+
0.015991 CAN 1 Status:chip status error passive - TxErr: 132 RxErr: 0
8+
0.015991 CAN 2 Status:chip status error active
9+
1.015991 1 Statistic: D 0 R 0 XD 0 XR 0 E 0 O 0 B 0.00%
10+
1.015991 2 Statistic: D 0 R 0 XD 0 XR 0 E 0 O 0 B 0.00%
11+
2.015992 1 Statistic: D 0 R 0 XD 0 XR 0 E 0 O 0 B 0.00%
12+
3.098426 1 18EBFF00x Rx d 8 01 A0 0F A6 60 3B D1 40 Length = 273910 BitCount = 141 ID = 418119424x
13+
3.148421 1 18EBFF00x Rx d 8 02 1F DE 80 25 DF C0 2B Length = 271910 BitCount = 140 ID = 418119424x
14+
3.197693 1 18EBFF00x Rx d 8 03 E1 00 4B FF FF 3C 0F Length = 283910 BitCount = 146 ID = 418119424x
15+
3.248765 1 18EBFF00x Rx d 8 04 00 4B FF FF FF FF FF Length = 283910 BitCount = 146 ID = 418119424x
16+
3.297743 1 J1939TP FEE3p 6 0 0 - Rx d 23 A0 0F A6 60 3B D1 40 1F DE 80 25 DF C0 2B E1 00 4B FF FF 3C 0F 00 4B FF FF FF FF FF FF FF FF FF FF FF FF
17+
17.876707 CAN 1 Status:chip status error passive - TxErr: 131 RxErr: 0
18+
17.876708 1 6F9 Rx d 8 05 0C 00 00 00 00 00 00 Length = 240015 BitCount = 124 ID = 1785
19+
17.876976 1 6F8 Rx d 8 FF 00 0C FE 00 00 00 00 Length = 239910 BitCount = 124 ID = 1784
20+
18.015997 1 Statistic: D 2 R 0 XD 0 XR 0 E 0 O 0 B 0.04%
21+
20.105214 2 18EBFF00x Rx d 8 01 A0 0F A6 60 3B D1 40 Length = 273925 BitCount = 141 ID = 418119424x
22+
20.155119 2 18EBFF00x Rx d 8 02 1F DE 80 25 DF C0 2B Length = 272152 BitCount = 140 ID = 418119424x
23+
20.204671 2 18EBFF00x Rx d 8 03 E1 00 4B FF FF 3C 0F Length = 283910 BitCount = 146 ID = 418119424x
24+
20.248887 2 18EBFF00x Rx d 8 04 00 4B FF FF FF FF FF Length = 283925 BitCount = 146 ID = 418119424x
25+
20.305233 2 J1939TP FEE3p 6 0 0 - Rx d 23 A0 0F A6 60 3B D1 40 1F DE 80 25 DF C0 2B E1 00 4B FF FF 3C 0F 00 4B FF FF FF FF FF FF FF FF FF FF FF FF
26+
113.016026 1 Statistic: D 0 R 0 XD 0 XR 0 E 0 O 0 B 0.00%
27+
113.016026 2 Statistic: D 0 R 0 XD 0 XR 0 E 0 O 0 B 0.00%
28+
End TriggerBlock

0 commit comments

Comments
 (0)