Added frame counter.
authorFlorian Pose <fp@igh-essen.com>
Tue, 21 Nov 2006 15:46:21 +0000
changeset 493 b17c95eac6b2
parent 492 9c58efb2c72d
child 494 178b1b43a88c
Added frame counter.
master/device.c
master/device.h
master/master.c
--- a/master/device.c	Tue Nov 21 15:13:48 2006 +0000
+++ b/master/device.c	Tue Nov 21 15:46:21 2006 +0000
@@ -71,6 +71,9 @@
     device->open = 0;
     device->link_state = 0; // down
 
+    device->tx_count = 0;
+    device->rx_count = 0;
+
 #ifdef EC_DBG_IF
     if (ec_debug_init(&device->dbg)) {
         EC_ERR("Failed to init debug device!\n");
@@ -146,6 +149,8 @@
     for (i = 0; i < 4; i++) ec_device_call_isr(device);
 
     device->link_state = 0;
+    device->tx_count = 0;
+    device->rx_count = 0;
 
     if (device->dev->open(device->dev) == 0) device->open = 1;
 
@@ -217,6 +222,7 @@
 
     // start sending
     device->dev->hard_start_xmit(device->tx_skb, device->dev);
+    device->tx_count++;
 }
 
 /*****************************************************************************/
@@ -251,6 +257,8 @@
                    size_t size /**< number of bytes received */
                    )
 {
+    device->rx_count++;
+
     if (unlikely(device->master->debug_level > 1)) {
         EC_DBG("Received frame:\n");
         ec_print_data_diff(device->tx_skb->data + ETH_HLEN,
--- a/master/device.h	Tue Nov 21 15:13:48 2006 +0000
+++ b/master/device.h	Tue Nov 21 15:46:21 2006 +0000
@@ -70,6 +70,8 @@
     unsigned long jiffies_isr; /**< jiffies of last ISR call */
     struct module *module; /**< pointer to the device's owning module */
     uint8_t link_state; /**< device link state */
+    unsigned int tx_count; /**< number of frames sent */
+    unsigned int rx_count; /**< number of frames received */
 #ifdef EC_DBG_IF
     ec_debug_t dbg; /**< debug device */
 #endif
--- a/master/master.c	Tue Nov 21 15:13:48 2006 +0000
+++ b/master/master.c	Tue Nov 21 15:46:21 2006 +0000
@@ -865,6 +865,13 @@
 
     off += sprintf(buffer + off, "\nSlaves: %i\n",
                    master->slave_count);
+    off += sprintf(buffer + off, "\nDevice:\n");
+    off += sprintf(buffer + off, "  Frames sent:     %u\n",
+		   master->device->tx_count);
+    off += sprintf(buffer + off, "  Frames received: %u\n",
+		   master->device->rx_count);
+    off += sprintf(buffer + off, "  Frames lost:     %u\n",
+		   master->device->tx_count - master->device->rx_count - 1);
 
     off += sprintf(buffer + off, "\nTiming (min/avg/max) [us]:\n");