equal
deleted
inserted
replaced
30 #include <iostream> |
30 #include <iostream> |
31 #include <map> |
31 #include <map> |
32 using namespace std; |
32 using namespace std; |
33 |
33 |
34 #include "CommandGraph.h" |
34 #include "CommandGraph.h" |
|
35 #include "MasterDevice.h" |
35 |
36 |
36 /*****************************************************************************/ |
37 /*****************************************************************************/ |
37 |
38 |
38 CommandGraph::CommandGraph(): |
39 CommandGraph::CommandGraph(): |
39 Command("graph", "Output the bus topology as a graph.") |
40 Command("graph", "Output the bus topology as a graph.") |
62 return str.str(); |
63 return str.str(); |
63 } |
64 } |
64 |
65 |
65 /****************************************************************************/ |
66 /****************************************************************************/ |
66 |
67 |
67 void CommandGraph::execute(MasterDevice &m, const StringVector &args) |
68 void CommandGraph::execute(const StringVector &args) |
68 { |
69 { |
69 ec_ioctl_master_t master; |
70 ec_ioctl_master_t master; |
70 unsigned int i; |
71 unsigned int i; |
71 typedef vector<ec_ioctl_slave_t> SlaveVector; |
72 typedef vector<ec_ioctl_slave_t> SlaveVector; |
72 SlaveVector slaves; |
73 SlaveVector slaves; |
87 stringstream err; |
88 stringstream err; |
88 err << "'" << getName() << "' takes no arguments!"; |
89 err << "'" << getName() << "' takes no arguments!"; |
89 throwInvalidUsageException(err); |
90 throwInvalidUsageException(err); |
90 } |
91 } |
91 |
92 |
|
93 if (getMasterIndices().size() != 1) { |
|
94 stringstream err; |
|
95 err << getName() << " requires to select a single master!"; |
|
96 throwInvalidUsageException(err); |
|
97 } |
|
98 MasterDevice m(getMasterIndices().front()); |
92 m.open(MasterDevice::Read); |
99 m.open(MasterDevice::Read); |
93 m.getMaster(&master); |
100 m.getMaster(&master); |
94 |
101 |
95 for (i = 0; i < master.slave_count; i++) { |
102 for (i = 0; i < master.slave_count; i++) { |
96 m.getSlave(&slave, i); |
103 m.getSlave(&slave, i); |