tool/CommandDownload.cpp
changeset 1826 ec6223c3b7ec
parent 1804 742607c464c4
child 1835 20748e9d2238
equal deleted inserted replaced
1825:65781b048a47 1826:ec6223c3b7ec
    30 #include <iostream>
    30 #include <iostream>
    31 #include <iomanip>
    31 #include <iomanip>
    32 using namespace std;
    32 using namespace std;
    33 
    33 
    34 #include "CommandDownload.h"
    34 #include "CommandDownload.h"
       
    35 #include "MasterDevice.h"
    35 
    36 
    36 /*****************************************************************************/
    37 /*****************************************************************************/
    37 
    38 
    38 CommandDownload::CommandDownload():
    39 CommandDownload::CommandDownload():
    39     SdoCommand("download", "Write an SDO entry to a slave.")
    40     SdoCommand("download", "Write an SDO entry to a slave.")
    81     return str.str();
    82     return str.str();
    82 }
    83 }
    83 
    84 
    84 /****************************************************************************/
    85 /****************************************************************************/
    85 
    86 
    86 void CommandDownload::execute(MasterDevice &m, const StringVector &args)
    87 void CommandDownload::execute(const StringVector &args)
    87 {
    88 {
    88     stringstream strIndex, strSubIndex, strValue, err;
    89     stringstream strIndex, strSubIndex, strValue, err;
    89     ec_ioctl_slave_sdo_download_t data;
    90     ec_ioctl_slave_sdo_download_t data;
    90     unsigned int number;
    91     unsigned int number;
    91     const DataType *dataType = NULL;
    92     const DataType *dataType = NULL;
   113         err << "Invalid SDO subindex '" << args[1] << "'!";
   114         err << "Invalid SDO subindex '" << args[1] << "'!";
   114         throwInvalidUsageException(err);
   115         throwInvalidUsageException(err);
   115     }
   116     }
   116     data.sdo_entry_subindex = number;
   117     data.sdo_entry_subindex = number;
   117 
   118 
       
   119     if (getMasterIndices().size() != 1) {
       
   120         err << getName() << " requires to select a single master!";
       
   121         throwInvalidUsageException(err);
       
   122     }
       
   123     MasterDevice m(getMasterIndices().front());
   118     m.open(MasterDevice::ReadWrite);
   124     m.open(MasterDevice::ReadWrite);
   119     slaves = selectedSlaves(m);
   125     slaves = selectedSlaves(m);
   120     if (slaves.size() != 1) {
   126     if (slaves.size() != 1) {
   121         throwSingleSlaveRequired(slaves.size());
   127         throwSingleSlaveRequired(slaves.size());
   122     }
   128     }