]> rtime.felk.cvut.cz Git - can-benchmark.git/commitdiff
ugw: Add statistics
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 14 Jan 2014 10:17:16 +0000 (11:17 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 14 Jan 2014 10:17:16 +0000 (11:17 +0100)
ugw/ugw.c

index 0e653d3d41b2a45b0007c021da9cecb3526c2664..fd4805bf72b4f053601429bb38da406841f6865e 100644 (file)
--- a/ugw/ugw.c
+++ b/ugw/ugw.c
@@ -22,6 +22,7 @@
 #include <arpa/inet.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <signal.h>
 
 #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;