From b3242ef8fddf71ee75cacc89932dfe96304c6d8a Mon Sep 17 00:00:00 2001
From: Florian Pose <fp@igh-essen.com>
Date: Fri, 24 Nov 2006 11:09:36 +0000
Subject: [PATCH] Fixed lost frames display bug when no frames were sent.

---
 master/master.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/master/master.c b/master/master.c
index 58a12175..a27f356a 100644
--- a/master/master.c
+++ b/master/master.c
@@ -842,6 +842,7 @@ ssize_t ec_master_info(ec_master_t *master, /**< EtherCAT master */
     off_t off = 0;
     ec_eoe_t *eoe;
     uint32_t cur, sum, min, max, pos, i;
+    unsigned int frames_lost;
 
     off += sprintf(buffer + off, "\nVersion: %s", ec_master_version_str);
     off += sprintf(buffer + off, "\nMode: ");
@@ -864,8 +865,9 @@ ssize_t ec_master_info(ec_master_t *master, /**< EtherCAT master */
 		   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);
+    frames_lost = master->device->tx_count - master->device->rx_count;
+    if (frames_lost) frames_lost--;
+    off += sprintf(buffer + off, "  Frames lost:     %u\n", frames_lost);
 
     off += sprintf(buffer + off, "\nTiming (min/avg/max) [us]:\n");
 
-- 
GitLab