Print certain logs only at debug_level.
authorFlorian Pose <fp@igh-essen.com>
Fri, 27 Oct 2006 13:31:26 +0000
changeset 459 f0da52cf6b5b
parent 458 6467f0f6e370
child 460 719ba8ccc509
Print certain logs only at debug_level.
master/fsm.c
master/fsm_coe.c
master/master.c
--- a/master/fsm.c	Fri Oct 27 13:20:16 2006 +0000
+++ b/master/fsm.c	Fri Oct 27 13:31:26 2006 +0000
@@ -492,7 +492,8 @@
     if (datagram->working_counter != 1) {
         if (slave->online) {
             slave->online = 0;
-            EC_INFO("Slave %i: offline.\n", slave->ring_position);
+            if (master->debug_level)
+                EC_DBG("Slave %i: offline.\n", slave->ring_position);
         }
         ec_fsm_master_action_next_slave_state(fsm);
         return;
@@ -501,19 +502,25 @@
     // slave responded
     new_state = EC_READ_U8(datagram->data);
     if (!slave->online) { // slave was offline before
-        char cur_state[EC_STATE_STRING_SIZE];
         slave->online = 1;
         slave->error_flag = 0; // clear error flag
         slave->current_state = new_state;
-        ec_state_string(slave->current_state, cur_state);
-        EC_INFO("Slave %i: online (%s).\n", slave->ring_position, cur_state);
+        if (master->debug_level) {
+            char cur_state[EC_STATE_STRING_SIZE];
+            ec_state_string(slave->current_state, cur_state);
+            EC_DBG("Slave %i: online (%s).\n",
+                   slave->ring_position, cur_state);
+        }
     }
     else if (new_state != slave->current_state) {
-        char old_state[EC_STATE_STRING_SIZE], cur_state[EC_STATE_STRING_SIZE];
-        ec_state_string(slave->current_state, old_state);
-        ec_state_string(new_state, cur_state);
-        EC_INFO("Slave %i: %s -> %s.\n",
-                slave->ring_position, old_state, cur_state);
+        if (master->debug_level) {
+            char old_state[EC_STATE_STRING_SIZE],
+                cur_state[EC_STATE_STRING_SIZE];
+            ec_state_string(slave->current_state, old_state);
+            ec_state_string(new_state, cur_state);
+            EC_DBG("Slave %i: %s -> %s.\n",
+                   slave->ring_position, old_state, cur_state);
+        }
         slave->current_state = new_state;
     }
 
--- a/master/fsm_coe.c	Fri Oct 27 13:20:16 2006 +0000
+++ b/master/fsm_coe.c	Fri Oct 27 13:31:26 2006 +0000
@@ -852,8 +852,9 @@
     ec_sdo_data_t *sdodata = fsm->sdodata;
     uint8_t *data;
 
-    EC_INFO("Downloading SDO 0x%04X:%i to slave %i.\n",
-            sdodata->index, sdodata->subindex, slave->ring_position);
+    if (fsm->slave->master->debug_level)
+        EC_DBG("Downloading SDO 0x%04X:%i to slave %i.\n",
+               sdodata->index, sdodata->subindex, slave->ring_position);
 
     if (slave->sii_rx_mailbox_size < 6 + 10 + sdodata->size) {
         EC_ERR("SDO fragmenting not supported yet!\n");
@@ -1029,8 +1030,9 @@
     ec_sdo_entry_t *entry = request->entry;
     uint8_t *data;
 
-    EC_INFO("Uploading SDO 0x%04X:%i from slave %i.\n",
-            sdo->index, entry->subindex, slave->ring_position);
+    if (master->debug_level)
+        EC_DBG("Uploading SDO 0x%04X:%i from slave %i.\n",
+               sdo->index, entry->subindex, slave->ring_position);
 
     if (!(data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 6))) {
         fsm->state = ec_fsm_coe_error;
--- a/master/master.c	Fri Oct 27 13:20:16 2006 +0000
+++ b/master/master.c	Fri Oct 27 13:31:26 2006 +0000
@@ -1245,8 +1245,8 @@
         if (cur < min) min = cur;
     }
 
-    EC_INFO("Bus time is (min/avg/max) %u / %u.%u / %u us.\n",
-            min, sum / 100, sum % 100, max);
+    EC_DBG("Bus time is (min/avg/max) %u / %u.%u / %u us.\n",
+           min, sum / 100, sum % 100, max);
     ec_datagram_clear(&datagram);
     return 0;