Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ repos:
hooks:
- id: cython-lint
- id: double-quote-cython-strings
- repo: https://github.com/cpplint/cpplint
rev: 2.0.2
hooks:
- id: cpplint
args:
- --quiet
- --counting=detailed
- --linelength=240
- --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/comma,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces
# TODO: enable this and fix all the errors
#- repo: https://github.com/cpplint/cpplint
# rev: 2.0.2
# hooks:
# - id: cpplint
# args:
# - --quiet
# - --counting=detailed
# - --linelength=240
# - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/comma,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces
1 change: 0 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ if platform.system() == "Darwin":
python_path = sysconfig.get_paths()['include']
cpppath = [
'#',
'#opendbc',
'/usr/lib/include',
python_path
]
Expand Down
3 changes: 0 additions & 3 deletions opendbc/can/common.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include <array>
#include <cstdio>
#include <string>
#include <unordered_map>
#include <vector>

#include "opendbc/can/common.h"

Expand Down
2 changes: 0 additions & 2 deletions opendbc/can/dbc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
#include <filesystem>
#include <fstream>
#include <map>
#include <memory>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <mutex>
#include <iterator>
Expand Down
2 changes: 0 additions & 2 deletions opendbc/can/packer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#include <cmath>
#include <map>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>

#include "opendbc/can/common.h"

Expand Down
3 changes: 0 additions & 3 deletions opendbc/can/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
#include <cassert>
#include <cstring>
#include <limits>
#include <set>
#include <stdexcept>
#include <sstream>
#include <string>
#include <vector>

#include "opendbc/can/common.h"

Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/board/can.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#include "safety/board/can_declarations.h"
#include "can_declarations.h"

static const unsigned char dlc_to_len[] = {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 12U, 16U, 20U, 24U, 32U, 48U, 64U};
2 changes: 1 addition & 1 deletion opendbc/safety/board/drivers/can_common.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "safety/board/drivers/can_common_declarations.h"
#include "can_common_declarations.h"

uint8_t calculate_checksum(const uint8_t *dat, uint32_t len) {
uint8_t checksum = 0U;
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/board/fake_stm.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdint.h>
#include <stdlib.h>

#include "safety/board/utils.h"
#include "utils.h"

#define ALLOW_DEBUG
#define PANDA
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/board/faults.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "safety/board/faults_declarations.h"
#include "faults_declarations.h"

uint8_t fault_status = FAULT_STATUS_NONE;
uint32_t faults = 0U;
Expand Down
10 changes: 5 additions & 5 deletions opendbc/safety/board/utils.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// cppcheck-suppress-macro misra-c2012-1.2; allow __typeof__ extension
#define MIN(a, b) ({ \
__typeof__(a) _a = (a); \
__typeof__(b) _b = (b); \
__typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
(_a < _b) ? _a : _b; \
})

// cppcheck-suppress-macro misra-c2012-1.2; allow __typeof__ extension
#define MAX(a, b) ({ \
__typeof__(a) _a = (a); \
__typeof__(b) _b = (b); \
__typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
(_a > _b) ? _a : _b; \
})

Expand All @@ -22,7 +22,7 @@

// cppcheck-suppress-macro misra-c2012-1.2; allow __typeof__ extension
#define ABS(a) ({ \
__typeof__(a) _a = (a); \
__typeof__ (a) _a = (a); \
(_a > 0) ? _a : (-_a); \
})

Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "safety/safety.h"
#include "safety.h"

// this file is checked by cppcheck

Expand Down
4 changes: 2 additions & 2 deletions opendbc/safety/safety.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety/board/can.h"
#include "safety_declarations.h"
#include "can.h"

// include the safety policies.
#include "safety/safety_defaults.h"
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety/safety_body.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

static void body_rx_hook(const CANPacket_t *to_push) {
// body is never at standstill
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety/safety_chrysler.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

typedef struct {
const int EPS_2;
Expand Down
6 changes: 3 additions & 3 deletions opendbc/safety/safety/safety_defaults.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

// GCOV_EXCL_START
// Unreachable by design (doesn't define any rx msgs)
Expand All @@ -13,7 +13,7 @@ void default_rx_hook(const CANPacket_t *to_push) {

static safety_config nooutput_init(uint16_t param) {
UNUSED(param);
return (safety_config){NULL, 0, NULL, 0, true}; // NOLINT(readability/braces)
return (safety_config){NULL, 0, NULL, 0, true};
}

// GCOV_EXCL_START
Expand All @@ -36,7 +36,7 @@ static safety_config alloutput_init(uint16_t param) {
const uint16_t ALLOUTPUT_PARAM_PASSTHROUGH = 1;
controls_allowed = true;
bool alloutput_passthrough = GET_FLAG(param, ALLOUTPUT_PARAM_PASSTHROUGH);
return (safety_config){NULL, 0, NULL, 0, !alloutput_passthrough}; // NOLINT(readability/braces)
return (safety_config){NULL, 0, NULL, 0, !alloutput_passthrough};
}

static bool alloutput_tx_hook(const CANPacket_t *to_send) {
Expand Down
4 changes: 2 additions & 2 deletions opendbc/safety/safety/safety_elm327.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety/safety_defaults.h"
#include "safety_declarations.h"
#include "safety_defaults.h"

static bool elm327_tx_hook(const CANPacket_t *to_send) {
const int GM_CAMERA_DIAG_ADDR = 0x24B;
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety/safety_ford.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

// Safety-relevant CAN messages for Ford vehicles.
#define FORD_EngBrakeData 0x165 // RX from PCM, for driver brake pedal and cruise state
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety/safety_gm.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

// TODO: do checksum and counter checks. Add correct timestep, 0.1s for now.
#define GM_COMMON_RX_CHECKS \
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety/safety_honda.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

// All common address checks except SCM_BUTTONS which isn't on one Nidec safety configuration
#define HONDA_COMMON_NO_SCM_FEEDBACK_RX_CHECKS(pt_bus) \
Expand Down
4 changes: 2 additions & 2 deletions opendbc/safety/safety/safety_hyundai.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety/safety_hyundai_common.h"
#include "safety_declarations.h"
#include "safety_hyundai_common.h"

#define HYUNDAI_LIMITS(steer, rate_up, rate_down) { \
.max_torque = (steer), \
Expand Down
4 changes: 2 additions & 2 deletions opendbc/safety/safety/safety_hyundai_canfd.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety/safety_hyundai_common.h"
#include "safety_declarations.h"
#include "safety_hyundai_common.h"

#define HYUNDAI_CANFD_CRUISE_BUTTON_TX_MSGS(bus) \
{0x1CF, bus, 8, .check_relay = false}, /* CRUISE_BUTTON */ \
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety/safety_hyundai_common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

extern uint16_t hyundai_canfd_crc_lut[256];
uint16_t hyundai_canfd_crc_lut[256];
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety/safety_mazda.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

// CAN msgs we care about
#define MAZDA_LKAS 0x243
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety/safety_nissan.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

static bool nissan_alt_eps = false;

Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety/safety_rivian.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

#define RIVIAN_MAX_SPEED_DELTA 2.0 // m/s

Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety/safety_subaru.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

#define SUBARU_STEERING_LIMITS_GENERATOR(steer_max, rate_up, rate_down) \
{ \
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety/safety_subaru_preglobal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

// Preglobal platform
// 0x161 is ES_CruiseThrottle
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety/safety_tesla.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

// parameters for lateral accel/jerk angle limiting using a simple vehicle model
typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety/safety_toyota.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety_declarations.h"

// Stock longitudinal
#define TOYOTA_BASE_TX_MSGS \
Expand Down
10 changes: 5 additions & 5 deletions opendbc/safety/safety/safety_volkswagen_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ static uint32_t volkswagen_mqb_meb_compute_crc(const CANPacket_t *to_push) {

uint8_t counter = volkswagen_mqb_meb_get_counter(to_push);
if (addr == MSG_LH_EPS_03) {
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];
} else if (addr == MSG_ESP_05) {
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];
} else if (addr == MSG_TSK_06) {
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];
} else if (addr == MSG_MOTOR_20) {
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];
} else if (addr == MSG_GRA_ACC_01) {
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];
} else {
// Undefined CAN message, CRC check expected to fail
}
Expand Down
4 changes: 2 additions & 2 deletions opendbc/safety/safety/safety_volkswagen_mqb.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety/safety_volkswagen_common.h"
#include "safety_declarations.h"
#include "safety_volkswagen_common.h"

static bool volkswagen_mqb_brake_pedal_switch = false;
static bool volkswagen_mqb_brake_pressure_detected = false;
Expand Down
4 changes: 2 additions & 2 deletions opendbc/safety/safety/safety_volkswagen_pq.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "safety/safety_declarations.h"
#include "safety/safety_volkswagen_common.h"
#include "safety_declarations.h"
#include "safety_volkswagen_common.h"

#define MSG_LENKHILFE_3 0x0D0 // RX from EPS, for steering angle and driver steering torque
#define MSG_HCA_1 0x0D2 // TX by OP, Heading Control Assist steering torque
Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/safety_declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
(config).tx_msgs = (tx); \
(config).tx_msgs_len = sizeof((tx)) / sizeof((tx)[0]); \
(config).disable_forwarding = false; \
} while (0);
} while(0);

#define UPDATE_VEHICLE_SPEED(val_ms) (update_sample(&vehicle_speed, ROUND((val_ms) * VEHICLE_SPEED_FACTOR)))

Expand Down
2 changes: 1 addition & 1 deletion opendbc/safety/tests/libsafety/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env = Environment(
'-Wfatal-errors',
'-Wno-pointer-to-int-cast',
],
CPPPATH=[".", "../../board/", "../../", "../../../"],
CPPPATH=[".", "../../board/", "../../"],
)
if system == "Darwin":
env.PrependENVPath('PATH', '/opt/homebrew/bin')
Expand Down
12 changes: 6 additions & 6 deletions opendbc/safety/tests/libsafety/safety.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include <stdbool.h>

#include "safety/board/fake_stm.h"
#include "safety/board/can.h"
#include "fake_stm.h"
#include "can.h"

//int safety_tx_hook(CANPacket_t *to_send) { return 1; }

#include "safety/board/faults.h"
#include "safety/safety.h"
#include "safety/board/drivers/can_common.h"
#include "faults.h"
#include "safety.h"
#include "drivers/can_common.h"

// libsafety stuff
#include "safety/tests/libsafety/safety_helpers.h"
#include "safety_helpers.h"
2 changes: 0 additions & 2 deletions opendbc/safety/tests/libsafety/safety_helpers.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <stdio.h>

void safety_tick_current_safety_config() {
safety_tick(&current_safety_config);
}
Expand Down
Loading