diff options
| -rw-r--r-- | meta-oe/recipes-extended/socketcan/can-utils/0001-lib-snprintf_can_error_frame-don-t-bail-out-if-CAN_E.patch | 70 | ||||
| -rw-r--r-- | meta-oe/recipes-extended/socketcan/can-utils_2023.03.bb | 1 |
2 files changed, 71 insertions, 0 deletions
diff --git a/meta-oe/recipes-extended/socketcan/can-utils/0001-lib-snprintf_can_error_frame-don-t-bail-out-if-CAN_E.patch b/meta-oe/recipes-extended/socketcan/can-utils/0001-lib-snprintf_can_error_frame-don-t-bail-out-if-CAN_E.patch new file mode 100644 index 0000000000..f393cce091 --- /dev/null +++ b/meta-oe/recipes-extended/socketcan/can-utils/0001-lib-snprintf_can_error_frame-don-t-bail-out-if-CAN_E.patch | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | From 7d59157d4d570ba994f7dd07243ac5fb1c541410 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Marc Kleine-Budde <mkl@pengutronix.de> | ||
| 3 | Date: Wed, 27 Sep 2023 16:15:52 +0200 | ||
| 4 | Subject: [PATCH] lib: snprintf_can_error_frame(): don't bail out if | ||
| 5 | CAN_ERR_CNT is set | ||
| 6 | |||
| 7 | If CAN_ERR_CNT is set, the snprintf_can_error_frame() bails out, as it | ||
| 8 | cannot decode CAN_ERR_CNT. | ||
| 9 | |||
| 10 | Fixes: 21fb43532e80 ("lib: snprintf_can_error_frame: print counter errors if CAN_ERR_CNT is set") | ||
| 11 | |||
| 12 | Upstream-Status: Backport [https://github.com/linux-can/can-utils/commit/7d59157d4d570ba994f7dd07243ac5fb1c541410] | ||
| 13 | --- | ||
| 14 | lib.c | 23 +++++++++++++++++++---- | ||
| 15 | 1 file changed, 19 insertions(+), 4 deletions(-) | ||
| 16 | |||
| 17 | diff --git a/lib.c b/lib.c | ||
| 18 | index d665c69..0201e94 100644 | ||
| 19 | --- a/lib.c | ||
| 20 | +++ b/lib.c | ||
| 21 | @@ -499,6 +499,7 @@ static const char *error_classes[] = { | ||
| 22 | "bus-off", | ||
| 23 | "bus-error", | ||
| 24 | "restarted-after-bus-off", | ||
| 25 | + "error-counter-tx-rx", | ||
| 26 | }; | ||
| 27 | |||
| 28 | static const char *controller_problems[] = { | ||
| 29 | @@ -636,6 +637,19 @@ static int snprintf_error_prot(char *buf, size_t len, const struct canfd_frame * | ||
| 30 | return n; | ||
| 31 | } | ||
| 32 | |||
| 33 | +static int snprintf_error_cnt(char *buf, size_t len, const struct canfd_frame *cf) | ||
| 34 | +{ | ||
| 35 | + int n = 0; | ||
| 36 | + | ||
| 37 | + if (len <= 0) | ||
| 38 | + return 0; | ||
| 39 | + | ||
| 40 | + n += snprintf(buf + n, len - n, "{{%d}{%d}}", | ||
| 41 | + cf->data[6], cf->data[7]); | ||
| 42 | + | ||
| 43 | + return n; | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | void snprintf_can_error_frame(char *buf, size_t len, const struct canfd_frame *cf, | ||
| 47 | const char* sep) | ||
| 48 | { | ||
| 49 | @@ -679,13 +693,14 @@ void snprintf_can_error_frame(char *buf, size_t len, const struct canfd_frame *c | ||
| 50 | n += snprintf_error_ctrl(buf + n, len - n, cf); | ||
| 51 | if (mask == CAN_ERR_PROT) | ||
| 52 | n += snprintf_error_prot(buf + n, len - n, cf); | ||
| 53 | + if (mask == CAN_ERR_CNT) | ||
| 54 | + n += snprintf_error_cnt(buf + n, len - n, cf); | ||
| 55 | classes++; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | - if (cf->can_id & CAN_ERR_CNT || cf->data[6] || cf->data[7]) { | ||
| 60 | - n += snprintf(buf + n, len - n, "%s", sep); | ||
| 61 | - n += snprintf(buf + n, len - n, "error-counter-tx-rx{{%d}{%d}}", | ||
| 62 | - cf->data[6], cf->data[7]); | ||
| 63 | + if (!(cf->can_id & CAN_ERR_CNT) && (cf->data[6] || cf->data[7])) { | ||
| 64 | + n += snprintf(buf + n, len - n, "%serror-counter-tx-rx", sep); | ||
| 65 | + n += snprintf_error_cnt(buf + n, len - n, cf); | ||
| 66 | } | ||
| 67 | } | ||
| 68 | -- | ||
| 69 | 2.43.0 | ||
| 70 | |||
diff --git a/meta-oe/recipes-extended/socketcan/can-utils_2023.03.bb b/meta-oe/recipes-extended/socketcan/can-utils_2023.03.bb index 5a7beb978a..0804b514a9 100644 --- a/meta-oe/recipes-extended/socketcan/can-utils_2023.03.bb +++ b/meta-oe/recipes-extended/socketcan/can-utils_2023.03.bb | |||
| @@ -6,6 +6,7 @@ DEPENDS = "libsocketcan" | |||
| 6 | 6 | ||
| 7 | SRC_URI = "git://github.com/linux-can/${BPN}.git;protocol=https;branch=master \ | 7 | SRC_URI = "git://github.com/linux-can/${BPN}.git;protocol=https;branch=master \ |
| 8 | file://0001-timestamp-formatting-always-use-64-bit-for-timestamp.patch \ | 8 | file://0001-timestamp-formatting-always-use-64-bit-for-timestamp.patch \ |
| 9 | file://0001-lib-snprintf_can_error_frame-don-t-bail-out-if-CAN_E.patch \ | ||
| 9 | " | 10 | " |
| 10 | 11 | ||
| 11 | SRCREV = "cfe41963f3425e9adb01a70cfaddedf5e5982720" | 12 | SRCREV = "cfe41963f3425e9adb01a70cfaddedf5e5982720" |
