Reverted default branch to stable-1.5.

This commit is contained in:
Florian Pose
2014-11-03 15:20:05 +01:00
parent 8479fd7675
commit 99418519bd
664 changed files with 837025 additions and 12883 deletions
+33 -32
View File
@@ -2,7 +2,7 @@
*
* $Id$
*
* Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH
* Copyright (C) 2006-2012 Florian Pose, Ingenieurgemeinschaft IgH
*
* This file is part of the IgH EtherCAT Master.
*
@@ -48,20 +48,20 @@ string CommandRegRead::helpString(const string &binaryBaseName) const
stringstream str;
str << binaryBaseName << " " << getName()
<< " [OPTIONS] <OFFSET> [LENGTH]" << endl
<< " [OPTIONS] <ADDRESS> [SIZE]" << endl
<< endl
<< getBriefDescription() << endl
<< endl
<< "This command requires a single slave to be selected." << endl
<< endl
<< "Arguments:" << endl
<< " OFFSET is the register address. Must" << endl
<< " be an unsigned 16 bit number." << endl
<< " LENGTH is the number of bytes to read and must also be" << endl
<< " an unsigned 16 bit number. OFFSET plus LENGTH" << endl
<< " may not exceed 64k. The length is ignored (and" << endl
<< " can be omitted), if a selected data type" << endl
<< " implies a length." << endl
<< " ADDRESS is the register address. Must" << endl
<< " be an unsigned 16 bit number." << endl
<< " SIZE is the number of bytes to read and must also be" << endl
<< " an unsigned 16 bit number. ADDRESS plus SIZE" << endl
<< " may not exceed 64k. The size is ignored (and" << endl
<< " can be omitted), if a selected data type" << endl
<< " implies a size." << endl
<< endl
<< typeInfo()
<< endl
@@ -81,7 +81,7 @@ string CommandRegRead::helpString(const string &binaryBaseName) const
void CommandRegRead::execute(const StringVector &args)
{
SlaveList slaves;
ec_ioctl_slave_reg_t data;
ec_ioctl_slave_reg_t io;
stringstream strOffset, err;
const DataType *dataType = NULL;
@@ -93,9 +93,9 @@ void CommandRegRead::execute(const StringVector &args)
strOffset << args[0];
strOffset
>> resetiosflags(ios::basefield) // guess base from prefix
>> data.offset;
>> io.address;
if (strOffset.fail()) {
err << "Invalid offset '" << args[0] << "'!";
err << "Invalid address '" << args[0] << "'!";
throwInvalidUsageException(err);
}
@@ -104,18 +104,18 @@ void CommandRegRead::execute(const StringVector &args)
strLength << args[1];
strLength
>> resetiosflags(ios::basefield) // guess base from prefix
>> data.length;
>> io.size;
if (strLength.fail()) {
err << "Invalid length '" << args[1] << "'!";
err << "Invalid size '" << args[1] << "'!";
throwInvalidUsageException(err);
}
if (!data.length) {
if (!io.size) {
err << "Length may not be zero!";
throwInvalidUsageException(err);
}
} else { // no length argument given
data.length = 0;
} else { // no size argument given
io.size = 0;
}
if (!getDataType().empty()) {
@@ -125,22 +125,22 @@ void CommandRegRead::execute(const StringVector &args)
}
if (dataType->byteSize) {
// override length argument
data.length = dataType->byteSize;
// override size argument
io.size = dataType->byteSize;
}
}
if (!data.length) {
err << "The length argument is mandatory, if no datatype is " << endl
<< "specified, or the datatype does not imply a length!";
if (!io.size) {
err << "The size argument is mandatory, if no datatype is " << endl
<< "specified, or the datatype does not imply a size!";
throwInvalidUsageException(err);
}
if ((uint32_t) data.offset + data.length > 0xffff) {
err << "Offset and length exceeding 64k!";
if ((uint32_t) io.address + io.size > 0xffff) {
err << "Address and size exceeding 64k!";
throwInvalidUsageException(err);
}
MasterDevice m(getSingleMasterIndex());
m.open(MasterDevice::Read);
slaves = selectedSlaves(m);
@@ -148,25 +148,26 @@ void CommandRegRead::execute(const StringVector &args)
if (slaves.size() != 1) {
throwSingleSlaveRequired(slaves.size());
}
data.slave_position = slaves.front().position;
io.slave_position = slaves.front().position;
io.emergency = false;
data.data = new uint8_t[data.length];
io.data = new uint8_t[io.size];
try {
m.readReg(&data);
m.readReg(&io);
} catch (MasterDeviceException &e) {
delete [] data.data;
delete [] io.data;
throw e;
}
try {
outputData(cout, dataType, data.data, data.length);
outputData(cout, dataType, io.data, io.size);
} catch (SizeException &e) {
delete [] data.data;
delete [] io.data;
throwCommandException(e.what());
}
delete [] data.data;
delete [] io.data;
}
/*****************************************************************************/