init
[protos/xbee-avr.git] / xbee_stats.c
1 /*
2  * Copyright (c) 2011, Olivier MATZ <zer0@droids-corp.org>
3  * All rights reserved.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  *     * Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     * Redistributions in binary form must reproduce the above copyright
10  *       notice, this list of conditions and the following disclaimer in the
11  *       documentation and/or other materials provided with the distribution.
12  *     * Neither the name of the University of California, Berkeley nor the
13  *       names of its contributors may be used to endorse or promote products
14  *       derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27
28 #include <aversive.h>
29 #include <aversive/queue.h>
30
31 #include <string.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <stdint.h>
35
36 #include "xbee_neighbor.h"
37 #include "xbee_stats.h"
38 #include "xbee_proto.h"
39 #include "xbee_buf.h"
40 #include "xbee.h"
41
42 struct xbee_stats *xbee_get_stats(struct xbee_dev *dev)
43 {
44         return &dev->stats;
45 }
46
47 void xbee_reset_stats(struct xbee_dev *dev)
48 {
49         memset(&dev->stats, 0, sizeof(dev->stats));
50 }
51
52 //XXX printf_P
53 void xbee_dump_stats(struct xbee_dev *dev)
54 {
55         printf("statistics on xbee_dev %p:\n", dev);
56         printf(" rx_frame: %d\n", dev->stats.rx_frame);
57         printf(" rx_atresp: %d\n", dev->stats.rx_atresp);
58         printf(" rx_atresp_error: %d\n", dev->stats.rx_atresp_error);
59         printf(" rx_modem_status: %d\n", dev->stats.rx_modem_status);
60         printf(" rx_xmit_status: %d\n", dev->stats.rx_xmit_status);
61         printf(" rx_xmit_status_error: %d\n", dev->stats.rx_xmit_status_error);
62         printf(" rx_data: %d\n", dev->stats.rx_data);
63         printf(" rx_expl_data: %d\n", dev->stats.rx_expl_data);
64         printf(" rx_node_id: %d\n", dev->stats.rx_node_id);
65         printf(" rx_rmt_atresp: %d\n", dev->stats.rx_rmt_atresp);
66         printf(" rx_rmt_atresp_error: %d\n", dev->stats.rx_rmt_atresp_error);
67         printf(" rx_frame_too_small: %d\n", dev->stats.rx_frame_too_small);
68         printf(" rx_frame_too_large: %d\n", dev->stats.rx_frame_too_large);
69         printf(" rx_invalid_cksum: %d\n", dev->stats.rx_invalid_cksum);
70         printf(" rx_invalid_type: %d\n", dev->stats.rx_invalid_type);
71         printf(" rx_no_delim: %d\n", dev->stats.rx_no_delim);
72         printf(" tx_frame: %d\n", dev->stats.tx_frame);
73         printf(" tx_atcmd: %d\n", dev->stats.tx_atcmd);
74         printf(" tx_atcmd_q: %d\n", dev->stats.tx_atcmd_q);
75         printf(" tx_data: %d\n", dev->stats.tx_data);
76         printf(" tx_expl_data: %d\n", dev->stats.tx_expl_data);
77         printf(" tx_xmit_retries: %d\n", dev->stats.tx_xmit_retries);
78         printf(" tx_rmt_atcmd: %d\n", dev->stats.tx_rmt_atcmd);
79         printf(" tx_invalid_type: %d\n", dev->stats.tx_invalid_type);
80         printf(" tx_invalid_channel: %d\n", dev->stats.tx_invalid_channel);
81 }