Shut down ELM327's 'protocol' before reconfiguring CAN
authornorly <ny-git@enpas.org>
Sun, 17 Feb 2019 23:34:10 +0000 (00:34 +0100)
committernorly <ny-git@enpas.org>
Sun, 17 Feb 2019 23:49:16 +0000 (00:49 +0100)
According to ELM327's manual, AT PC should be sent before issuing AT PB.

module/elmcan.c

index d5c289c82bc4c3b603115aca13592407cb420f89..ffdb60e32c9a1a2f6084a321490fe6e4333b79d8 100644 (file)
@@ -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);