@@ -51,7 +51,12 @@ def __iter__(self) -> Generator[Message, None, None]:
51
51
continue
52
52
53
53
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
55
60
timestamp = float (timestamp_string [1 :- 1 ])
56
61
can_id_string , data = frame .split ("#" , maxsplit = 1 )
57
62
@@ -101,6 +106,7 @@ def __iter__(self) -> Generator[Message, None, None]:
101
106
is_extended_id = is_extended ,
102
107
is_remote_frame = is_remote_frame ,
103
108
is_fd = is_fd ,
109
+ is_rx = is_rx ,
104
110
bitrate_switch = brs ,
105
111
error_state_indicator = esi ,
106
112
dlc = dlc ,
@@ -164,8 +170,13 @@ def on_message_received(self, msg):
164
170
else :
165
171
framestr += " %03X#" % (msg .arbitration_id )
166
172
173
+ if msg .is_error_frame :
174
+ eol = "\n "
175
+ else :
176
+ eol = " R\n " if msg .is_rx else " T\n "
177
+
167
178
if msg .is_remote_frame :
168
- framestr += "R \n "
179
+ framestr += f"R { eol } "
169
180
else :
170
181
if msg .is_fd :
171
182
fd_flags = 0
@@ -174,6 +185,6 @@ def on_message_received(self, msg):
174
185
if msg .error_state_indicator :
175
186
fd_flags |= CANFD_ESI
176
187
framestr += "#%X" % fd_flags
177
- framestr += "%s \n " % ( msg .data .hex ().upper ())
188
+ framestr += f" { msg .data .hex ().upper ()} { eol } "
178
189
179
190
self .file .write (framestr )
0 commit comments