From: norly Date: Sun, 17 Feb 2019 23:34:10 +0000 (+0100) Subject: Shut down ELM327's 'protocol' before reconfiguring CAN X-Git-Url: https://git.enpas.org/?a=commitdiff_plain;h=f0002fd16d426878024ee5dfea9f57560c4cda37;p=elmcan.git Shut down ELM327's 'protocol' before reconfiguring CAN According to ELM327's manual, AT PC should be sent before issuing AT PB. --- 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);