Skip to content

Add CAN and LIN database creation examples#219

Merged
epage merged 8 commits intoni:masterfrom
d-bohls:databaseExamples
Jan 26, 2018
Merged

Add CAN and LIN database creation examples#219
epage merged 8 commits intoni:masterfrom
d-bohls:databaseExamples

Conversation

@d-bohls
Copy link
Contributor

@d-bohls d-bohls commented Jan 22, 2018

Fixes #218

  • This contribution adheres to CONTRIBUTING.md.
  • New tests have been created for any new features or regression tests for bugfixes.
  • tox successfully runs, including unit tests and style checks (see CONTRIBUTING.md).

@coveralls
Copy link

coveralls commented Jan 22, 2018

Coverage Status

Coverage increased (+2.5%) to 67.818% when pulling 024bacc on d-bohls:databaseExamples into 3f72c1f on ni:master.

Copy link
Contributor

@epage epage left a comment

Choose a reason for hiding this comment

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

Overall, good job! Also, the commit history is very clean!

Some minor comments on conventional commit style

  • chore(API): Add enum for LinProtocolVersion
    • I'd classify chore as work that has no user impact, like changing line endings, comment styles, etc. By default, chore does not show up in the changelog with the tooling I at least use
      • fix(examples): Fix typo in comment is a good example of a chore.
    • I'd put the focus on this more on the major impact. LinProtocolVersion by itself isn't too helpful.
    • So maybe something like fix(API): Expose Ecu.lin_protocol_ver as the new LinProtocolVer enum
  • chore(API): Change LinSchedEntry.frames to Frames
    • This would be a fix like LinProtocolVersion
  • renaming user-visible API calls, changing data types on user-visible API calls, etc should be noted in a BREAKING CHANGES section in the commit message.
    • Now whether we bump 0.x (pre-release's major) for this sake is philosophical (was this API more of an easter egg / early access and doesn't need to be taken into account with semver?)

nixnet/_enums.py Outdated
CRC = _cconsts.NX_LIN_LAST_ERR_CODE_CRC


class LinProtocolVersion(enum.Enum):
Copy link
Contributor

Choose a reason for hiding this comment

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

Weren't we talking about abbreviating Version here like in the constant name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did change the members. I'll change the class name to LinProtocolVer too.

def get_database_ref_array(ref, prop_id):
# type: (int, int) -> typing.Iterable[int]
value_size = _funcs.nx_get_property_size(ref, prop_id)
value_size = _funcs.nxdb_get_property_size(ref, prop_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, copy/paste bug on my part. Sorry you had to deal with it


from nixnet import _props
from nixnet import constants
from nixnet.db import _frame
Copy link
Contributor

Choose a reason for hiding this comment

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

Is linsched_entry a descendant of frame?

I recommend all back references do the imports in the functions for consistency to help avoid problems

Copy link
Contributor Author

@d-bohls d-bohls Jan 26, 2018

Choose a reason for hiding this comment

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

I don't think so. The hierarchy looks like this:

Cluster
___Frame
___LinSched
______LinSchedEntry

So Frame is a sibling of LinSchedEntry's parent.

from nixnet import db


def main():
Copy link
Contributor

Choose a reason for hiding this comment

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

Each example

  • Should have a unit test
  • Should be included in the documentation

from nixnet import db


def main():
Copy link
Contributor

Choose a reason for hiding this comment

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

Each example

  • Should have a unit test
  • Should be included in the documentation

@property
def frames(self):
return _props.get_lin_sched_entry_frames(self._handle)
# type: () -> typing.Iterable[_frame.Frame]
Copy link
Contributor

Choose a reason for hiding this comment

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

From travis: nixnet/db/_linsched_entry.py:58: error: Name 'typing' is not defined

You need to import typing. See some of the other files for how to do it without causing flake8 problems

@frames.setter
def frames(self, value):
_props.set_lin_sched_entry_frames(self._handle, value)
# type: (typing.Iterable[_frame.Frame]) -> None
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto about mypy error from travis

In CONTRIBUTING.rst, the tox integration command that
includes LIN should use output interface LIN2 and not CAN2.
Use nxdb_get_property_size instead of nx_get_property_size
when getting the size of database properties.
Fixes ni#218

BREAKING CHANGE: Rename `Db.cluster` to `Db.clusters`
BREAKING CHANGE:

Modify LinSchedEntry.frames to get/set a list of
Frame objects instead of a list of db refs.
BREAKING CHANGE:

Add enum LinProtocolVer and modify Ecu.lin_protocol_ver to use it.
Add database creation examples for CAN and LIN.
Add documentation and testing for the examples.
@epage
Copy link
Contributor

epage commented Jan 26, 2018

Well, I see nothing wrong and I happen to still have write access. I guess I'll merge this :)

@epage epage merged commit cdef471 into ni:master Jan 26, 2018
@d-bohls d-bohls deleted the databaseExamples branch January 26, 2018 22:01
@d-bohls d-bohls self-assigned this Mar 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Db.cluster should be Db.clusters

3 participants