-
Notifications
You must be signed in to change notification settings - Fork 638
Improve USB2CAN interface #511
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
Could someone test this? I do not have the required hardware. |
I will try today, but can currently only offer a test with the adapter connected. My hardware for actual bus communications with the python-can based software is out of reach. |
If anyone wants I can send one TouCAN converter for free for testing. |
I didn't have time to dig much deeper yet, but initial testing has resulted in the following exception:
|
So So unless someone passes in a non-ASCII |
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.
Seems like the configuration string handling is a little messy overall. Too many layers passing down their arguments to each other.
I also noticed that the connection usually fails on first try. The second attempt to open the interface succeeds, but I haven't tested whether the transmitted objects are actually seen on the CAN bus. |
The code for selecting the serial number now looks as follows: # get the serial number of the device
if "serial" in kwargs:
device_id = kwargs["serial"]
else:
device_id = channel
# search for a serial number if the device_id is None or empty
if not device_id:
devices = find_serial_devices()
if not devices:
raise CanError("could not automatically find any serial device")
device_id = devices[0] I adapted the documentation accordingly. |
Codecov Report
@@ Coverage Diff @@
## develop #511 +/- ##
===========================================
- Coverage 64.52% 64.46% -0.07%
===========================================
Files 63 63
Lines 5647 5651 +4
===========================================
- Hits 3644 3643 -1
- Misses 2003 2008 +5 |
Removing the trivial function |
@acolomb Could you find out why this happens? |
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.
I tested this rather quickly, and the return value of CanalOpen()
was 1681, which I think is a valid handle, but triggered an exception. Good job on making those more verbose, btw.
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.
This is actually an improvement to the auto-detection logic, and I think we are getting close.
Sorry if my comments are a little chaotic, I'm still getting used to GitHub's review interface. Just added one more comment to your first commit in this PR, but I don't know where it shows up now. |
…/python-can into usb2can-improvements-from-canal
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.
I found the cause for the truncated serial numbers, see comments in code.
Looks good except for a few nitpicks ;-)
@felixdivo I hope you are getting notification e-mails for my inline code comments, because even I cannot find all of them inside the PR view on GitHub. Sorry again for the confusion... |
Yep, I'm getting notifications. ;) And they could be even messier, trust me ... |
So I think the only thing missing now is the |
Could one of you {@hardbyte, @christiansandberg} please review & merge this? I thinks it's 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.
I've had a quick look through the changes and all looks good to me.
Thanks @felixdivo and @acolomb
This basically replaces #245 and instead of creating a new interface, applies the changes to
usb2can
.New features:
_detect_available_configs()
API