From 8b5dee0e36334412500b1ba41dca51fd10cbb56e Mon Sep 17 00:00:00 2001 From: norly Date: Thu, 10 Feb 2022 23:09:35 +0100 Subject: [PATCH] Remove accept_flaky_uart module option. Maybe we really shouldn't *too* lenient - the hexdump parsing code bails on the first strange character anyway. --- module/elmcan.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/module/elmcan.c b/module/elmcan.c index ac7036e..3d35821 100644 --- a/module/elmcan.c +++ b/module/elmcan.c @@ -42,15 +42,6 @@ MODULE_DESCRIPTION("ELM327 based CAN interface"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Max Staudt "); -/* If this is enabled, we'll try to make the best of the situation - * even if we receive unexpected characters on the line. - * No guarantees. - * Handle with care, it's likely your hardware is unreliable! - */ -static bool accept_flaky_uart; -module_param_named(accept_flaky_uart, accept_flaky_uart, bool, 0444); -MODULE_PARM_DESC(accept_flaky_uart, "Don't bail at the first invalid character. Behavior undefined."); - /* Line discipline ID number */ #ifndef N_ELMCAN #define N_ELMCAN 29 @@ -448,12 +439,10 @@ static int elm327_parse_frame(struct elmcan *elm, int len) } } - /* If we accept stray characters coming in: - * Check for stray characters on a payload line. - * No idea what causes this. + /* Sanity check whether the line is really a clean hexdump, + * or terminated by an error message, or contains garbage. */ - if (accept_flaky_uart && - hexlen < len && + if (hexlen < len && !isdigit(elm->rxbuf[hexlen]) && !isupper(elm->rxbuf[hexlen]) && '<' != elm->rxbuf[hexlen] && @@ -938,8 +927,7 @@ static void put_elm(struct elmcan *elm) static bool elmcan_is_valid_rx_char(char c) { - return (accept_flaky_uart || - isdigit(c) || + return (isdigit(c) || isupper(c) || c == ELM327_MAGIC_CHAR || c == ELM327_READY_CHAR || -- 2.30.2