@@ -51,7 +51,12 @@ def __iter__(self) -> Generator[Message, None, None]:
5151 continue
5252
5353 channel_string : str
54- timestamp_string , channel_string , frame = temp .split ()
54+ if temp [- 2 :].lower () in (" r" , " t" ):
55+ timestamp_string , channel_string , frame , is_rx_string = temp .split ()
56+ is_rx = is_rx_string .strip ().lower () == "r"
57+ else :
58+ timestamp_string , channel_string , frame = temp .split ()
59+ is_rx = True
5560 timestamp = float (timestamp_string [1 :- 1 ])
5661 can_id_string , data = frame .split ("#" , maxsplit = 1 )
5762
@@ -101,6 +106,7 @@ def __iter__(self) -> Generator[Message, None, None]:
101106 is_extended_id = is_extended ,
102107 is_remote_frame = is_remote_frame ,
103108 is_fd = is_fd ,
109+ is_rx = is_rx ,
104110 bitrate_switch = brs ,
105111 error_state_indicator = esi ,
106112 dlc = dlc ,
@@ -164,8 +170,13 @@ def on_message_received(self, msg):
164170 else :
165171 framestr += " %03X#" % (msg .arbitration_id )
166172
173+ if msg .is_error_frame :
174+ eol = "\n "
175+ else :
176+ eol = " R\n " if msg .is_rx else " T\n "
177+
167178 if msg .is_remote_frame :
168- framestr += "R \n "
179+ framestr += f"R { eol } "
169180 else :
170181 if msg .is_fd :
171182 fd_flags = 0
@@ -174,6 +185,6 @@ def on_message_received(self, msg):
174185 if msg .error_state_indicator :
175186 fd_flags |= CANFD_ESI
176187 framestr += "#%X" % fd_flags
177- framestr += "%s \n " % ( msg .data .hex ().upper ())
188+ framestr += f" { msg .data .hex ().upper ()} { eol } "
178189
179190 self .file .write (framestr )
0 commit comments