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@1144: << " 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@1144: << " the Pdo name, if avaliable. Note that a 'Tx' and 'Rx'" << endl fp@1144: << " are seen from the slave's point of view. 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@1144: << " hexadecimal), the length in bit and the description, if" << endl fp@1144: << " available. 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@1144: << " or 'all' for all 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@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: listSlavePdos(m, *si, showHeader); fp@1142: } fp@1142: } fp@1142: fp@1142: /****************************************************************************/ fp@1142: fp@1142: void CommandPdos::listSlavePdos( 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_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@1151: if (showHeader) fp@1151: cout << "=== Slave " << slave.position << " ===" << endl; fp@1142: fp@1142: for (i = 0; i < slave.sync_count; i++) { fp@1151: m.getSync(&sync, slave.position, 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@1151: m.getPdo(&pdo, slave.position, 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@1151: m.getPdoEntry(&entry, slave.position, 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: /*****************************************************************************/