Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Commit

Permalink
Added linter to opendbc (commaai#203)
Browse files Browse the repository at this point in the history
* Added linter to opendbc

* this?

* This should work

* another try

* added pylintrc
  • Loading branch information
rbiasini authored Dec 3, 2019
1 parent d452706 commit d309cdc
Show file tree
Hide file tree
Showing 5 changed files with 612 additions and 5 deletions.
10 changes: 7 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ pr: none

pool:
vmImage: 'ubuntu-16.04'

steps:
- script: |
set -e
docker build -t opendbc .
displayName: 'Build'
- script: |
docker run opendbc bash -c "python -m unittest discover opendbc"
displayName: 'Run Tests'
displayName: 'Unit tests'
- script: |
docker run opendbc bash -c "cd opendbc/can/tests/linter_python; PYTHONPATH=/ ./flake8_opendbc.sh"
docker run opendbc bash -c "cd opendbc/can/tests/linter_python; PYTHONPATH=/ ./pylint_opendbc.sh"
displayName: 'Python linter'
3 changes: 1 addition & 2 deletions can/dbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ def get_signals(self, msg):

if __name__ == "__main__":
from opendbc import DBC_PATH
import numpy as np

dbc_test = dbc(os.path.join(DBC_PATH, 'toyota_prius_2017_pt_generated.dbc'))
msg = ('STEER_ANGLE_SENSOR', {'STEER_ANGLE': -6.0, 'STEER_RATE': 4, 'STEER_FRACTION': -0.2})
Expand All @@ -267,7 +266,7 @@ def get_signals(self, msg):

dbc_test = dbc(os.path.join(DBC_PATH, 'hyundai_santa_fe_2019_ccan.dbc'))
decoded = dbc_test.decode((0x2b0, 0, "\xfa\xfe\x00\x07\x12"))
assert np.isclose(decoded[1]['SAS_Angle'], -26.2)
assert abs(decoded[1]['SAS_Angle'] - (-26.2)) < 0.001

msg = ('SAS11', {'SAS_Stat': 7.0, 'MsgCount': 0.0, 'SAS_Angle': -26.200000000000003, 'SAS_Speed': 0.0, 'CheckSum': 0.0})
encoded = dbc_test.encode(*msg)
Expand Down
Loading

0 comments on commit d309cdc

Please sign in to comment.