-
Notifications
You must be signed in to change notification settings - Fork 630
Add NI-XNET CANFD interface #968
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
Codecov Report
@@ Coverage Diff @@
## develop #968 +/- ##
===========================================
+ Coverage 70.78% 70.96% +0.17%
===========================================
Files 75 76 +1
Lines 7267 7708 +441
===========================================
+ Hits 5144 5470 +326
- Misses 2123 2238 +115 |
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.
Nice! You could also add the dependency as an extra in setup.py.
can/interfaces/nixnet.py
Outdated
|
||
def _recv_internal(self, timeout): | ||
try: | ||
fr = self.__session_receive.frames.read(4, timeout=0.0) |
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.
Don't you want to use the timeout argument here? Otherwise there is no place for the CPU to do other things. If you want to read multiple frames at once for optimization you can skip the read operation if the queue is not empty.
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 only a trick to make it working without modifying the nixnet library from National. With a positive timeout of any value it doesn't works. And regarding the queue and the 4 frames reading is because they have hardcoded a fixed length for reading of 24 bytes, so this is needed to be able to read 64 bytes CANFD frames, or at least, is the easy way I have found without patching the underlaying library. Also, it's a good idea to skip the reading if the queue is not empty, I'll do it.
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.
The library definitely seems a bit unfinished but that's not your fault.
is_extended_id=can_frame.identifier.extended, | ||
# Get identifier from CanIdentifier structure | ||
arbitration_id=can_frame.identifier.identifier, | ||
dlc=len(can_frame.payload), |
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.
Remote frames don't contain any data, isn't there a DLC attribute?
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.
No, there isn't...
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.
Okay, no big deal. RTR is not used that much nowadays anyway.
can/interfaces/nixnet.py
Outdated
# if msg.bitrate_switch: | ||
# type_message = constants.FrameType.CANFDBRS_DATA | ||
# else: | ||
# type_message = constants.FrameType.CANFD_DATA |
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.
Doesn't this work?
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'm sorry, I forgot to change it back.
Yes, this works in this layer. I think we have the problem with can-isotp or udsoncan.
@@ -0,0 +1,22 @@ | |||
NI-XNET |
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.
Oh, and you also need to add this to interfaces.rst.
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.
Done!
is_extended_id=can_frame.identifier.extended, | ||
# Get identifier from CanIdentifier structure | ||
arbitration_id=can_frame.identifier.identifier, | ||
dlc=len(can_frame.payload), |
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.
Okay, no big deal. RTR is not used that much nowadays anyway.
can/interfaces/nixnet.py
Outdated
|
||
def _recv_internal(self, timeout): | ||
try: | ||
fr = self.__session_receive.frames.read(4, timeout=0.0) |
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.
The library definitely seems a bit unfinished but that's not your fault.
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.
You may need to run your files through black to make CI happy.
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.
🎆 Thanks for the contribution!
Hi, I'm not sure if I need to do anything else in order to close the pull request or if it's pending for someone. |
Add support to NI-XNET interfaces from National Instruments