fp@1142: /***************************************************************************** fp@1142: * fp@1142: * $Id$ fp@1142: * fp@1142: ****************************************************************************/ fp@1142: fp@1142: #include fp@1142: #include fp@1142: using namespace std; fp@1142: fp@1142: #include "CommandSdos.h" fp@1142: #include "coe_datatypes.h" fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: CommandSdos::CommandSdos(): fp@1142: Command("sdos", "List Sdo dictionaries.") fp@1142: { fp@1142: } fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: string CommandSdos::helpString() const fp@1142: { fp@1142: stringstream str; fp@1142: fp@1142: str << getName() << " [OPTIONS]" << endl fp@1142: << endl fp@1142: << getBriefDescription() << endl fp@1142: << endl fp@1142: << "Sdo dictionary information is displayed in two layers," << endl fp@1142: << "which are indented accordingly:" << endl fp@1142: << endl fp@1142: << "1) Sdos - Hexadecimal Sdo index and the name. Example:" << endl fp@1142: << endl fp@1142: << " Sdo 0x1018, \"Identity object\"" << endl fp@1142: << endl fp@1142: << "2) Sdo entries - Sdo index and Sdo entry subindex (both" << endl fp@1142: << " hexadecimal) followed by the data type, the length in" << endl fp@1142: << " bit, and the description. Example:" << endl fp@1142: << endl fp@1142: << " 0x1018:01, uint32, 32 bit, \"Vendor id\"" << endl fp@1142: << endl fp@1144: << "If the --quiet option is given, only the Sdos are output." fp@1142: << endl << endl fp@1142: << "Command-specific options:" << endl fp@1157: << " --alias -a " << endl fp@1157: << " --position -p Slave selection. See the help of" << endl fp@1157: << " the 'slaves' command." << endl fp@1157: << " --quiet -q Only output Sdos (without the" << endl fp@1157: << " Sdo entries)." << endl fp@1142: << endl fp@1142: << numericInfo(); fp@1142: fp@1142: return str.str(); fp@1142: } fp@1142: fp@1142: /****************************************************************************/ fp@1142: fp@1142: void CommandSdos::execute(MasterDevice &m, const StringVector &args) fp@1142: { fp@1151: SlaveList slaves; fp@1151: SlaveList::const_iterator si; fp@1151: bool showHeader; fp@1151: fp@1142: m.open(MasterDevice::Read); fp@1151: slaves = selectedSlaves(m); fp@1151: showHeader = slaves.size() > 1; fp@1142: fp@1151: for (si = slaves.begin(); si != slaves.end(); si++) { fp@1151: listSlaveSdos(m, *si, showHeader); fp@1142: } fp@1142: } fp@1142: fp@1142: /****************************************************************************/ fp@1142: fp@1142: void CommandSdos::listSlaveSdos( fp@1142: MasterDevice &m, fp@1151: const ec_ioctl_slave_t &slave, fp@1151: bool showHeader fp@1142: ) fp@1142: { fp@1142: ec_ioctl_slave_sdo_t sdo; fp@1142: ec_ioctl_slave_sdo_entry_t entry; fp@1142: unsigned int i, j; fp@1142: const CoEDataType *d; fp@1142: fp@1151: if (showHeader) fp@1151: cout << "=== Slave " << slave.position << " ===" << endl; fp@1142: fp@1142: for (i = 0; i < slave.sdo_count; i++) { fp@1151: m.getSdo(&sdo, slave.position, i); fp@1142: fp@1142: cout << "Sdo 0x" fp@1142: << hex << setfill('0') fp@1142: << setw(4) << sdo.sdo_index fp@1142: << ", \"" << sdo.name << "\"" << endl; fp@1142: fp@1142: if (getVerbosity() == Quiet) fp@1142: continue; fp@1142: fp@1142: for (j = 0; j <= sdo.max_subindex; j++) { fp@1151: m.getSdoEntry(&entry, slave.position, -i, j); fp@1142: fp@1142: cout << " 0x" << hex << setfill('0') fp@1142: << setw(4) << sdo.sdo_index << ":" fp@1142: << setw(2) << (unsigned int) entry.sdo_entry_subindex fp@1142: << ", "; fp@1142: fp@1142: if ((d = findDataType(entry.data_type))) { fp@1142: cout << d->name; fp@1142: } else { fp@1142: cout << "type " << setw(4) << entry.data_type; fp@1142: } fp@1142: fp@1142: cout << ", " << dec << entry.bit_length << " bit, \"" fp@1142: << entry.description << "\"" << endl; fp@1142: } fp@1142: } fp@1142: } fp@1142: fp@1142: /*****************************************************************************/