[IO][canutils]: use common CAN interface names in generated logfile - #1271
Conversation
| channel = msg.channel if msg.channel is not None else self.channel | ||
|
|
||
| framestr = "(%f) %s" % (timestamp, channel) | ||
| framestr = "(%f) can%s" % (timestamp, channel) |
There was a problem hiding this comment.
msg.channel might can be a string like "can0". You'd get "cancan0" here.
There was a problem hiding this comment.
Good point!
Unfortunately I'm not really familiar with Python, but would it make sense to add some isdigit() vodoo to catch the case that we are only dealing with numbers and add "can" only in these cases?
There was a problem hiding this comment.
you could use
if isinstance(channel, int):
...There was a problem hiding this comment.
Hi @zariiii9003 ,
I looked at the docs and also at some code - but I don't have Python knowledge that goes beyond my original patch :-/
Would you mind to provide a patch/PR that adds "can" before the channel only when channel is a simple number?
Thanks!
Codecov Report
@@ Coverage Diff @@
## develop #1271 +/- ##
===========================================
- Coverage 66.02% 66.01% -0.01%
===========================================
Files 86 86
Lines 8912 8914 +2
===========================================
+ Hits 5884 5885 +1
- Misses 3028 3029 +1 |
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 only a number. Author: Brian Thorne <brian@hardbyte.nz> Suggested-by: Oliver Hartkopp <socketcan@hartkopp.net> Tested-by: Oliver Hartkopp <socketcan@hartkopp.net>
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.
Signed-off-by: Oliver Hartkopp socketcan@hartkopp.net