442 |
442 |
443 // Check for pending Sdo requests |
443 // Check for pending Sdo requests |
444 if (ec_fsm_master_action_process_sdo(fsm)) |
444 if (ec_fsm_master_action_process_sdo(fsm)) |
445 return; |
445 return; |
446 |
446 |
447 if (master->mode == EC_MASTER_MODE_IDLE) { |
447 // check, if slaves have an Sdo dictionary to read out. |
448 |
448 list_for_each_entry(slave, &master->slaves, list) { |
449 // check, if slaves have an Sdo dictionary to read out. |
449 if (!(slave->sii.mailbox_protocols & EC_MBOX_COE) |
450 list_for_each_entry(slave, &master->slaves, list) { |
|
451 if (!(slave->sii.mailbox_protocols & EC_MBOX_COE) |
|
452 || slave->sdo_dictionary_fetched |
450 || slave->sdo_dictionary_fetched |
453 || slave->current_state == EC_SLAVE_STATE_INIT |
451 || slave->current_state == EC_SLAVE_STATE_INIT |
454 || jiffies - slave->jiffies_preop < EC_WAIT_SDO_DICT * HZ |
452 || jiffies - slave->jiffies_preop < EC_WAIT_SDO_DICT * HZ |
455 || slave->error_flag) continue; |
453 || slave->error_flag) continue; |
456 |
454 |
457 if (master->debug_level) { |
455 if (master->debug_level) { |
458 EC_DBG("Fetching Sdo dictionary from slave %u.\n", |
456 EC_DBG("Fetching Sdo dictionary from slave %u.\n", |
459 slave->ring_position); |
457 slave->ring_position); |
460 } |
|
461 |
|
462 slave->sdo_dictionary_fetched = 1; |
|
463 |
|
464 // start fetching Sdo dictionary |
|
465 fsm->idle = 0; |
|
466 fsm->slave = slave; |
|
467 fsm->state = ec_fsm_master_state_sdo_dictionary; |
|
468 ec_fsm_coe_dictionary(&fsm->fsm_coe, slave); |
|
469 ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately |
|
470 return; |
|
471 } |
458 } |
472 |
459 |
473 // check for pending SII write operations. |
460 slave->sdo_dictionary_fetched = 1; |
474 if (ec_fsm_master_action_process_sii(fsm)) |
461 |
475 return; // SII write request found |
462 // start fetching Sdo dictionary |
476 } |
463 fsm->idle = 0; |
|
464 fsm->slave = slave; |
|
465 fsm->state = ec_fsm_master_state_sdo_dictionary; |
|
466 ec_fsm_coe_dictionary(&fsm->fsm_coe, slave); |
|
467 ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately |
|
468 return; |
|
469 } |
|
470 |
|
471 // check for pending SII write operations. |
|
472 if (ec_fsm_master_action_process_sii(fsm)) |
|
473 return; // SII write request found |
477 |
474 |
478 fsm->state = ec_fsm_master_state_end; |
475 fsm->state = ec_fsm_master_state_end; |
479 } |
476 } |
480 |
477 |
481 /*****************************************************************************/ |
478 /*****************************************************************************/ |
840 // Sdo dictionary fetching finished |
837 // Sdo dictionary fetching finished |
841 |
838 |
842 if (master->debug_level) { |
839 if (master->debug_level) { |
843 unsigned int sdo_count, entry_count; |
840 unsigned int sdo_count, entry_count; |
844 ec_slave_sdo_dict_info(slave, &sdo_count, &entry_count); |
841 ec_slave_sdo_dict_info(slave, &sdo_count, &entry_count); |
845 EC_DBG("Fetched %i Sdos and %i entries from slave %i.\n", |
842 EC_DBG("Fetched %u Sdos and %u entries from slave %u.\n", |
846 sdo_count, entry_count, slave->ring_position); |
843 sdo_count, entry_count, slave->ring_position); |
847 } |
844 } |
848 |
845 |
849 fsm->state = ec_fsm_master_state_end; |
846 fsm->state = ec_fsm_master_state_end; |
850 } |
847 } |