Improve error handling in case of stray characters
authornorly <ny-git@enpas.org>
Thu, 10 Feb 2022 20:39:25 +0000 (21:39 +0100)
committernorly <ny-git@enpas.org>
Thu, 10 Feb 2022 22:03:43 +0000 (23:03 +0100)
module/elmcan.c

index c1e665e722c62ff378c017c0ff7f1f61a4daf519..49df7c1600ca993703e97811f3f5227d8822095f 100644 (file)
@@ -396,8 +396,11 @@ static void elm327_parse_error(struct elmcan *elm, int len)
                }
                break;
        default:
-               /* Don't emit an error frame if we're unsure */
-               return;
+               /* Something else has happened.
+                * Maybe garbage on the UART line.
+                * Emit a generic error frame.
+                */
+               break;
        }
 
        elm327_feed_frame_to_netdev(elm, &frame);
@@ -451,7 +454,6 @@ static int elm327_parse_frame(struct elmcan *elm, int len)
                /* The line is likely garbled anyway, so bail.
                 * The main code will restart listening.
                 */
-               elm327_kick_into_cmd_mode(elm);
                return -ENODATA;
        }