@@ -66,6 +66,13 @@ class BLFParseError(Exception):
6666# valid data bytes, data
6767CAN_FD_MSG_STRUCT = struct .Struct ("<HBBLLBBB5x64s" )
6868
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+
6976# channel, length, flags, ecc, position, dlc, frame length, id, flags ext, data
7077CAN_ERROR_EXT_STRUCT = struct .Struct ("<HHLBBBxLLH2x8s" )
7178
@@ -81,6 +88,7 @@ class BLFParseError(Exception):
8188CAN_MESSAGE2 = 86
8289GLOBAL_MARKER = 96
8390CAN_FD_MESSAGE = 100
91+ CAN_FD_MESSAGE_64 = 101
8492
8593NO_COMPRESSION = 0
8694ZLIB_DEFLATE = 2
@@ -91,6 +99,12 @@ class BLFParseError(Exception):
9199BRS = 0x2
92100ESI = 0x4
93101
102+ # CAN FD 64 Flags
103+ REMOTE_FLAG_64 = 0x0010
104+ EDL_64 = 0x1000
105+ BRS_64 = 0x2000
106+ ESI_64 = 0x4000
107+
94108TIME_TEN_MICS = 0x00000001
95109TIME_ONE_NANS = 0x00000002
96110
@@ -236,6 +250,29 @@ def __iter__(self):
236250 data = can_data [:length ],
237251 channel = channel - 1 )
238252 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
239276 elif obj_type == CAN_ERROR_EXT :
240277 (channel , _ , _ , _ , _ , dlc , _ , can_id , _ ,
241278 can_data ) = CAN_ERROR_EXT_STRUCT .unpack_from (data , pos )
@@ -247,6 +284,8 @@ def __iter__(self):
247284 data = can_data [:dlc ],
248285 channel = channel - 1 )
249286 yield msg
287+ # else:
288+ # LOG.warning("Unknown object type (%d)", obj_type)
250289
251290 pos = next_pos
252291
0 commit comments