Skip to content

Commit

Permalink
Merge pull request BogGyver#11 from BogGyver/Tesla_pedal_noLogo
Browse files Browse the repository at this point in the history
Tesla pedal no logo - ALCA
  • Loading branch information
ErichMoraga authored Oct 10, 2018
2 parents 61ea653 + 1291592 commit 6d6c0b4
Show file tree
Hide file tree
Showing 125 changed files with 7,278 additions and 1,907 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ selfdrive/test/tests/plant/out
/src/

one

.vscode/settings.json
launch_chffrplus.sh

4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ script:
- docker run --rm
-v "$(pwd)"/selfdrive/test/tests/plant/out:/tmp/openpilot/selfdrive/test/tests/plant/out
tmppilot /bin/sh -c 'cd /tmp/openpilot/selfdrive/test/tests/plant && OPTEST=1 ./test_longitudinal.py'

branches:
only:
- /.*/
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files.associations": {
"algorithm": "cpp",
"chrono": "cpp",
"limits": "cpp"
}
}
10 changes: 5 additions & 5 deletions cereal/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
PWD := $(shell pwd)

SRCS := log.capnp car.capnp
SRCS := log.capnp car.capnp ui.capnp

GENS := gen/cpp/car.capnp.c++ gen/cpp/log.capnp.c++
JS := gen/js/car.capnp.js gen/js/log.capnp.js
GENS := gen/cpp/car.capnp.c++ gen/cpp/log.capnp.c++ gen/cpp/ui.capnp.c++
JS := gen/js/car.capnp.js gen/js/log.capnp.js gen/js/ui.capnp.js

UNAME_M ?= $(shell uname -m)

# only generate C++ for docker tests
ifneq ($(OPTEST),1)
GENS += gen/c/car.capnp.c gen/c/log.capnp.c gen/c/include/c++.capnp.h gen/c/include/java.capnp.h
GENS += gen/c/car.capnp.c gen/c/log.capnp.c gen/c/ui.capnp.c gen/c/include/c++.capnp.h gen/c/include/java.capnp.h

ifeq ($(UNAME_M),x86_64)
GENS += gen/java/Car.java gen/java/Log.java
GENS += gen/java/Car.java gen/java/Log.java gen/java/Ui.java
endif

endif
Expand Down
1 change: 1 addition & 0 deletions cereal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

log = capnp.load(os.path.join(CEREAL_PATH, "log.capnp"))
car = capnp.load(os.path.join(CEREAL_PATH, "car.capnp"))
ui = capnp.load(os.path.join(CEREAL_PATH, "ui.capnp"))
64 changes: 64 additions & 0 deletions cereal/ui.capnp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using Cxx = import "./include/c++.capnp";
$Cxx.namespace("cereal");

using Java = import "./include/java.capnp";
$Java.package("ai.comma.openpilot.cereal");
$Java.outerClassname("Ui");

using Car = import "car.capnp";

@0xce6ca45dddcd5317;

struct UIButtonInfo {
# button ID 0..5
btnId @0 :Int8;
# internal button name
btnName @1 :Text;
# display label for button (3 chars)
btnLabel @2 :Text;
# buttons status: 0 = DISABLED, 1 = AVAILABLE, 2 = ENABLED, 3 = WARNING, 9 = NOT AVAILABLE
btnStatus @3 :Int16;
# small font label shows below the main label, max 7 chars
btnLabel2 @4 :Text;
}

struct UIButtonStatus {
# button ID 0..5
btnId @0 :Int8;
# buttons status: 0 = DISABLED, 1 = AVAILABLE, 2 = ENABLED, 3 = WARNING, 9 = NOT AVAILABLE
btnStatus @1 :Int16;
}

struct UICustomAlert {
caStatus @0 :Int8;
caText @1 :Text;
}

struct UISetCar {
icCarFolder @0 :Text;
icCarName @1 :Text;
}

struct UIPlaySound {
sndSound @0 :Int8;
}

struct UIUpdate {
uiDoUpdate @0 :Int8;
uiStatus @1 :Int8;
uiCanDisplayMessage @2 :Int8;
}

#struct UIEvent {
# # in nanoseconds?
# logMonoTime @0 :UInt64;
#
# union {
# uiButtonInfo @1 :UIButtonInfo;
# uiCustomAlert @2 :UICustomAlert;
# uiSetCar @3 :UISetCar;
# uiButtonStatus @4 :UIButtonStatus;
# uiUpdate @5 :UIUpdate;
# uiPlaySound @6 :UIPlaySound;
# }
#}
2 changes: 1 addition & 1 deletion common/fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ def eliminate_incompatible_cars(msg, candidate_cars):

def all_known_cars():
"""Returns a list of all known car strings."""
return _FINGERPRINTS.keys()
return _FINGERPRINTS.keys()
2 changes: 1 addition & 1 deletion common/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,4 @@ def put(self, key, dat):

# Test multiprocess:
# seq 0 100000 | xargs -P20 -I{} python common/params.py DongleId {} && sleep 0.05
# while python common/params.py DongleId; do sleep 0.05; done
# while python common/params.py DongleId; do sleep 0.05; done
43 changes: 31 additions & 12 deletions opendbc/tesla_can.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ BO_ 3 STW_ANGL_STAT: 8 STW
SG_ MC_STW_ANGL_STAT : 55|4@0+ (1,0) [0|15] "" NEO
SG_ CRC_STW_ANGL_STAT : 63|8@0+ (1,0) [0|255] "" NEO

BO_ 14 STW_ANGLHP_STAT: 8 STW
BO_ 14 STW_ANGLHP_STAT: 8 STW

SG_ StW_AnglHP : 5|14@0+ (0.1,-819.2) [-819.2|819] "deg" NEO
SG_ StW_AnglHP_Spd : 21|14@0+ (0.5,-4096) [-4096|4095.5] "deg/s" NEO
SG_ StW_AnglHP_Sens_Stat : 33|2@0+ (1,0) [0|0] "" NEO
Expand Down Expand Up @@ -147,19 +148,21 @@ BO_ 309 ESP_135h: 5 ESP
SG_ ESP_espOffLamp : 31|1@0+ (1,0) [-1|2] "" NEO
SG_ ESP_stabilityControlSts : 14|3@0+ (1,0) [6|7] "" NEO
SG_ ESP_tcLampFlash : 5|1@0+ (1,0) [-1|2] "" NEO
SG_ ESP_tcOffLamp : 15|1@0+ (1,0) [0|1] "" NEOBO_ 341 ESP_B: 8 ESP
SG_ ESP_BChecksum : 39|8@0+ (1,0) [0|255] "" NEO,EPAS
SG_ ESP_BCounter : 62|4@0+ (1,0) [1|15] "" NEO,EPAS
SG_ ESP_vehicleSpeed : 47|16@0+ (0.00999999978,0) [0|0] "kph" NEO,EPAS
SG_ ESP_vehicleSpeedQF : 57|2@0+ (1,0) [1|2] "" NEO,EPAS
SG_ ESP_wheelPulseCountFrL : 7|8@0+ (1,0) [0|254] "" NEO,EPAS
SG_ ESP_wheelPulseCountFrR : 15|8@0+ (1,0) [0|254] "" NEO,EPAS
SG_ ESP_wheelPulseCountReL : 23|8@0+ (1,0) [0|254] "" NEO,EPAS
SG_ ESP_tcOffLamp : 15|1@0+ (1,0) [0|1] "" NEO

BO_ 341 ESP_B: 8 ESP
SG_ ESP_BChecksum : 39|8@0+ (1,0) [0|255] "" NEO,EPAS
SG_ ESP_BCounter : 62|4@0+ (1,0) [1|15] "" NEO,EPAS
SG_ ESP_vehicleSpeed : 47|16@0+ (0.00999999978,0) [0|0] "kph" NEO,EPAS
SG_ ESP_vehicleSpeedQF : 57|2@0+ (1,0) [1|2] "" NEO,EPAS
SG_ ESP_wheelPulseCountFrL : 7|8@0+ (1,0) [0|254] "" NEO,EPAS
SG_ ESP_wheelPulseCountFrR : 15|8@0+ (1,0) [0|254] "" NEO,EPAS
SG_ ESP_wheelPulseCountReL : 23|8@0+ (1,0) [0|254] "" NEO,EPAS
SG_ ESP_wheelPulseCountReR : 31|8@0+ (1,0) [0|254] "" NEO,EPAS

BO_ 532 EPB_epasControl: 3 EPB
SG_ EPB_epasControlChecksum : 23|8@0+ (1,0) [0|255] "" NEO,EPAS
SG_ EPB_epasControlCounter : 11|4@0+ (1,0) [0|15] "" NEO,EPAS
BO_ 532 EPB_epasControl: 3 EPB
SG_ EPB_epasControlChecksum : 23|8@0+ (1,0) [0|255] "" NEO,EPAS
SG_ EPB_epasControlCounter : 11|4@0+ (1,0) [0|15] "" NEO,EPAS
SG_ EPB_epasEACAllow : 2|3@0+ (1,0) [4|7] "" NEO,EPAS

BO_ 792 GTW_carState: 8 GTW
Expand Down Expand Up @@ -307,6 +310,21 @@ BO_ 840 GTW_status: 8 GTW
SG_ GTW_statusChecksum : 63|8@0+ (1,0) [0|255] "" NEO
SG_ GTW_statusCounter : 51|4@0+ (1,0) [0|15] "" NEO

BO_ 1361 GAS_COMMAND: 6 EON
SG_ GAS_COMMAND : 7|16@0+ (0.0507968128,-22.85856576) [0|1] "" INTERCEPTOR
SG_ GAS_COMMAND2 : 23|16@0+ (0.1015936256,-22.85856576) [0|1] "" INTERCEPTOR
SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR
SG_ IDX : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR
SG_ CHECKSUM : 47|8@0+ (1,0) [0|3] "" INTERCEPTOR

BO_ 1362 GAS_SENSOR: 6 INTERCEPTOR
SG_ INTERCEPTOR_GAS : 7|16@0+ (0.0507968128,-22.85856576) [0|1] "" EON
SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.1015936256,-22.85856576) [0|1] "" EON
SG_ STATE : 35|4@0+ (1,0) [0|15] "" EON
SG_ IDX : 39|4@0+ (1,0) [0|15] "" EON
SG_ CHECKSUM : 47|8@0+ (1,0) [0|3] "" EON


VAL_ 3 StW_Angl 16383 "SNA" ;
VAL_ 3 StW_AnglSens_Id 2 "MUST" 0 "PSBL" 1 "SELF" ;
VAL_ 3 StW_AnglSens_Stat 2 "ERR" 3 "ERR_INI" 1 "INI" 0 "OK" ;
Expand Down Expand Up @@ -417,5 +435,6 @@ VAL_ 904 MCU_clusterReadyForDrive 0 "NO_SNA" 1 "YES" ;
VAL_ 1160 DAS_steeringAngleRequest 16384 "ZERO_ANGLE" ;
VAL_ 1160 DAS_steeringControlType 1 "ANGLE_CONTROL" 3 "DISABLED" 0 "NONE" 2 "RESERVED" ;
VAL_ 1160 DAS_steeringHapticRequest 1 "ACTIVE" 0 "IDLE" ;
VAL_ 1362 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;

CM_ "CHFFR_METRIC 1160 DAS_steeringAngleRequest STEER_ANGLE 0.1098666 180; CHFFR_METRIC 264 DI_motorRPM ENGINE_RPM 1 0";
Empty file modified panda/board/get_sdk.sh
100755 → 100644
Empty file.
Empty file modified panda/board/get_sdk_mac.sh
100755 → 100644
Empty file.
11 changes: 10 additions & 1 deletion panda/board/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// ********************* includes *********************

#include "libc.h"
#include "safety.h"
#include "provision.h"

#include "drivers/drivers.h"
Expand All @@ -19,6 +18,7 @@
#include "drivers/can.h"
#include "drivers/spi.h"
#include "drivers/timer.h"
#include "safety.h"


// ***************************** fan *****************************
Expand Down Expand Up @@ -291,6 +291,15 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
can_silent = ALL_CAN_BUT_MAIN_SILENT;
can_autobaud_enabled[0] = false;
break;
case SAFETY_TESLA:
can_silent = ALL_CAN_LIVE;
can_autobaud_enabled[0] = false;
can_autobaud_enabled[1] = false;
#ifdef PANDA
can_autobaud_enabled[2] = false;
#endif
// MISSING: setup GMLAN pin as output and high level to switch EPAS CAN on Tesla Giraffe
break;
default:
can_silent = ALL_CAN_LIVE;
can_autobaud_enabled[0] = false;
Expand Down
1 change: 1 addition & 0 deletions panda/board/pedal.honda/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj/*
59 changes: 59 additions & 0 deletions panda/board/pedal.honda/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# :set noet
PROJ_NAME = comma

CFLAGS = -O2 -Wall -std=gnu11 -DPEDAL
CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m3
CFLAGS += -msoft-float -DSTM32F2 -DSTM32F205xx
CFLAGS += -I ../inc -I ../ -I ../../ -nostdlib
CFLAGS += -T../stm32_flash.ld

STARTUP_FILE = startup_stm32f205xx

CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
OBJDUMP = arm-none-eabi-objdump
DFU_UTIL = "dfu-util"

# pedal only uses the debug cert
CERT = ../../certs/debug
CFLAGS += "-DALLOW_DEBUG"

canflash: obj/$(PROJ_NAME).bin
../../tests/pedal/enter_canloader.py $<

usbflash: obj/$(PROJ_NAME).bin
../../tests/pedal/enter_canloader.py; sleep 0.5
PYTHONPATH=../../ python -c "from python import Panda; p = [x for x in [Panda(x) for x in Panda.list()] if x.bootstub]; assert(len(p)==1); p[0].flash('obj/$(PROJ_NAME).bin', reconnect=False)"

recover: obj/bootstub.bin obj/$(PROJ_NAME).bin
../../tests/pedal/enter_canloader.py --recover; sleep 0.5
$(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08004000 -D obj/$(PROJ_NAME).bin
$(DFU_UTIL) -d 0483:df11 -a 0 -s 0x08000000:leave -D obj/bootstub.bin

obj/main.o: main.c ../*.h
mkdir -p obj
$(CC) $(CFLAGS) -o $@ -c $<

obj/bootstub.o: ../bootstub.c ../*.h
mkdir -p obj
$(CC) $(CFLAGS) -o $@ -c $<

obj/$(STARTUP_FILE).o: ../$(STARTUP_FILE).s
$(CC) $(CFLAGS) -o $@ -c $<

obj/%.o: ../../crypto/%.c
$(CC) $(CFLAGS) -o $@ -c $<

obj/$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/main.o
# hack
$(CC) -Wl,--section-start,.isr_vector=0x8004000 $(CFLAGS) -o obj/$(PROJ_NAME).elf $^
$(OBJCOPY) -v -O binary obj/$(PROJ_NAME).elf obj/code.bin
SETLEN=1 ../../crypto/sign.py obj/code.bin $@ $(CERT)

obj/bootstub.bin: obj/$(STARTUP_FILE).o obj/bootstub.o obj/sha.o obj/rsa.o
$(CC) $(CFLAGS) -o obj/bootstub.$(PROJ_NAME).elf $^
$(OBJCOPY) -v -O binary obj/bootstub.$(PROJ_NAME).elf $@

clean:
rm -f obj/*

28 changes: 28 additions & 0 deletions panda/board/pedal.honda/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
This is the firmware for the comma pedal. It borrows a lot from panda.

The comma pedal is a gas pedal interceptor for Honda/Acura. It allows you to "virtually" press the pedal.

This is the open source software. Note that it is not ready to use yet.

== Test Plan ==

* Startup
** Confirm STATE_FAULT_STARTUP
* Timeout
** Send value
** Confirm value is output
** Stop sending messages
** Confirm value is passthru after 100ms
** Confirm STATE_FAULT_TIMEOUT
* Random values
** Send random 6 byte messages
** Confirm random values cause passthru
** Confirm STATE_FAULT_BAD_CHECKSUM
* Same message lockout
** Send same message repeated
** Confirm timeout behavior
* Don't set enable
** Confirm no output
* Set enable and values
** Confirm output

Loading

0 comments on commit 6d6c0b4

Please sign in to comment.