Open master device as late as possible.

This commit is contained in:
Florian Pose
2010-03-11 15:03:52 +01:00
parent fb8a75570d
commit ddaee8a1fc
27 changed files with 154 additions and 107 deletions

View File

@@ -67,6 +67,7 @@ string CommandGraph::helpString() const
void CommandGraph::execute(const StringVector &args)
{
MasterIndexList masterIndices;
ec_ioctl_master_t master;
unsigned int i;
typedef vector<ec_ioctl_slave_t> SlaveVector;
@@ -90,12 +91,13 @@ void CommandGraph::execute(const StringVector &args)
throwInvalidUsageException(err);
}
if (getMasterIndices().size() != 1) {
masterIndices = getMasterIndices();
if (masterIndices.size() != 1) {
stringstream err;
err << getName() << " requires to select a single master!";
throwInvalidUsageException(err);
}
MasterDevice m(getMasterIndices().front());
MasterDevice m(masterIndices.front());
m.open(MasterDevice::Read);
m.getMaster(&master);