Skip to content

Commit

Permalink
Squashed 'opendbc/' changes from e92e74311..b875f970f
Browse files Browse the repository at this point in the history
b875f970f Stricter pylint
daf3bc988 HRV correct GAS_PEDAL (#266)
c25b757ac Update X-trail HUD message name, added SPEED_MPH signal (#269)
1f1ff225b enable almost all flake8 checks
4c59163aa two spaces before inline comment

git-subtree-dir: opendbc
git-subtree-split: b875f970fc6ddad5befe2f6831f4bcda354d8bea
  • Loading branch information
Vehicle Researcher committed Jun 5, 2020
1 parent 35bd9d9 commit a18bd33
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 22 deletions.
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ repos:
hooks:
- id: flake8
args:
- --select=F
- --ignore=E111,E114,E121,E124,E302,E501,E741
- --statistics
- repo: local
hooks:
- id: pylint
Expand All @@ -24,4 +25,4 @@ repos:
language: system
types: [python]
args:
- --disable=R,C,W
- --disable=C,R,W0613,W0511,W0212,W0201,W0311,W0106,W0603,W0621,W0703,E1136
9 changes: 5 additions & 4 deletions can/dbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def int_or_float(s):
else:
return float(s)


DBCSignal = namedtuple(
"DBCSignal", ["name", "start_bit", "size", "is_little_endian", "is_signed",
"factor", "offset", "tmin", "tmax", "units"])
Expand Down Expand Up @@ -41,7 +42,7 @@ def __init__(self, fn):
self.def_vals = defaultdict(list)

# lookup to bit reverse each byte
self.bits_index = [(i & ~0b111) + ((-i-1) & 0b111) for i in range(64)]
self.bits_index = [(i & ~0b111) + ((-i - 1) & 0b111) for i in range(64)]

for l in self.txt:
l = l.strip()
Expand Down Expand Up @@ -103,7 +104,7 @@ def __init__(self, fn):

# convert strings to UPPER_CASE_WITH_UNDERSCORES
defvals[1::2] = [d.strip().upper().replace(" ", "_") for d in defvals[1::2]]
defvals = '"'+"".join(str(i) for i in defvals)+'"'
defvals = '"' + "".join(str(i) for i in defvals) + '"'

self.def_vals[ids].append((sgname, defvals))

Expand Down Expand Up @@ -193,12 +194,12 @@ def decode(self, x, arr=None, debug=False):
if arr is None:
out = {}
else:
out = [None]*len(arr)
out = [None] * len(arr)

msg = self.msgs.get(x[0])
if msg is None:
if x[0] not in self._warned_addresses:
#print("WARNING: Unknown message address {}".format(x[0]))
# print("WARNING: Unknown message address {}".format(x[0]))
self._warned_addresses.add(x[0])
return None, None

Expand Down
2 changes: 1 addition & 1 deletion can/packer_pyx_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ def get_ext_filename(self, ext_name):
)

if platform.system() == "Darwin":
os.system("install_name_tool -change opendbc/can/libdbc.dylib "+BASEDIR+"/opendbc/can/libdbc.dylib packer_pyx.so")
os.system("install_name_tool -change opendbc/can/libdbc.dylib " + BASEDIR + "/opendbc/can/libdbc.dylib packer_pyx.so")
2 changes: 1 addition & 1 deletion can/parser.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from opendbc.can.parser_pyx import CANParser # pylint: disable=no-name-in-module, import-error
from opendbc.can.parser_pyx import CANParser # pylint: disable=no-name-in-module, import-error
assert CANParser
2 changes: 1 addition & 1 deletion can/parser_pyx_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ def get_ext_filename(self, ext_name):
)

if platform.system() == "Darwin":
os.system("install_name_tool -change opendbc/can/libdbc.dylib "+BASEDIR+"/opendbc/can/libdbc.dylib parser_pyx.so")
os.system("install_name_tool -change opendbc/can/libdbc.dylib " + BASEDIR + "/opendbc/can/libdbc.dylib parser_pyx.so")
5 changes: 3 additions & 2 deletions can/process_dbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def process(in_fn, out_fn):
dbc_name = os.path.split(out_fn)[-1].replace('.cc', '')
#print("processing %s: %s -> %s" % (dbc_name, in_fn, out_fn))
# print("processing %s: %s -> %s" % (dbc_name, in_fn, out_fn))

template_fn = os.path.join(os.path.dirname(__file__), "dbc_template.cc")

Expand Down Expand Up @@ -70,7 +70,7 @@ def process(in_fn, out_fn):
little_endian = None

# sanity checks on expected COUNTER and CHECKSUM rules, as packer and parser auto-compute those signals
for address, msg_name, msg_size, sigs in msgs:
for address, msg_name, _, sigs in msgs:
dbc_msg_name = dbc_name + " " + msg_name
for sig in sigs:
if checksum_type is not None:
Expand Down Expand Up @@ -122,5 +122,6 @@ def main():

process(in_fn, out_fn)


if __name__ == '__main__':
main()
6 changes: 1 addition & 5 deletions generator/honda/honda_hrv_touring_2019_can.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ BO_ 228 STEERING_CONTROL: 5 ADAS
SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS
SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS

BO_ 304 GAS_PEDAL_2: 8 PCM
SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON
SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON
BO_ 316 GAS_PEDAL: 8 PCM
SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON

BO_ 342 STEERING_SENSORS: 6 EPS
SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON
Expand Down
6 changes: 1 addition & 5 deletions honda_hrv_touring_2019_can_generated.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,8 @@ BO_ 228 STEERING_CONTROL: 5 ADAS
SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS
SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS

BO_ 304 GAS_PEDAL_2: 8 PCM
SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON
SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON
BO_ 316 GAS_PEDAL: 8 PCM
SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON

BO_ 342 STEERING_SENSORS: 6 EPS
SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON
Expand Down
3 changes: 2 additions & 1 deletion nissan_x_trail_2017.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ BO_ 1228 PROPILOT_HUD_INFO_MSG: 8 XXX
BO_ 1227 LKAS_SETTINGS: 8 XXX
SG_ LKAS_ENABLED : 51|1@0+ (1,0) [0|1] "" XXX

BO_ 1273 SEATBELT: 7 XXX
BO_ 1273 HUD: 7 XXX
SG_ SEATBELT_DRIVER_LATCHED : 25|1@0+ (1,0) [0|1] "" XXX
SG_ SPEED_MPH : 5|1@0+ (1,0) [0|1] "" XXX

VAL_ 1055 GEAR_SHIFTER 6 "L" 4 "D" 3 "N" 2 "R" 1 "P" ;
VAL_ 1228 PROPILOT_NA_MSGS 0 "NO_MSG" 1 "NA_FRONT_CAMERA_IMPARED" 2 "STEERING_ASSIST_ON_STANDBY" 3 "NA_PARKING_ASSIST_ENABLED" 4 "STEER_ASSIST_CURRENTLY_NA" 5 "NA_BAD_WEATHER" 6 "NA_PARK_BRAKE_ON" 7 "NA_SEATBELT_NOT_FASTENED" ;
Expand Down

0 comments on commit a18bd33

Please sign in to comment.