310 } |
315 } |
311 } |
316 } |
312 |
317 |
313 /****************************************************************************/ |
318 /****************************************************************************/ |
314 |
319 |
315 void Master::listPdos(int slavePosition, bool quiet) |
320 void Master::listPdos(int slavePosition) |
316 { |
321 { |
317 open(Read); |
322 open(Read); |
318 |
323 |
319 if (slavePosition == -1) { |
324 if (slavePosition == -1) { |
320 unsigned int numSlaves = slaveCount(), i; |
325 unsigned int numSlaves = slaveCount(), i; |
321 |
326 |
322 for (i = 0; i < numSlaves; i++) { |
327 for (i = 0; i < numSlaves; i++) { |
323 listSlavePdos(i, quiet, true); |
328 listSlavePdos(i, true); |
324 } |
329 } |
325 } else { |
330 } else { |
326 listSlavePdos(slavePosition, quiet, false); |
331 listSlavePdos(slavePosition, false); |
327 } |
332 } |
328 } |
333 } |
329 |
334 |
330 /****************************************************************************/ |
335 /****************************************************************************/ |
331 |
336 |
332 void Master::listSdos(int slavePosition, bool quiet) |
337 void Master::listSdos(int slavePosition) |
333 { |
338 { |
334 open(Read); |
339 open(Read); |
335 |
340 |
336 if (slavePosition == -1) { |
341 if (slavePosition == -1) { |
337 unsigned int numSlaves = slaveCount(), i; |
342 unsigned int numSlaves = slaveCount(), i; |
338 |
343 |
339 for (i = 0; i < numSlaves; i++) { |
344 for (i = 0; i < numSlaves; i++) { |
340 listSlaveSdos(i, quiet, true); |
345 listSlaveSdos(i, true); |
341 } |
346 } |
342 } else { |
347 } else { |
343 listSlaveSdos(slavePosition, quiet, false); |
348 listSlaveSdos(slavePosition, false); |
344 } |
349 } |
345 } |
350 } |
346 |
351 |
347 /****************************************************************************/ |
352 /****************************************************************************/ |
348 |
353 |
352 const vector<string> &commandArgs |
357 const vector<string> &commandArgs |
353 ) |
358 ) |
354 { |
359 { |
355 stringstream strIndex, strSubIndex, strValue, err; |
360 stringstream strIndex, strSubIndex, strValue, err; |
356 ec_ioctl_slave_sdo_download_t data; |
361 ec_ioctl_slave_sdo_download_t data; |
357 unsigned int i, number; |
362 unsigned int number; |
358 const CoEDataType *dataType = NULL; |
363 const CoEDataType *dataType = NULL; |
359 |
364 |
360 if (slavePosition < 0) { |
365 if (slavePosition < 0) { |
361 err << "'sdo_download' requires a slave! Please specify --slave."; |
366 err << "'sdo_download' requires a slave! Please specify --slave."; |
362 throw MasterException(err.str()); |
367 throw MasterException(err.str()); |
392 err << "Invalid data type '" << dataTypeStr << "'!"; |
397 err << "Invalid data type '" << dataTypeStr << "'!"; |
393 throw MasterException(err.str()); |
398 throw MasterException(err.str()); |
394 } |
399 } |
395 } else { // no data type specified: fetch from dictionary |
400 } else { // no data type specified: fetch from dictionary |
396 ec_ioctl_slave_sdo_entry_t entry; |
401 ec_ioctl_slave_sdo_entry_t entry; |
397 unsigned int entryByteSize; |
|
398 |
402 |
399 open(ReadWrite); |
403 open(ReadWrite); |
400 |
404 |
401 try { |
405 try { |
402 getSdoEntry(&entry, slavePosition, |
406 getSdoEntry(&entry, slavePosition, |
522 ) |
526 ) |
523 { |
527 { |
524 stringstream strIndex, strSubIndex; |
528 stringstream strIndex, strSubIndex; |
525 int sval; |
529 int sval; |
526 ec_ioctl_slave_sdo_upload_t data; |
530 ec_ioctl_slave_sdo_upload_t data; |
527 unsigned int i, uval; |
531 unsigned int uval; |
528 const CoEDataType *dataType = NULL; |
532 const CoEDataType *dataType = NULL; |
529 |
533 |
530 if (slavePosition < 0) { |
534 if (slavePosition < 0) { |
531 stringstream err; |
535 stringstream err; |
532 err << "'sdo_upload' requires a slave! Please specify --slave."; |
536 err << "'sdo_upload' requires a slave! Please specify --slave."; |
567 err << "Invalid data type '" << dataTypeStr << "'!"; |
571 err << "Invalid data type '" << dataTypeStr << "'!"; |
568 throw MasterException(err.str()); |
572 throw MasterException(err.str()); |
569 } |
573 } |
570 } else { // no data type specified: fetch from dictionary |
574 } else { // no data type specified: fetch from dictionary |
571 ec_ioctl_slave_sdo_entry_t entry; |
575 ec_ioctl_slave_sdo_entry_t entry; |
572 unsigned int entryByteSize; |
|
573 |
576 |
574 open(Read); |
577 open(Read); |
575 |
578 |
576 try { |
579 try { |
577 getSdoEntry(&entry, slavePosition, |
580 getSdoEntry(&entry, slavePosition, |
663 delete [] data.target; |
666 delete [] data.target; |
664 } |
667 } |
665 |
668 |
666 /****************************************************************************/ |
669 /****************************************************************************/ |
667 |
670 |
668 void Master::showSlaves(int slavePosition, bool verbose) |
671 void Master::showSlaves(int slavePosition) |
669 { |
672 { |
670 open(Read); |
673 open(Read); |
671 |
674 |
672 if (verbose) { |
675 if (verbosity == Verbose) { |
673 if (slavePosition == -1) { |
676 if (slavePosition == -1) { |
674 unsigned int numSlaves = slaveCount(), i; |
677 unsigned int numSlaves = slaveCount(), i; |
675 |
678 |
676 for (i = 0; i < numSlaves; i++) { |
679 for (i = 0; i < numSlaves; i++) { |
677 showSlave(i); |
680 showSlave(i); |
973 |
976 |
974 /*****************************************************************************/ |
977 /*****************************************************************************/ |
975 |
978 |
976 /** Lists the complete bus configuration. |
979 /** Lists the complete bus configuration. |
977 */ |
980 */ |
978 void Master::showConfigs() |
981 void Master::showDetailedConfigs() |
979 { |
982 { |
980 ec_ioctl_master_t master; |
983 ec_ioctl_master_t master; |
981 unsigned int i, j, k, l; |
984 unsigned int i, j, k, l; |
982 ec_ioctl_config_t config; |
985 ec_ioctl_config_t config; |
983 ec_ioctl_config_pdo_t pdo; |
986 ec_ioctl_config_pdo_t pdo; |
1246 |
1249 |
1247 /****************************************************************************/ |
1250 /****************************************************************************/ |
1248 |
1251 |
1249 void Master::listSlavePdos( |
1252 void Master::listSlavePdos( |
1250 uint16_t slavePosition, |
1253 uint16_t slavePosition, |
1251 bool quiet, |
|
1252 bool withHeader |
1254 bool withHeader |
1253 ) |
1255 ) |
1254 { |
1256 { |
1255 ec_ioctl_slave_t slave; |
1257 ec_ioctl_slave_t slave; |
1256 ec_ioctl_slave_sync_t sync; |
1258 ec_ioctl_slave_sync_t sync; |
1285 << "xPdo 0x" |
1287 << "xPdo 0x" |
1286 << hex << setfill('0') |
1288 << hex << setfill('0') |
1287 << setw(4) << pdo.index |
1289 << setw(4) << pdo.index |
1288 << " \"" << pdo.name << "\"" << endl; |
1290 << " \"" << pdo.name << "\"" << endl; |
1289 |
1291 |
1290 if (quiet) |
1292 if (verbosity == Quiet) |
1291 continue; |
1293 continue; |
1292 |
1294 |
1293 for (k = 0; k < pdo.entry_count; k++) { |
1295 for (k = 0; k < pdo.entry_count; k++) { |
1294 getPdoEntry(&entry, slavePosition, i, j, k); |
1296 getPdoEntry(&entry, slavePosition, i, j, k); |
1295 |
1297 |
1306 |
1308 |
1307 /****************************************************************************/ |
1309 /****************************************************************************/ |
1308 |
1310 |
1309 void Master::listSlaveSdos( |
1311 void Master::listSlaveSdos( |
1310 uint16_t slavePosition, |
1312 uint16_t slavePosition, |
1311 bool quiet, |
|
1312 bool withHeader |
1313 bool withHeader |
1313 ) |
1314 ) |
1314 { |
1315 { |
1315 ec_ioctl_slave_t slave; |
1316 ec_ioctl_slave_t slave; |
1316 ec_ioctl_slave_sdo_t sdo; |
1317 ec_ioctl_slave_sdo_t sdo; |
1317 ec_ioctl_slave_sdo_entry_t entry; |
1318 ec_ioctl_slave_sdo_entry_t entry; |
1318 unsigned int i, j, k; |
1319 unsigned int i, j; |
1319 const CoEDataType *d; |
1320 const CoEDataType *d; |
1320 |
1321 |
1321 getSlave(&slave, slavePosition); |
1322 getSlave(&slave, slavePosition); |
1322 |
1323 |
1323 if (withHeader) |
1324 if (withHeader) |
1329 cout << "Sdo 0x" |
1330 cout << "Sdo 0x" |
1330 << hex << setfill('0') |
1331 << hex << setfill('0') |
1331 << setw(4) << sdo.sdo_index |
1332 << setw(4) << sdo.sdo_index |
1332 << ", \"" << sdo.name << "\"" << endl; |
1333 << ", \"" << sdo.name << "\"" << endl; |
1333 |
1334 |
1334 if (quiet) |
1335 if (verbosity == Quiet) |
1335 continue; |
1336 continue; |
1336 |
1337 |
1337 for (j = 0; j <= sdo.max_subindex; j++) { |
1338 for (j = 0; j <= sdo.max_subindex; j++) { |
1338 getSdoEntry(&entry, slavePosition, -i, j); |
1339 getSdoEntry(&entry, slavePosition, -i, j); |
1339 |
1340 |