Skip to content

Commit

Permalink
Grey gps fix (commaai#423)
Browse files Browse the repository at this point in the history
* Fixed GPS enabling on EON builds

* Bumped version

* Added automated GPS test

* Added import

* Fixed linting
  • Loading branch information
robbederks authored Jan 13, 2020
1 parent bcd556b commit 3b35621
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.7.2
v1.7.3
24 changes: 23 additions & 1 deletion board/boards/grey.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@ void grey_init(void) {
current_board->set_esp_gps_mode(ESP_GPS_ENABLED);
}

void grey_set_esp_gps_mode(uint8_t mode) {
switch (mode) {
case ESP_GPS_DISABLED:
// GPS OFF
set_gpio_output(GPIOC, 14, 0);
set_gpio_output(GPIOC, 5, 0);
break;
case ESP_GPS_ENABLED:
// GPS ON
set_gpio_output(GPIOC, 14, 1);
set_gpio_output(GPIOC, 5, 1);
break;
case ESP_GPS_BOOTMODE:
set_gpio_output(GPIOC, 14, 1);
set_gpio_output(GPIOC, 5, 0);
break;
default:
puts("Invalid ESP/GPS mode\n");
break;
}
}

const board board_grey = {
.board_type = "Grey",
.harness_config = &white_harness_config,
Expand All @@ -19,7 +41,7 @@ const board board_grey = {
.enable_can_transcievers = white_enable_can_transcievers,
.set_led = white_set_led,
.set_usb_power_mode = white_set_usb_power_mode,
.set_esp_gps_mode = white_set_esp_gps_mode,
.set_esp_gps_mode = grey_set_esp_gps_mode,
.set_can_mode = white_set_can_mode,
.usb_power_mode_tick = white_usb_power_mode_tick,
.check_ignition = white_check_ignition,
Expand Down
23 changes: 23 additions & 0 deletions tests/automated/8_gps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import time
from panda import PandaSerial
from .helpers import reset_pandas, test_all_gps_pandas, panda_connect_and_init

# Reset the pandas before running tests
def aaaa_reset_before_tests():
reset_pandas()

@test_all_gps_pandas
@panda_connect_and_init
def test_gps_version(p):
serial = PandaSerial(p, 1, 9600)
# Reset and check twice to make sure the enabling works
for i in range(2):
# Reset GPS
p.set_esp_power(0)
time.sleep(0.5)
p.set_esp_power(1)
time.sleep(1)

# Read startup message and check if version is contained
dat = serial.read(0x1000) # Read one full panda DMA buffer. This should include the startup message
assert b'HPG 1.40ROV' in dat
4 changes: 4 additions & 0 deletions tests/automated/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
BUS_SPEEDS = [(0, SPEED_NORMAL), (1, SPEED_NORMAL), (2, SPEED_NORMAL), (3, SPEED_GMLAN)]
TIMEOUT = 30
GEN2_HW_TYPES = [Panda.HW_TYPE_BLACK_PANDA, Panda.HW_TYPE_UNO]
GPS_HW_TYPES = [Panda.HW_TYPE_GREY_PANDA, Panda.HW_TYPE_BLACK_PANDA, Panda.HW_TYPE_UNO]

# Enable fault debug
faulthandler.enable(all_threads=False)
Expand Down Expand Up @@ -48,6 +49,9 @@ def init_panda_serials():
test_all_gen2_pandas = parameterized(
list(map(lambda x: x[0], filter(lambda x: x[1] in GEN2_HW_TYPES, _panda_serials)))
)
test_all_gps_pandas = parameterized(
list(map(lambda x: x[0], filter(lambda x: x[1] in GPS_HW_TYPES, _panda_serials)))
)
test_white_and_grey = parameterized([
param(panda_type=Panda.HW_TYPE_WHITE_PANDA),
param(panda_type=Panda.HW_TYPE_GREY_PANDA)
Expand Down

0 comments on commit 3b35621

Please sign in to comment.