From 79fb1c5934a574ffa161960cad4c422acd96eae5 Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Wed, 24 Feb 2010 17:24:20 +0100 Subject: [PATCH] Improved multi-master capabilities of ethercat tool. --- TODO | 3 +++ tool/CommandCStruct.cpp | 2 +- tool/CommandConfig.cpp | 4 ++-- tool/CommandData.cpp | 19 +++++++++---------- tool/CommandDomains.cpp | 2 +- tool/CommandEoe.cpp | 16 +++++++++------- tool/CommandPdos.cpp | 2 +- tool/CommandSdos.cpp | 2 +- tool/CommandSlaves.cpp | 8 ++++---- 9 files changed, 31 insertions(+), 27 deletions(-) diff --git a/TODO b/TODO index 82acde4a..0ecae307 100644 --- a/TODO +++ b/TODO @@ -28,6 +28,9 @@ Version 1.5.0: * Output hexadecimal values in 'ethercat xml'. * Add native drivers from 2.6.24 up to 2.6.31. * Reset al_states on link down. +* Implement indent in 'ethercat ma' +* Add master index to log messages. +* Implement 0xXXXX:YY format for specifying SDOs. Future issues: diff --git a/tool/CommandCStruct.cpp b/tool/CommandCStruct.cpp index d3d8fc75..b49b72e0 100644 --- a/tool/CommandCStruct.cpp +++ b/tool/CommandCStruct.cpp @@ -165,7 +165,7 @@ void CommandCStruct::generateSlaveCStruct( } cout - << "/* Slave " << slave.position; + << "/* Master " << m.getIndex() << ", Slave " << slave.position; if (strlen(slave.order)) { cout << ", \"" << slave.order << "\""; } diff --git a/tool/CommandConfig.cpp b/tool/CommandConfig.cpp index 32e371b9..6ee8dec4 100644 --- a/tool/CommandConfig.cpp +++ b/tool/CommandConfig.cpp @@ -121,8 +121,8 @@ void CommandConfig::execute(const StringVector &args) m.open(MasterDevice::Read); configs = selectedConfigs(m); - if (doIndent) { - cout << "Master" << dec << *mi << endl; + if (configs.size() && doIndent) { + cout << "Master" << dec << m.getIndex() << endl; } if (getVerbosity() == Verbose) { diff --git a/tool/CommandData.cpp b/tool/CommandData.cpp index d2a2fe6e..f7e3952e 100644 --- a/tool/CommandData.cpp +++ b/tool/CommandData.cpp @@ -75,17 +75,16 @@ void CommandData::execute(const StringVector &args) throwInvalidUsageException(err); } - if (getMasterIndices().size() != 1) { - stringstream err; - err << getName() << " requires to select a single master!"; - throwInvalidUsageException(err); - } - MasterDevice m(getMasterIndices().front()); - m.open(MasterDevice::Read); - domains = selectedDomains(m); + MasterIndexList::const_iterator mi; + for (mi = getMasterIndices().begin(); + mi != getMasterIndices().end(); mi++) { + MasterDevice m(*mi); + m.open(MasterDevice::Read); + domains = selectedDomains(m); - for (di = domains.begin(); di != domains.end(); di++) { - outputDomainData(m, *di); + for (di = domains.begin(); di != domains.end(); di++) { + outputDomainData(m, *di); + } } } diff --git a/tool/CommandDomains.cpp b/tool/CommandDomains.cpp index 959305c0..09b612be 100644 --- a/tool/CommandDomains.cpp +++ b/tool/CommandDomains.cpp @@ -110,7 +110,7 @@ void CommandDomains::execute(const StringVector &args) m.open(MasterDevice::Read); domains = selectedDomains(m); - if (doIndent) { + if (domains.size() && doIndent) { cout << "Master" << dec << *mi << endl; } diff --git a/tool/CommandEoe.cpp b/tool/CommandEoe.cpp index 5474ad39..d972de39 100644 --- a/tool/CommandEoe.cpp +++ b/tool/CommandEoe.cpp @@ -84,14 +84,16 @@ void CommandEoe::execute(const StringVector &args) m.open(MasterDevice::Read); m.getMaster(&master); - if (doIndent) { - cout << "Master" << dec << *mi << endl; - } + if (master.eoe_handler_count) { + if (doIndent) { + cout << "Master" << dec << *mi << endl; + } - cout << indent << "Interface Slave State " - << "RxBytes RxRate " - << "TxBytes TxRate TxQueue" - << endl; + cout << indent << "Interface Slave State " + << "RxBytes RxRate " + << "TxBytes TxRate TxQueue" + << endl; + } for (i = 0; i < master.eoe_handler_count; i++) { stringstream queue; diff --git a/tool/CommandPdos.cpp b/tool/CommandPdos.cpp index 876de3c5..13098c77 100644 --- a/tool/CommandPdos.cpp +++ b/tool/CommandPdos.cpp @@ -129,7 +129,7 @@ void CommandPdos::listSlavePdos( ec_ioctl_slave_sync_pdo_entry_t entry; unsigned int i, j, k; - if (showHeader) + if (showHeader && slave.sync_count) cout << "=== Master " << m.getIndex() << ", Slave " << slave.position << " ===" << endl; diff --git a/tool/CommandSdos.cpp b/tool/CommandSdos.cpp index 484c14f4..772c306e 100644 --- a/tool/CommandSdos.cpp +++ b/tool/CommandSdos.cpp @@ -127,7 +127,7 @@ void CommandSdos::listSlaveSdos( unsigned int i, j; const DataType *d; - if (showHeader) + if (showHeader && slave.sdo_count) cout << "=== Master " << m.getIndex() << ", Slave " << slave.position << " ===" << endl; diff --git a/tool/CommandSlaves.cpp b/tool/CommandSlaves.cpp index 1ef54eb5..8e4f6bc3 100644 --- a/tool/CommandSlaves.cpp +++ b/tool/CommandSlaves.cpp @@ -125,10 +125,6 @@ void CommandSlaves::execute(const StringVector &args) m.open(MasterDevice::Read); slaves = selectedSlaves(m); - if (doIndent) { - cout << "Master" << dec << *mi << endl; - } - if (getVerbosity() == Verbose) { showSlaves(m, slaves); } else { @@ -213,6 +209,10 @@ void CommandSlaves::listSlaves( aliasIndex++; } + if (infoList.size() && doIndent) { + cout << "Master" << dec << m.getIndex() << endl; + } + for (iter = infoList.begin(); iter != infoList.end(); iter++) { cout << indent << setfill(' ') << right << setw(maxPosWidth) << iter->pos << " "