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
Added extra info for Kvaser dongles #1763
Conversation
Changed Kvaser auto-detection function to return additional info regarding the dongles found, such as Serial Number, Name and Dongle Channel number. In this way it's possible to discern between different physical dongles connected to the PC and if they are Virtual Channels or not.
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.
Looks good to me. Thanks for the contribution.
can/interfaces/kvaser/canlib.py
Outdated
return f"{name_decoded}, S/N {serial.value} (#{number.value + 1})" | ||
|
||
return { | ||
"name": name.value.decode("ascii", errors="replace"), |
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.
"name": name.value.decode("ascii", errors="replace"), | |
"device_name": name.value.decode("ascii", errors="replace"), |
Changed "name" into "device_name" as suggested by python-can owner.
can/interfaces/kvaser/canlib.py
Outdated
@@ -471,6 +471,7 @@ def __init__( | |||
log.info("Found %d available channels", num_channels) | |||
for idx in range(num_channels): | |||
channel_info = get_channel_info(idx) | |||
channel_info = f"{channel_info["device_name"]}, S/N {channel_info["serial"]} (#{channel_info["dongle 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.
Double quotes inside of double quotes is a syntax error in older Python versions.
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.
Sorry, I just started using Python last year with the latest version and I'm unaware of these retrocompatibility issues. Can I change it using single quotes for the f-string but maitain the dict indexing inside it with double quotes? Thanks in advance
Changed " with ' for retrocompatibility problem with older Python versions.
Changed Kvaser auto-detection function to return additional info regarding the found dongles, such as Serial Number, Name and Dongle Channel number.
In this way it's possible to discern between different physical dongles connected to the PC and if they are Virtual Channels or not.