Skip to content

Commit 5f01a81

Browse files
committed
[IO][canutils]: use common CAN interface names in generated logfile
CAN interfaces in canutils logfiles are usually named 'can0', 'can32' or 'vcan8'. This allows to split logfiles just by performing 'grep' or to rename CAN interfaces easily with 'sed'. The current implementation of the canutils log file writer just provides channel numbers for CAN interfaces. This patch adds the string 'can' to the channel number to make it look like a usual canutils logfiles that can be preprocessed as described above. The string 'can' is added when the provided CAN channel is a only number. Author: Brian Thorne <[email protected]> Suggested-by: Oliver Hartkopp <[email protected]> Tested-by: Oliver Hartkopp <[email protected]>
1 parent 4d9b32c commit 5f01a81

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

can/io/canutils.py

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ def on_message_received(self, msg):
160160
timestamp = msg.timestamp
161161

162162
channel = msg.channel if msg.channel is not None else self.channel
163+
if isinstance(channel, int) or isinstance(channel, str) and channel.isdigit():
164+
channel = f"can{channel}"
163165

164166
framestr = "(%f) %s" % (timestamp, channel)
165167

0 commit comments

Comments
 (0)