mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-08-08 01:35:40 +08:00
add DragonBTG mode
This commit is contained in:
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
mode=$1
|
||||
if [ $1 -eq 1 ]; then
|
||||
printf %s "1" > /data/params/d/DragonBTG
|
||||
fi
|
||||
if [ $1 -eq 0 ]; then
|
||||
printf %s "0" > /data/params/d/DragonBTG
|
||||
fi
|
||||
|
||||
rm -rf /data/openpilot/selfdrive/boardd/boardd && reboot
|
||||
+3
-2
@@ -150,8 +150,8 @@ keys = {
|
||||
"DragonEnableSlowOnCurve": [TxType.PERSISTENT],
|
||||
"DragonEnableLeadCarMovingAlert": [TxType.PERSISTENT],
|
||||
"DragonToyotaSnGMod": [TxType.PERSISTENT],
|
||||
"DragonIsEON": [TxType.PERSISTENT],
|
||||
"DragonHWChecked": [TxType.PERSISTENT],
|
||||
"DragonIsEON": [TxType.PERSISTENT], # deprecated
|
||||
"DragonHWChecked": [TxType.PERSISTENT], # deprecated
|
||||
"DragonEnableSRLearner": [TxType.PERSISTENT],
|
||||
"DragonWazeMode": [TxType.PERSISTENT],
|
||||
"DragonRunWaze": [TxType.PERSISTENT],
|
||||
@@ -160,6 +160,7 @@ keys = {
|
||||
"DragonAssistedLCMinMPH": [TxType.PERSISTENT],
|
||||
"DragonAutoLCMinMPH": [TxType.PERSISTENT],
|
||||
"DragonAutoLCDelay": [TxType.PERSISTENT],
|
||||
"DragonBTG": [TxType.PERSISTENT],
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
Import('env', 'common', 'messaging')
|
||||
|
||||
# dragonpilot - Add read DragonBTG value
|
||||
if FindFile('DragonBTG', '/data/params/d') != None:
|
||||
with open('/data/params/d/DragonBTG') as f:
|
||||
if (int(f.read())) == 1:
|
||||
env.Append(CCFLAGS='-DDragonBTG')
|
||||
|
||||
env.Program('boardd.cc', LIBS=['usb-1.0', common, messaging, 'pthread', 'zmq', 'capnp', 'kj'])
|
||||
env.Library('libcan_list_to_can_capnp', ['can_list_to_can_capnp.cc'])
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ void pigeon_init();
|
||||
void *pigeon_thread(void *crap);
|
||||
|
||||
void *safety_setter_thread(void *s) {
|
||||
#ifndef DragonBTG
|
||||
// diagnostic only is the default, needed for VIN query
|
||||
pthread_mutex_lock(&usb_lock);
|
||||
libusb_control_transfer(dev_handle, 0x40, 0xdc, (uint16_t)(cereal::CarParams::SafetyModel::ELM327), 0, NULL, 0, TIMEOUT);
|
||||
@@ -101,6 +102,7 @@ void *safety_setter_thread(void *s) {
|
||||
pthread_mutex_lock(&usb_lock);
|
||||
libusb_control_transfer(dev_handle, 0x40, 0xdc, (uint16_t)(cereal::CarParams::SafetyModel::NO_OUTPUT), 0, NULL, 0, TIMEOUT);
|
||||
pthread_mutex_unlock(&usb_lock);
|
||||
#endif
|
||||
|
||||
char *value;
|
||||
size_t value_sz = 0;
|
||||
@@ -355,12 +357,14 @@ void can_health(PubSocket *publisher) {
|
||||
} while(cnt != sizeof(health));
|
||||
pthread_mutex_unlock(&usb_lock);
|
||||
|
||||
#ifndef DragonBTG
|
||||
// Make sure CAN buses are live: safety_setter_thread does not work if Panda CAN are silent and there is only one other CAN node
|
||||
if (health.safety_model == (uint8_t)(cereal::CarParams::SafetyModel::SILENT)) {
|
||||
pthread_mutex_lock(&usb_lock);
|
||||
libusb_control_transfer(dev_handle, 0x40, 0xdc, (uint16_t)(cereal::CarParams::SafetyModel::NO_OUTPUT), 0, NULL, 0, TIMEOUT);
|
||||
pthread_mutex_unlock(&usb_lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool ignition = ((health.ignition_line != 0) || (health.ignition_can != 0));
|
||||
|
||||
@@ -396,12 +400,14 @@ void can_health(PubSocket *publisher) {
|
||||
libusb_control_transfer(dev_handle, 0xc0, 0xe7, 1, 0, NULL, 0, TIMEOUT);
|
||||
pthread_mutex_unlock(&usb_lock);
|
||||
}
|
||||
#ifndef DragonBTG
|
||||
// set safety mode to NO_OUTPUT when car is off. ELM327 is an alternative if we want to leverage athenad/connect
|
||||
if (!ignition && (health.safety_model != (uint8_t)(cereal::CarParams::SafetyModel::NO_OUTPUT))) {
|
||||
pthread_mutex_lock(&usb_lock);
|
||||
libusb_control_transfer(dev_handle, 0x40, 0xdc, (uint16_t)(cereal::CarParams::SafetyModel::NO_OUTPUT), 0, NULL, 0, TIMEOUT);
|
||||
pthread_mutex_unlock(&usb_lock);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// clear VIN, CarParams, and set new safety on car start
|
||||
@@ -813,6 +819,11 @@ void *pigeon_thread(void *crap) {
|
||||
if (pigeon_needs_init) {
|
||||
pigeon_needs_init = false;
|
||||
pigeon_init();
|
||||
#ifdef DragonBTG
|
||||
pthread_mutex_lock(&usb_lock);
|
||||
libusb_control_transfer(dev_handle, 0x40, 0xdc, 2, 100, NULL, 0, TIMEOUT);
|
||||
pthread_mutex_unlock(&usb_lock);
|
||||
#endif
|
||||
}
|
||||
int alen = 0;
|
||||
while (alen < 0xfc0) {
|
||||
@@ -855,6 +866,9 @@ int set_realtime_priority(int level) {
|
||||
int main() {
|
||||
int err;
|
||||
LOGW("starting boardd");
|
||||
#ifdef DragonBTG
|
||||
LOGW("boardd is running in DragonBTG mode");
|
||||
#endif
|
||||
|
||||
// set process priority
|
||||
err = set_realtime_priority(4);
|
||||
|
||||
@@ -54,8 +54,6 @@ default_conf = {
|
||||
'DragonEnableSlowOnCurve': '1',
|
||||
'DragonEnableLeadCarMovingAlert': '0',
|
||||
'DragonToyotaSnGMod': '0',
|
||||
'DragonIsEON': '1',
|
||||
'DragonHWChecked': '0',
|
||||
'DragonEnableSRLearner': '1',
|
||||
'DragonWazeMode': '0',
|
||||
'DragonRunWaze': '0',
|
||||
@@ -64,36 +62,34 @@ default_conf = {
|
||||
'DragonAssistedLCMinMPH': 37,
|
||||
'DragonAutoLCMinMPH': 60,
|
||||
'DragonAutoLCDelay': 2,
|
||||
'DragonBTG': 0,
|
||||
}
|
||||
|
||||
deprecated_conf = {
|
||||
'DragonDisableDriverSafetyCheck': 'DragonEnableDriverSafetyCheck',
|
||||
'DragonTempDisableSteerOnSignal': 'DragonEnableSteeringOnSignal',
|
||||
'DragonDisableLogger': 'DragonEnableLogger',
|
||||
'DragonDisableUploader': 'DragonEnableUploader',
|
||||
'DragonBBUI': 'DragonUIDev',
|
||||
'DragonIsEON': '',
|
||||
'DragonHWChecked': '',
|
||||
}
|
||||
|
||||
# deprecated_conf_invert = {
|
||||
deprecated_conf_invert = {
|
||||
# 'DragonDisableDriverSafetyCheck': True,
|
||||
# 'DragonTempDisableSteerOnSignal': False,
|
||||
# 'DragonDisableLogger': True,
|
||||
# 'DragonDisableUploader': True,
|
||||
# 'DragonBBUI': False
|
||||
# }
|
||||
}
|
||||
|
||||
def dragonpilot_set_params(params):
|
||||
# remove deprecated params
|
||||
# for old, new in deprecated_conf.items():
|
||||
# if params.get(old) is not None:
|
||||
# if new is not None:
|
||||
# old_val = str(params.get(old))
|
||||
# new_val = old_val
|
||||
# # invert the value if true
|
||||
# if old in deprecated_conf_invert and deprecated_conf_invert[old] is True:
|
||||
# new_val = "1" if old_val == "0" else "0"
|
||||
# put_nonblocking(new, new_val)
|
||||
# params.delete(old)
|
||||
for old, new in deprecated_conf.items():
|
||||
if params.get(old) is not None:
|
||||
if new is not None:
|
||||
old_val = str(params.get(old))
|
||||
new_val = old_val
|
||||
# invert the value if true
|
||||
if old in deprecated_conf_invert and deprecated_conf_invert[old] is True:
|
||||
new_val = "1" if old_val == "0" else "0"
|
||||
put_nonblocking(new, new_val)
|
||||
params.delete(old)
|
||||
|
||||
# set params
|
||||
for key, val in default_conf.items():
|
||||
|
||||
@@ -178,9 +178,6 @@ def thermald_thread():
|
||||
dragon_charging_ctrl = True if params.get('DragonChargingCtrl', encoding='utf8') == "1" else False
|
||||
dragon_charging_max = int(params.get('DragonCharging'))
|
||||
dragon_discharging_min = int(params.get('DragonDisCharging'))
|
||||
charging_disabled = False
|
||||
dragon_hw_checked = True if params.get('DragonHWChecked', encoding='utf8') == "1" else False
|
||||
dragon_is_eon = False if params.get('DragonIsEON', encoding='utf8') == "0" else True
|
||||
|
||||
while 1:
|
||||
health = messaging.recv_sock(health_sock, wait=True)
|
||||
|
||||
Reference in New Issue
Block a user