From f0002fd16d426878024ee5dfea9f57560c4cda37 Mon Sep 17 00:00:00 2001 From: norly Date: Mon, 18 Feb 2019 00:34:10 +0100 Subject: [PATCH] Shut down ELM327's 'protocol' before reconfiguring CAN According to ELM327's manual, AT PC should be sent before issuing AT PB. --- module/elmcan.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/module/elmcan.c b/module/elmcan.c index d5c289c..ffdb60e 100644 --- a/module/elmcan.c +++ b/module/elmcan.c @@ -66,6 +66,7 @@ enum ELM_TODO { ELM_TODO_CANID_11BIT, ELM_TODO_CANID_29BIT_LOW, ELM_TODO_CANID_29BIT_HIGH, + ELM_TODO_CAN_CONFIG_PART2, ELM_TODO_CAN_CONFIG, ELM_TODO_RESPONSES, ELM_TODO_SILENT_MONITOR, @@ -595,6 +596,10 @@ static void elm327_handle_prompt(struct elmcan *elm) !(elm->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)); } else if (test_and_clear_bit(ELM_TODO_CAN_CONFIG, &elm->cmds_todo)) { + sprintf(local_txbuf, "ATPC\r"); + set_bit(ELM_TODO_CAN_CONFIG_PART2, &elm->cmds_todo); + + } else if (test_and_clear_bit(ELM_TODO_CAN_CONFIG_PART2, &elm->cmds_todo)) { sprintf(local_txbuf, "ATPB%04X\r", elm->can_config); -- 2.30.2