-
Notifications
You must be signed in to change notification settings - Fork 665
Add a new interface: dg interface #677
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
Update version to 3.1.1 and record in changelog
Release 3.2.0
Add notes to changelog.
Release v3.3.0
christiansandberg
left a comment
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 committed a pyc file instead of the source file. Is this intentional?
Codecov Report
@@ Coverage Diff @@
## develop #677 +/- ##
=========================================
Coverage ? 2.72%
=========================================
Files ? 71
Lines ? 6717
Branches ? 0
=========================================
Hits ? 183
Misses ? 6534
Partials ? 0 |
|
We are aware we missed the 'dgBus' in can/interfaces/init.py. We'll fix that. |
In `PcanBus.send()`, we initially set `msgType` based on all the flags of `msg`, including RTR. In the if/else for `self.fd`, we are incorrectly resetting it if rtr. We should not, and so we are no longer doing it.
|
Maybe it would make sense to export most of the code to an external package and import it as an optional dependency. |
You are correct. I will pull out the module for the BEACON tool into an external package. |
…tional dependency.
|
I am still having an issue getting this pull request to complete the testing. As requested by zariiii9003, I have removed the files. Should I just open a new pull request? |
|
The log file says you have to fix the syntax in the |
hardbyte
left a comment
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 PR, everything is looking pretty good. I've left comments inline.
How did you get on splitting out a new Python library implementing the DG Gryphon Protocol?
I'd like to see tests for the utility functions _dict_to_msg and _list_to_int and their inverse.
There is still a .pyc file which should be removed.
| # ********************************************************************** | ||
| # File Name: test_dg.py | ||
| # Author(s): mohtake <mohtake@dgtech.com> | ||
| # Target Project: python-can | ||
| # Description: | ||
| # Notes: | ||
| # ********************************************************************** | ||
| # |
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.
| # ********************************************************************** | |
| # File Name: test_dg.py | |
| # Author(s): mohtake <mohtake@dgtech.com> | |
| # Target Project: python-can | |
| # Description: | |
| # Notes: | |
| # ********************************************************************** | |
| # |
| self.ip = kwargs["ip"] if "ip" in kwargs else "localhost" | ||
| self.is_fd = kwargs["is_fd"] if "is_fd" in kwargs else False | ||
| self.bitrate = kwargs["bitrate"] if "bitrate" in kwargs else 500000 | ||
| self.termination = kwargs["termination"] if "termination" in kwargs else True | ||
| self.pre_iso = kwargs["pre_iso"] if "pre_iso" in kwargs else False | ||
| self.data_bitrate = ( | ||
| kwargs["data_bitrate"] if "data_bitrate" in kwargs else 2000000 | ||
| ) |
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.
It would be more idiomatic to have kwargs.get("ip", "localhost") for all of these.
| #!/usr/bin/python | ||
| # | ||
| # ---------------------------------------------------------------------- | ||
| # pylint: disable=invalid-name | ||
| # ---------------------------------------------------------------------- | ||
| # | ||
| # ********************************************************************** | ||
| # | ||
| # File Name: dg.py | ||
| # Author(s): mohtake <mohtake@dgtech.com> | ||
| # Target Project: python-can | ||
| # Description: | ||
| # Notes: | ||
| # ********************************************************************** | ||
| # | ||
|
|
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.
| #!/usr/bin/python | |
| # | |
| # ---------------------------------------------------------------------- | |
| # pylint: disable=invalid-name | |
| # ---------------------------------------------------------------------- | |
| # | |
| # ********************************************************************** | |
| # | |
| # File Name: dg.py | |
| # Author(s): mohtake <mohtake@dgtech.com> | |
| # Target Project: python-can | |
| # Description: | |
| # Notes: | |
| # ********************************************************************** | |
| # |
| # ---------------------------------------------------------------------- | ||
| import weakref | ||
| from can import BusABC, Message | ||
| from can.interfaces.dg.dg_gryphon_protocol import server_commands |
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 think the new dependency needs to be added and this import updated?
|
|
||
|
|
||
| class DGBus(BusABC): | ||
| """ Beacon python-can backend API """ |
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.
Any other backend specific notes aimed at developer users should go here. For instance I'd assume the messages are timestamped in hardware?
It also looks like you aren't supporting in hardware filtering? Is that a limitation of the gryphon protocol?
| self.beacon.CMD_CARD_SET_FILTER_MODE( | ||
| self.channel, self.beacon.FILTER_OFF_PASS_ALL | ||
| ) |
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 assume there isn't any downside to calling this, and then a few lines down via the super calling set_filters?
| self.channel, self.beacon.FILTER_OFF_PASS_ALL | ||
| ) | ||
| self.channel_info = ("dg channel '%s' on " + self.mode) % self.channel | ||
| super(DGBus, self).__init__(self.channel, None) |
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.
Something seems fishy here. Can you please explicitly deal with can_filters
As written I think they are just being dropped?
| for item in filters: | ||
| dataFil["filter_blocks"].append({}) | ||
| dataFil["filter_blocks"][counter]["byte_offset"] = 0 | ||
| dataFil["filter_blocks"][counter][ | ||
| "data_type" | ||
| ] = self.beacon.FILTER_DATA_TYPE_HEADER | ||
| dataFil["filter_blocks"][counter]["operator"] = self.beacon.BIT_FIELD_CHECK | ||
| dataFil["filter_blocks"][counter]["mask"] = self._int_to_list( | ||
| item["can_mask"] | ||
| ) | ||
| dataFil["filter_blocks"][counter]["pattern"] = self._int_to_list( | ||
| item["can_id"] | ||
| ) | ||
| counter += 1 |
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.
| for item in filters: | |
| dataFil["filter_blocks"].append({}) | |
| dataFil["filter_blocks"][counter]["byte_offset"] = 0 | |
| dataFil["filter_blocks"][counter][ | |
| "data_type" | |
| ] = self.beacon.FILTER_DATA_TYPE_HEADER | |
| dataFil["filter_blocks"][counter]["operator"] = self.beacon.BIT_FIELD_CHECK | |
| dataFil["filter_blocks"][counter]["mask"] = self._int_to_list( | |
| item["can_mask"] | |
| ) | |
| dataFil["filter_blocks"][counter]["pattern"] = self._int_to_list( | |
| item["can_id"] | |
| ) | |
| counter += 1 | |
| for item in filters: | |
| dataFil["filter_blocks"].append({ | |
| "byte_offset": 0, | |
| "data_type": self.beacon.FILTER_DATA_TYPE_HEADER, | |
| "operator": self.beacon.BIT_FIELD_CHECK, | |
| "mask": self._int_to_list(item["can_mask"]), | |
| "pattern": self._int_to_list(item["can_id"]) | |
| }) |
| ) | ||
|
|
||
| def stop(self): | ||
| self.beaconref().CMD_SCHED_KILL_TX(self.channel, self.idIn) |
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.
| self.beaconref().CMD_SCHED_KILL_TX(self.channel, self.idIn) | |
| self.beaconref().CMD_SCHED_KILL_TX(self.channel, self.idIn) | |
| ================ | ||
|
|
||
| Interface to `DG Technologies <http://dgtech.com>`__ Beacon | ||
|
|
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.
Are there any extra drivers required for this? What platforms (operating systems) does it run on?
| The ``DGBus`` class implements several python-can methods:: | ||
|
|
||
| send, send_periodic, recv, set_filters, flush_tx_buffer, _detect_available_configs, shutdown |
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 think there is no need to mention the methods which definitely need to be implemented anyways. It raises the question if other interfaces do it even if they do not mention it. I'd suggest including these:
| The ``DGBus`` class implements several python-can methods:: | |
| send, send_periodic, recv, set_filters, flush_tx_buffer, _detect_available_configs, shutdown | |
| The ``DGBus`` class implements several optional methods: ``send_periodic`` and ``set_filters`` within the driver, as well as ``flush_tx_buffer`` and ``_detect_available_configs``. |
|
Cool mocking tests! |
|
@markcdg Do you plan on working further on this PR? It looks like a neat addition to the library! |
|
I opened #1132 to track this topic and will close this one as there is apparently no development effort going on. |
Here is a new interface for the DG BEACON tool from DG Technologies, Inc. (www.dgtech.com).
Note: we changed the version to 3.2.2, but you will need set it the correct version.