equal
deleted
inserted
replaced
32 #include <fstream> |
32 #include <fstream> |
33 using namespace std; |
33 using namespace std; |
34 |
34 |
35 #include "CommandRegWrite.h" |
35 #include "CommandRegWrite.h" |
36 #include "sii_crc.h" |
36 #include "sii_crc.h" |
|
37 #include "MasterDevice.h" |
37 |
38 |
38 /*****************************************************************************/ |
39 /*****************************************************************************/ |
39 |
40 |
40 CommandRegWrite::CommandRegWrite(): |
41 CommandRegWrite::CommandRegWrite(): |
41 CommandReg("reg_write", "Write data to a slave's registers.") |
42 CommandReg("reg_write", "Write data to a slave's registers.") |
78 return str.str(); |
79 return str.str(); |
79 } |
80 } |
80 |
81 |
81 /****************************************************************************/ |
82 /****************************************************************************/ |
82 |
83 |
83 void CommandRegWrite::execute(MasterDevice &m, const StringVector &args) |
84 void CommandRegWrite::execute(const StringVector &args) |
84 { |
85 { |
85 stringstream strOffset, err; |
86 stringstream strOffset, err; |
86 ec_ioctl_slave_reg_t data; |
87 ec_ioctl_slave_reg_t data; |
87 ifstream file; |
88 ifstream file; |
88 SlaveList slaves; |
89 SlaveList slaves; |
98 >> data.offset; |
99 >> data.offset; |
99 if (strOffset.fail()) { |
100 if (strOffset.fail()) { |
100 err << "Invalid offset '" << args[0] << "'!"; |
101 err << "Invalid offset '" << args[0] << "'!"; |
101 throwInvalidUsageException(err); |
102 throwInvalidUsageException(err); |
102 } |
103 } |
|
104 |
|
105 if (getMasterIndices().size() != 1) { |
|
106 err << getName() << " requires to select a single master!"; |
|
107 throwInvalidUsageException(err); |
|
108 } |
|
109 MasterDevice m(getMasterIndices().front()); |
103 |
110 |
104 if (getDataType().empty()) { |
111 if (getDataType().empty()) { |
105 if (args[1] == "-") { |
112 if (args[1] == "-") { |
106 loadRegData(&data, cin); |
113 loadRegData(&data, cin); |
107 } else { |
114 } else { |