From 38aa03e0f7f858b38ffd7a1c9f392e6abd135795 Mon Sep 17 00:00:00 2001 From: Jessy Diamond Exum Date: Tue, 11 Jul 2017 21:57:16 -0700 Subject: [PATCH] Moved boardd loopback config to envvar. --- selfdrive/boardd/boardd.cc | 13 ++++++++----- selfdrive/boardd/test_boardd_loopback.py | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc index 31b28a2aa1..b0cd7d3597 100644 --- a/selfdrive/boardd/boardd.cc +++ b/selfdrive/boardd/boardd.cc @@ -23,8 +23,6 @@ #include "common/swaglog.h" #include "common/timing.h" -//#define DEBUG_WITH_PANDA_LOOPBACK - int do_exit = 0; libusb_context *ctx = NULL; @@ -33,6 +31,7 @@ pthread_mutex_t usb_lock; bool spoofing_started = false; bool fake_send = false; +bool loopback_can = false; // double the FIFO size #define RECV_SIZE (0x1000) @@ -54,9 +53,9 @@ bool usb_connect() { err = libusb_claim_interface(dev_handle, 0); if (err != 0) { return false; } - #ifdef DEBUG_WITH_PANDA_LOOPBACK - libusb_control_transfer(dev_handle, 0xc0, 0xe5, 1, 0, NULL, 0, TIMEOUT); - #endif + if(loopback_can) { + libusb_control_transfer(dev_handle, 0xc0, 0xe5, 1, 0, NULL, 0, TIMEOUT); + } // power off ESP libusb_control_transfer(dev_handle, 0xc0, 0xd9, 0, 0, NULL, 0, TIMEOUT); @@ -337,6 +336,10 @@ int main() { fake_send = true; } + if(getenv("BOARDD_LOOPBACK")){ + loopback_can = true; + } + // init libusb err = libusb_init(&ctx); assert(err == 0); diff --git a/selfdrive/boardd/test_boardd_loopback.py b/selfdrive/boardd/test_boardd_loopback.py index 60d973fa48..33ad63659b 100644 --- a/selfdrive/boardd/test_boardd_loopback.py +++ b/selfdrive/boardd/test_boardd_loopback.py @@ -1,4 +1,4 @@ -"""Enable the DEBUG_WITH_PANDA_LOOPBACK define in boardd.cc before test.""" +"""Run boardd with the BOARDD_LOOPBACK envvar before running this test.""" import os import random