-
Notifications
You must be signed in to change notification settings - Fork 633
[IO][canutils]: use common CAN interface names in generated logfile #1271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
can/io/canutils.py
Outdated
@@ -161,7 +161,7 @@ def on_message_received(self, msg): | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msg.channel might can be a string like "can0"
. You'd get "cancan0"
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could use
if isinstance(channel, int):
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big 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 <[email protected]> Suggested-by: Oliver Hartkopp <[email protected]> Tested-by: Oliver Hartkopp <[email protected]>
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 [email protected]