Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit d585a9b
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Mon Jan 2 16:10:04 2023 -0800

    Hyundai CAN-FD: SCC upper jerk limit signal (commaai#775)

    upper jerk

commit 107b96a
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Sun Jan 1 17:09:27 2023 -0800

    add some type hints (commaai#774)

    * type stubs for common, parser_pyx

    * Cleanup imports

    * values are indeed floats

    * common.pyi complete, added cpp stubs

    * parser_pyx.pyi complete

    * CANPacker completed

    * Holding temp changes...

    * remove *.pyi

    * just remove skip-file

    Co-authored-by: Jason Shuler <jshuler@gmail.com>

commit dcab27c
Author: Greg Hogan <gregjhogan@gmail.com>
Date:   Sun Jan 1 16:10:26 2023 -0800

    toyota: update CAR_MOVEMENT and ODOMETER signal (commaai#748)

commit 28f78f3
Author: Louie Lu <git@louie.lu>
Date:   Sun Jan 1 19:09:34 2023 -0500

    Mazda: Add vehicle acceleration of x and y axis (NED) (commaai#767)

commit 06a3e7d
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Sat Dec 31 16:49:26 2022 -0800

    add cpplint (commaai#773)

    * add cpplint

    * passes

    * bump cereal

    * here's a real hash

commit e8e97fc
Author: Shane Smiskol <shane@smiskol.com>
Date:   Thu Dec 15 15:19:11 2022 -0800

    Bump pylint to 2.15.4 (commaai#765)

    bump

commit 119f3f6
Author: Shane Smiskol <shane@smiskol.com>
Date:   Thu Dec 15 13:16:57 2022 -0800

    Bump pylint version (commaai#764)

    bump pylint

commit 4a7ad63
Author: Shane Smiskol <shane@smiskol.com>
Date:   Mon Dec 12 23:04:12 2022 -0800

    HKG CAN-FD: add brake error signal (commaai#762)

    * add brake errors

    * rename and add comment

    * fix

commit bb71829
Author: Shane Smiskol <shane@smiskol.com>
Date:   Mon Dec 12 17:10:47 2022 -0800

    GM: add comment for ACCAlwaysOne

commit 38fe4d3
Author: Shane Smiskol <shane@smiskol.com>
Date:   Mon Dec 12 17:03:36 2022 -0800

    GM: add steering buttons ACC-related bit (commaai#761)

    * add missing acc bit

    * this just looks better

commit 1f8aa05
Author: Shane Smiskol <shane@smiskol.com>
Date:   Thu Dec 8 20:35:26 2022 -0800

    Toyota: update LTA signals (commaai#759)

    * si

    * fix comments

    * run generator

    * Revert "run generator"

    This reverts commit 2b67e4c.

    Revert "fix comments"

    This reverts commit 7f95fd2.

    Revert "si"

    This reverts commit f058760.

    * sort and add LKA_ACTIVE signal (also flip STEER_REQUEST and _2)

    * Revert "sort and add LKA_ACTIVE signal (also flip STEER_REQUEST and _2)"

    This reverts commit 4ffd0f2.

    * minimal changes

    * run generator

commit fae2238
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Wed Dec 7 15:13:14 2022 -0800

    more canfd hkg blinker signals

commit 94fff47
Author: Shane Smiskol <shane@smiskol.com>
Date:   Sat Dec 3 02:02:55 2022 -0800

    Toyota: add steer_unavailable EPS states (commaai#756)

    * add lxa_unavailable states

    * generate

    * better to be more descriptive

    * better

commit 18e4ceb
Author: Shane Smiskol <shane@smiskol.com>
Date:   Sat Dec 3 00:39:47 2022 -0800

    Toyota: fix ACC fault signal comment (commaai#755)

    better name and comment

commit 4e3899c
Author: Shane Smiskol <shane@smiskol.com>
Date:   Fri Dec 2 21:02:00 2022 -0800

    Toyota: add ACC faulted signals (commaai#754)

    * add acc faulted signal to toyota dbc

    * generate

commit 3737675
Author: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com>
Date:   Thu Dec 1 17:21:27 2022 -0500

    HKG: Additional Distance Unit Signal (commaai#753)

    HKG: Car Port for Kia Sorento Plug-in Hybrid 2022

commit 900d8d1
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Mon Nov 28 21:41:29 2022 -0800

    Hyundai: CAN-FD RSPAS messages (commaai#752)

    * Hyundai: CAN-FD RSPAS messages

    * fix checksum

commit 871e054
Author: Shane Smiskol <shane@smiskol.com>
Date:   Tue Nov 22 14:57:13 2022 -0800

    GM: add cruise state signal (commaai#750)

    * add cruise state signal

    * values

    * accurate

commit cb53738
Author: Cameron Clough <cameronjclough@gmail.com>
Date:   Mon Nov 21 00:08:22 2022 -0800

    update README link to cabana

    closes commaai#733

commit 16efea3
Author: Willem Melching <willem.melching@gmail.com>
Date:   Tue Nov 15 19:51:42 2022 +0100

    add missing iterator include (commaai#747)

commit 296f190
Author: Shane Smiskol <shane@smiskol.com>
Date:   Wed Nov 2 16:17:20 2022 -0700

    GM: add bits for moving backwards (commaai#737)

    add bits for moving forward/backwards

commit 2304ecf
Author: Shane Smiskol <shane@smiskol.com>
Date:   Wed Nov 2 15:39:33 2022 -0700

    GM: add new undefined brake-related signals (commaai#736)

    * add some more brake related signals i found

    * generate

    * standardize name

    * add comments

    * generate

    * fix signal definition

commit 909e650
Author: ioniq5-cz <111085918+ioniq5-cz@users.noreply.github.com>
Date:   Mon Oct 31 22:02:35 2022 +0100

    CAN-FD HKG - Secondary Speed Limit, Schoolzone and bugfix (commaai#735)

    Secondary Speed Limit, Schoolzone and bugfix

commit b3dc569
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Sun Oct 30 17:57:29 2022 -0700

    EV6 longitudinal signals (commaai#734)

    * match to can platform

    * more matching

    * little more

commit 063f70a
Author: ioniq5-cz <111085918+ioniq5-cz@users.noreply.github.com>
Date:   Sat Oct 29 21:47:01 2022 +0200

    CAN-FD HGK - additional icons and chime from cars dash (commaai#728)

    additional Icons and chime from Dash

commit 526e21d
Author: ioniq5-cz <111085918+ioniq5-cz@users.noreply.github.com>
Date:   Fri Oct 28 21:42:39 2022 +0200

    Hyundai CAN-FD: fix set speed signal size (commaai#729)

    * additional Icons and chime from Dash

    * Fix for EU cars using kph with 127 limit

    * 255 max

    * remove factor 0.5

    * removing unused NEW_SIGNAL_4 on 103

commit bf30c91
Author: ioniq5-cz <111085918+ioniq5-cz@users.noreply.github.com>
Date:   Tue Oct 25 08:05:52 2022 +0200

    CAN-FD HKG - Speed Limits from Dashboard (commaai#727)

    * SPEED_LIMITS HDA2 Dash

    * cleanup

    * cleanup 2

    * Final Adjustments

    * cleanup

    * cleanup 2

    * clean title for HDA2

    * change title since it covers hda 1 and 2

commit a95b0ae
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Mon Oct 24 19:15:26 2022 -0700

    ev6 blindspot signals

commit e111117
Author: Brandon Smyth <bjsmyth@umich.edu>
Date:   Mon Oct 24 19:23:43 2022 -0400

    Ford: correct syntax error (commaai#720)

    Correct syntax error

    Co-authored-by: Brandon <brandon@Weston.local>

commit d1dffa1
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Sun Oct 23 17:34:46 2022 -0700

    unpin scons

commit 4e9acc8
Author: Jiapeng Li <gapleehit@gmail.com>
Date:   Fri Oct 21 11:08:47 2022 +0800

    [docker] rm cereal .git folder (commaai#721)

    * [docker] rm cereal .git folder

    * Update Dockerfile

    Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

commit 7bd94e3
Author: Shane Smiskol <shane@smiskol.com>
Date:   Thu Oct 20 19:28:28 2022 -0700

    HKG CAN-FD: rename common brake signal (commaai#725)

    * rename brake signals

    * move

    * fix

    * add comments

commit 1903dc5
Author: Shane Smiskol <shane@smiskol.com>
Date:   Thu Oct 20 15:36:44 2022 -0700

    HKG CAN-FD: BRAKE_POSITION is signed (commaai#724)

    * signed

    * cmt

commit 27022cc
Author: Shane Smiskol <shane@smiskol.com>
Date:   Thu Oct 20 14:31:00 2022 -0700

    HKG CAN-FD: rename brake pressure signal, add position signal (commaai#723)

    * add brake percent/pressure

    * This are actually swapped

    * add comments

commit a58a58a
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Wed Oct 19 21:50:34 2022 -0700

    Hyundai CAN-FD: a few TCS signals (commaai#722)

commit 8a37db4
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Wed Oct 19 11:15:19 2022 -0700

    EV6 corner radars (commaai#719)

    * ev6 blindspot radars

    * Update hyundai_canfd.dbc

commit 8f245e6
Author: Eric Day <smartype@gmail.com>
Date:   Tue Oct 18 12:27:50 2022 +0800

    Toyota: radar dsu tss-p radar support, aka nodsu (commaai#707)

    * Toyota: radar dsu tss-p radar support, aka nodsu

    * update LONG_DIST factor to 0.03

commit ad45ef8
Author: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com>
Date:   Tue Oct 18 00:25:46 2022 -0400

    Hyundai CAN-FD: support for ICE cars (commaai#680)

    * Hyundai: Car Port for Santa Cruz 2022

    * Define gears

    * Wrong definition

commit c131dce
Author: Dean Lee <deanlee3@gmail.com>
Date:   Tue Oct 18 12:25:13 2022 +0800

    CANParser: parse DBC from stream (commaai#718)

commit dde0ff6
Author: Jason Young <46612682+jyoung8607@users.noreply.github.com>
Date:   Wed Oct 12 19:26:00 2022 -0400

    VW MQB: Update ACC messages (commaai#717)

    * add/update ACC messages

    * lower diff

commit 04cc54d
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Tue Oct 11 18:46:02 2022 -0700

    EV6 radar + longitudinal messages (commaai#714)

    * EV6 radar messages

    * fix radar messages

    * adrv messages

    * start adrv

    * one more

    * it's on both, but don't want to split the dbc yet

    * and the signals

    * accel signals

    * little more

    * few more

    * getting somewhere

commit a70a900
Author: Greg Hogan <gregjhogan@gmail.com>
Date:   Tue Oct 11 16:04:19 2022 -0700

    Hyundai corner radar DBC (commaai#712)

    * corner radar dbc based on palisade

    * 0x100/0x200 scale/offset

    * update DBC

    * generate dbc properly

commit c35e813
Author: Shane Smiskol <shane@smiskol.com>
Date:   Mon Oct 10 23:04:08 2022 -0700

    HKG CAN-FD: add LKA fault signal (commaai#716)

    * Add LKA fault signal

    * add comment

    * change to 1 bit

commit 0c80dc3
Author: Shane Smiskol <shane@smiskol.com>
Date:   Sat Oct 8 22:14:50 2022 -0700

    Add missing checksum and counter signals for PSCMStatus (commaai#715)

    * Add missing checksum and counter signals for PSCMStatus

    * flip

commit c090e49
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Fri Oct 7 17:12:17 2022 -0700

    Revert "EV6 radar messages"

    This reverts commit b3be6e9.

commit b3be6e9
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Fri Oct 7 17:03:24 2022 -0700

    EV6 radar messages

commit 6fc6781
Author: Shane Smiskol <shane@smiskol.com>
Date:   Fri Oct 7 15:50:33 2022 -0700

    Add comment about variable length GM message, fix comment syntax

commit ae2fd93
Author: Cameron Clough <cameronjclough@gmail.com>
Date:   Wed Oct 5 19:42:01 2022 -0700

    Revert "Ford: fix steering command signal ranges (commaai#683)"

    This reverts commit 778894f.

commit 9ddcdb2
Author: Greg Hogan <gregjhogan@gmail.com>
Date:   Mon Oct 3 18:43:26 2022 -0700

    hyundai: fix FCA11 checksum and counter (commaai#656)

commit 3a03644
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Mon Oct 3 14:27:27 2022 -0700

    hyundai_kia_generic: add values for ACCEnable signal

commit 738e8aa
Author: Greg Hogan <gregjhogan@gmail.com>
Date:   Sun Sep 25 08:31:57 2022 -0700

    CAN-FD messages can be 64 bytes (commaai#711)

commit eaac172
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Wed Sep 21 21:40:31 2022 -0700

    setup generator for hyundai radar dbc (commaai#710)

    * setup generator for hyundai radar dbc

    * fix indentation

commit 1f47ae8
Author: Shane Smiskol <shane@smiskol.com>
Date:   Mon Sep 19 11:48:09 2022 -0700

    Honda Bosch Radarless: add standstill bit (commaai#699)

    * Update honda_civic_ex_2022_can.dbc

    * Update honda_civic_ex_2022_can.dbc

    * run generator

commit 3008f67
Author: Greg Hogan <gregjhogan@gmail.com>
Date:   Sat Sep 17 16:02:44 2022 -0700

    hyundai: fix CAN-FD steering angle rate signal (commaai#708)

    * hyundai: fix canfd steering angle rate signal

    * make consistent with non-canfd definition

commit 82435e5
Author: ioniq5-cz <111085918+ioniq5-cz@users.noreply.github.com>
Date:   Thu Sep 8 21:28:07 2022 +0200

    Hyundai: Add FCA signal for CAN-FD (commaai#706)

    * new signal for FCA detection IONIQ 5 HDA2

    * Cleanup

    * cleanup

    * cleanup2

commit e95ed31
Author: martinl <martin@mlp.ee>
Date:   Thu Sep 8 06:37:36 2022 +0300

    Add test for Subaru Brake_Status Signal1 large value (commaai#702)

    * Add test for Subaru Brake_Status Signal1 large value

    * fix

    Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

commit 40c6132
Author: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com>
Date:   Wed Sep 7 16:43:01 2022 -0400

    Hyundai: Add Manumatic/Paddle Shifter signal (commaai#705)

commit d588872
Author: Comma Device <device@comma.ai>
Date:   Fri Sep 2 19:00:25 2022 -0400

    can parser: reduce spammy debug messages

commit 83d4cb9
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Wed Aug 31 15:17:08 2022 -0700

    fix typo

commit 8a60d0d
Author: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Date:   Wed Aug 31 15:01:27 2022 -0700

    hyundai canfd: add a couple brake signals

commit 63581cc
Author: Shane Smiskol <shane@smiskol.com>
Date:   Mon Aug 29 22:59:48 2022 -0700

    Toyota: add universal units signal (commaai#695)

    * Toyota: add universal units signal

    * not vehicle units

    * Update comment

    * Update comment 2

    * Update comment 2

    * Update signal name for RC and IS

commit 778894f
Author: Cameron Clough <cameronjclough@gmail.com>
Date:   Mon Aug 29 14:02:03 2022 -0700

    Ford: fix steering command signal ranges (commaai#683)

    fix LatCtlPath_An_Actl signal range

commit d8e7566
Author: Cameron Clough <cameronjclough@gmail.com>
Date:   Mon Aug 29 13:46:28 2022 -0700

    ford: another mystery bit (commaai#697)

    Found another signal to passthrough
  • Loading branch information
budney committed Jan 7, 2023
1 parent 7e45de4 commit 04f9e6b
Show file tree
Hide file tree
Showing 36 changed files with 1,797 additions and 642 deletions.
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ repos:
exclude: 'site_scons/'
args:
- --disable=C,R,W0613,W0511,W0212,W0201,W0311,W0106,W0603,W0621,W0703,E1136
- repo: https://github.com/cpplint/cpplint
rev: 1.6.1
hooks:
- id: cpplint
args:
- --quiet
- --counting=detailed
- --linelength=240
- --filter=-legal,-build/include_order,-readability/casting,-whitespace/braces,-whitespace/indent,-whitespace/operators,-build/c++11,-readability/todo,-runtime/explicit,-runtime/int,-whitespace/comments,-readability/braces,-runtime/arrays,-runtime/references
- repo: local
hooks:
- id: cppcheck
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ ENV PYTHONPATH=/project

WORKDIR /project
# TODO: Add tag to cereal
RUN git clone https://github.com/commaai/cereal.git /project/cereal && cd /project/cereal && git checkout d46f37c314bb92306207db44693b2f58c31f66b9
RUN git clone https://github.com/commaai/cereal.git /project/cereal && \
cd /project/cereal && \
git checkout 959ff79963b80829be9902d146c31fda44dbbd20

COPY SConstruct .
COPY ./site_scons /project/site_scons
COPY . /project/opendbc

RUN rm -rf /project/opendbc/.git
RUN rm -rf /project/opendbc/.git && \
rm -rf /project/cereal/.git
RUN scons -c && scons -j$(nproc)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Wondering what's the DBC file format? [Here](http://www.socialledge.com/sjsu/ind

## How to start reverse engineering cars

[opendbc](https://github.com/commaai/opendbc) is integrated with [cabana](https://community.comma.ai/cabana/).
[opendbc](https://github.com/commaai/opendbc) is integrated with [cabana](https://github.com/commaai/openpilot/tree/master/tools/cabana).

Use [panda](https://github.com/commaai/panda) to connect your car to a computer.

Expand Down
3 changes: 0 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ cereal_dir = Dir('.')
python_path = sysconfig.get_paths()['include']
cpppath = [
'#',
'#cereal',
"#cereal/messaging",
"#opendbc/can",
'/usr/lib/include',
python_path
]
Expand Down
46 changes: 23 additions & 23 deletions can/common.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "common.h"
#include "opendbc/can/common.h"


unsigned int honda_checksum(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d) {
int s = 0;
Expand Down Expand Up @@ -34,7 +35,7 @@ unsigned int subaru_checksum(uint32_t address, const Signal &sig, const std::vec
}

unsigned int chrysler_checksum(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d) {
/* jeep chrysler canbus checksum from http://illmatics.com/Remote%20Car%20Hacking.pdf */
// jeep chrysler canbus checksum from http://illmatics.com/Remote%20Car%20Hacking.pdf
uint8_t checksum = 0xFF;
for (int j = 0; j < (d.size() - 1); j++) {
uint8_t shift = 0x80;
Expand Down Expand Up @@ -123,64 +124,64 @@ unsigned int volkswagen_mqb_checksum(uint32_t address, const Signal &sig, const
// Look up and apply the magic final CRC padding byte, which permutes by CAN
// address, and additionally (for SOME addresses) by the message counter.
uint8_t counter = d[1] & 0x0F;
switch(address) {
switch (address) {
case 0x86: // LWI_01 Steering Angle
crc ^= (uint8_t[]){0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86}[counter];
crc ^= (uint8_t[]){0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86}[counter];
break;
case 0x9F: // LH_EPS_03 Electric Power Steering
crc ^= (uint8_t[]){0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5}[counter];
crc ^= (uint8_t[]){0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5}[counter];
break;
case 0xAD: // Getriebe_11 Automatic Gearbox
crc ^= (uint8_t[]){0x3F,0x69,0x39,0xDC,0x94,0xF9,0x14,0x64,0xD8,0x6A,0x34,0xCE,0xA2,0x55,0xB5,0x2C}[counter];
crc ^= (uint8_t[]){0x3F, 0x69, 0x39, 0xDC, 0x94, 0xF9, 0x14, 0x64, 0xD8, 0x6A, 0x34, 0xCE, 0xA2, 0x55, 0xB5, 0x2C}[counter];
break;
case 0xFD: // ESP_21 Electronic Stability Program
crc ^= (uint8_t[]){0xB4,0xEF,0xF8,0x49,0x1E,0xE5,0xC2,0xC0,0x97,0x19,0x3C,0xC9,0xF1,0x98,0xD6,0x61}[counter];
crc ^= (uint8_t[]){0xB4, 0xEF, 0xF8, 0x49, 0x1E, 0xE5, 0xC2, 0xC0, 0x97, 0x19, 0x3C, 0xC9, 0xF1, 0x98, 0xD6, 0x61}[counter];
break;
case 0x106: // ESP_05 Electronic Stability Program
crc ^= (uint8_t[]){0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07}[counter];
crc ^= (uint8_t[]){0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07}[counter];
break;
case 0x117: // ACC_10 Automatic Cruise Control
crc ^= (uint8_t[]){0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16}[counter];
crc ^= (uint8_t[]){0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16}[counter];
break;
case 0x120: // TSK_06 Drivetrain Coordinator
crc ^= (uint8_t[]){0xC4,0xE2,0x4F,0xE4,0xF8,0x2F,0x56,0x81,0x9F,0xE5,0x83,0x44,0x05,0x3F,0x97,0xDF}[counter];
crc ^= (uint8_t[]){0xC4, 0xE2, 0x4F, 0xE4, 0xF8, 0x2F, 0x56, 0x81, 0x9F, 0xE5, 0x83, 0x44, 0x05, 0x3F, 0x97, 0xDF}[counter];
break;
case 0x121: // Motor_20 Driver Throttle Inputs
crc ^= (uint8_t[]){0xE9,0x65,0xAE,0x6B,0x7B,0x35,0xE5,0x5F,0x4E,0xC7,0x86,0xA2,0xBB,0xDD,0xEB,0xB4}[counter];
crc ^= (uint8_t[]){0xE9, 0x65, 0xAE, 0x6B, 0x7B, 0x35, 0xE5, 0x5F, 0x4E, 0xC7, 0x86, 0xA2, 0xBB, 0xDD, 0xEB, 0xB4}[counter];
break;
case 0x122: // ACC_06 Automatic Cruise Control
crc ^= (uint8_t[]){0x37,0x7D,0xF3,0xA9,0x18,0x46,0x6D,0x4D,0x3D,0x71,0x92,0x9C,0xE5,0x32,0x10,0xB9}[counter];
crc ^= (uint8_t[]){0x37, 0x7D, 0xF3, 0xA9, 0x18, 0x46, 0x6D, 0x4D, 0x3D, 0x71, 0x92, 0x9C, 0xE5, 0x32, 0x10, 0xB9}[counter];
break;
case 0x126: // HCA_01 Heading Control Assist
crc ^= (uint8_t[]){0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA}[counter];
crc ^= (uint8_t[]){0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA}[counter];
break;
case 0x12B: // GRA_ACC_01 Steering wheel controls for ACC
crc ^= (uint8_t[]){0x6A,0x38,0xB4,0x27,0x22,0xEF,0xE1,0xBB,0xF8,0x80,0x84,0x49,0xC7,0x9E,0x1E,0x2B}[counter];
crc ^= (uint8_t[]){0x6A, 0x38, 0xB4, 0x27, 0x22, 0xEF, 0xE1, 0xBB, 0xF8, 0x80, 0x84, 0x49, 0xC7, 0x9E, 0x1E, 0x2B}[counter];
break;
case 0x12E: // ACC_07 Automatic Cruise Control
crc ^= (uint8_t[]){0xF8,0xE5,0x97,0xC9,0xD6,0x07,0x47,0x21,0x66,0xDD,0xCF,0x6F,0xA1,0x94,0x74,0x63}[counter];
crc ^= (uint8_t[]){0xF8, 0xE5, 0x97, 0xC9, 0xD6, 0x07, 0x47, 0x21, 0x66, 0xDD, 0xCF, 0x6F, 0xA1, 0x94, 0x74, 0x63}[counter];
break;
case 0x187: // EV_Gearshift "Gear" selection data for EVs with no gearbox
crc ^= (uint8_t[]){0x7F,0xED,0x17,0xC2,0x7C,0xEB,0x44,0x21,0x01,0xFA,0xDB,0x15,0x4A,0x6B,0x23,0x05}[counter];
crc ^= (uint8_t[]){0x7F, 0xED, 0x17, 0xC2, 0x7C, 0xEB, 0x44, 0x21, 0x01, 0xFA, 0xDB, 0x15, 0x4A, 0x6B, 0x23, 0x05}[counter];
break;
case 0x30C: // ACC_02 Automatic Cruise Control
crc ^= (uint8_t[]){0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F}[counter];
crc ^= (uint8_t[]){0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F}[counter];
break;
case 0x30F: // SWA_01 Lane Change Assist (SpurWechselAssistent)
crc ^= (uint8_t[]){0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C}[counter];
crc ^= (uint8_t[]){0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C}[counter];
break;
case 0x324: // ACC_04 Automatic Cruise Control
crc ^= (uint8_t[]){0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27}[counter];
crc ^= (uint8_t[]){0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27}[counter];
break;
case 0x3C0: // Klemmen_Status_01 ignition and starting status
crc ^= (uint8_t[]){0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3}[counter];
crc ^= (uint8_t[]){0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3}[counter];
break;
case 0x65D: // ESP_20 Electronic Stability Program
crc ^= (uint8_t[]){0xAC,0xB3,0xAB,0xEB,0x7A,0xE1,0x3B,0xF7,0x73,0xBA,0x7C,0x9E,0x06,0x5F,0x02,0xD9}[counter];
crc ^= (uint8_t[]){0xAC, 0xB3, 0xAB, 0xEB, 0x7A, 0xE1, 0x3B, 0xF7, 0x73, 0xBA, 0x7C, 0x9E, 0x06, 0x5F, 0x02, 0xD9}[counter];
break;
default: // As-yet undefined CAN message, CRC check expected to fail
printf("Attempt to CRC check undefined Volkswagen message 0x%02X\n", address);
crc ^= (uint8_t[]){0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}[counter];
crc ^= (uint8_t[]){0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}[counter];
break;
}
crc = crc8_lut_8h2f[crc];
Expand Down Expand Up @@ -221,7 +222,6 @@ unsigned int pedal_checksum(uint32_t address, const Signal &sig, const std::vect
}

unsigned int hkg_can_fd_checksum(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d) {

uint16_t crc = 0;

for (int i = 2; i < d.size(); i++) {
Expand Down
7 changes: 5 additions & 2 deletions can/common.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#pragma once

#include <vector>
#include <map>
#include <string>
#include <utility>
#include <unordered_map>
#include <vector>

#include "common_dbc.h"
#include <capnp/dynamic.h>
#include <capnp/serialize.h>

#ifndef DYNAMIC_CAPNP
#include "cereal/gen/cpp/log.capnp.h"
#endif

#include "opendbc/can/common_dbc.h"

#define INFO printf
#define WARN printf
#define DEBUG(...)
Expand Down
11 changes: 11 additions & 0 deletions can/common_dbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ struct DBC {
std::vector<Val> vals;
};

typedef struct ChecksumState {
int checksum_size;
int counter_size;
int checksum_start_bit;
int counter_start_bit;
bool little_endian;
SignalType checksum_type;
unsigned int (*calc_checksum)(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d);
} ChecksumState;

DBC* dbc_parse(const std::string& dbc_path);
DBC* dbc_parse_from_stream(const std::string &dbc_name, std::istream &stream, ChecksumState *checksum = nullptr);
const DBC* dbc_lookup(const std::string& dbc_name);
std::vector<std::string> get_dbc_names();
38 changes: 16 additions & 22 deletions can/dbc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#include <vector>
#include <mutex>
#include <cstring>
#include <iterator>

#include "common.h"
#include "common_dbc.h"
#include "opendbc/can/common.h"
#include "opendbc/can/common_dbc.h"

std::regex bo_regexp(R"(^BO_ (\w+) (\w+) *: (\w+) (\w+))");
std::regex sg_regexp(R"(^SG_ (\w+) : (\d+)\|(\d+)@(\d+)([\+|\-]) \(([0-9.+\-eE]+),([0-9.+\-eE]+)\) \[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] \"(.*)\" (.*))");
Expand Down Expand Up @@ -47,16 +48,6 @@ inline std::string& trim(std::string& s, const char* t = " \t\n\r\f\v") {
return s.erase(0, s.find_first_not_of(t));
}

typedef struct ChecksumState {
int checksum_size;
int counter_size;
int checksum_start_bit;
int counter_start_bit;
bool little_endian;
SignalType checksum_type;
unsigned int (*calc_checksum)(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d);
} ChecksumState;

ChecksumState* get_checksum(const std::string& dbc_name) {
ChecksumState* s = nullptr;
if (startswith(dbc_name, {"honda_", "acura_"})) {
Expand Down Expand Up @@ -107,14 +98,7 @@ void set_signal_type(Signal& s, ChecksumState* chk, const std::string& dbc_name,
}
}

DBC* dbc_parse(const std::string& dbc_path) {
std::ifstream infile(dbc_path);
if (!infile) return nullptr;

const std::string dbc_name = std::filesystem::path(dbc_path).filename();

std::unique_ptr<ChecksumState> checksum(get_checksum(dbc_name));

DBC* dbc_parse_from_stream(const std::string &dbc_name, std::istream &stream, ChecksumState *checksum) {
uint32_t address = 0;
std::set<uint32_t> address_set;
std::set<std::string> msg_name_set;
Expand All @@ -134,7 +118,7 @@ DBC* dbc_parse(const std::string& dbc_path) {
int line_num = 0;
std::smatch match;
// TODO: see if we can speed up the regex statements in this loop, SG_ is specifically the slowest
while (std::getline(infile, line)) {
while (std::getline(stream, line)) {
line = trim(line);
line_num += 1;
if (startswith(line, "BO_ ")) {
Expand Down Expand Up @@ -168,7 +152,7 @@ DBC* dbc_parse(const std::string& dbc_path) {
sig.is_signed = match[offset + 5].str() == "-";
sig.factor = std::stod(match[offset + 6].str());
sig.offset = std::stod(match[offset + 7].str());
set_signal_type(sig, checksum.get(), dbc_name, line_num);
set_signal_type(sig, checksum, dbc_name, line_num);
if (sig.is_little_endian) {
sig.lsb = sig.start_bit;
sig.msb = sig.start_bit + sig.size - 1;
Expand Down Expand Up @@ -213,6 +197,16 @@ DBC* dbc_parse(const std::string& dbc_path) {
return dbc;
}

DBC* dbc_parse(const std::string& dbc_path) {
std::ifstream infile(dbc_path);
if (!infile) return nullptr;

const std::string dbc_name = std::filesystem::path(dbc_path).filename();

std::unique_ptr<ChecksumState> checksum(get_checksum(dbc_name));
return dbc_parse_from_stream(dbc_name, infile, checksum.get());
}

const std::string get_dbc_root_path() {
char *basedir = std::getenv("BASEDIR");
if (basedir != NULL) {
Expand Down
2 changes: 1 addition & 1 deletion can/packer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <map>
#include <cmath>

#include "common.h"
#include "opendbc/can/common.h"


void set_value(std::vector<uint8_t> &msg, const Signal &sig, int64_t ival) {
Expand Down
3 changes: 1 addition & 2 deletions can/packer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# pylint: skip-file
from opendbc.can.packer_pyx import CANPacker
from opendbc.can.packer_pyx import CANPacker # pylint: disable=no-name-in-module, import-error
assert CANPacker
16 changes: 8 additions & 8 deletions can/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int64_t get_raw_value(const std::vector<uint8_t> &msg, const Signal &sig) {
int msb = (int)(sig.msb / 8) == i ? sig.msb : (i+1)*8 - 1;
int size = msb - lsb + 1;

uint8_t d = (msg[i] >> (lsb - (i*8))) & ((1ULL << size) - 1);
uint64_t d = (msg[i] >> (lsb - (i*8))) & ((1ULL << size) - 1);
ret |= d << (bits - size);

bits -= size;
Expand All @@ -32,7 +32,6 @@ int64_t get_raw_value(const std::vector<uint8_t> &msg, const Signal &sig) {


bool MessageState::parse(uint64_t sec, const std::vector<uint8_t> &dat) {

for (int i = 0; i < parse_sigs.size(); i++) {
auto &sig = parse_sigs[i];

Expand Down Expand Up @@ -94,7 +93,6 @@ CANParser::CANParser(int abus, const std::string& dbc_name,
const std::vector<MessageParseOptions> &options,
const std::vector<SignalParseOptions> &sigoptions)
: bus(abus), aligned_buf(kj::heapArray<capnp::word>(1024)) {

dbc = dbc_lookup(dbc_name);
assert(dbc);
init_crc_lookup_tables();
Expand Down Expand Up @@ -127,7 +125,7 @@ CANParser::CANParser(int abus, const std::string& dbc_name,
}

state.size = msg->size;
assert(state.size < 64); // max signal size is 64 bytes
assert(state.size <= 64); // max signal size is 64 bytes

// track checksums and counters for this message
for (const auto& sig : msg->sigs) {
Expand Down Expand Up @@ -287,10 +285,12 @@ void CANParser::UpdateValid(uint64_t sec) {
const bool missing = state.last_seen_nanos == 0;
const bool timed_out = (sec - state.last_seen_nanos) > state.check_threshold;
if (state.check_threshold > 0 && (missing || timed_out)) {
if (missing) {
LOGE("0x%X MISSING", state.address);
} else if (show_missing) {
LOGE("0x%X TIMEOUT", state.address);
if (show_missing && !bus_timeout) {
if (missing) {
LOGE("0x%X NOT SEEN", state.address);
} else if (timed_out) {
LOGE("0x%X TIMED OUT", state.address);
}
}
_valid = false;
}
Expand Down
9 changes: 9 additions & 0 deletions can/tests/test.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ BO_ 228 STEERING_CONTROL: 5 EON
SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS
SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS

BO_ 316 Brake_Status: 8 XXX
SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX
SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" XXX
SG_ Signal1 : 12|46@1+ (1,0) [0|1] "" XXX
SG_ ES_Brake : 58|1@1+ (1,0) [0|1] "" XXX
SG_ Signal2 : 59|3@1+ (1,0) [0|1] "" XXX
SG_ Brake : 62|1@1+ (1,0) [0|1] "" XXX
SG_ Signal3 : 63|1@1+ (1,0) [0|1] "" XXX

BO_ 245 CAN_FD_MESSAGE: 32 XXX
SG_ COUNTER : 7|8@0+ (1,0) [0|1] "" XXX
SG_ SIGNED : 22|16@0- (1,0) [0|1] "" XXX
Expand Down
Loading

0 comments on commit 04f9e6b

Please sign in to comment.