rc_proto: add license hdr
[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/pgmspace.h>
30 #include <aversive/queue.h>
31
32 #include <string.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <stdint.h>
36
37 #include "xbee_neighbor.h"
38 #include "xbee_stats.h"
39 #include "xbee_proto.h"
40 #include "xbee_buf.h"
41 #include "xbee.h"
42
43 struct xbee_stats *xbee_get_stats(struct xbee_dev *dev)
44 {
45         return &dev->stats;
46 }
47
48 void xbee_reset_stats(struct xbee_dev *dev)
49 {
50         memset(&dev->stats, 0, sizeof(dev->stats));
51 }
52
53 //XXX printf_P
54 void xbee_dump_stats(struct xbee_dev *dev)
55 {
56         printf_P(PSTR("statistics on xbee_dev %p:\r\n"), dev);
57         printf_P(PSTR(" rx_frame: %d\r\n"), dev->stats.rx_frame);
58         printf_P(PSTR(" rx_atresp: %d\r\n"), dev->stats.rx_atresp);
59         printf_P(PSTR(" rx_atresp_error: %d\r\n"), dev->stats.rx_atresp_error);
60         printf_P(PSTR(" rx_modem_status: %d\r\n"), dev->stats.rx_modem_status);
61         printf_P(PSTR(" rx_xmit_status: %d\r\n"), dev->stats.rx_xmit_status);
62         printf_P(PSTR(" rx_xmit_status_error: %d\r\n"), dev->stats.rx_xmit_status_error);
63         printf_P(PSTR(" rx_data: %d\r\n"), dev->stats.rx_data);
64         printf_P(PSTR(" rx_expl_data: %d\r\n"), dev->stats.rx_expl_data);
65         printf_P(PSTR(" rx_node_id: %d\r\n"), dev->stats.rx_node_id);
66         printf_P(PSTR(" rx_rmt_atresp: %d\r\n"), dev->stats.rx_rmt_atresp);
67         printf_P(PSTR(" rx_rmt_atresp_error: %d\r\n"), dev->stats.rx_rmt_atresp_error);
68         printf_P(PSTR(" rx_frame_too_small: %d\r\n"), dev->stats.rx_frame_too_small);
69         printf_P(PSTR(" rx_frame_too_large: %d\r\n"), dev->stats.rx_frame_too_large);
70         printf_P(PSTR(" rx_invalid_cksum: %d\r\n"), dev->stats.rx_invalid_cksum);
71         printf_P(PSTR(" rx_invalid_type: %d\r\n"), dev->stats.rx_invalid_type);
72         printf_P(PSTR(" rx_no_delim: %d\r\n"), dev->stats.rx_no_delim);
73         printf_P(PSTR(" tx_frame: %d\r\n"), dev->stats.tx_frame);
74         printf_P(PSTR(" tx_atcmd: %d\r\n"), dev->stats.tx_atcmd);
75         printf_P(PSTR(" tx_atcmd_q: %d\r\n"), dev->stats.tx_atcmd_q);
76         printf_P(PSTR(" tx_data: %d\r\n"), dev->stats.tx_data);
77         printf_P(PSTR(" tx_expl_data: %d\r\n"), dev->stats.tx_expl_data);
78         printf_P(PSTR(" tx_xmit_retries: %d\r\n"), dev->stats.tx_xmit_retries);
79         printf_P(PSTR(" tx_rmt_atcmd: %d\r\n"), dev->stats.tx_rmt_atcmd);
80         printf_P(PSTR(" tx_invalid_type: %d\r\n"), dev->stats.tx_invalid_type);
81         printf_P(PSTR(" tx_invalid_channel: %d\r\n"), dev->stats.tx_invalid_channel);
82 }