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

Show attached slave position and state in 'ethercat config'.

parent ca542003
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,6 @@ Version 1.4.0: ...@@ -16,7 +16,6 @@ Version 1.4.0:
* ethercat tool: * ethercat tool:
- Replace --slave by --position. - Replace --slave by --position.
- Add --alias option. - Add --alias option.
- Show attached slave position.
- Show Pdos in 'ethercat slave -v'. - Show Pdos in 'ethercat slave -v'.
- Accept files from stdin. - Accept files from stdin.
- Display attached device's MAC address instead of ff's. - Display attached device's MAC address instead of ff's.
......
...@@ -994,9 +994,7 @@ int ec_cdev_ioctl_config( ...@@ -994,9 +994,7 @@ int ec_cdev_ioctl_config(
ec_pdo_list_count(&sc->sync_configs[i].pdos); ec_pdo_list_count(&sc->sync_configs[i].pdos);
} }
data.sdo_count = ec_slave_config_sdo_count(sc); data.sdo_count = ec_slave_config_sdo_count(sc);
data.attached = sc->slave != NULL; data.slave_position = sc->slave ? sc->slave->ring_position : -1;
data.operational = sc->slave &&
sc->slave->current_state == EC_SLAVE_STATE_OP;
up(&master->master_sem); up(&master->master_sem);
......
...@@ -301,8 +301,7 @@ typedef struct { ...@@ -301,8 +301,7 @@ typedef struct {
uint32_t pdo_count; uint32_t pdo_count;
} syncs[EC_MAX_SYNC_MANAGERS]; } syncs[EC_MAX_SYNC_MANAGERS];
uint32_t sdo_count; uint32_t sdo_count;
uint8_t attached : 1, int32_t slave_position;
operational : 1;
} ec_ioctl_config_t; } ec_ioctl_config_t;
/*****************************************************************************/ /*****************************************************************************/
......
...@@ -33,11 +33,16 @@ string CommandConfig::helpString() const ...@@ -33,11 +33,16 @@ string CommandConfig::helpString() const
<< "Without the --verbose option, slave configurations are" << endl << "Without the --verbose option, slave configurations are" << endl
<< "output one-per-line. Example:" << endl << "output one-per-line. Example:" << endl
<< endl << endl
<< "1001:0 0x0000003b/0x02010000 - -" << endl << "1001:0 0x0000003b/0x02010000 3 OP" << endl
<< "| | | |" << endl << "| | | |" << endl
<< "| | | \\- Slave is operational." << "| | | \\- Application-layer" << endl
<< endl << "| | | state of the attached" << endl
<< "| | \\- Slave has been found." << endl << "| | | slave, or '-', if no" << endl
<< "| | | slave is attached." << endl
<< "| | \\- Absolute decimal ring" << endl
<< "| | position of the attached" << endl
<< "| | slave, or '-' if none" << endl
<< "| | attached." << endl
<< "| \\- Vendor ID and product code (both" << endl << "| \\- Vendor ID and product code (both" << endl
<< "| hexadecimal)." << endl << "| hexadecimal)." << endl
<< "\\- Alias and relative position (both decimal)." << endl << "\\- Alias and relative position (both decimal)." << endl
...@@ -86,7 +91,7 @@ void CommandConfig::execute(MasterDevice &m, const StringVector &args) ...@@ -86,7 +91,7 @@ void CommandConfig::execute(MasterDevice &m, const StringVector &args)
if (getVerbosity() == Verbose) { if (getVerbosity() == Verbose) {
showDetailedConfigs(m, configList); showDetailedConfigs(m, configList);
} else { } else {
listConfigs(configList); listConfigs(m, configList);
} }
} }
...@@ -101,6 +106,7 @@ void CommandConfig::showDetailedConfigs( ...@@ -101,6 +106,7 @@ void CommandConfig::showDetailedConfigs(
{ {
ConfigList::const_iterator configIter; ConfigList::const_iterator configIter;
unsigned int j, k, l; unsigned int j, k, l;
ec_ioctl_slave_t slave;
ec_ioctl_config_pdo_t pdo; ec_ioctl_config_pdo_t pdo;
ec_ioctl_config_pdo_entry_t entry; ec_ioctl_config_pdo_entry_t entry;
ec_ioctl_config_sdo_t sdo; ec_ioctl_config_sdo_t sdo;
...@@ -117,8 +123,15 @@ void CommandConfig::showDetailedConfigs( ...@@ -117,8 +123,15 @@ void CommandConfig::showDetailedConfigs(
<< setw(8) << configIter->vendor_id << endl << setw(8) << configIter->vendor_id << endl
<< "Product code: 0x" << "Product code: 0x"
<< setw(8) << configIter->product_code << endl << setw(8) << configIter->product_code << endl
<< "Attached: " << (configIter->attached ? "yes" : "no") << endl << "Attached slave: ";
<< "Operational: " << (configIter->operational ? "yes" : "no") << endl;
if (configIter->slave_position != -1) {
m.getSlave(&slave, configIter->slave_position);
cout << configIter->slave_position
<< " (" << alStateString(slave.state) << ")" << endl;
} else {
cout << "none" << endl;
}
for (j = 0; j < EC_MAX_SYNC_MANAGERS; j++) { for (j = 0; j < EC_MAX_SYNC_MANAGERS; j++) {
if (configIter->syncs[j].pdo_count) { if (configIter->syncs[j].pdo_count) {
...@@ -188,7 +201,10 @@ void CommandConfig::showDetailedConfigs( ...@@ -188,7 +201,10 @@ void CommandConfig::showDetailedConfigs(
/** Lists the bus configuration. /** Lists the bus configuration.
*/ */
void CommandConfig::listConfigs(const ConfigList &configList) void CommandConfig::listConfigs(
MasterDevice &m,
const ConfigList &configList
)
{ {
ConfigList::const_iterator configIter; ConfigList::const_iterator configIter;
stringstream str; stringstream str;
...@@ -197,7 +213,8 @@ void CommandConfig::listConfigs(const ConfigList &configList) ...@@ -197,7 +213,8 @@ void CommandConfig::listConfigs(const ConfigList &configList)
InfoList list; InfoList list;
InfoList::const_iterator iter; InfoList::const_iterator iter;
unsigned int maxAliasWidth = 0, maxPosWidth = 0, unsigned int maxAliasWidth = 0, maxPosWidth = 0,
maxAttWidth = 0, maxOpWidth = 0; maxSlavePosWidth = 0, maxStateWidth = 0;
ec_ioctl_slave_t slave;
for (configIter = configList.begin(); for (configIter = configList.begin();
configIter != configList.end(); configIter != configList.end();
...@@ -220,15 +237,29 @@ void CommandConfig::listConfigs(const ConfigList &configList) ...@@ -220,15 +237,29 @@ void CommandConfig::listConfigs(const ConfigList &configList)
str.clear(); str.clear();
str.str(""); str.str("");
str << (configIter->attached ? "attached" : "-"); if (configIter->slave_position != -1) {
info.att = str.str(); m.getSlave(&slave, configIter->slave_position);
str.clear();
str.str("");
str << (configIter->operational ? "operational" : "-"); str << configIter->slave_position;
info.op = str.str(); info.slavePos = str.str();
str.clear(); str.clear();
str.str(""); str.str("");
str << alStateString(slave.state);
info.state = str.str();
str.clear();
str.str("");
} else {
str << "-";
info.slavePos = str.str();
str.clear();
str.str("");
str << "-";
info.state = str.str();
str.clear();
str.str("");
}
list.push_back(info); list.push_back(info);
...@@ -236,10 +267,10 @@ void CommandConfig::listConfigs(const ConfigList &configList) ...@@ -236,10 +267,10 @@ void CommandConfig::listConfigs(const ConfigList &configList)
maxAliasWidth = info.alias.length(); maxAliasWidth = info.alias.length();
if (info.pos.length() > maxPosWidth) if (info.pos.length() > maxPosWidth)
maxPosWidth = info.pos.length(); maxPosWidth = info.pos.length();
if (info.att.length() > maxAttWidth) if (info.slavePos.length() > maxSlavePosWidth)
maxAttWidth = info.att.length(); maxSlavePosWidth = info.slavePos.length();
if (info.op.length() > maxOpWidth) if (info.state.length() > maxStateWidth)
maxOpWidth = info.op.length(); maxStateWidth = info.state.length();
} }
for (iter = list.begin(); iter != list.end(); iter++) { for (iter = list.begin(); iter != list.end(); iter++) {
...@@ -250,8 +281,8 @@ void CommandConfig::listConfigs(const ConfigList &configList) ...@@ -250,8 +281,8 @@ void CommandConfig::listConfigs(const ConfigList &configList)
<< " " << " "
<< iter->ident << iter->ident
<< " " << " "
<< setw(maxAttWidth) << iter->att << " " << setw(maxSlavePosWidth) << iter->slavePos << " "
<< setw(maxOpWidth) << iter->op << " " << setw(maxStateWidth) << iter->state << " "
<< endl; << endl;
} }
} }
......
...@@ -28,14 +28,14 @@ class CommandConfig: ...@@ -28,14 +28,14 @@ class CommandConfig:
string alias; string alias;
string pos; string pos;
string ident; string ident;
string att; string slavePos;
string op; string state;
}; };
typedef list<ec_ioctl_config_t> ConfigList; typedef list<ec_ioctl_config_t> ConfigList;
void showDetailedConfigs(MasterDevice &, const ConfigList &); void showDetailedConfigs(MasterDevice &, const ConfigList &);
void listConfigs(const ConfigList &); void listConfigs(MasterDevice &m, const ConfigList &);
}; };
/****************************************************************************/ /****************************************************************************/
......
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