45 string CommandDownload::helpString() const |
45 string CommandDownload::helpString() const |
46 { |
46 { |
47 stringstream str; |
47 stringstream str; |
48 |
48 |
49 str << getName() << " [OPTIONS] <INDEX> <SUBINDEX> <VALUE>" << endl |
49 str << getName() << " [OPTIONS] <INDEX> <SUBINDEX> <VALUE>" << 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 |
60 << endl |
60 << endl |
61 << "These are the valid SDO entry data types:" << endl |
61 << "These are the valid SDO entry data types:" << endl |
62 << " int8, int16, int32, uint8, uint16, uint32, string," << endl |
62 << " int8, int16, int32, uint8, uint16, uint32, string," << endl |
63 << " octet_string." << endl |
63 << " octet_string." << endl |
64 << endl |
64 << endl |
65 << "Arguments:" << endl |
65 << "Arguments:" << endl |
66 << " INDEX is the SDO index and must be an unsigned" << endl |
66 << " INDEX is the SDO index and must be an unsigned" << endl |
67 << " 16 bit number." << endl |
67 << " 16 bit number." << endl |
68 << " SUBINDEX is the SDO entry subindex and must be an" << endl |
68 << " SUBINDEX is the SDO entry subindex and must be an" << endl |
69 << " unsigned 8 bit number." << endl |
69 << " unsigned 8 bit number." << endl |
70 << " VALUE is the value to download and must correspond" << endl |
70 << " VALUE is the value to download and must correspond" << endl |
71 << " to the SDO entry datatype (see above)." << endl |
71 << " to the SDO entry datatype (see above)." << endl |
72 << endl |
72 << endl |
73 << "Command-specific options:" << endl |
73 << "Command-specific options:" << endl |
74 << " --alias -a <alias>" << endl |
74 << " --alias -a <alias>" << endl |
75 << " --position -p <pos> Slave selection. See the help of" << endl |
75 << " --position -p <pos> Slave selection. See the help of" << endl |
76 << " the 'slaves' command." << endl |
76 << " the 'slaves' command." << endl |
77 << " --type -t <type> SDO entry data type (see above)." << endl |
77 << " --type -t <type> SDO entry data type (see above)." << endl |
78 << endl |
78 << endl |
79 << numericInfo(); |
79 << numericInfo(); |
80 |
80 |
81 return str.str(); |
81 return str.str(); |
82 } |
82 } |
83 |
83 |
84 /****************************************************************************/ |
84 /****************************************************************************/ |
85 |
85 |
86 void CommandDownload::execute(MasterDevice &m, const StringVector &args) |
86 void CommandDownload::execute(MasterDevice &m, const StringVector &args) |
233 err << "Invalid value argument '" << args[2] |
233 err << "Invalid value argument '" << args[2] |
234 << "' for type '" << dataType->name << "'!"; |
234 << "' for type '" << dataType->name << "'!"; |
235 throwInvalidUsageException(err); |
235 throwInvalidUsageException(err); |
236 } |
236 } |
237 |
237 |
238 try { |
238 try { |
239 m.sdoDownload(&data); |
239 m.sdoDownload(&data); |
240 } catch (MasterDeviceSdoAbortException &e) { |
240 } catch (MasterDeviceSdoAbortException &e) { |
241 delete [] data.data; |
241 delete [] data.data; |
242 err << "SDO transfer aborted with code 0x" |
242 err << "SDO transfer aborted with code 0x" |
243 << setfill('0') << hex << setw(8) << e.abortCode |
243 << setfill('0') << hex << setw(8) << e.abortCode |
244 << ": " << abortText(e.abortCode); |
244 << ": " << abortText(e.abortCode); |
245 throwCommandException(err); |
245 throwCommandException(err); |
246 } catch(MasterDeviceException &e) { |
246 } catch(MasterDeviceException &e) { |
247 delete [] data.data; |
247 delete [] data.data; |
248 throw e; |
248 throw e; |
249 } |
249 } |
250 |
250 |
251 delete [] data.data; |
251 delete [] data.data; |