From 269a6c4ec5cf0aa2aa4b8ce92614a8003c166323 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 14 Jan 2014 11:17:16 +0100 Subject: [PATCH] ugw: Add statistics --- ugw/ugw.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ugw/ugw.c b/ugw/ugw.c index 0e653d3..fd4805b 100644 --- a/ugw/ugw.c +++ b/ugw/ugw.c @@ -22,6 +22,7 @@ #include #include #include +#include #ifndef SO_BUSY_POLL #define SO_BUSY_POLL 46 @@ -71,6 +72,18 @@ struct out_ctx { int (*out_fn)(struct out_ctx *ctx, struct can_frame *cf); }; +struct stats { + int store; + int send; +} stats; + +void sigint(int v) +{ + printf("store:%d\nsend:%d\ntotal:%d\n", + stats.store, stats.send, stats.store + stats.send); + exit(0); +} + enum in2out in_read(struct in_ctx *ctx, struct can_frame *cf) { int ret = read(ctx->s, cf, sizeof(*cf)); @@ -396,6 +409,7 @@ int main(int argc, char *argv[]) if (optind+1 < argc) devout = argv[optind+1]; + signal(SIGINT, sigint); gw(); return 0; -- 2.39.2