fp@1126: /***************************************************************************** fp@1126: * fp@1126: * $Id$ fp@1126: * fp@1126: ****************************************************************************/ fp@1126: fp@1126: #include fp@1126: #include fp@1126: using namespace std; fp@1126: fp@1126: #include "globals.h" fp@1126: #include "coe_datatypes.h" fp@1126: fp@1126: /****************************************************************************/ fp@1126: fp@1126: const char *help_sdos = fp@1126: "[OPTIONS]\n" fp@1126: "\n" fp@1137: "Displays the Sdo dictionary with Sdos and Sdo entries.\n" fp@1126: "\n" fp@1137: "Sdo dictionary information is displayed in two layers, with are\n" fp@1137: "indented accordingly:\n" fp@1137: "\n" fp@1137: "1) Sdos - Hexadecimal Sdo index and the name. Example:\n" fp@1137: "\n" fp@1137: " Sdo 0x1018, \"Identity object\"\n" fp@1137: "\n" fp@1137: "2) Sdo entries - Sdo index and Sdo entry subindex (both hexadecimal)\n" fp@1137: " followed by the data type, the length in bit, and the description.\n" fp@1137: " Example:\n" fp@1137: "\n" fp@1137: " 0x1018:01, uint32, 32 bit, \"Vendor id\"\n" fp@1137: "\n" fp@1137: "If the --quiet option is given, only the Sdos are printed.\n" fp@1137: "\n" fp@1137: "Command-specific options:\n" fp@1137: " --slave -s Positive numerical ring position, or 'all' for\n" fp@1137: " all slaves (default).\n" fp@1137: " --quiet -q Print only Sdos (without Sdo entries).\n" fp@1137: "\n" fp@1137: "Numerical values can be specified either with decimal (no prefix),\n" fp@1137: "octal (prefix '0') or hexadecimal (prefix '0x') base.\n"; fp@1126: fp@1126: /****************************************************************************/ fp@1126: fp@1126: void listSlaveSdos(uint16_t, bool); fp@1126: fp@1126: /****************************************************************************/ fp@1126: fp@1126: void command_sdos(void) fp@1126: { fp@1126: masterDev.open(MasterDevice::Read); fp@1126: fp@1126: if (slavePosition == -1) { fp@1126: unsigned int numSlaves = masterDev.slaveCount(), i; fp@1126: fp@1126: for (i = 0; i < numSlaves; i++) { fp@1126: listSlaveSdos(i, true); fp@1126: } fp@1126: } else { fp@1126: listSlaveSdos(slavePosition, false); fp@1126: } fp@1126: } fp@1126: fp@1126: /****************************************************************************/ fp@1126: fp@1126: void listSlaveSdos( fp@1126: uint16_t slavePosition, fp@1126: bool withHeader fp@1126: ) fp@1126: { fp@1126: ec_ioctl_slave_t slave; fp@1126: ec_ioctl_slave_sdo_t sdo; fp@1126: ec_ioctl_slave_sdo_entry_t entry; fp@1126: unsigned int i, j; fp@1126: const CoEDataType *d; fp@1126: fp@1126: masterDev.getSlave(&slave, slavePosition); fp@1126: fp@1126: if (withHeader) fp@1126: cout << "=== Slave " << slavePosition << " ===" << endl; fp@1126: fp@1126: for (i = 0; i < slave.sdo_count; i++) { fp@1126: masterDev.getSdo(&sdo, slavePosition, i); fp@1126: fp@1126: cout << "Sdo 0x" fp@1126: << hex << setfill('0') fp@1126: << setw(4) << sdo.sdo_index fp@1126: << ", \"" << sdo.name << "\"" << endl; fp@1126: fp@1126: if (verbosity == Quiet) fp@1126: continue; fp@1126: fp@1126: for (j = 0; j <= sdo.max_subindex; j++) { fp@1126: masterDev.getSdoEntry(&entry, slavePosition, -i, j); fp@1126: fp@1126: cout << " 0x" << hex << setfill('0') fp@1126: << setw(4) << sdo.sdo_index << ":" fp@1126: << setw(2) << (unsigned int) entry.sdo_entry_subindex fp@1126: << ", "; fp@1126: fp@1126: if ((d = findDataType(entry.data_type))) { fp@1126: cout << d->name; fp@1126: } else { fp@1126: cout << "type " << setw(4) << entry.data_type; fp@1126: } fp@1126: fp@1126: cout << ", " << dec << entry.bit_length << " bit, \"" fp@1126: << entry.description << "\"" << endl; fp@1126: } fp@1126: } fp@1126: } fp@1126: fp@1126: /*****************************************************************************/