Skip to content
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

Add device_id parameter to PcanBus constructor #1346

Merged
merged 3 commits into from Jul 24, 2022

Conversation

lumagi
Copy link
Collaborator

@lumagi lumagi commented Jul 8, 2022

This pull request adds support for constructing PCAN bus instances based on the device ID.

Before, it was only possible to select a certain bus based on the channel name (i.e. PCAN_USBBUSx). This can be troublesome since the order of the devices is not necessarily consistent across reboots or USB reconnects. With this patch, it is possible to choose the device based on its device ID. The device ID can be freely set through the API or PCAN-View.

Things to discuss before a merge:

  • At the moment, the implementation tests all possible PCAN channels. A more suitable method which queries the driver for active channels was introduced in version 4.4.0. I refrained from using it because I believe this addition was fairly recent and using it would make the feature incompatible to older API versions.

The new device_id parameter can be used to select a PCAN
channel based on the freely programmable device ID of a
PCAN USB device. This change allows for a more deterministic
channel selection since the device ID does not change
between restarts.
@codecov
Copy link

codecov bot commented Jul 10, 2022

Codecov Report

Merging #1346 (6de3bcf) into develop (5bca2d7) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop    #1346      +/-   ##
===========================================
+ Coverage    66.01%   66.06%   +0.04%     
===========================================
  Files           86       86              
  Lines         8960     8973      +13     
===========================================
+ Hits          5915     5928      +13     
  Misses        3045     3045              

@zariiii9003
Copy link
Collaborator

Can you format your code with black?

lumagi and others added 2 commits July 14, 2022 18:18
Co-authored-by: zariiii9003 <52598363+zariiii9003@users.noreply.github.com>
@lumagi
Copy link
Collaborator Author

lumagi commented Jul 22, 2022

@zariiii9003 Is there anything else you need me to do for the merge?

Copy link
Collaborator

@zariiii9003 zariiii9003 left a 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.

@zariiii9003 zariiii9003 merged commit b9d9d01 into hardbyte:develop Jul 24, 2022
@lumagi lumagi deleted the feature/pcan_by_dev_id branch January 2, 2023 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants