Skovbrynet / Mbed 2 deprecated TankCounter

Dependencies:   EthernetInterface NTPClient SDFileSystem TextLCD WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip FATFileSystem

Committer:
Tuxitheone
Date:
Mon Feb 29 18:59:15 2016 +0000
Revision:
0:ecaf3e593122
TankCounter

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Tuxitheone 0:ecaf3e593122 1 /**
Tuxitheone 0:ecaf3e593122 2 * @file
Tuxitheone 0:ecaf3e593122 3 * Statistics module
Tuxitheone 0:ecaf3e593122 4 *
Tuxitheone 0:ecaf3e593122 5 */
Tuxitheone 0:ecaf3e593122 6
Tuxitheone 0:ecaf3e593122 7 /*
Tuxitheone 0:ecaf3e593122 8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
Tuxitheone 0:ecaf3e593122 9 * All rights reserved.
Tuxitheone 0:ecaf3e593122 10 *
Tuxitheone 0:ecaf3e593122 11 * Redistribution and use in source and binary forms, with or without modification,
Tuxitheone 0:ecaf3e593122 12 * are permitted provided that the following conditions are met:
Tuxitheone 0:ecaf3e593122 13 *
Tuxitheone 0:ecaf3e593122 14 * 1. Redistributions of source code must retain the above copyright notice,
Tuxitheone 0:ecaf3e593122 15 * this list of conditions and the following disclaimer.
Tuxitheone 0:ecaf3e593122 16 * 2. Redistributions in binary form must reproduce the above copyright notice,
Tuxitheone 0:ecaf3e593122 17 * this list of conditions and the following disclaimer in the documentation
Tuxitheone 0:ecaf3e593122 18 * and/or other materials provided with the distribution.
Tuxitheone 0:ecaf3e593122 19 * 3. The name of the author may not be used to endorse or promote products
Tuxitheone 0:ecaf3e593122 20 * derived from this software without specific prior written permission.
Tuxitheone 0:ecaf3e593122 21 *
Tuxitheone 0:ecaf3e593122 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
Tuxitheone 0:ecaf3e593122 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
Tuxitheone 0:ecaf3e593122 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
Tuxitheone 0:ecaf3e593122 25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Tuxitheone 0:ecaf3e593122 26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
Tuxitheone 0:ecaf3e593122 27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Tuxitheone 0:ecaf3e593122 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Tuxitheone 0:ecaf3e593122 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
Tuxitheone 0:ecaf3e593122 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
Tuxitheone 0:ecaf3e593122 31 * OF SUCH DAMAGE.
Tuxitheone 0:ecaf3e593122 32 *
Tuxitheone 0:ecaf3e593122 33 * This file is part of the lwIP TCP/IP stack.
Tuxitheone 0:ecaf3e593122 34 *
Tuxitheone 0:ecaf3e593122 35 * Author: Adam Dunkels <adam@sics.se>
Tuxitheone 0:ecaf3e593122 36 *
Tuxitheone 0:ecaf3e593122 37 */
Tuxitheone 0:ecaf3e593122 38
Tuxitheone 0:ecaf3e593122 39 #include "lwip/opt.h"
Tuxitheone 0:ecaf3e593122 40
Tuxitheone 0:ecaf3e593122 41 #if LWIP_STATS /* don't build if not configured for use in lwipopts.h */
Tuxitheone 0:ecaf3e593122 42
Tuxitheone 0:ecaf3e593122 43 #include "lwip/def.h"
Tuxitheone 0:ecaf3e593122 44 #include "lwip/stats.h"
Tuxitheone 0:ecaf3e593122 45 #include "lwip/mem.h"
Tuxitheone 0:ecaf3e593122 46
Tuxitheone 0:ecaf3e593122 47 #include <string.h>
Tuxitheone 0:ecaf3e593122 48
Tuxitheone 0:ecaf3e593122 49 struct stats_ lwip_stats;
Tuxitheone 0:ecaf3e593122 50
Tuxitheone 0:ecaf3e593122 51 void stats_init(void)
Tuxitheone 0:ecaf3e593122 52 {
Tuxitheone 0:ecaf3e593122 53 #ifdef LWIP_DEBUG
Tuxitheone 0:ecaf3e593122 54 #if MEMP_STATS
Tuxitheone 0:ecaf3e593122 55 const char * memp_names[] = {
Tuxitheone 0:ecaf3e593122 56 #define LWIP_MEMPOOL(name,num,size,desc) desc,
Tuxitheone 0:ecaf3e593122 57 #include "lwip/memp_std.h"
Tuxitheone 0:ecaf3e593122 58 };
Tuxitheone 0:ecaf3e593122 59 int i;
Tuxitheone 0:ecaf3e593122 60 for (i = 0; i < MEMP_MAX; i++) {
Tuxitheone 0:ecaf3e593122 61 lwip_stats.memp[i].name = memp_names[i];
Tuxitheone 0:ecaf3e593122 62 }
Tuxitheone 0:ecaf3e593122 63 #endif /* MEMP_STATS */
Tuxitheone 0:ecaf3e593122 64 #if MEM_STATS
Tuxitheone 0:ecaf3e593122 65 lwip_stats.mem.name = "MEM";
Tuxitheone 0:ecaf3e593122 66 #endif /* MEM_STATS */
Tuxitheone 0:ecaf3e593122 67 #endif /* LWIP_DEBUG */
Tuxitheone 0:ecaf3e593122 68 }
Tuxitheone 0:ecaf3e593122 69
Tuxitheone 0:ecaf3e593122 70 #if LWIP_STATS_DISPLAY
Tuxitheone 0:ecaf3e593122 71 void
Tuxitheone 0:ecaf3e593122 72 stats_display_proto(struct stats_proto *proto, char *name)
Tuxitheone 0:ecaf3e593122 73 {
Tuxitheone 0:ecaf3e593122 74 LWIP_PLATFORM_DIAG(("\n%s\n\t", name));
Tuxitheone 0:ecaf3e593122 75 LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit));
Tuxitheone 0:ecaf3e593122 76 LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv));
Tuxitheone 0:ecaf3e593122 77 LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw));
Tuxitheone 0:ecaf3e593122 78 LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop));
Tuxitheone 0:ecaf3e593122 79 LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr));
Tuxitheone 0:ecaf3e593122 80 LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr));
Tuxitheone 0:ecaf3e593122 81 LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr));
Tuxitheone 0:ecaf3e593122 82 LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr));
Tuxitheone 0:ecaf3e593122 83 LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr));
Tuxitheone 0:ecaf3e593122 84 LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr));
Tuxitheone 0:ecaf3e593122 85 LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err));
Tuxitheone 0:ecaf3e593122 86 LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit));
Tuxitheone 0:ecaf3e593122 87 }
Tuxitheone 0:ecaf3e593122 88
Tuxitheone 0:ecaf3e593122 89 #if IGMP_STATS
Tuxitheone 0:ecaf3e593122 90 void
Tuxitheone 0:ecaf3e593122 91 stats_display_igmp(struct stats_igmp *igmp)
Tuxitheone 0:ecaf3e593122 92 {
Tuxitheone 0:ecaf3e593122 93 LWIP_PLATFORM_DIAG(("\nIGMP\n\t"));
Tuxitheone 0:ecaf3e593122 94 LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", igmp->xmit));
Tuxitheone 0:ecaf3e593122 95 LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", igmp->recv));
Tuxitheone 0:ecaf3e593122 96 LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", igmp->drop));
Tuxitheone 0:ecaf3e593122 97 LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr));
Tuxitheone 0:ecaf3e593122 98 LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr));
Tuxitheone 0:ecaf3e593122 99 LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", igmp->memerr));
Tuxitheone 0:ecaf3e593122 100 LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", igmp->proterr));
Tuxitheone 0:ecaf3e593122 101 LWIP_PLATFORM_DIAG(("rx_v1: %"STAT_COUNTER_F"\n\t", igmp->rx_v1));
Tuxitheone 0:ecaf3e593122 102 LWIP_PLATFORM_DIAG(("rx_group: %"STAT_COUNTER_F"\n", igmp->rx_group));
Tuxitheone 0:ecaf3e593122 103 LWIP_PLATFORM_DIAG(("rx_general: %"STAT_COUNTER_F"\n", igmp->rx_general));
Tuxitheone 0:ecaf3e593122 104 LWIP_PLATFORM_DIAG(("rx_report: %"STAT_COUNTER_F"\n\t", igmp->rx_report));
Tuxitheone 0:ecaf3e593122 105 LWIP_PLATFORM_DIAG(("tx_join: %"STAT_COUNTER_F"\n\t", igmp->tx_join));
Tuxitheone 0:ecaf3e593122 106 LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave));
Tuxitheone 0:ecaf3e593122 107 LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report));
Tuxitheone 0:ecaf3e593122 108 }
Tuxitheone 0:ecaf3e593122 109 #endif /* IGMP_STATS */
Tuxitheone 0:ecaf3e593122 110
Tuxitheone 0:ecaf3e593122 111 #if MEM_STATS || MEMP_STATS
Tuxitheone 0:ecaf3e593122 112 void
Tuxitheone 0:ecaf3e593122 113 stats_display_mem(struct stats_mem *mem, char *name)
Tuxitheone 0:ecaf3e593122 114 {
Tuxitheone 0:ecaf3e593122 115 LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name));
Tuxitheone 0:ecaf3e593122 116 LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail));
Tuxitheone 0:ecaf3e593122 117 LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used));
Tuxitheone 0:ecaf3e593122 118 LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max));
Tuxitheone 0:ecaf3e593122 119 LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err));
Tuxitheone 0:ecaf3e593122 120 }
Tuxitheone 0:ecaf3e593122 121
Tuxitheone 0:ecaf3e593122 122 #if MEMP_STATS
Tuxitheone 0:ecaf3e593122 123 void
Tuxitheone 0:ecaf3e593122 124 stats_display_memp(struct stats_mem *mem, int index)
Tuxitheone 0:ecaf3e593122 125 {
Tuxitheone 0:ecaf3e593122 126 char * memp_names[] = {
Tuxitheone 0:ecaf3e593122 127 #define LWIP_MEMPOOL(name,num,size,desc) desc,
Tuxitheone 0:ecaf3e593122 128 #include "lwip/memp_std.h"
Tuxitheone 0:ecaf3e593122 129 };
Tuxitheone 0:ecaf3e593122 130 if(index < MEMP_MAX) {
Tuxitheone 0:ecaf3e593122 131 stats_display_mem(mem, memp_names[index]);
Tuxitheone 0:ecaf3e593122 132 }
Tuxitheone 0:ecaf3e593122 133 }
Tuxitheone 0:ecaf3e593122 134 #endif /* MEMP_STATS */
Tuxitheone 0:ecaf3e593122 135 #endif /* MEM_STATS || MEMP_STATS */
Tuxitheone 0:ecaf3e593122 136
Tuxitheone 0:ecaf3e593122 137 #if SYS_STATS
Tuxitheone 0:ecaf3e593122 138 void
Tuxitheone 0:ecaf3e593122 139 stats_display_sys(struct stats_sys *sys)
Tuxitheone 0:ecaf3e593122 140 {
Tuxitheone 0:ecaf3e593122 141 LWIP_PLATFORM_DIAG(("\nSYS\n\t"));
Tuxitheone 0:ecaf3e593122 142 LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used));
Tuxitheone 0:ecaf3e593122 143 LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max));
Tuxitheone 0:ecaf3e593122 144 LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err));
Tuxitheone 0:ecaf3e593122 145 LWIP_PLATFORM_DIAG(("mutex.used: %"U32_F"\n\t", (u32_t)sys->mutex.used));
Tuxitheone 0:ecaf3e593122 146 LWIP_PLATFORM_DIAG(("mutex.max: %"U32_F"\n\t", (u32_t)sys->mutex.max));
Tuxitheone 0:ecaf3e593122 147 LWIP_PLATFORM_DIAG(("mutex.err: %"U32_F"\n\t", (u32_t)sys->mutex.err));
Tuxitheone 0:ecaf3e593122 148 LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used));
Tuxitheone 0:ecaf3e593122 149 LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max));
Tuxitheone 0:ecaf3e593122 150 LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err));
Tuxitheone 0:ecaf3e593122 151 }
Tuxitheone 0:ecaf3e593122 152 #endif /* SYS_STATS */
Tuxitheone 0:ecaf3e593122 153
Tuxitheone 0:ecaf3e593122 154 void
Tuxitheone 0:ecaf3e593122 155 stats_display(void)
Tuxitheone 0:ecaf3e593122 156 {
Tuxitheone 0:ecaf3e593122 157 s16_t i;
Tuxitheone 0:ecaf3e593122 158
Tuxitheone 0:ecaf3e593122 159 LINK_STATS_DISPLAY();
Tuxitheone 0:ecaf3e593122 160 ETHARP_STATS_DISPLAY();
Tuxitheone 0:ecaf3e593122 161 IPFRAG_STATS_DISPLAY();
Tuxitheone 0:ecaf3e593122 162 IP_STATS_DISPLAY();
Tuxitheone 0:ecaf3e593122 163 IGMP_STATS_DISPLAY();
Tuxitheone 0:ecaf3e593122 164 ICMP_STATS_DISPLAY();
Tuxitheone 0:ecaf3e593122 165 UDP_STATS_DISPLAY();
Tuxitheone 0:ecaf3e593122 166 TCP_STATS_DISPLAY();
Tuxitheone 0:ecaf3e593122 167 MEM_STATS_DISPLAY();
Tuxitheone 0:ecaf3e593122 168 for (i = 0; i < MEMP_MAX; i++) {
Tuxitheone 0:ecaf3e593122 169 MEMP_STATS_DISPLAY(i);
Tuxitheone 0:ecaf3e593122 170 }
Tuxitheone 0:ecaf3e593122 171 SYS_STATS_DISPLAY();
Tuxitheone 0:ecaf3e593122 172 }
Tuxitheone 0:ecaf3e593122 173 #endif /* LWIP_STATS_DISPLAY */
Tuxitheone 0:ecaf3e593122 174
Tuxitheone 0:ecaf3e593122 175 #endif /* LWIP_STATS */
Tuxitheone 0:ecaf3e593122 176