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 "CommandPdos.h" fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: CommandPdos::CommandPdos(): fp@1142: Command("pdos", "List Sync managers, Pdo assignment and mapping.") fp@1142: { fp@1142: } fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: string CommandPdos::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: << "The information is displayed in three layers, which are" << endl fp@1142: << "indented accordingly:" << endl fp@1142: << endl fp@1142: << "1) Sync managers - Contains the sync manager information" << endl fp@1142: << " from the SII: Index, physical start address, default" << endl fp@1142: << " size (value from the SII), control register and enable" << endl fp@1142: << " word. Example:" << endl fp@1142: << endl fp@1142: << " SM3: PhysAddr 0x1100, DefaultSize 0, ControlRegister 0x20," fp@1142: << "Enable 1" << endl fp@1142: << endl fp@1142: << "2) Assigned Pdos - Pdo direction, hexadecimal index and" << endl fp@1142: << " -if available- the Pdo name. Example:" << endl fp@1142: << endl fp@1142: << " TxPdo 0x1a00 \"Channel1\"" << endl fp@1142: << endl fp@1142: << "3) Mapped Pdo entries - Pdo entry index and subindex (both" << endl fp@1142: << " hexadecimal), the length in bit and -if available- the" << endl fp@1142: << " description. Example:" << endl fp@1142: << endl fp@1142: << " Pdo entry 0x3101:01, 8 bit, \"Status\"" << endl fp@1142: << endl fp@1142: << "Note, that the displayed Pdo assignment and Pdo mapping" << endl fp@1142: << "information can either originate from the SII or from the" << endl fp@1142: << "CoE communication area." << endl fp@1142: << endl fp@1142: << "Command-specific options:" << endl fp@1142: << " --slave -s Positive numerical ring position," << endl fp@1142: << " or 'all' forall slaves (default)." << 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 CommandPdos::execute(MasterDevice &m, const StringVector &args) fp@1142: { fp@1142: m.open(MasterDevice::Read); fp@1142: fp@1142: if (slavePosition == -1) { fp@1142: unsigned int numSlaves = m.slaveCount(), i; fp@1142: fp@1142: for (i = 0; i < numSlaves; i++) { fp@1142: listSlavePdos(m, i, true); fp@1142: } fp@1142: } else { fp@1142: listSlavePdos(m, slavePosition, false); fp@1142: } fp@1142: } fp@1142: fp@1142: /****************************************************************************/ fp@1142: fp@1142: void CommandPdos::listSlavePdos( fp@1142: MasterDevice &m, fp@1142: uint16_t slavePosition, fp@1142: bool withHeader fp@1142: ) fp@1142: { fp@1142: ec_ioctl_slave_t slave; fp@1142: ec_ioctl_slave_sync_t sync; fp@1142: ec_ioctl_slave_sync_pdo_t pdo; fp@1142: ec_ioctl_slave_sync_pdo_entry_t entry; fp@1142: unsigned int i, j, k; fp@1142: fp@1142: m.getSlave(&slave, slavePosition); fp@1142: fp@1142: if (withHeader) fp@1142: cout << "=== Slave " << slavePosition << " ===" << endl; fp@1142: fp@1142: for (i = 0; i < slave.sync_count; i++) { fp@1142: m.getSync(&sync, slavePosition, i); fp@1142: fp@1142: cout << "SM" << i << ":" fp@1142: << " PhysAddr 0x" fp@1142: << hex << setfill('0') fp@1142: << setw(4) << sync.physical_start_address fp@1142: << ", DefaultSize " fp@1142: << dec << setfill(' ') << setw(4) << sync.default_size fp@1142: << ", ControlRegister 0x" fp@1142: << hex << setfill('0') << setw(2) fp@1142: << (unsigned int) sync.control_register fp@1142: << ", Enable " << dec << (unsigned int) sync.enable fp@1142: << endl; fp@1142: fp@1142: for (j = 0; j < sync.pdo_count; j++) { fp@1142: m.getPdo(&pdo, slavePosition, i, j); fp@1142: fp@1142: cout << " " << (sync.control_register & 0x04 ? "R" : "T") fp@1142: << "xPdo 0x" fp@1142: << hex << setfill('0') fp@1142: << setw(4) << pdo.index fp@1142: << " \"" << pdo.name << "\"" << endl; fp@1142: fp@1142: if (getVerbosity() == Quiet) fp@1142: continue; fp@1142: fp@1142: for (k = 0; k < pdo.entry_count; k++) { fp@1142: m.getPdoEntry(&entry, slavePosition, i, j, k); fp@1142: fp@1142: cout << " Pdo entry 0x" fp@1142: << hex << setfill('0') fp@1142: << setw(4) << entry.index fp@1142: << ":" << setw(2) << (unsigned int) entry.subindex fp@1142: << ", " << dec << (unsigned int) entry.bit_length fp@1142: << " bit, \"" << entry.name << "\"" << endl; fp@1142: } fp@1142: } fp@1142: } fp@1142: } fp@1142: fp@1142: /*****************************************************************************/