tool/CommandSiiWrite.cpp
changeset 1826 ec6223c3b7ec
parent 1804 742607c464c4
child 1869 14f634f5b613
equal deleted inserted replaced
1825:65781b048a47 1826:ec6223c3b7ec
    32 #include <fstream>
    32 #include <fstream>
    33 using namespace std;
    33 using namespace std;
    34 
    34 
    35 #include "CommandSiiWrite.h"
    35 #include "CommandSiiWrite.h"
    36 #include "sii_crc.h"
    36 #include "sii_crc.h"
       
    37 #include "MasterDevice.h"
    37 
    38 
    38 /*****************************************************************************/
    39 /*****************************************************************************/
    39 
    40 
    40 CommandSiiWrite::CommandSiiWrite():
    41 CommandSiiWrite::CommandSiiWrite():
    41     Command("sii_write", "Write SII contents to a slave.")
    42     Command("sii_write", "Write SII contents to a slave.")
    73     return str.str();
    74     return str.str();
    74 }
    75 }
    75 
    76 
    76 /****************************************************************************/
    77 /****************************************************************************/
    77 
    78 
    78 void CommandSiiWrite::execute(MasterDevice &m, const StringVector &args)
    79 void CommandSiiWrite::execute(const StringVector &args)
    79 {
    80 {
    80     stringstream err;
    81     stringstream err;
    81     ec_ioctl_slave_sii_t data;
    82     ec_ioctl_slave_sii_t data;
    82     ifstream file;
    83     ifstream file;
    83     SlaveList slaves;
    84     SlaveList slaves;
    84 
    85 
    85     if (args.size() != 1) {
    86     if (args.size() != 1) {
    86         err << "'" << getName() << "' takes exactly one argument!";
    87         err << "'" << getName() << "' takes exactly one argument!";
    87         throwInvalidUsageException(err);
    88         throwInvalidUsageException(err);
    88     }
    89     }
       
    90 
       
    91     if (getMasterIndices().size() != 1) {
       
    92         err << getName() << " requires to select a single master!";
       
    93         throwInvalidUsageException(err);
       
    94     }
       
    95     MasterDevice m(getMasterIndices().front());
    89 
    96 
    90     if (args[0] == "-") {
    97     if (args[0] == "-") {
    91         loadSiiData(&data, cin);
    98         loadSiiData(&data, cin);
    92     } else {
    99     } else {
    93         file.open(args[0].c_str(), ifstream::in | ifstream::binary);
   100         file.open(args[0].c_str(), ifstream::in | ifstream::binary);