tool/CommandUpload.cpp
changeset 1804 742607c464c4
parent 1393 979a7b26036d
child 1826 ec6223c3b7ec
equal deleted inserted replaced
1803:5b04770444df 1804:742607c464c4
    49     str << getName() << " [OPTIONS] <INDEX> <SUBINDEX>" << endl
    49     str << getName() << " [OPTIONS] <INDEX> <SUBINDEX>" << endl
    50         << endl
    50         << endl
    51         << getBriefDescription() << endl
    51         << getBriefDescription() << endl
    52         << endl
    52         << endl
    53         << "This command requires a single slave to be selected." << endl
    53         << "This command requires a single slave to be selected." << endl
    54     	<< endl
    54         << endl
    55         << "The data type of the SDO entry is taken from the SDO" << endl
    55         << "The data type of the SDO entry is taken from the SDO" << endl
    56         << "dictionary by default. It can be overridden with the" << endl
    56         << "dictionary by default. It can be overridden with the" << endl
    57         << "--type option. If the slave does not support the SDO" << endl
    57         << "--type option. If the slave does not support the SDO" << endl
    58         << "information service or the SDO is not in the dictionary," << endl
    58         << "information service or the SDO is not in the dictionary," << endl
    59         << "the --type option is mandatory."  << endl
    59         << "the --type option is mandatory."  << endl
   150         data.target_size = DefaultBufferSize;
   150         data.target_size = DefaultBufferSize;
   151     }
   151     }
   152 
   152 
   153     data.target = new uint8_t[data.target_size + 1];
   153     data.target = new uint8_t[data.target_size + 1];
   154 
   154 
   155 	try {
   155     try {
   156 		m.sdoUpload(&data);
   156         m.sdoUpload(&data);
   157 	} catch (MasterDeviceSdoAbortException &e) {
   157     } catch (MasterDeviceSdoAbortException &e) {
   158         delete [] data.target;
   158         delete [] data.target;
   159         err << "SDO transfer aborted with code 0x"
   159         err << "SDO transfer aborted with code 0x"
   160             << setfill('0') << hex << setw(8) << e.abortCode
   160             << setfill('0') << hex << setw(8) << e.abortCode
   161             << ": " << abortText(e.abortCode);
   161             << ": " << abortText(e.abortCode);
   162         throwCommandException(err);
   162         throwCommandException(err);
   163 	} catch (MasterDeviceException &e) {
   163     } catch (MasterDeviceException &e) {
   164         delete [] data.target;
   164         delete [] data.target;
   165         throw e;
   165         throw e;
   166     }
   166     }
   167 
   167 
   168     m.close();
   168     m.close();
   235 }
   235 }
   236 
   236 
   237 /****************************************************************************/
   237 /****************************************************************************/
   238 
   238 
   239 void CommandUpload::printRawData(
   239 void CommandUpload::printRawData(
   240 		const uint8_t *data,
   240         const uint8_t *data,
   241 		unsigned int size
   241         unsigned int size
   242 		)
   242         )
   243 {
   243 {
   244     cout << hex << setfill('0');
   244     cout << hex << setfill('0');
   245     while (size--) {
   245     while (size--) {
   246         cout << "0x" << setw(2) << (unsigned int) *data++;
   246         cout << "0x" << setw(2) << (unsigned int) *data++;
   247         if (size)
   247         if (size)