Skip to content

Commit

Permalink
Squashed 'panda/' changes from 256d274..a648cca
Browse files Browse the repository at this point in the history
a648cca Add os import
042562d Extracted wifi connect from test helpers
ac0fd5d query fw versions example - use extended diagnostic session
4e9d788 Remove not-needed cadillac-init
f0a5d15 typo
c093286 Add bootkick after re-enabling phone power (#401)
eadb0db security upgrades (#397)
7c13bec Command to get signature (#399)
dad439a static assert on size of health packet (#398)
da9da46 Fix VERSION
df4159c Revert "Revert "Register readback on most modules. Still need to convert the other ones (#396)""
56ec215 Revert "Register readback on most modules. Still need to convert the other ones (#396)"
893e486 Register readback on most modules. Still need to convert the other ones (#396)
6bbae7b VW safety: allow cancel spam on both buses to be compatible with camera and gateway integration
d5f7a28 bump panda
1bcc351 ignition_can: set it to False after 2s of not seeing CAN msgs
96137f1 VW can based ignition not needed. it has ignition line at camera as well.
1b004a1 Same flake8 version as the one in openpilot
e82ba5f Same pylint version as the one in openpilot
656f99b Interrupt refactor (NVIC_SM_1: #334) and Fault handling (#377) (PR #373)
000282e Fix can_logger.py to run correctly on python3 (#392)
7f9b4a5 Fix USB device enumeration on Windows 8.1 and Windows 10 (#393)
dec565c Update Misra test coverage, which now includes rule 2.7
fb6bc3b Fix Misra
878dd00 solve race condition is relay_malfunction right after changing the relay status by adding a counter
2d4cb05 add a safety mode counter
a6797a21 Implement USB power mode on uno
670f90c Merge branch 'master' of github.com:commaai/panda
ca39a5d Added faults integer to health packet
e1c34a1 Panda Jungle testing (#394)
2a093a3 Added heartbeat to echo test
2246435 Fixed health struct size. We should really get an automated test for this
f458d67 Add uptime counter to the health packet (#391)
1662481 enable CAN transcievers outside the set_safety_mode function, which is not related
a7c9874 bump panda ver
1192d93 Power saving refactor (#389)
d58d08f Fix Misra 17.8: can't mod function params
bc685ac Minor indent
a54b86c Failure of set_safety_mode falls back to SILENT. Failure to set silent results in hanging
597436d NOOUTPUT safety mode is now SILENT. NOOUTPUT still exists but keeps C… (#388)
d229f8d ESP forced off in EON build. this prevents ESP to be turned on when e… (#387)
8a044b3 forgot Hyundai: now also using make_msg
4f9c879 remove abunch of lines from safety regression tests by using common make_msg function
fb81414 mispelled word
57f5ef8 Fix misra: addr can't be more than 29 bits anyway
68ff501 typo
d5c772b Fixe Toyota message white-list
48197a9 Better masking for ELM mode
b8fe78c VW is also tested for safety replay
212d336 Safety Chrysler: Added cancel spam button check
d44b562 fix print in example
02d579a functional addr handling
6249a18 tx_hook shall have a white-list of messages (#381)
8138fc1 uds: handle function addrs and fw version query example
6626a54 Fixed python health api
b9b79e8 uds zero second timeout
e0de1a4 define ALLOW_DEBUG in safety tests
86dec4b Safety modes that violate ISO26262 requirements are not compiled in RELEASE build
e74ed93 safety tests a bit more simplified
2027765 relay malfunction test centralized
8af1a01 clean up safety tests
e8f7a3b upd panda
cfcce8f WIP: Relay malfunction (#384)
69d9d61 No tabs in mazda safety
a86418c insignificant changes
f239b99 single addr was better
d063a18 Hyundai safety: re-enable button spam safety check
4d1edc0 skip tx_hook if a message is forwarded (#379)
df2ff04 bump version
168461d added fault state to health packet
b3e1a13 uds: better debug prints
68c39fb uds: no need for threads if you always drain rx
91b7c5b bump Panda Ver
26cb4dc Fixed pylint error
32725cc Fixed misra compliance
e33b4be Added echo script
312ba62 minor comment cleanupo
e90897a Fix board detection on white
0e72c18 always stop executing if safety mode fails to be set (suggested by jyoung8607)
e8d7ed1 Rename function name to not confuse safety_set_mode and set_safety_mode
ff86db6 improve uds message processing
512ab3f except Exception
37ce507 py3 all
bac4d85 dos and python3
501db8d uds drain before send and use has_obd()
f2cbec1 Added has_obd() to python library
48e5b18 Add SDK downloading to the build step (#314)
e0762c2 Add Python & USB API for controlling phone power (#313)
ba9fb69 New health packet struct also in the python libs

git-subtree-dir: panda
git-subtree-split: a648cca
  • Loading branch information
Vehicle Researcher committed Dec 13, 2019
1 parent 22023eb commit bc7b9b3
Show file tree
Hide file tree
Showing 105 changed files with 2,447 additions and 1,675 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- run:
name: Build ESP image
command: |
docker run panda_build /bin/bash -c "cd /panda/boardesp; make user1.bin"
docker run panda_build /bin/bash -c "cd /panda/boardesp; ./get_sdk.sh; make user1.bin"
safety_replay:
machine:
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ ENV PYTHONPATH /tmp:$PYTHONPATH
COPY ./boardesp/get_sdk_ci.sh /tmp/panda/boardesp/
COPY ./boardesp/python2_make.py /tmp/panda/boardesp/

COPY ./panda_jungle /tmp/panda_jungle

RUN useradd --system -s /sbin/nologin pandauser
RUN mkdir -p /tmp/panda/boardesp/esp-open-sdk
RUN chown pandauser /tmp/panda/boardesp/esp-open-sdk
Expand Down
5 changes: 5 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ pipeline {
steps {
timeout(time: 60, unit: 'MINUTES') {
script {
try {
sh 'cp -R /home/batman/panda_jungle .'
} catch (err) {
echo "Folder already exists"
}
sh 'git archive -v -o panda.tar.gz --format=tar.gz HEAD'
dockerImage = docker.build("${env.DOCKER_IMAGE_TAG}")
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ To print out the serial console from the ESP8266, run PORT=1 tests/debug_console
Safety Model
------

When a panda powers up, by default it's in `SAFETY_NOOUTPUT` mode. While in no output mode, the buses are also forced to be silent. In order to send messages, you have to select a safety mode. Currently, setting safety modes is only supported over USB.
When a panda powers up, by default it's in `SAFETY_SILENT` mode. While in `SAFETY_SILENT` mode, the buses are also forced to be silent. In order to send messages, you have to select a safety mode. Currently, setting safety modes is only supported over USB.

Safety modes optionally supports `controls_allowed`, which allows or blocks a subset of messages based on a customizable state in the board.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.5.9
v1.6.9
4 changes: 3 additions & 1 deletion board/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

void detect_board_type(void) {
#ifdef PANDA
// SPI lines floating: white (TODO: is this reliable?)
// SPI lines floating: white (TODO: is this reliable? Not really, we have to enable ESP/GPS to be able to detect this on the UART)
set_gpio_output(GPIOC, 14, 1);
set_gpio_output(GPIOC, 5, 1);
if((detect_with_pull(GPIOA, 4, PULL_DOWN)) || (detect_with_pull(GPIOA, 5, PULL_DOWN)) || (detect_with_pull(GPIOA, 6, PULL_DOWN)) || (detect_with_pull(GPIOA, 7, PULL_DOWN))){
hw_type = HW_TYPE_WHITE_PANDA;
current_board = &board_white;
Expand Down
4 changes: 3 additions & 1 deletion board/board_declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ typedef void (*board_set_led)(uint8_t color, bool enabled);
typedef void (*board_set_usb_power_mode)(uint8_t mode);
typedef void (*board_set_esp_gps_mode)(uint8_t mode);
typedef void (*board_set_can_mode)(uint8_t mode);
typedef void (*board_usb_power_mode_tick)(uint64_t tcnt);
typedef void (*board_usb_power_mode_tick)(uint32_t uptime);
typedef bool (*board_check_ignition)(void);
typedef uint32_t (*board_read_current)(void);
typedef void (*board_set_ir_power)(uint8_t percentage);
typedef void (*board_set_fan_power)(uint8_t percentage);
typedef void (*board_set_phone_power)(bool enabled);

struct board {
const char *board_type;
Expand All @@ -27,6 +28,7 @@ struct board {
board_read_current read_current;
board_set_ir_power set_ir_power;
board_set_fan_power set_fan_power;
board_set_phone_power set_phone_power;
};

// ******************* Definitions ********************
Expand Down
14 changes: 11 additions & 3 deletions board/boards/black.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ void black_set_can_mode(uint8_t mode){
}
}

void black_usb_power_mode_tick(uint64_t tcnt){
UNUSED(tcnt);
void black_usb_power_mode_tick(uint32_t uptime){
UNUSED(uptime);
// Not applicable
}

Expand All @@ -146,6 +146,10 @@ void black_set_fan_power(uint8_t percentage){
UNUSED(percentage);
}

void black_set_phone_power(bool enabled){
UNUSED(enabled);
}

void black_init(void) {
common_init_gpio();

Expand All @@ -158,6 +162,9 @@ void black_init(void) {
set_gpio_mode(GPIOC, 0, MODE_ANALOG);
set_gpio_mode(GPIOC, 3, MODE_ANALOG);

// Set default state of GPS
current_board->set_esp_gps_mode(ESP_GPS_ENABLED);

// C10: OBD_SBU1_RELAY (harness relay driving output)
// C11: OBD_SBU2_RELAY (harness relay driving output)
set_gpio_mode(GPIOC, 10, MODE_OUTPUT);
Expand Down Expand Up @@ -227,5 +234,6 @@ const board board_black = {
.check_ignition = black_check_ignition,
.read_current = black_read_current,
.set_fan_power = black_set_fan_power,
.set_ir_power = black_set_ir_power
.set_ir_power = black_set_ir_power,
.set_phone_power = black_set_phone_power
};
2 changes: 1 addition & 1 deletion board/boards/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void peripherals_init(void){
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN; // pedal and fan PWM
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN; // gmlan_alt and IR PWM
//RCC->APB1ENR |= RCC_APB1ENR_TIM5EN;
//RCC->APB1ENR |= RCC_APB1ENR_TIM6EN;
RCC->APB1ENR |= RCC_APB1ENR_TIM6EN; // interrupt timer
RCC->APB1ENR |= RCC_APB1ENR_PWREN; // for RTC config
RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN;
Expand Down
13 changes: 11 additions & 2 deletions board/boards/grey.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
// ////////// //

// Most hardware functionality is similar to white panda

void grey_init(void) {
white_grey_common_init();

// Set default state of GPS
current_board->set_esp_gps_mode(ESP_GPS_ENABLED);
}

const board board_grey = {
.board_type = "Grey",
.harness_config = &white_harness_config,
.init = white_init,
.init = grey_init,
.enable_can_transciever = white_enable_can_transciever,
.enable_can_transcievers = white_enable_can_transcievers,
.set_led = white_set_led,
Expand All @@ -17,5 +25,6 @@ const board board_grey = {
.check_ignition = white_check_ignition,
.read_current = white_read_current,
.set_fan_power = white_set_fan_power,
.set_ir_power = white_set_ir_power
.set_ir_power = white_set_ir_power,
.set_phone_power = white_set_phone_power
};
11 changes: 8 additions & 3 deletions board/boards/pedal.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ void pedal_set_can_mode(uint8_t mode){
}
}

void pedal_usb_power_mode_tick(uint64_t tcnt){
UNUSED(tcnt);
void pedal_usb_power_mode_tick(uint32_t uptime){
UNUSED(uptime);
// Not applicable
}

Expand All @@ -73,6 +73,10 @@ void pedal_set_fan_power(uint8_t percentage){
UNUSED(percentage);
}

void pedal_set_phone_power(bool enabled){
UNUSED(enabled);
}

void pedal_init(void) {
common_init_gpio();

Expand Down Expand Up @@ -108,5 +112,6 @@ const board board_pedal = {
.check_ignition = pedal_check_ignition,
.read_current = pedal_read_current,
.set_fan_power = pedal_set_fan_power,
.set_ir_power = pedal_set_ir_power
.set_ir_power = pedal_set_ir_power,
.set_phone_power = pedal_set_phone_power
};
56 changes: 45 additions & 11 deletions board/boards/uno.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// ///////////// //
// Uno + Harness //
// ///////////// //
#define BOOTKICK_TIME 3U
uint8_t bootkick_timer = 0U;

void uno_enable_can_transciever(uint8_t transciever, bool enabled) {
switch (transciever){
Expand Down Expand Up @@ -48,9 +50,38 @@ void uno_set_gps_load_switch(bool enabled) {
set_gpio_output(GPIOC, 12, enabled);
}

void uno_set_bootkick(bool enabled){
set_gpio_output(GPIOB, 14, !enabled);
}

void uno_bootkick(void) {
bootkick_timer = BOOTKICK_TIME;
uno_set_bootkick(true);
}

void uno_set_phone_power(bool enabled){
set_gpio_output(GPIOB, 4, enabled);
}

void uno_set_usb_power_mode(uint8_t mode) {
UNUSED(mode);
puts("Setting USB mode makes no sense on UNO\n");
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;
default:
puts("Invalid USB power mode\n");
break;
}
if (valid) {
usb_power_mode = mode;
}
}

void uno_set_esp_gps_mode(uint8_t mode) {
Expand Down Expand Up @@ -106,12 +137,11 @@ void uno_set_can_mode(uint8_t mode){
}
}

void uno_set_bootkick(bool enabled){
set_gpio_output(GPIOB, 14, !enabled);
}

void uno_usb_power_mode_tick(uint64_t tcnt){
if(tcnt == 3U){
void uno_usb_power_mode_tick(uint32_t uptime){
UNUSED(uptime);
if(bootkick_timer != 0U){
bootkick_timer--;
} else {
uno_set_bootkick(false);
}
}
Expand Down Expand Up @@ -152,6 +182,9 @@ void uno_init(void) {
set_gpio_mode(GPIOC, 0, MODE_ANALOG);
set_gpio_mode(GPIOC, 3, MODE_ANALOG);

// Set default state of GPS
current_board->set_esp_gps_mode(ESP_GPS_ENABLED);

// C10: OBD_SBU1_RELAY (harness relay driving output)
// C11: OBD_SBU2_RELAY (harness relay driving output)
set_gpio_mode(GPIOC, 10, MODE_OUTPUT);
Expand All @@ -168,7 +201,7 @@ void uno_init(void) {
uno_set_gps_load_switch(true);

// Turn on phone regulator
set_gpio_output(GPIOB, 4, 1);
uno_set_phone_power(true);

// Initialize IR PWM and set to 0%
set_gpio_alternate(GPIOB, 7, GPIO_AF2_TIM4);
Expand Down Expand Up @@ -212,7 +245,7 @@ void uno_init(void) {
}

// Bootkick phone
uno_set_bootkick(true);
uno_bootkick();
}

const harness_configuration uno_harness_config = {
Expand Down Expand Up @@ -243,5 +276,6 @@ const board board_uno = {
.check_ignition = uno_check_ignition,
.read_current = uno_read_current,
.set_fan_power = uno_set_fan_power,
.set_ir_power = uno_set_ir_power
.set_ir_power = uno_set_ir_power,
.set_phone_power = uno_set_phone_power
};
Loading

0 comments on commit bc7b9b3

Please sign in to comment.