@@ -66,6 +66,13 @@ class BLFParseError(Exception):
66
66
# valid data bytes, data
67
67
CAN_FD_MSG_STRUCT = struct .Struct ("<HBBLLBBB5x64s" )
68
68
69
+ # channel, dlc, valid payload length of data, tx count, arbitration id,
70
+ # frame length, flags, bit rate used in arbitration phase,
71
+ # bit rate used in data phase, time offset of brs field,
72
+ # time offset of crc delimiter field, bit count, direction,
73
+ # offset if extDataOffset is used, crc
74
+ CAN_FD_MSG_64_STRUCT = struct .Struct ("<BBBBLLLLLLLHBBL" )
75
+
69
76
# channel, length, flags, ecc, position, dlc, frame length, id, flags ext, data
70
77
CAN_ERROR_EXT_STRUCT = struct .Struct ("<HHLBBBxLLH2x8s" )
71
78
@@ -81,6 +88,7 @@ class BLFParseError(Exception):
81
88
CAN_MESSAGE2 = 86
82
89
GLOBAL_MARKER = 96
83
90
CAN_FD_MESSAGE = 100
91
+ CAN_FD_MESSAGE_64 = 101
84
92
85
93
NO_COMPRESSION = 0
86
94
ZLIB_DEFLATE = 2
@@ -91,6 +99,12 @@ class BLFParseError(Exception):
91
99
BRS = 0x2
92
100
ESI = 0x4
93
101
102
+ # CAN FD 64 Flags
103
+ REMOTE_FLAG_64 = 0x0010
104
+ EDL_64 = 0x1000
105
+ BRS_64 = 0x2000
106
+ ESI_64 = 0x4000
107
+
94
108
TIME_TEN_MICS = 0x00000001
95
109
TIME_ONE_NANS = 0x00000002
96
110
@@ -236,6 +250,29 @@ def __iter__(self):
236
250
data = can_data [:length ],
237
251
channel = channel - 1 )
238
252
yield msg
253
+ elif obj_type == CAN_FD_MESSAGE_64 :
254
+ (
255
+ channel , dlc , _ , _ , can_id , _ , fd_flags
256
+ ) = CAN_FD_MSG_64_STRUCT .unpack_from (data , pos )[:7 ]
257
+ length = dlc2len (dlc )
258
+ can_data = struct .unpack_from (
259
+ "<{}s" .format (length ),
260
+ data ,
261
+ pos + CAN_FD_MSG_64_STRUCT .size
262
+ )[0 ]
263
+ msg = Message (
264
+ timestamp = timestamp ,
265
+ arbitration_id = can_id & 0x1FFFFFFF ,
266
+ is_extended_id = bool (can_id & CAN_MSG_EXT ),
267
+ is_remote_frame = bool (fd_flags & REMOTE_FLAG_64 ),
268
+ is_fd = bool (fd_flags & EDL_64 ),
269
+ bitrate_switch = bool (fd_flags & BRS_64 ),
270
+ error_state_indicator = bool (fd_flags & ESI_64 ),
271
+ dlc = length ,
272
+ data = can_data [:length ],
273
+ channel = channel - 1
274
+ )
275
+ yield msg
239
276
elif obj_type == CAN_ERROR_EXT :
240
277
(channel , _ , _ , _ , _ , dlc , _ , can_id , _ ,
241
278
can_data ) = CAN_ERROR_EXT_STRUCT .unpack_from (data , pos )
@@ -247,6 +284,8 @@ def __iter__(self):
247
284
data = can_data [:dlc ],
248
285
channel = channel - 1 )
249
286
yield msg
287
+ # else:
288
+ # LOG.warning("Unknown object type (%d)", obj_type)
250
289
251
290
pos = next_pos
252
291
0 commit comments