From ea4e92944c235bc04e76e213db8db0f4758ddc75 Mon Sep 17 00:00:00 2001 From: Firmware Batman Date: Tue, 22 Aug 2017 13:36:20 -0700 Subject: [PATCH] blue led is used for can receiving now --- board/drivers/can.h | 2 +- board/main.c | 10 +++------- panda/__init__.py | 17 +++++++++-------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/board/drivers/can.h b/board/drivers/can.h index e5051bf82..c6caf36f7 100644 --- a/board/drivers/can.h +++ b/board/drivers/can.h @@ -361,7 +361,7 @@ void can_rx(uint8_t can_number) { safety_rx_hook(&to_push); #ifdef PANDA - set_led(LED_GREEN, 1); + set_led(LED_BLUE, 1); #endif can_push(&can_rx_q, &to_push); diff --git a/board/main.c b/board/main.c index 75e825e38..38c1bda80 100644 --- a/board/main.c +++ b/board/main.c @@ -582,12 +582,8 @@ int main() { puth(can_tx2_q.r_ptr); puts(" "); puth(can_tx2_q.w_ptr); puts("\n"); #endif - // set LED to be controls allowed, blue on panda, green on legacy - #ifdef PANDA - set_led(LED_BLUE, controls_allowed); - #else - set_led(LED_GREEN, controls_allowed); - #endif + // set green LED to be controls allowed + set_led(LED_GREEN, controls_allowed); // blink the red LED for (int fade = 0; fade < 1024; fade += 8) { @@ -601,7 +597,7 @@ int main() { // turn off the green LED, turned on by CAN #ifdef PANDA - set_led(LED_GREEN, 0); + set_led(LED_BLUE, 0); #endif } diff --git a/panda/__init__.py b/panda/__init__.py index bd23d77a1..97e1edd6e 100644 --- a/panda/__init__.py +++ b/panda/__init__.py @@ -126,7 +126,7 @@ class Panda(object): #print(device) if device.getVendorID() == 0xbbaa and device.getProductID() in [0xddcc, 0xddee]: if self._serial is None or device.getSerialNumber() == self._serial: - print("opening device", device.getSerialNumber()) + print("opening device", device.getSerialNumber(), hex(device.getProductID())) self.bootstub = device.getProductID() == 0xddee self.legacy = (device.getbcdDevice() != 0x2300) self._handle = device.open() @@ -166,19 +166,20 @@ class Panda(object): self.connect() - def flash(self, fn=None): + def flash(self, fn=None, code=None): if not self.bootstub: self.reset(enter_bootstub=True) assert(self.bootstub) - if fn is None: + if fn is None and code is None: ret = os.system("cd %s && make clean && make -f %s %s" % (os.path.join(BASEDIR, "board"), "Makefile.legacy" if self.legacy else "Makefile", "obj/comma.bin" if self.legacy else "obj/panda.bin")) fn = os.path.join(BASEDIR, "board", "obj", "comma.bin" if self.legacy else "panda.bin") - with open(fn) as f: - dat = f.read() + if code is None: + with open(fn) as f: + code = f.read() # get version print("flash: version is "+self.get_version()) @@ -199,8 +200,8 @@ class Panda(object): # flash over EP2 STEP = 0x10 print("flash: flashing") - for i in range(0, len(dat), STEP): - self._handle.bulkWrite(2, dat[i:i+STEP]) + for i in range(0, len(code), STEP): + self._handle.bulkWrite(2, code[i:i+STEP]) # reset print("flash: resetting") @@ -229,7 +230,7 @@ class Panda(object): context = usb1.USBContext() ret = [] for device in context.getDeviceList(skip_on_error=True): - if device.getVendorID() == 0xbbaa and device.getProductID() == 0xddcc: + if device.getVendorID() == 0xbbaa and device.getProductID() in [0xddcc, 0xddee]: ret.append(device.getSerialNumber()) # TODO: detect if this is real #ret += ["WIFI"]