Web server based weather station using Sparkfun Weather Meters.

Dependencies:   FatFileSystem mbed WeatherMeters SDFileSystem

Committer:
AdamGreen
Date:
Thu Feb 23 21:38:39 2012 +0000
Revision:
0:616601bde9fb

        

Who changed what in which revision?

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