tool/CommandDownload.cpp
changeset 1184 75cd6681eb08
parent 1166 006244d53f68
child 1254 c19d273a9e76
child 1686 e206f4485f60
equal deleted inserted replaced
1183:d77f634ab0b5 1184:75cd6681eb08
     7 #include <iostream>
     7 #include <iostream>
     8 #include <iomanip>
     8 #include <iomanip>
     9 using namespace std;
     9 using namespace std;
    10 
    10 
    11 #include "CommandDownload.h"
    11 #include "CommandDownload.h"
    12 #include "coe_datatypes.h"
       
    13 #include "byteorder.h"
    12 #include "byteorder.h"
    14 
    13 
    15 /*****************************************************************************/
    14 /*****************************************************************************/
    16 
    15 
    17 CommandDownload::CommandDownload():
    16 CommandDownload::CommandDownload():
    18     Command("download", "Write an Sdo entry to a slave.")
    17     SdoCommand("download", "Write an Sdo entry to a slave.")
    19 {
    18 {
    20 }
    19 }
    21 
    20 
    22 /*****************************************************************************/
    21 /*****************************************************************************/
    23 
    22 
    64 void CommandDownload::execute(MasterDevice &m, const StringVector &args)
    63 void CommandDownload::execute(MasterDevice &m, const StringVector &args)
    65 {
    64 {
    66     stringstream strIndex, strSubIndex, strValue, err;
    65     stringstream strIndex, strSubIndex, strValue, err;
    67     ec_ioctl_slave_sdo_download_t data;
    66     ec_ioctl_slave_sdo_download_t data;
    68     unsigned int number;
    67     unsigned int number;
    69     const CoEDataType *dataType = NULL;
    68     const DataType *dataType = NULL;
    70     SlaveList slaves;
    69     SlaveList slaves;
    71 
    70 
    72     if (args.size() != 3) {
    71     if (args.size() != 3) {
    73         err << "'" << getName() << "' takes 3 arguments!";
    72         err << "'" << getName() << "' takes 3 arguments!";
    74         throwInvalidUsageException(err);
    73         throwInvalidUsageException(err);
   205         throwInvalidUsageException(err);
   204         throwInvalidUsageException(err);
   206     }
   205     }
   207 
   206 
   208 	try {
   207 	try {
   209         m.sdoDownload(&data);
   208         m.sdoDownload(&data);
       
   209 	} catch (MasterDeviceSdoAbortException &e) {
       
   210         delete [] data.data;
       
   211         err << "Sdo transfer aborted with code 0x"
       
   212             << setfill('0') << hex << setw(8) << e.abortCode
       
   213             << ": " << abortText(e.abortCode);
       
   214         throwCommandException(err);
   210 	} catch(MasterDeviceException &e) {
   215 	} catch(MasterDeviceException &e) {
   211         delete [] data.data;
   216         delete [] data.data;
   212         throw e;
   217         throw e;
   213     }
   218     }
   214 
   219