fp@1142: /***************************************************************************** fp@1142: * fp@1142: * $Id$ fp@1142: * fp@1142: ****************************************************************************/ fp@1142: fp@1142: #include fp@1142: using namespace std; fp@1142: fp@1142: #include "CommandData.h" fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: CommandData::CommandData(): fp@1142: Command("data", "Output binary domain process data.") fp@1142: { fp@1142: } fp@1142: fp@1142: /*****************************************************************************/ fp@1142: fp@1142: string CommandData::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: << " --domain -d Positive numerical domain index, or" << endl fp@1142: << " 'all' for all domains (default). In" << endl fp@1142: << " this case, data of all domains are" << endl fp@1142: << " concatenated." << 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 CommandData::execute(MasterDevice &m, const StringVector &args) fp@1142: { fp@1142: m.open(MasterDevice::Read); fp@1142: fp@1142: if (domainIndex == -1) { fp@1142: unsigned int i; fp@1142: ec_ioctl_master_t master; fp@1142: fp@1142: m.getMaster(&master); fp@1142: fp@1142: for (i = 0; i < master.domain_count; i++) { fp@1142: outputDomainData(m, i); fp@1142: } fp@1142: } else { fp@1142: outputDomainData(m, domainIndex); fp@1142: } fp@1142: } fp@1142: fp@1142: /****************************************************************************/ fp@1142: fp@1142: void CommandData::outputDomainData(MasterDevice &m, unsigned int domainIndex) fp@1142: { fp@1142: ec_ioctl_domain_t domain; fp@1142: ec_ioctl_domain_data_t data; fp@1142: unsigned char *processData; fp@1142: unsigned int i; fp@1142: fp@1142: m.getDomain(&domain, domainIndex); fp@1142: fp@1142: if (!domain.data_size) fp@1142: return; fp@1142: fp@1142: processData = new unsigned char[domain.data_size]; fp@1142: fp@1142: try { fp@1142: m.getData(&data, domainIndex, domain.data_size, processData); fp@1142: } catch (MasterDeviceException &e) { fp@1142: delete [] processData; fp@1142: throw e; fp@1142: } fp@1142: fp@1142: for (i = 0; i < data.data_size; i++) fp@1142: cout << processData[i]; fp@1142: cout.flush(); fp@1142: fp@1142: delete [] processData; fp@1142: } fp@1142: fp@1142: /****************************************************************************/