From 14e5931da9cef62a0ad3efbd8ef4bb808cc7e1e8 Mon Sep 17 00:00:00 2001 From: Firmware Batman Date: Thu, 27 Apr 2017 11:32:14 -0700 Subject: [PATCH] interrupt endpoint works --- boardesp/proxy.c | 11 ++++++++--- tests/standalone_test.py | 10 ++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/boardesp/proxy.c b/boardesp/proxy.c index 5efc9859..099b9f66 100644 --- a/boardesp/proxy.c +++ b/boardesp/proxy.c @@ -117,18 +117,23 @@ void ICACHE_FLASH_ATTR some_timerfunc(void *arg) { } if (i != 0) { - espconn_send(&tcp_conn, buf, i*0x10); + espconn_send(&inter_conn, buf, i*0x10); } } +volatile int timer_started = 0; + void ICACHE_FLASH_ATTR inter_connect_cb(void *arg) { struct espconn *conn = (struct espconn *)arg; espconn_set_opt(&tcp_conn, ESPCONN_NODELAY); // setup timer at 200hz // TODO: disable when it runs out - os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL); - os_timer_arm(&some_timer, 5, 1); + if (!timer_started) { + os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL); + os_timer_arm(&some_timer, 5, 1); + timer_started = 1; + } } void ICACHE_FLASH_ATTR wifi_init() { diff --git a/tests/standalone_test.py b/tests/standalone_test.py index 23ac346f..16d9ca1e 100755 --- a/tests/standalone_test.py +++ b/tests/standalone_test.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import os from panda.lib.panda import Panda +import time if __name__ == "__main__": if os.getenv("WIFI") is not None: @@ -9,3 +10,12 @@ if __name__ == "__main__": p = Panda() print p.health() + while 1: + # flood + p.can_send(0xaa, "\xaa"*8, 0) + p.can_send(0xaa, "\xaa"*8, 1) + p.can_send(0xaa, "\xaa"*8, 4) + time.sleep(0.01) + + print p.can_recv() +