Skip to content
Snippets Groups Projects
Commit 99a633c9 authored by Florian Pose's avatar Florian Pose
Browse files

Evaluate CoE details from general category; moved current consumption

into general category info.
parent 833aae6f
No related branches found
No related tags found
No related merge requests found
...@@ -189,6 +189,16 @@ void ec_fsm_pdo_config_next_pdo( ...@@ -189,6 +189,16 @@ void ec_fsm_pdo_config_next_pdo(
return; return;
} }
// Pdo configuration has to be changed. Does the slave support this?
if (fsm->slave->sii.mailbox_protocols & EC_MBOX_COE
|| (fsm->slave->sii.has_general
&& !fsm->slave->sii.coe_details.enable_pdo_configuration)) {
EC_ERR("Slave %u does not support changing the Pdo configuration!\n",
fsm->slave->ring_position);
fsm->state = ec_fsm_pdo_config_state_error;
return;
}
if (fsm->slave->master->debug_level) { if (fsm->slave->master->debug_level) {
EC_DBG("Changing configuration of Pdo 0x%04X of slave %u.\n", EC_DBG("Changing configuration of Pdo 0x%04X of slave %u.\n",
fsm->pdo->index, fsm->slave->ring_position); fsm->pdo->index, fsm->slave->ring_position);
......
...@@ -180,6 +180,16 @@ void ec_fsm_pdo_mapping_next_dir( ...@@ -180,6 +180,16 @@ void ec_fsm_pdo_mapping_next_dir(
if (ec_pdo_mapping_equal(&fsm->sync->mapping, fsm->mapping)) if (ec_pdo_mapping_equal(&fsm->sync->mapping, fsm->mapping))
continue; continue;
// Pdo mapping has to be changed. Does the slave support this?
if (!fsm->slave->sii.mailbox_protocols & EC_MBOX_COE
|| (fsm->slave->sii.has_general
&& !fsm->slave->sii.coe_details.enable_pdo_assign)) {
EC_ERR("Slave %u does not support changing the Pdo mapping!\n",
fsm->slave->ring_position);
fsm->state = ec_fsm_pdo_mapping_state_error;
return;
}
if (fsm->slave->master->debug_level) { if (fsm->slave->master->debug_level) {
EC_DBG("Changing Pdo mapping for SM%u of slave %u.\n", EC_DBG("Changing Pdo mapping for SM%u of slave %u.\n",
fsm->sync->index, fsm->slave->ring_position); fsm->sync->index, fsm->slave->ring_position);
......
...@@ -140,17 +140,23 @@ int ec_slave_init(ec_slave_t *slave, /**< EtherCAT slave */ ...@@ -140,17 +140,23 @@ int ec_slave_init(ec_slave_t *slave, /**< EtherCAT slave */
slave->sii.tx_mailbox_offset = 0; slave->sii.tx_mailbox_offset = 0;
slave->sii.tx_mailbox_size = 0; slave->sii.tx_mailbox_size = 0;
slave->sii.mailbox_protocols = 0; slave->sii.mailbox_protocols = 0;
slave->sii.strings = NULL;
slave->sii.string_count = 0;
slave->sii.has_general = 0;
slave->sii.group = NULL; slave->sii.group = NULL;
slave->sii.image = NULL; slave->sii.image = NULL;
slave->sii.order = NULL; slave->sii.order = NULL;
slave->sii.name = NULL; slave->sii.name = NULL;
memset(&slave->sii.coe_details, 0x00, sizeof(ec_sii_coe_details_t));
slave->sii.current_on_ebus = 0; slave->sii.current_on_ebus = 0;
slave->sii.strings = NULL;
slave->sii.string_count = 0;
slave->sii.syncs = NULL; slave->sii.syncs = NULL;
slave->sii.sync_count = 0; slave->sii.sync_count = 0;
INIT_LIST_HEAD(&slave->sii.pdos); INIT_LIST_HEAD(&slave->sii.pdos);
INIT_LIST_HEAD(&slave->sdo_dictionary); INIT_LIST_HEAD(&slave->sdo_dictionary);
slave->sdo_dictionary_fetched = 0; slave->sdo_dictionary_fetched = 0;
...@@ -434,8 +440,9 @@ int ec_slave_fetch_sii_general( ...@@ -434,8 +440,9 @@ int ec_slave_fetch_sii_general(
slave->sii.physical_layer[i] = slave->sii.physical_layer[i] =
(data[4] & (0x03 << (i * 2))) >> (i * 2); (data[4] & (0x03 << (i * 2))) >> (i * 2);
memcpy(&slave->sii.coe_details, data + 5, 1);
slave->sii.current_on_ebus = EC_READ_S16(data + 0x0C); slave->sii.current_on_ebus = EC_READ_S16(data + 0x0C);
slave->sii.has_general = 1;
return 0; return 0;
} }
...@@ -701,11 +708,7 @@ ssize_t ec_slave_info(const ec_slave_t *slave, /**< EtherCAT slave */ ...@@ -701,11 +708,7 @@ ssize_t ec_slave_info(const ec_slave_t *slave, /**< EtherCAT slave */
buf += sprintf(buf, "\n\n"); buf += sprintf(buf, "\n\n");
} }
buf += sprintf(buf, "Current consumption: %i mA\n\n", if (slave->sii.has_general) {
slave->sii.current_on_ebus);
if (slave->sii.group || slave->sii.image || slave->sii.order
|| slave->sii.name) {
buf += sprintf(buf, "General:\n"); buf += sprintf(buf, "General:\n");
if (slave->sii.group) if (slave->sii.group)
...@@ -717,7 +720,27 @@ ssize_t ec_slave_info(const ec_slave_t *slave, /**< EtherCAT slave */ ...@@ -717,7 +720,27 @@ ssize_t ec_slave_info(const ec_slave_t *slave, /**< EtherCAT slave */
slave->sii.order); slave->sii.order);
if (slave->sii.name) if (slave->sii.name)
buf += sprintf(buf, " Name: %s\n", slave->sii.name); buf += sprintf(buf, " Name: %s\n", slave->sii.name);
buf += sprintf(buf, "\n"); if (slave->sii.mailbox_protocols & EC_MBOX_COE) {
buf += sprintf(buf, " CoE details:\n");
buf += sprintf(buf, " Enable Sdo: %s\n",
slave->sii.coe_details.enable_sdo ? "yes" : "no");
buf += sprintf(buf, " Enable Sdo Info: %s\n",
slave->sii.coe_details.enable_sdo_info ? "yes" : "no");
buf += sprintf(buf, " Enable Pdo Assign: %s\n",
slave->sii.coe_details.enable_pdo_assign ? "yes" : "no");
buf += sprintf(buf, " Enable Pdo Configuration: %s\n",
slave->sii.coe_details.enable_pdo_configuration ?
"yes" : "no");
buf += sprintf(buf, " Enable Upload at startup: %s\n",
slave->sii.coe_details.enable_upload_at_startup ?
"yes" : "no");
buf += sprintf(buf, " Enable Sdo complete access: %s\n",
slave->sii.coe_details.enable_sdo_complete_access
? "yes" : "no");
}
buf += sprintf(buf, " Current consumption: %i mA\n\n",
slave->sii.current_on_ebus);
} }
if (slave->sii.sync_count) { if (slave->sii.sync_count) {
......
...@@ -103,6 +103,19 @@ enum { ...@@ -103,6 +103,19 @@ enum {
/*****************************************************************************/ /*****************************************************************************/
/** Slave information interface CAnopen-over-EtherCAT details flags.
*/
typedef struct {
uint8_t enable_sdo : 1; /**< Enable Sdo access. */
uint8_t enable_sdo_info : 1; /**< SDO information service available. */
uint8_t enable_pdo_assign : 1; /**< Pdo mapping configurable. */
uint8_t enable_pdo_configuration : 1; /**< Pdo configuration possible. */
uint8_t enable_upload_at_startup : 1; /**< ? */
uint8_t enable_sdo_complete_access : 1; /**< Complete access possible. */
} ec_sii_coe_details_t;
/*****************************************************************************/
/** Slave information interface data. /** Slave information interface data.
*/ */
typedef struct { typedef struct {
...@@ -123,11 +136,13 @@ typedef struct { ...@@ -123,11 +136,13 @@ typedef struct {
unsigned int string_count; /**< number of EEPROM strings */ unsigned int string_count; /**< number of EEPROM strings */
// General // General
uint8_t physical_layer[4]; /**< port media */ unsigned int has_general; /**< General category present. */
char *group; /**< slave group acc. to EEPROM */ char *group; /**< slave group acc. to EEPROM */
char *image; /**< slave image name acc. to EEPROM */ char *image; /**< slave image name acc. to EEPROM */
char *order; /**< slave order number acc. to EEPROM */ char *order; /**< slave order number acc. to EEPROM */
char *name; /**< slave name acc. to EEPROM */ char *name; /**< slave name acc. to EEPROM */
uint8_t physical_layer[4]; /**< port media */
ec_sii_coe_details_t coe_details; /**< CoE detail flags. */
int16_t current_on_ebus; /**< power consumption */ int16_t current_on_ebus; /**< power consumption */
// SyncM // SyncM
......
...@@ -83,6 +83,7 @@ sub query ...@@ -83,6 +83,7 @@ sub query
next unless $entry =~ /^slave(\d+)$/; next unless $entry =~ /^slave(\d+)$/;
$slave = {}; $slave = {};
$slave->{'current'} = 0;
$slave_info_file = "$master_dir/$entry/info"; $slave_info_file = "$master_dir/$entry/info";
open INFO, $slave_info_file or die open INFO, $slave_info_file or die
"ERROR: Failed to open $slave_info_file."; "ERROR: Failed to open $slave_info_file.";
...@@ -103,8 +104,6 @@ sub query ...@@ -103,8 +104,6 @@ sub query
$slave->{'state'} = $1; $slave->{'state'} = $1;
} elsif ($line =~ /^Configured station alias: .* \((\d+)\)$/) { } elsif ($line =~ /^Configured station alias: .* \((\d+)\)$/) {
$slave->{'alias'} = $1; $slave->{'alias'} = $1;
} elsif ($line =~ /^Current consumption: (-?\d+) mA$/) {
$slave->{'current'} = $1;
} }
} elsif ($category eq "Identity") { } elsif ($category eq "Identity") {
if ($line =~ /Vendor ID: .* \((\d+)\)$/) { if ($line =~ /Vendor ID: .* \((\d+)\)$/) {
...@@ -115,6 +114,8 @@ sub query ...@@ -115,6 +114,8 @@ sub query
} elsif ($category eq "General") { } elsif ($category eq "General") {
if ($line =~ /Name: (.*)$/) { if ($line =~ /Name: (.*)$/) {
$slave->{'name'} = $1; $slave->{'name'} = $1;
} elsif ($line =~ /Current consumption: (-?\d+) mA$/) {
$slave->{'current'} = $1;
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment