diff options
| -rw-r--r-- | meta-oe/recipes-extended/socketcan/canutils/0001-canutils-candump-Add-error-frame-s-handling.patch | 94 | ||||
| -rw-r--r-- | meta-oe/recipes-extended/socketcan/canutils_4.0.6.bb | 5 |
2 files changed, 97 insertions, 2 deletions
diff --git a/meta-oe/recipes-extended/socketcan/canutils/0001-canutils-candump-Add-error-frame-s-handling.patch b/meta-oe/recipes-extended/socketcan/canutils/0001-canutils-candump-Add-error-frame-s-handling.patch new file mode 100644 index 0000000000..fcc38e0617 --- /dev/null +++ b/meta-oe/recipes-extended/socketcan/canutils/0001-canutils-candump-Add-error-frame-s-handling.patch | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | From bab595e38295dcafcfc17a011d3d51f2df1618e6 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: AnilKumar Ch <anilkumar@ti.com> | ||
| 3 | Date: Tue, 10 Jan 2012 18:55:11 +0530 | ||
| 4 | Subject: [PATCH] canutils: candump: Add error frame's handling | ||
| 5 | |||
| 6 | This patch adds the error handling capability to candump utility | ||
| 7 | by adding error flags for displaying all kind of error frames | ||
| 8 | like tx_timeout, lost arbitration, controller problems, buserrors, | ||
| 9 | bus warnings etc. | ||
| 10 | |||
| 11 | Usage of candump for error frame display on console: | ||
| 12 | candump [<can-interface>] [Options] | ||
| 13 | Ex: candump can0 --error | ||
| 14 | |||
| 15 | This patch is created on top of canutils-4.0.6 tag from | ||
| 16 | http://git.pengutronix.de/?p=tools/canutils.git | ||
| 17 | |||
| 18 | Signed-off-by: AnilKumar Ch <anilkumar@ti.com> | ||
| 19 | Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> | ||
| 20 | --- | ||
| 21 | Upstream-Status: Backport | ||
| 22 | |||
| 23 | src/candump.c | 20 ++++++++++++++++++++ | ||
| 24 | 1 file changed, 20 insertions(+) | ||
| 25 | |||
| 26 | diff --git a/src/candump.c b/src/candump.c | ||
| 27 | index 259d442..c16425b 100644 | ||
| 28 | --- a/src/candump.c | ||
| 29 | +++ b/src/candump.c | ||
| 30 | @@ -20,6 +20,7 @@ | ||
| 31 | |||
| 32 | #include <linux/can.h> | ||
| 33 | #include <linux/can/raw.h> | ||
| 34 | +#include <linux/can/error.h> | ||
| 35 | |||
| 36 | extern int optind, opterr, optopt; | ||
| 37 | |||
| 38 | @@ -40,6 +41,7 @@ static void print_usage(char *prg) | ||
| 39 | " -p, --protocol=PROTO\t" "CAN protocol (default CAN_RAW = %d)\n" | ||
| 40 | " --filter=id:mask[:id:mask]...\n" | ||
| 41 | "\t\t\t" "apply filter\n" | ||
| 42 | + " -e, --error\t\t" "dump error frames along with data frames\n" | ||
| 43 | " -h, --help\t\t" "this help\n" | ||
| 44 | " -o <filename>\t\t" "output into filename\n" | ||
| 45 | " -d\t\t\t" "daemonize\n" | ||
| 46 | @@ -86,6 +88,11 @@ int main(int argc, char **argv) | ||
| 47 | int nbytes, i; | ||
| 48 | int opt, optdaemon = 0; | ||
| 49 | uint32_t id, mask; | ||
| 50 | + int error = 0; | ||
| 51 | + can_err_mask_t err_mask = (CAN_ERR_TX_TIMEOUT | CAN_ERR_LOSTARB | | ||
| 52 | + CAN_ERR_CRTL | CAN_ERR_PROT | | ||
| 53 | + CAN_ERR_TRX | CAN_ERR_ACK | CAN_ERR_BUSOFF | | ||
| 54 | + CAN_ERR_BUSERROR); | ||
| 55 | |||
| 56 | signal(SIGPIPE, SIG_IGN); | ||
| 57 | |||
| 58 | @@ -95,6 +102,7 @@ int main(int argc, char **argv) | ||
| 59 | { "protocol", required_argument, 0, 'p' }, | ||
| 60 | { "type", required_argument, 0, 't' }, | ||
| 61 | { "filter", required_argument, 0, FILTER_OPTION }, | ||
| 62 | + { "error", no_argument, 0, 'e' }, | ||
| 63 | { "version", no_argument, 0, VERSION_OPTION}, | ||
| 64 | { 0, 0, 0, 0}, | ||
| 65 | }; | ||
| 66 | @@ -121,6 +129,10 @@ int main(int argc, char **argv) | ||
| 67 | proto = strtoul(optarg, NULL, 0); | ||
| 68 | break; | ||
| 69 | |||
| 70 | + case 'e': | ||
| 71 | + error = 1; | ||
| 72 | + break; | ||
| 73 | + | ||
| 74 | case 'o': | ||
| 75 | optout = optarg; | ||
| 76 | break; | ||
| 77 | @@ -186,6 +198,14 @@ int main(int argc, char **argv) | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | + if (error) { | ||
| 82 | + if (setsockopt(s, SOL_CAN_RAW, CAN_RAW_ERR_FILTER, &err_mask, | ||
| 83 | + sizeof(err_mask)) != 0) { | ||
| 84 | + perror("setsockopt"); | ||
| 85 | + exit(1); | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | if (optdaemon) | ||
| 90 | daemon(1, 0); | ||
| 91 | else { | ||
| 92 | -- | ||
| 93 | 1.8.3.1 | ||
| 94 | |||
diff --git a/meta-oe/recipes-extended/socketcan/canutils_4.0.6.bb b/meta-oe/recipes-extended/socketcan/canutils_4.0.6.bb index 3bc2f93cf1..504c5109fa 100644 --- a/meta-oe/recipes-extended/socketcan/canutils_4.0.6.bb +++ b/meta-oe/recipes-extended/socketcan/canutils_4.0.6.bb | |||
| @@ -7,8 +7,9 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f" | |||
| 7 | 7 | ||
| 8 | DEPENDS = "libsocketcan" | 8 | DEPENDS = "libsocketcan" |
| 9 | 9 | ||
| 10 | TAG = "canutils-${PV}" | 10 | SRCREV = "299dff7f5322bf0348dcdd60071958ebedf5f09d" |
| 11 | SRC_URI = "git://git.pengutronix.de/git/tools/canutils.git;tag=${TAG} \ | 11 | SRC_URI = "git://git.pengutronix.de/git/tools/canutils.git;protocol=git \ |
| 12 | file://0001-canutils-candump-Add-error-frame-s-handling.patch \ | ||
| 12 | " | 13 | " |
| 13 | 14 | ||
| 14 | S = "${WORKDIR}/git" | 15 | S = "${WORKDIR}/git" |
