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 "CommandMaster.h" fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: CommandMaster::CommandMaster(): fp@1143: Command("master", "Show master and Ethernet device information.") fp@1142: { fp@1142: } fp@1142: fp@1142: /****************************************************************************/ fp@1142: fp@1142: string CommandMaster::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: << "Command-specific options:" << endl fp@1142: << " --master -m Index of the master to use. Default: 0." fp@1142: << endl << endl fp@1142: << numericInfo(); fp@1142: fp@1142: return str.str(); fp@1142: } fp@1142: fp@1142: /****************************************************************************/ fp@1142: fp@1142: void CommandMaster::execute(MasterDevice &m, const StringVector &args) fp@1142: { fp@1142: ec_ioctl_master_t data; fp@1142: stringstream err; fp@1142: unsigned int i; fp@1142: fp@1142: m.open(MasterDevice::Read); fp@1142: m.getMaster(&data); fp@1142: fp@1142: cout fp@1166: << "Master" << m.getIndex() << endl fp@1142: << " Phase: "; fp@1142: fp@1142: switch (data.phase) { fp@1142: case 0: cout << "Waiting for device..."; break; fp@1142: case 1: cout << "Idle"; break; fp@1142: case 2: cout << "Operation"; break; fp@1142: default: cout << "???"; fp@1142: } fp@1142: fp@1142: cout << endl fp@1142: << " Slaves: " << data.slave_count << endl; fp@1142: fp@1142: for (i = 0; i < 2; i++) { fp@1142: cout << " Device" << i << ": "; fp@1142: if (data.devices[i].address[0] == 0x00 fp@1142: && data.devices[i].address[1] == 0x00 fp@1142: && data.devices[i].address[2] == 0x00 fp@1142: && data.devices[i].address[3] == 0x00 fp@1142: && data.devices[i].address[4] == 0x00 fp@1142: && data.devices[i].address[5] == 0x00) { fp@1142: cout << "None."; fp@1142: } else { fp@1142: cout << hex << setfill('0') fp@1142: << setw(2) << (unsigned int) data.devices[i].address[0] << ":" fp@1142: << setw(2) << (unsigned int) data.devices[i].address[1] << ":" fp@1142: << setw(2) << (unsigned int) data.devices[i].address[2] << ":" fp@1142: << setw(2) << (unsigned int) data.devices[i].address[3] << ":" fp@1142: << setw(2) << (unsigned int) data.devices[i].address[4] << ":" fp@1142: << setw(2) << (unsigned int) data.devices[i].address[5] << " (" fp@1142: << (data.devices[i].attached ? "attached" : "waiting...") fp@1142: << ")" << endl << dec fp@1142: << " Tx count: " << data.devices[i].tx_count << endl fp@1142: << " Rx count: " << data.devices[i].rx_count; fp@1142: } fp@1142: cout << endl; fp@1142: } fp@1142: } fp@1142: fp@1142: /*****************************************************************************/