Newer
Older
Florian Pose
committed
}
else {
EC_INFO("%i) UNKNOWN SLAVE: vendor 0x%08X, product 0x%08X\n",
slave->ring_position, slave->sii_vendor_id,
slave->sii_product_code);
Florian Pose
committed
}
if (!verbosity) return;
EC_INFO(" Station address: 0x%04X\n", slave->station_address);
Florian Pose
committed
EC_INFO(" Data link status:\n");
for (i = 0; i < 4; i++) {
EC_INFO(" Port %i: link %s, loop %s, %s\n", i,
slave->dl_link[i] ? "up" : "down",
slave->dl_loop[i] ? "closed" : "open",
slave->dl_signal[i] ? "signal detected" : "no signal");
EC_INFO(" Base information:\n");
EC_INFO(" Type %u, revision %i, build %i\n",
slave->base_type, slave->base_revision, slave->base_build);
EC_INFO(" Supported FMMUs: %i, sync managers: %i\n",
slave->base_fmmu_count, slave->base_sync_count);
if (slave->sii_mailbox_protocols) {
EC_INFO(" Mailbox communication:\n");
EC_INFO(" RX mailbox: 0x%04X/%i, TX mailbox: 0x%04X/%i\n",
slave->sii_rx_mailbox_offset, slave->sii_rx_mailbox_size,
slave->sii_tx_mailbox_offset, slave->sii_tx_mailbox_size);
EC_INFO(" Supported protocols: ");
first = 1;
if (slave->sii_mailbox_protocols & EC_MBOX_AOE) {
printk("AoE");
first = 0;
}
if (slave->sii_mailbox_protocols & EC_MBOX_EOE) {
if (!first) printk(", ");
printk("EoE");
first = 0;
}
if (slave->sii_mailbox_protocols & EC_MBOX_COE) {
if (!first) printk(", ");
printk("CoE");
first = 0;
}
if (slave->sii_mailbox_protocols & EC_MBOX_FOE) {
if (!first) printk(", ");
printk("FoE");
first = 0;
if (slave->sii_mailbox_protocols & EC_MBOX_SOE) {
if (!first) printk(", ");
printk("SoE");
first = 0;
}
if (slave->sii_mailbox_protocols & EC_MBOX_VOE) {
if (!first) printk(", ");
printk("VoE");
}
printk("\n");
}
EC_INFO(" EEPROM data:\n");
EC_INFO(" Configured station alias: 0x%04X (%i)\n",
slave->sii_alias, slave->sii_alias);
EC_INFO(" Vendor-ID: 0x%08X, Product code: 0x%08X\n",
slave->sii_vendor_id, slave->sii_product_code);
EC_INFO(" Revision number: 0x%08X, Serial number: 0x%08X\n",
slave->sii_revision_number, slave->sii_serial_number);
if (slave->eeprom_name)
EC_INFO(" Name: %s\n", slave->eeprom_name);
EC_INFO(" Group: %s\n", slave->eeprom_group);
EC_INFO(" Description: %s\n", slave->eeprom_desc);
if (!list_empty(&slave->eeprom_syncs)) {
EC_INFO(" Sync-Managers:\n");
list_for_each_entry(sync, &slave->eeprom_syncs, list) {
EC_INFO(" %i: 0x%04X, length %i, control 0x%02X, %s\n",
sync->index, sync->physical_start_address,
sync->length, sync->control_register,
sync->enable ? "enable" : "disable");
Florian Pose
committed
}
Florian Pose
committed
list_for_each_entry(pdo, &slave->eeprom_pdos, list) {
EC_INFO(" %s \"%s\" (0x%04X), -> Sync-Manager %i\n",
pdo->type == EC_RX_PDO ? "RXPDO" : "TXPDO",
pdo->name ? pdo->name : "???",
pdo->index, pdo->sync_manager);
list_for_each_entry(pdo_entry, &pdo->entries, list) {
EC_INFO(" \"%s\" 0x%04X:%X, %i Bit\n",
pdo_entry->name ? pdo_entry->name : "???",
pdo_entry->index, pdo_entry->subindex,
pdo_entry->bit_length);
if (verbosity < 2) return;
if (!list_empty(&slave->sdo_dictionary)) {
EC_INFO(" SDO-Dictionary:\n");
list_for_each_entry(sdo, &slave->sdo_dictionary, list) {
EC_INFO(" 0x%04X \"%s\"\n", sdo->index,
sdo->name ? sdo->name : "");
EC_INFO(" Object code: 0x%02X\n", sdo->object_code);
list_for_each_entry(sdo_entry, &sdo->entries, list) {
EC_INFO(" 0x%04X:%i \"%s\", type 0x%04X, %i bits\n",
sdo->index, sdo_entry->subindex,
sdo_entry->name ? sdo_entry->name : "",
sdo_entry->data_type, sdo_entry->bit_length);
Florian Pose
committed
/*****************************************************************************/
/**
Gibt die Zhlerstnde der CRC-Fault-Counter aus und setzt diese zurck.
\return 0 bei Erfolg, sonst < 0
*/
int ec_slave_check_crc(ec_slave_t *slave /**< EtherCAT-Slave */)
{
ec_command_t *command;
command = &slave->master->simple_command;
if (ec_command_nprd(command, slave->station_address, 0x0300, 4)) return -1;
if (unlikely(ec_master_simple_io(slave->master, command))) {
EC_WARN("Reading CRC fault counters failed on slave %i!\n",
return -1;
}
// No CRC faults.
if (!EC_READ_U32(command->data)) return 0;
if (EC_READ_U8(command->data))
EC_WARN("%3i RX-error%s on slave %i, channel A.\n",
EC_READ_U8(command->data),
EC_READ_U8(command->data) == 1 ? "" : "s",
if (EC_READ_U8(command->data + 1))
EC_WARN("%3i invalid frame%s on slave %i, channel A.\n",
EC_READ_U8(command->data + 1),
EC_READ_U8(command->data + 1) == 1 ? "" : "s",
if (EC_READ_U8(command->data + 2))
EC_WARN("%3i RX-error%s on slave %i, channel B.\n",
EC_READ_U8(command->data + 2),
EC_READ_U8(command->data + 2) == 1 ? "" : "s",
if (EC_READ_U8(command->data + 3))
EC_WARN("%3i invalid frame%s on slave %i, channel B.\n",
EC_READ_U8(command->data + 3),
EC_READ_U8(command->data + 3) == 1 ? "" : "s",
// Reset CRC counters
if (ec_command_npwr(command, slave->station_address, 0x0300, 4)) return -1;
EC_WRITE_U32(command->data, 0x00000000);
if (unlikely(ec_master_simple_io(slave->master, command))) {
EC_WARN("Resetting CRC fault counters failed on slave %i!\n",
return -1;
}
return 0;
}
/*****************************************************************************/
/**
Schreibt den "Configured station alias".
\return 0, wenn alles ok, sonst < 0
*/
int ecrt_slave_write_alias(ec_slave_t *slave, /** EtherCAT-Slave */
uint16_t alias /** Neuer Alias */
)
{
return ec_slave_sii_write16(slave, 0x0004, alias);
}
/*****************************************************************************/
/**
Formatiert Attribut-Daten fr lesenden Zugriff im SysFS
\return Anzahl Bytes im Speicher
*/
ssize_t ec_show_slave_attribute(struct kobject *kobj, /**< KObject */
struct attribute *attr, /**< Attribut */
char *buffer /**< Speicher fr die Daten */
)
{
ec_slave_t *slave = container_of(kobj, ec_slave_t, kobj);
if (attr == &attr_ring_position) {
return sprintf(buffer, "%i\n", slave->ring_position);
}
Florian Pose
committed
else if (attr == &attr_coupler_address) {
return sprintf(buffer, "%i:%i\n", slave->coupler_index,
slave->coupler_subindex);
}
else if (attr == &attr_vendor_name) {
if (slave->type)
return sprintf(buffer, "%s\n", slave->type->vendor_name);
}
else if (attr == &attr_product_name) {
if (slave->type)
return sprintf(buffer, "%s\n", slave->type->product_name);
}
else if (attr == &attr_product_desc) {
if (slave->type)
return sprintf(buffer, "%s\n", slave->type->description);
}
else if (attr == &attr_type) {
if (slave->type) {
if (slave->type->special == EC_TYPE_BUS_COUPLER)
return sprintf(buffer, "coupler\n");
else
return sprintf(buffer, "normal\n");
}
}
return 0;
}
/*****************************************************************************/
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
const ec_code_msg_t al_status_messages[] = {
{0x0001, "Unspecified error"},
{0x0011, "Invalud requested state change"},
{0x0012, "Unknown requested state"},
{0x0013, "Bootstrap not supported"},
{0x0014, "No valid firmware"},
{0x0015, "Invalid mailbox configuration"},
{0x0016, "Invalid mailbox configuration"},
{0x0017, "Invalid sync manager configuration"},
{0x0018, "No valid inputs available"},
{0x0019, "No valid outputs"},
{0x001A, "Synchronisation error"},
{0x001B, "Sync manager watchdog"},
{0x0020, "Slave needs cold start"},
{0x0021, "Slave needs INIT"},
{0x0022, "Slave needs PREOP"},
{0x0023, "Slave needs SAVEOP"},
{}
};
/*****************************************************************************/
EXPORT_SYMBOL(ecrt_slave_write_alias);
/*****************************************************************************/
/* Emacs-Konfiguration
;;; Local Variables: ***
Florian Pose
committed
;;; c-basic-offset:4 ***