From 3b35621671aaa6de3fc66d85d30e4208a77e2489 Mon Sep 17 00:00:00 2001 From: robbederks Date: Mon, 13 Jan 2020 15:06:35 -0800 Subject: [PATCH] Grey gps fix (#423) * Fixed GPS enabling on EON builds * Bumped version * Added automated GPS test * Added import * Fixed linting --- VERSION | 2 +- board/boards/grey.h | 24 +++++++++++++++++++++++- tests/automated/8_gps.py | 23 +++++++++++++++++++++++ tests/automated/helpers.py | 4 ++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 tests/automated/8_gps.py diff --git a/VERSION b/VERSION index 75e4760..0d687f1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v1.7.2 \ No newline at end of file +v1.7.3 \ No newline at end of file diff --git a/board/boards/grey.h b/board/boards/grey.h index 3dcb730..1c7278d 100644 --- a/board/boards/grey.h +++ b/board/boards/grey.h @@ -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, @@ -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, diff --git a/tests/automated/8_gps.py b/tests/automated/8_gps.py new file mode 100644 index 0000000..fc387c9 --- /dev/null +++ b/tests/automated/8_gps.py @@ -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 \ No newline at end of file diff --git a/tests/automated/helpers.py b/tests/automated/helpers.py index 43179e6..6b963e9 100644 --- a/tests/automated/helpers.py +++ b/tests/automated/helpers.py @@ -15,6 +15,7 @@ SPEED_GMLAN = 33.3 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) @@ -48,6 +49,9 @@ test_all_pandas = parameterized( 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)