119 slave->error_flag = 0; |
119 slave->error_flag = 0; |
120 slave->online_state = EC_SLAVE_ONLINE; |
120 slave->online_state = EC_SLAVE_ONLINE; |
121 slave->fmmu_count = 0; |
121 slave->fmmu_count = 0; |
122 slave->pdos_registered = 0; |
122 slave->pdos_registered = 0; |
123 |
123 |
124 slave->coupler_index = 0; |
|
125 slave->coupler_subindex = 0xFFFF; |
|
126 |
|
127 slave->base_type = 0; |
124 slave->base_type = 0; |
128 slave->base_revision = 0; |
125 slave->base_revision = 0; |
129 slave->base_build = 0; |
126 slave->base_build = 0; |
130 slave->base_fmmu_count = 0; |
127 slave->base_fmmu_count = 0; |
131 |
128 |
697 off += sprintf(buffer + off, ")\nFlags: %s, %s\n", |
694 off += sprintf(buffer + off, ")\nFlags: %s, %s\n", |
698 slave->online_state == EC_SLAVE_ONLINE ? "online" : "OFFLINE", |
695 slave->online_state == EC_SLAVE_ONLINE ? "online" : "OFFLINE", |
699 slave->error_flag ? "ERROR" : "ok"); |
696 slave->error_flag ? "ERROR" : "ok"); |
700 off += sprintf(buffer + off, "Ring position: %i\n", |
697 off += sprintf(buffer + off, "Ring position: %i\n", |
701 slave->ring_position); |
698 slave->ring_position); |
702 off += sprintf(buffer + off, "Advanced position: %i:%i\n", |
|
703 slave->coupler_index, slave->coupler_subindex); |
|
704 off += sprintf(buffer + off, "Coupler: %s\n", |
|
705 ec_slave_is_coupler(slave) ? "yes" : "no"); |
|
706 off += sprintf(buffer + off, "Current consumption: %i mA\n\n", |
699 off += sprintf(buffer + off, "Current consumption: %i mA\n\n", |
707 slave->sii_current_on_ebus); |
700 slave->sii_current_on_ebus); |
708 |
701 |
709 off += sprintf(buffer + off, "Data link status:\n"); |
702 off += sprintf(buffer + off, "Data link status:\n"); |
710 for (i = 0; i < 4; i++) { |
703 for (i = 0; i < 4; i++) { |
1126 } |
1119 } |
1127 |
1120 |
1128 /*****************************************************************************/ |
1121 /*****************************************************************************/ |
1129 |
1122 |
1130 /** |
1123 /** |
1131 \return non-zero if slave is a bus coupler |
|
1132 */ |
|
1133 |
|
1134 int ec_slave_is_coupler(const ec_slave_t *slave /**< EtherCAT slave */) |
|
1135 { |
|
1136 // TODO: Better bus coupler criterion |
|
1137 return slave->sii_vendor_id == 0x00000002 |
|
1138 && slave->sii_product_code == 0x044C2C52; |
|
1139 } |
|
1140 |
|
1141 /*****************************************************************************/ |
|
1142 |
|
1143 /** |
|
1144 \return 0 in case of success, else < 0 |
1124 \return 0 in case of success, else < 0 |
1145 */ |
1125 */ |
1146 |
1126 |
1147 int ec_slave_conf_sdo(ec_slave_t *slave, /**< EtherCAT slave */ |
1127 int ec_slave_conf_sdo(ec_slave_t *slave, /**< EtherCAT slave */ |
1148 uint16_t sdo_index, /**< SDO index */ |
1128 uint16_t sdo_index, /**< SDO index */ |
1190 uint32_t product_code /**< product code */ |
1170 uint32_t product_code /**< product code */ |
1191 ) |
1171 ) |
1192 { |
1172 { |
1193 if (vendor_id != slave->sii_vendor_id || |
1173 if (vendor_id != slave->sii_vendor_id || |
1194 product_code != slave->sii_product_code) { |
1174 product_code != slave->sii_product_code) { |
1195 EC_ERR("Invalid slave type at position %i - Requested: 0x%08X 0x%08X," |
1175 EC_ERR("Invalid slave type at position %i:\n", slave->ring_position); |
1196 " found: 0x%08X 0x%08X\".\n", slave->ring_position, vendor_id, |
1176 EC_ERR(" Requested: 0x%08X 0x%08X\n", vendor_id, product_code); |
1197 product_code, slave->sii_vendor_id, slave->sii_product_code); |
1177 EC_ERR(" Found: 0x%08X 0x%08X\n", |
|
1178 slave->sii_vendor_id, slave->sii_product_code); |
1198 return -1; |
1179 return -1; |
1199 } |
1180 } |
1200 return 0; |
1181 return 0; |
1201 } |
1182 } |
1202 |
1183 |