Skip to content

Pass flags instead of flags_t type for USB2CAN#1252

Merged
felixdivo merged 2 commits intohardbyte:developfrom
jacobian91:develop
Feb 11, 2022
Merged

Pass flags instead of flags_t type for USB2CAN#1252
felixdivo merged 2 commits intohardbyte:developfrom
jacobian91:develop

Conversation

@jacobian91
Copy link
Copy Markdown
Contributor

It looks like flags_t the type was being used instead of the flags argument.

@jacobian91
Copy link
Copy Markdown
Contributor Author

This is the traceback when encountering this error:

Unable to create CAN node Traceback (most recent call last):

File "...\site-packages\can\interfaces\usb2can\usb2canabstractionlayer.py", line 141, in open
    result = self.__m_dllBasic.CanalOpen(config_ascii, flags)
             │                           │             └ <class 'ctypes.c_ulong'>
             │                           └ b'F8BAFED8; 500'<can.interfaces.usb2can.usb2canabstractionlayer.Usb2CanAbstractionLayer object at 0x0000020F03E5D370>

ctypes.ArgumentError: argument 2: <class 'TypeError'>: Don't know how to convert parameter 2

Comment thread can/interfaces/usb2can/usb2canInterface.py

super().__init__(
channel=channel, dll=dll, flags_t=flags_t, bitrate=bitrate, *args, **kwargs
channel=channel, dll=dll, flags=flags, bitrate=bitrate, *args, **kwargs
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since BusABC does not know these, we can also ignore them here.

Suggested change
channel=channel, dll=dll, flags=flags, bitrate=bitrate, *args, **kwargs
channel=channel, bitrate=bitrate, *args, **kwargs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've also removed bitrate as it looks like BusABC doesn't use this either, so now this line is super().__init__(channel=channel, **kwargs).
I've removed the *args as well to prevent errors from positional vs keyword argument ordering. the BusABC argument can_filters could get passed into Usb2canBus via kwargs.

@felixdivo felixdivo added this to the 4.0.0 Release milestone Feb 6, 2022
@felixdivo
Copy link
Copy Markdown
Collaborator

Thanks @jacobian91!

@felixdivo felixdivo added the bug label Feb 6, 2022
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 6, 2022

Codecov Report

Merging #1252 (1c70545) into develop (257d57d) will not change coverage.
The diff coverage is 0.00%.

@@           Coverage Diff            @@
##           develop    #1252   +/-   ##
========================================
  Coverage    65.89%   65.89%           
========================================
  Files           86       86           
  Lines         8887     8887           
========================================
  Hits          5856     5856           
  Misses        3031     3031           

dll="usb2can.dll",
flags=0x00000008,
*args,
*_,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Optional style change, this documents that all additional positional arguments get ignored but won't throw an exception when passed in.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, that's fine. We don't have a unified handling of that case anyways.

@felixdivo felixdivo requested a review from hardbyte February 9, 2022 10:19
@felixdivo felixdivo merged commit 20b3138 into hardbyte:develop Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants