# HG changeset patch # User Florian Pose # Date 1239094820 0 # Node ID cbceb0e2f2a08b86f32887272bd9f39064519b2e # Parent 1853f6c0b9b22edc4020e2ef4ead98b114108291 Reading more base information (incl. whether DC supported). diff -r 1853f6c0b9b2 -r cbceb0e2f2a0 master/cdev.c --- a/master/cdev.c Mon Apr 06 09:48:01 2009 +0000 +++ b/master/cdev.c Tue Apr 07 09:00:20 2009 +0000 @@ -209,6 +209,7 @@ { ec_ioctl_slave_t data; const ec_slave_t *slave; + int i; if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { return -EFAULT; @@ -242,6 +243,12 @@ data.coe_details = slave->sii.coe_details; data.general_flags = slave->sii.general_flags; data.current_on_ebus = slave->sii.current_on_ebus; + for (i = 0; i < EC_MAX_PORTS; i++) { + data.ports[i] = slave->base_ports[i]; + } + data.fmmu_bit = slave->base_fmmu_bit_operation; + data.dc_supported = slave->base_dc_supported; + data.dc_range = slave->base_dc_range; data.al_state = slave->current_state; data.error_flag = slave->error_flag; diff -r 1853f6c0b9b2 -r cbceb0e2f2a0 master/fsm_slave_scan.c --- a/master/fsm_slave_scan.c Mon Apr 06 09:48:01 2009 +0000 +++ b/master/fsm_slave_scan.c Tue Apr 07 09:00:20 2009 +0000 @@ -247,7 +247,7 @@ } // read base data - ec_datagram_fprd(datagram, fsm->slave->station_address, 0x0000, 6); + ec_datagram_fprd(datagram, fsm->slave->station_address, 0x0000, 12); ec_datagram_zero(datagram); fsm->retries = EC_FSM_RETRIES; fsm->state = ec_fsm_slave_scan_state_base; @@ -263,6 +263,8 @@ { ec_datagram_t *datagram = fsm->datagram; ec_slave_t *slave = fsm->slave; + u8 octet; + int i; if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) return; @@ -287,8 +289,8 @@ slave->base_type = EC_READ_U8 (datagram->data); slave->base_revision = EC_READ_U8 (datagram->data + 1); slave->base_build = EC_READ_U16(datagram->data + 2); + slave->base_fmmu_count = EC_READ_U8 (datagram->data + 4); - if (slave->base_fmmu_count > EC_MAX_FMMUS) { EC_WARN("Slave %u has more FMMUs (%u) than the master can" " handle (%u).\n", slave->ring_position, @@ -296,6 +298,24 @@ slave->base_fmmu_count = EC_MAX_FMMUS; } + slave->base_sync_count = EC_READ_U8 (datagram->data + 5); + if (slave->base_sync_count > EC_MAX_SYNC_MANAGERS) { + EC_WARN("Slave %u provides more sync managers (%u) than the master can" + " handle (%u).\n", slave->ring_position, + slave->base_sync_count, EC_MAX_SYNC_MANAGERS); + slave->base_sync_count = EC_MAX_SYNC_MANAGERS; + } + + octet = EC_READ_U8(datagram->data + 7); + for (i = 0; i < EC_MAX_PORTS; i++) { + slave->base_ports[i] = (octet >> (2 * i)) & 0x03; + } + + octet = EC_READ_U8(datagram->data + 8); + slave->base_fmmu_bit_operation = octet & 0x01; + slave->base_dc_supported = (octet >> 2) & 0x01; + slave->base_dc_range = ((octet >> 3) & 0x01) ? EC_DC_64 : EC_DC_32; + // read data link status ec_datagram_fprd(datagram, slave->station_address, 0x0110, 2); ec_datagram_zero(datagram); diff -r 1853f6c0b9b2 -r cbceb0e2f2a0 master/globals.h --- a/master/globals.h Mon Apr 06 09:48:01 2009 +0000 +++ b/master/globals.h Tue Apr 07 09:00:20 2009 +0000 @@ -157,6 +157,23 @@ uint8_t enable_not_lrw : 1; /**< Slave does not support LRW. */ } ec_sii_general_flags_t; +/** EtherCAT slave port descriptor. + */ +typedef enum { + EC_PORT_NOT_IMPLEMENTED, + EC_PORT_NOT_CONFIGURED, + EC_PORT_EBUS, + EC_PORT_MII +} ec_slave_port_desc_t; + +/** EtherCAT slave distributed clocks range. + */ +typedef enum { + EC_DC_32, /**< 32 bit. */ + EC_DC_64 /*< 64 bit for system time, system time offset and + port 0 receive time. */ +} ec_slave_dc_range_t; + /*****************************************************************************/ /** Convenience macro for printing EtherCAT-specific information to syslog. diff -r 1853f6c0b9b2 -r cbceb0e2f2a0 master/ioctl.h --- a/master/ioctl.h Mon Apr 06 09:48:01 2009 +0000 +++ b/master/ioctl.h Tue Apr 07 09:00:20 2009 +0000 @@ -157,6 +157,10 @@ ec_sii_coe_details_t coe_details; ec_sii_general_flags_t general_flags; int16_t current_on_ebus; + ec_slave_port_desc_t ports[EC_MAX_PORTS]; + uint8_t fmmu_bit; + uint8_t dc_supported; + ec_slave_dc_range_t dc_range; uint8_t al_state; uint8_t error_flag; uint8_t sync_count; diff -r 1853f6c0b9b2 -r cbceb0e2f2a0 master/slave.c --- a/master/slave.c Mon Apr 06 09:48:01 2009 +0000 +++ b/master/slave.c Tue Apr 07 09:00:20 2009 +0000 @@ -86,14 +86,21 @@ slave->base_revision = 0; slave->base_build = 0; slave->base_fmmu_count = 0; + slave->base_sync_count = 0; for (i = 0; i < EC_MAX_PORTS; i++) { + slave->base_ports[i] = EC_PORT_NOT_IMPLEMENTED; + slave->ports[i].dl_link = 0; slave->ports[i].dl_loop = 0; slave->ports[i].dl_signal = 0; slave->sii.physical_layer[i] = 0xFF; } + slave->base_fmmu_bit_operation = 0; + slave->base_dc_supported = 0; + slave->base_dc_range = EC_DC_32; + slave->sii_words = NULL; slave->sii_nwords = 0; diff -r 1853f6c0b9b2 -r cbceb0e2f2a0 master/slave.h --- a/master/slave.h Mon Apr 06 09:48:01 2009 +0000 +++ b/master/slave.h Tue Apr 07 09:00:20 2009 +0000 @@ -127,7 +127,12 @@ uint8_t base_type; /**< Slave type. */ uint8_t base_revision; /**< Revision. */ uint16_t base_build; /**< Build number. */ - uint16_t base_fmmu_count; /**< Number of supported FMMUs. */ + uint8_t base_fmmu_count; /**< Number of supported FMMUs. */ + uint8_t base_sync_count; /**< Number of supported sync managers. */ + ec_slave_port_desc_t base_ports[EC_MAX_PORTS]; /**< Port descriptors. */ + uint8_t base_fmmu_bit_operation; /**< FMMU bit operation is supported. */ + uint8_t base_dc_supported; /**< Distributed clocks are supported. */ + ec_slave_dc_range_t base_dc_range; /**< DC range. */ // data link status ec_slave_port_t ports[EC_MAX_PORTS]; /**< Port link status. */ diff -r 1853f6c0b9b2 -r cbceb0e2f2a0 tool/CommandSlaves.cpp --- a/tool/CommandSlaves.cpp Mon Apr 06 09:48:01 2009 +0000 +++ b/tool/CommandSlaves.cpp Tue Apr 07 09:00:20 2009 +0000 @@ -219,6 +219,7 @@ ) { SlaveList::const_iterator si; + int i; for (si = slaves.begin(); si != slaves.end(); si++) { cout << "=== Slave " << dec << si->position << " ===" << endl; @@ -240,6 +241,50 @@ << " Serial number: 0x" << setw(8) << si->serial_number << endl; + cout << "Ports:" << endl; + for (i = 0; i < EC_MAX_PORTS; i++) { + cout << " " << i << ": "; + switch (si->ports[i]) { + case EC_PORT_NOT_IMPLEMENTED: + cout << "Not implemented."; + break; + case EC_PORT_NOT_CONFIGURED: + cout << "Not configured."; + break; + case EC_PORT_EBUS: + cout << "EBUS."; + break; + case EC_PORT_MII: + cout << "MII."; + break; + default: + cout << "???"; + } + cout << endl; + } + + cout << "DL information:" << endl + << " FMMU bit operation: " + << (si->fmmu_bit ? "yes" : "no") << endl + << " Distributed clocks: "; + if (si->dc_supported) { + cout << "yes ("; + switch (si->dc_range) { + case EC_DC_32: + cout << "32 bit"; + break; + case EC_DC_64: + cout << "64 bit"; + break; + default: + cout << "???"; + } + cout << ")"; + } else { + cout << "no"; + } + cout << endl; + if (si->mailbox_protocols) { list protoList; list::const_iterator protoIter;