master/slave.c
changeset 140 b09658e50d6f
parent 139 998215ab9b92
child 142 e933f1adb550
equal deleted inserted replaced
139:998215ab9b92 140:b09658e50d6f
   851 
   851 
   852 /*****************************************************************************/
   852 /*****************************************************************************/
   853 
   853 
   854 /**
   854 /**
   855    Gibt alle Informationen über einen EtherCAT-Slave aus.
   855    Gibt alle Informationen über einen EtherCAT-Slave aus.
   856 */
   856 
   857 
   857    Verbosity:
   858 void ec_slave_print(const ec_slave_t *slave /**< EtherCAT-Slave */)
   858      0 - Nur Slavetypen und Adressen
       
   859      1 - mit EEPROM-Informationen
       
   860     >1 - mit SDO-Dictionaries
       
   861 */
       
   862 
       
   863 void ec_slave_print(const ec_slave_t *slave, /**< EtherCAT-Slave */
       
   864                     unsigned int verbosity /**< Geschwätzigkeit */
       
   865                     )
   859 {
   866 {
   860     ec_eeprom_sync_t *sync;
   867     ec_eeprom_sync_t *sync;
   861     ec_eeprom_pdo_t *pdo;
   868     ec_eeprom_pdo_t *pdo;
   862     ec_eeprom_pdo_entry_t *pdo_entry;
   869     ec_eeprom_pdo_entry_t *pdo_entry;
   863     ec_sdo_t *sdo;
   870     ec_sdo_t *sdo;
   876     }
   883     }
   877 
   884 
   878     EC_INFO("| Ring position: %i, Station address: 0x%04X\n",
   885     EC_INFO("| Ring position: %i, Station address: 0x%04X\n",
   879             slave->ring_position, slave->station_address);
   886             slave->ring_position, slave->station_address);
   880 
   887 
   881     EC_INFO("| Base information:\n");
   888     if (verbosity > 0) // Etwas geschwätziger
   882     EC_INFO("|   Type %u, Revision %i, Build %i\n",
   889     {
   883             slave->base_type, slave->base_revision, slave->base_build);
   890         EC_INFO("| Base information:\n");
   884     EC_INFO("|   Supported FMMUs: %i, Sync managers: %i\n",
   891         EC_INFO("|   Type %u, Revision %i, Build %i\n",
   885             slave->base_fmmu_count, slave->base_sync_count);
   892                 slave->base_type, slave->base_revision, slave->base_build);
   886 
   893         EC_INFO("|   Supported FMMUs: %i, Sync managers: %i\n",
   887     if (slave->sii_mailbox_protocols) {
   894                 slave->base_fmmu_count, slave->base_sync_count);
   888         EC_INFO("| Mailbox communication:\n");
   895 
   889         EC_INFO("|   RX mailbox: 0x%04X/%i, TX mailbox: 0x%04X/%i\n",
   896         if (slave->sii_mailbox_protocols) {
   890                 slave->sii_rx_mailbox_offset, slave->sii_rx_mailbox_size,
   897             EC_INFO("| Mailbox communication:\n");
   891                 slave->sii_tx_mailbox_offset, slave->sii_tx_mailbox_size);
   898             EC_INFO("|   RX mailbox: 0x%04X/%i, TX mailbox: 0x%04X/%i\n",
   892         EC_INFO("|   Supported protocols: ");
   899                     slave->sii_rx_mailbox_offset, slave->sii_rx_mailbox_size,
   893 
   900                     slave->sii_tx_mailbox_offset, slave->sii_tx_mailbox_size);
   894         first = 1;
   901             EC_INFO("|   Supported protocols: ");
   895         if (slave->sii_mailbox_protocols & EC_MBOX_AOE) {
   902 
   896             printk("AoE");
   903             first = 1;
   897             first = 0;
   904             if (slave->sii_mailbox_protocols & EC_MBOX_AOE) {
   898         }
   905                 printk("AoE");
   899         if (slave->sii_mailbox_protocols & EC_MBOX_EOE) {
   906                 first = 0;
   900             if (!first) printk(", ");
   907             }
   901             printk("EoE");
   908             if (slave->sii_mailbox_protocols & EC_MBOX_EOE) {
   902             first = 0;
   909                 if (!first) printk(", ");
   903         }
   910                 printk("EoE");
   904         if (slave->sii_mailbox_protocols & EC_MBOX_COE) {
   911                 first = 0;
   905             if (!first) printk(", ");
   912             }
   906             printk("CoE");
   913             if (slave->sii_mailbox_protocols & EC_MBOX_COE) {
   907             first = 0;
   914                 if (!first) printk(", ");
   908         }
   915                 printk("CoE");
   909         if (slave->sii_mailbox_protocols & EC_MBOX_FOE) {
   916                 first = 0;
   910             if (!first) printk(", ");
   917             }
   911             printk("FoE");
   918             if (slave->sii_mailbox_protocols & EC_MBOX_FOE) {
   912             first = 0;
   919                 if (!first) printk(", ");
   913         }
   920                 printk("FoE");
   914         if (slave->sii_mailbox_protocols & EC_MBOX_SOE) {
   921                 first = 0;
   915             if (!first) printk(", ");
   922             }
   916             printk("SoE");
   923             if (slave->sii_mailbox_protocols & EC_MBOX_SOE) {
   917             first = 0;
   924                 if (!first) printk(", ");
   918         }
   925                 printk("SoE");
   919         if (slave->sii_mailbox_protocols & EC_MBOX_VOE) {
   926                 first = 0;
   920             if (!first) printk(", ");
   927             }
   921             printk("VoE");
   928             if (slave->sii_mailbox_protocols & EC_MBOX_VOE) {
   922         }
   929                 if (!first) printk(", ");
   923         printk("\n");
   930                 printk("VoE");
   924     }
   931             }
   925 
   932             printk("\n");
   926     EC_INFO("| EEPROM data:\n");
   933         }
   927 
   934 
   928     if (slave->sii_alias)
   935         EC_INFO("| EEPROM data:\n");
   929         EC_INFO("|   Configured station alias: 0x%04X (%i)\n",
   936 
   930                 slave->sii_alias, slave->sii_alias);
   937         if (slave->sii_alias)
   931 
   938             EC_INFO("|   Configured station alias: 0x%04X (%i)\n",
   932     EC_INFO("|   Vendor-ID: 0x%08X, Product code: 0x%08X\n",
   939                     slave->sii_alias, slave->sii_alias);
   933             slave->sii_vendor_id, slave->sii_product_code);
   940 
   934     EC_INFO("|   Revision number: 0x%08X, Serial number: 0x%08X\n",
   941         EC_INFO("|   Vendor-ID: 0x%08X, Product code: 0x%08X\n",
   935             slave->sii_revision_number, slave->sii_serial_number);
   942                 slave->sii_vendor_id, slave->sii_product_code);
   936 
   943         EC_INFO("|   Revision number: 0x%08X, Serial number: 0x%08X\n",
   937     if (slave->eeprom_name)
   944                 slave->sii_revision_number, slave->sii_serial_number);
   938         EC_INFO("|   Name: %s\n", slave->eeprom_name);
   945 
   939     if (slave->eeprom_group)
   946         if (slave->eeprom_name)
   940         EC_INFO("|   Group: %s\n", slave->eeprom_group);
   947             EC_INFO("|   Name: %s\n", slave->eeprom_name);
   941     if (slave->eeprom_desc)
   948         if (slave->eeprom_group)
   942         EC_INFO("|   Description: %s\n", slave->eeprom_desc);
   949             EC_INFO("|   Group: %s\n", slave->eeprom_group);
   943 
   950         if (slave->eeprom_desc)
   944     if (!list_empty(&slave->eeprom_syncs)) {
   951             EC_INFO("|   Description: %s\n", slave->eeprom_desc);
   945         EC_INFO("|   Sync-Managers:\n");
   952 
   946         list_for_each_entry(sync, &slave->eeprom_syncs, list) {
   953         if (!list_empty(&slave->eeprom_syncs)) {
   947             EC_INFO("|     %i: 0x%04X, length %i, control 0x%02X, %s\n",
   954             EC_INFO("|   Sync-Managers:\n");
   948                     sync->index, sync->physical_start_address, sync->length,
   955             list_for_each_entry(sync, &slave->eeprom_syncs, list) {
   949                     sync->control_register,
   956                 EC_INFO("|     %i: 0x%04X, length %i, control 0x%02X, %s\n",
   950                     sync->enable ? "enable" : "disable");
   957                         sync->index, sync->physical_start_address,
   951         }
   958                         sync->length, sync->control_register,
   952     }
   959                         sync->enable ? "enable" : "disable");
   953 
   960             }
   954     list_for_each_entry(pdo, &slave->eeprom_pdos, list) {
   961         }
   955         EC_INFO("|   %s \"%s\" (0x%04X), -> Sync-Manager %i\n",
   962 
   956                 pdo->type == EC_RX_PDO ? "RXPDO" : "TXPDO",
   963         list_for_each_entry(pdo, &slave->eeprom_pdos, list) {
   957                 pdo->name ? pdo->name : "???",
   964             EC_INFO("|   %s \"%s\" (0x%04X), -> Sync-Manager %i\n",
   958                 pdo->index, pdo->sync_manager);
   965                     pdo->type == EC_RX_PDO ? "RXPDO" : "TXPDO",
   959 
   966                     pdo->name ? pdo->name : "???",
   960         list_for_each_entry(pdo_entry, &pdo->entries, list) {
   967                     pdo->index, pdo->sync_manager);
   961             EC_INFO("|     \"%s\" 0x%04X:%X, %i Bit\n",
   968 
   962                     pdo_entry->name ? pdo_entry->name : "???",
   969             list_for_each_entry(pdo_entry, &pdo->entries, list) {
   963                     pdo_entry->index, pdo_entry->subindex,
   970                 EC_INFO("|     \"%s\" 0x%04X:%X, %i Bit\n",
   964                     pdo_entry->bit_length);
   971                         pdo_entry->name ? pdo_entry->name : "???",
   965         }
   972                         pdo_entry->index, pdo_entry->subindex,
   966     }
   973                         pdo_entry->bit_length);
   967 
   974             }
   968     if (!list_empty(&slave->sdo_dictionary)) {
   975         }
   969         EC_INFO("|   SDO-Dictionary:\n");
   976     }
   970         list_for_each_entry(sdo, &slave->sdo_dictionary, list) {
   977 
   971             EC_INFO("|     0x%04X \"%s\"\n", sdo->index,
   978     if (verbosity > 1) // sehr geschwätzig
   972                     sdo->name ? sdo->name : "");
   979     {
   973             EC_INFO("|       Type 0x%04X, features: 0x%02X\n",
   980         if (!list_empty(&slave->sdo_dictionary)) {
   974                     sdo->type, sdo->features);
   981             EC_INFO("|   SDO-Dictionary:\n");
   975             list_for_each_entry(sdo_entry, &sdo->entries, list) {
   982             list_for_each_entry(sdo, &slave->sdo_dictionary, list) {
   976                 EC_INFO("|       0x%04X:%i \"%s\", type 0x%04X, %i bits\n",
   983                 EC_INFO("|     0x%04X \"%s\"\n", sdo->index,
   977                         sdo->index, sdo_entry->subindex,
   984                         sdo->name ? sdo->name : "");
   978                         sdo_entry->name ? sdo_entry->name : "",
   985                 EC_INFO("|       Type 0x%04X, features: 0x%02X\n",
   979                         sdo_entry->data_type, sdo_entry->bit_length);
   986                         sdo->type, sdo->features);
       
   987                 list_for_each_entry(sdo_entry, &sdo->entries, list) {
       
   988                     EC_INFO("|       0x%04X:%i \"%s\", type 0x%04X, %i bits\n",
       
   989                             sdo->index, sdo_entry->subindex,
       
   990                             sdo_entry->name ? sdo_entry->name : "",
       
   991                             sdo_entry->data_type, sdo_entry->bit_length);
       
   992                 }
   980             }
   993             }
   981         }
   994         }
   982     }
   995     }
   983 
   996 
   984     EC_INFO("x---------------------------------------------\n");
   997     EC_INFO("x---------------------------------------------\n");