dragonpilot mod for 0.8.5-4

This commit is contained in:
Rick Lan
2021-07-02 12:49:43 +08:00
parent 145b222f0d
commit 522fb06db7
224 changed files with 9120 additions and 7777 deletions
View File
+10
View File
@@ -36,6 +36,16 @@ else:
"-g",
]
if FindFile('dp_vw', '/data/params/d') != None:
with open('/data/params/d/dp_vw_panda') as f:
if (int(f.read().strip())) == 1:
PROJECT_FLAGS += ['-Dvw']
if FindFile('dp_panda_fake_black', '/data/params/d') != None:
with open('/data/params/d/dp_panda_fake_black') as f:
if (int(f.read().strip())) == 1:
PROJECT_FLAGS += ['-Dfake_black_panda']
if not PC:
PROJECT_FLAGS += ["-DEON"]
BUILDER = "EON"
+3 -6
View File
@@ -56,12 +56,7 @@ void uno_set_gps_load_switch(bool enabled) {
}
void uno_set_bootkick(bool enabled){
if(enabled){
set_gpio_output(GPIOB, 14, false);
} else {
// We want the pin to be floating, not forced high!
set_gpio_mode(GPIOB, 14, MODE_INPUT);
}
set_gpio_output(GPIOB, 14, !enabled);
}
void uno_bootkick(void) {
@@ -77,9 +72,11 @@ void uno_set_usb_power_mode(uint8_t mode) {
bool valid = false;
switch (mode) {
case USB_POWER_CLIENT:
uno_set_phone_power(false);
valid = true;
break;
case USB_POWER_CDP:
uno_set_phone_power(true);
uno_bootkick();
valid = true;
break;
+18
View File
@@ -127,10 +127,24 @@ void set_safety_mode(uint16_t mode, int16_t param) {
switch (mode_copy) {
case SAFETY_SILENT:
set_intercept_relay(false);
#ifdef vw
// Volkswagen community port:
// J533 integrations with White/Grey Panda really need Panda to respond
// at all times. Let the CAN transceivers ACK traffic unless this is
// BP/Uno where the physical relay makes it irrelevant. This makes
// SILENT identical to NOOUTPUT for White/Grey Panda.
if (board_has_obd()) {
current_board->set_can_mode(CAN_MODE_NORMAL);
can_silent = ALL_CAN_SILENT;
} else {
can_silent = ALL_CAN_LIVE;
}
#else
if (board_has_obd()) {
current_board->set_can_mode(CAN_MODE_NORMAL);
}
can_silent = ALL_CAN_SILENT;
#endif
break;
case SAFETY_NOOUTPUT:
set_intercept_relay(false);
@@ -333,7 +347,11 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired)
break;
// **** 0xc1: get hardware type
case 0xc1:
#ifdef fake_black_panda
resp[0] = HW_TYPE_BLACK_PANDA;
#else
resp[0] = hw_type;
#endif
resp_len = 1;
break;
// **** 0xd0: fetch serial number
+7
View File
@@ -28,7 +28,14 @@ void set_power_save_state(int state) {
enable = true;
}
#ifdef vw
// Volkswagen community port:
// If this is a White or Grey Panda, always keep the CAN transceivers
// powered up so that transparent forwarding is maintained.
current_board->enable_can_transceivers(board_has_obd() ? enable : true);
#else
current_board->enable_can_transceivers(enable);
#endif
// Switch EPS/GPS
if (enable) {
+24 -1
View File
@@ -24,9 +24,32 @@ static int nooutput_tx_lin_hook(int lin_num, uint8_t *data, int len) {
}
static int default_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
UNUSED(bus_num);
UNUSED(to_fwd);
#ifdef vw
// Volkswagen community port: Advanced Virtual Relay Technology!
// Make Panda fully transparent from bus 0->2 and bus 2->0 if not otherwise
// instructed by EON/OP, returning the car to stock behavior under NOOUTPUT.
// Don't do this for BP/C2, where we have Advanced Actual Relay Technology.
int bus_fwd = -1;
if(!board_has_relay()) {
switch (bus_num) {
case 0:
bus_fwd = 2;
break;
case 2:
bus_fwd = 0;
break;
default:
bus_fwd = -1;
break;
}
}
return bus_fwd;
#else
UNUSED(bus_num);
return -1;
#endif
}
const safety_hooks nooutput_hooks = {
+2 -2
View File
@@ -1,8 +1,8 @@
// Safety-relevant steering constants for Volkswagen
const int VOLKSWAGEN_MAX_STEER = 300; // 3.0 Nm (EPS side max of 3.0Nm with fault if violated)
const int VOLKSWAGEN_MAX_RT_DELTA = 75; // 4 max rate up * 50Hz send rate * 250000 RT interval / 1000000 = 50 ; 50 * 1.5 for safety pad = 75
const int VOLKSWAGEN_MAX_RT_DELTA = 188; // 10 max rate up * 50Hz send rate * 250000 RT interval / 1000000 = 125 ; 125 * 1.5 for safety pad = 187.5
const uint32_t VOLKSWAGEN_RT_INTERVAL = 250000; // 250ms between real time checks
const int VOLKSWAGEN_MAX_RATE_UP = 4; // 2.0 Nm/s RoC limit (EPS rack has own soft-limit of 5.0 Nm/s)
const int VOLKSWAGEN_MAX_RATE_UP = 10; // 5.0 Nm/s RoC limit (EPS rack has own soft-limit of 5.0 Nm/s)
const int VOLKSWAGEN_MAX_RATE_DOWN = 10; // 5.0 Nm/s RoC limit (EPS rack has own soft-limit of 5.0 Nm/s)
const int VOLKSWAGEN_DRIVER_TORQUE_ALLOWANCE = 80;
const int VOLKSWAGEN_DRIVER_TORQUE_FACTOR = 3;