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

Fixed pcan Unpack error #1767

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion can/interfaces/pcan/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ def GetValue(self, Channel, Parameter):
elif Parameter == PCAN_ATTACHED_CHANNELS:
res = self.GetValue(Channel, PCAN_ATTACHED_CHANNELS_COUNT)
if TPCANStatus(res[0]) != PCAN_ERROR_OK:
return (TPCANStatus(res[0]),)
return TPCANStatus(res[0]), ()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return TPCANStatus(res[0]), ()
return TPCANStatus(res[0]), None

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you expect to receive an Iterable, returning an empty tuple is better so you don't have to check if it is "None" before using it in a For loop.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the error case. There is no valid result, so it is not used here:

return interfaces

mybuffer = (TPCANChannelInformation * res[1])()

elif (
Expand Down