Print certain logs only at debug_level.

This commit is contained in:
Florian Pose 2006-10-27 13:31:26 +00:00
parent 7a114fdb9d
commit fa99dfa321
3 changed files with 24 additions and 15 deletions

View File

@ -492,7 +492,8 @@ void ec_fsm_master_read_states(ec_fsm_t *fsm /**< finite state machine */)
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 @@ void ec_fsm_master_read_states(ec_fsm_t *fsm /**< finite state machine */)
// 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;
}

View File

@ -852,8 +852,9 @@ void ec_fsm_coe_down_start(ec_fsm_coe_t *fsm /**< finite state machine */)
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 @@ void ec_fsm_coe_up_start(ec_fsm_coe_t *fsm /**< finite state machine */)
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;

View File

@ -1245,8 +1245,8 @@ int ec_master_measure_bus_time(ec_master_t *master)
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;