diff --git a/boardesp/elm327.c b/boardesp/elm327.c index 2401f9d..b2ef852 100644 --- a/boardesp/elm327.c +++ b/boardesp/elm327.c @@ -849,6 +849,9 @@ static void ICACHE_FLASH_ATTR elm_rx_cb(void *arg, char *data, uint16_t len) { if(loopcount){ os_timer_disarm(&elm_timeout); loopcount = 0; + got_msg_this_run = false; + can_tx_worked = false; + did_multimessage = false; os_printf("Interrupting operation, stopping timer. msg len: %d\n", len); elm_append_rsp_const("STOPPED\r\r>"); diff --git a/tests/automated/elm_wifi.py b/tests/automated/elm_wifi.py index e136e93..9556222 100644 --- a/tests/automated/elm_wifi.py +++ b/tests/automated/elm_wifi.py @@ -333,6 +333,36 @@ def test_elm_send_can_multiline_msg_throughput(): sim.join() s.close() +def test_elm_interrupted_obd_cmd_resets_state(): + s = elm_connect() + serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None + sim = elm_car_simulator.ELMCanCarSimulator(serial, silent=True) + sim.start() + + try: + sync_reset(s) + send_compare(s, b'ATE0\r', b'ATE0\rOK\r\r>') # Echo OFF + send_compare(s, b'ATS0\r', b'OK\r\r>') # Spaces OFF + s.send(b"09fd\r") + ready = select.select([s], [], [], 4) + assert ready[0], "Socket did not receive data within the timeout duration." + s.send(b"ATI\r") + + assert b"236\r0:49FD01AAAAAA\r" in s.recv(10000) + + #Will likely have to be improved to scan for STOPPED if the FW gets more responsive. + ready = select.select([s], [], [], 4) + assert ready[0], "Socket did not receive data within the timeout duration." + + assert b"STOPPED" in s.recv(10000) + + sim.set_enable(False) + send_compare(s, b'09fd\r', b"NO DATA\r\r>") + finally: + sim.stop() + sim.join() + s.close() + def test_elm_can_baud(): s = elm_connect() serial = os.getenv("CANSIMSERIAL") if os.getenv("CANSIMSERIAL") else None