* [PATCH] canutils: candump: Add error frame's handling
@ 2012-01-10 13:25 AnilKumar Ch
2012-01-10 13:40 ` Marc Kleine-Budde
0 siblings, 1 reply; 3+ messages in thread
From: AnilKumar Ch @ 2012-01-10 13:25 UTC (permalink / raw)
To: mkl, m.kleine-budde, r.schwebel, linux-can; +Cc: nsekhar, AnilKumar Ch
This patch adds the error handling capability to candump utility
by adding error flags for displaying all kind of error frames
like tx_timeout, lost arbitration, controller problems, buserrors,
bus warnings etc.
Usage of candump for error frame display on console:
candump [<can-interface>] [Options]
Ex: candump can0 --error
This patch is created on top of canutils-4.0.6 tag from
http://git.pengutronix.de/?p=tools/canutils.git
Signed-off-by: AnilKumar Ch <anilkumar@ti.com>
---
src/candump.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/src/candump.c b/src/candump.c
index 259d442..c16425b 100644
--- a/src/candump.c
+++ b/src/candump.c
@@ -20,6 +20,7 @@
#include <linux/can.h>
#include <linux/can/raw.h>
+#include <linux/can/error.h>
extern int optind, opterr, optopt;
@@ -40,6 +41,7 @@ static void print_usage(char *prg)
" -p, --protocol=PROTO\t" "CAN protocol (default CAN_RAW = %d)\n"
" --filter=id:mask[:id:mask]...\n"
"\t\t\t" "apply filter\n"
+ " -e, --error\t\t" "dump error frames along with data frames\n"
" -h, --help\t\t" "this help\n"
" -o <filename>\t\t" "output into filename\n"
" -d\t\t\t" "daemonize\n"
@@ -86,6 +88,11 @@ int main(int argc, char **argv)
int nbytes, i;
int opt, optdaemon = 0;
uint32_t id, mask;
+ int error = 0;
+ can_err_mask_t err_mask = (CAN_ERR_TX_TIMEOUT | CAN_ERR_LOSTARB |
+ CAN_ERR_CRTL | CAN_ERR_PROT |
+ CAN_ERR_TRX | CAN_ERR_ACK | CAN_ERR_BUSOFF |
+ CAN_ERR_BUSERROR);
signal(SIGPIPE, SIG_IGN);
@@ -95,6 +102,7 @@ int main(int argc, char **argv)
{ "protocol", required_argument, 0, 'p' },
{ "type", required_argument, 0, 't' },
{ "filter", required_argument, 0, FILTER_OPTION },
+ { "error", no_argument, 0, 'e' },
{ "version", no_argument, 0, VERSION_OPTION},
{ 0, 0, 0, 0},
};
@@ -121,6 +129,10 @@ int main(int argc, char **argv)
proto = strtoul(optarg, NULL, 0);
break;
+ case 'e':
+ error = 1;
+ break;
+
case 'o':
optout = optarg;
break;
@@ -186,6 +198,14 @@ int main(int argc, char **argv)
}
}
+ if (error) {
+ if (setsockopt(s, SOL_CAN_RAW, CAN_RAW_ERR_FILTER, &err_mask,
+ sizeof(err_mask)) != 0) {
+ perror("setsockopt");
+ exit(1);
+ }
+ }
+
if (optdaemon)
daemon(1, 0);
else {
--
1.7.5.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] canutils: candump: Add error frame's handling
2012-01-10 13:25 [PATCH] canutils: candump: Add error frame's handling AnilKumar Ch
@ 2012-01-10 13:40 ` Marc Kleine-Budde
2012-01-10 14:01 ` Wolfgang Grandegger
0 siblings, 1 reply; 3+ messages in thread
From: Marc Kleine-Budde @ 2012-01-10 13:40 UTC (permalink / raw)
To: AnilKumar Ch; +Cc: m.kleine-budde, r.schwebel, linux-can, nsekhar
[-- Attachment #1: Type: text/plain, Size: 809 bytes --]
On 01/10/2012 02:25 PM, AnilKumar Ch wrote:
> This patch adds the error handling capability to candump utility
> by adding error flags for displaying all kind of error frames
> like tx_timeout, lost arbitration, controller problems, buserrors,
> bus warnings etc.
>
> Usage of candump for error frame display on console:
> candump [<can-interface>] [Options]
> Ex: candump can0 --error
>
> This patch is created on top of canutils-4.0.6 tag from
> http://git.pengutronix.de/?p=tools/canutils.git
Tnx, applied
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] canutils: candump: Add error frame's handling
2012-01-10 13:40 ` Marc Kleine-Budde
@ 2012-01-10 14:01 ` Wolfgang Grandegger
0 siblings, 0 replies; 3+ messages in thread
From: Wolfgang Grandegger @ 2012-01-10 14:01 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: AnilKumar Ch, m.kleine-budde, r.schwebel, linux-can, nsekhar
On 01/10/2012 02:40 PM, Marc Kleine-Budde wrote:
> On 01/10/2012 02:25 PM, AnilKumar Ch wrote:
>> This patch adds the error handling capability to candump utility
>> by adding error flags for displaying all kind of error frames
>> like tx_timeout, lost arbitration, controller problems, buserrors,
>> bus warnings etc.
>>
>> Usage of candump for error frame display on console:
>> candump [<can-interface>] [Options]
>> Ex: candump can0 --error
>>
>> This patch is created on top of canutils-4.0.6 tag from
>> http://git.pengutronix.de/?p=tools/canutils.git
>
> Tnx, applied
BTW: In the official can-utils, we also have the possibility to display
human readable error messages:
https://gitorious.org/linux-can/can-utils/commit/796475677af173599db655064413f0692c15df3e
Wolfgang.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-01-10 14:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-10 13:25 [PATCH] canutils: candump: Add error frame's handling AnilKumar Ch
2012-01-10 13:40 ` Marc Kleine-Budde
2012-01-10 14:01 ` Wolfgang Grandegger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).