@@ -59,9 +59,13 @@ def __iter__(self):
59
59
temp = line .strip ()
60
60
if not temp or not temp [0 ].isdigit ():
61
61
continue
62
-
62
+ is_fd = False
63
63
try :
64
64
timestamp , channel , dummy = temp .split (None , 2 ) # , frameType, dlc, frameData
65
+ if channel == "CANFD" :
66
+ timestamp , _ , channel , _ , dummy = temp .split (None , 4 )
67
+ is_fd = True
68
+
65
69
except ValueError :
66
70
# we parsed an empty comment
67
71
continue
@@ -95,16 +99,32 @@ def __iter__(self):
95
99
yield msg
96
100
97
101
else :
102
+ brs = None
103
+ esi = None
104
+ data_length = 0
98
105
try :
99
- # this only works if dlc > 0 and thus data is availabe
100
- can_id_str , _ , _ , dlc , data = dummy .split (None , 4 )
106
+ # this only works if dlc > 0 and thus data is available
107
+ if not is_fd :
108
+ can_id_str , _ , _ , dlc , data = dummy .split (None , 4 )
109
+ else :
110
+ can_id_str , frame_name , brs , esi , dlc , data_length , data = dummy .split (
111
+ None , 6
112
+ )
113
+ if frame_name .isdigit ():
114
+ # Empty frame_name
115
+ can_id_str , brs , esi , dlc , data_length , data = dummy .split (
116
+ None , 5
117
+ )
101
118
except ValueError :
102
119
# but if not, we only want to get the stuff up to the dlc
103
120
can_id_str , _ , _ , dlc = dummy .split (None , 3 )
104
121
# and we set data to an empty sequence manually
105
122
data = ''
106
-
107
- dlc = int (dlc )
123
+ dlc = int (dlc , 16 )
124
+ if is_fd :
125
+ # For fd frames, dlc and data length might not be equal and
126
+ # data_length is the actual size of the data
127
+ dlc = int (data_length )
108
128
frame = bytearray ()
109
129
data = data .split ()
110
130
for byte in data [0 :dlc ]:
@@ -119,7 +139,10 @@ def __iter__(self):
119
139
is_remote_frame = False ,
120
140
dlc = dlc ,
121
141
data = frame ,
122
- channel = channel
142
+ is_fd = is_fd ,
143
+ channel = channel ,
144
+ bitrate_switch = is_fd and brs == "1" ,
145
+ error_state_indicator = is_fd and esi == "1" ,
123
146
)
124
147
125
148
self .stop ()
0 commit comments