mirror of
https://gitlab.com/etherlab.org/ethercat.git
synced 2026-08-18 17:17:23 +08:00
Implemented SoE write state machine and soe_write command.
This commit is contained in:
+12
-12
@@ -74,7 +74,7 @@ void CommandSoeRead::execute(const StringVector &args)
|
||||
SlaveList slaves;
|
||||
stringstream err, strIdn;
|
||||
const DataType *dataType = NULL;
|
||||
ec_ioctl_slave_soe_t data;
|
||||
ec_ioctl_slave_soe_read_t ioctl;
|
||||
|
||||
if (args.size() != 1) {
|
||||
err << "'" << getName() << "' takes one argument!";
|
||||
@@ -84,7 +84,7 @@ void CommandSoeRead::execute(const StringVector &args)
|
||||
strIdn << args[0];
|
||||
strIdn
|
||||
>> resetiosflags(ios::basefield) // guess base from prefix
|
||||
>> data.idn;
|
||||
>> ioctl.idn;
|
||||
if (strIdn.fail()) {
|
||||
err << "Invalid IDN '" << args[0] << "'!";
|
||||
throwInvalidUsageException(err);
|
||||
@@ -100,7 +100,7 @@ void CommandSoeRead::execute(const StringVector &args)
|
||||
if (slaves.size() != 1) {
|
||||
throwSingleSlaveRequired(slaves.size());
|
||||
}
|
||||
data.slave_position = slaves.front().position;
|
||||
ioctl.slave_position = slaves.front().position;
|
||||
|
||||
if (getDataType().empty()) {
|
||||
dataType = findDataType("raw"); // FIXME
|
||||
@@ -112,35 +112,35 @@ void CommandSoeRead::execute(const StringVector &args)
|
||||
}
|
||||
|
||||
if (dataType->byteSize) {
|
||||
data.mem_size = dataType->byteSize;
|
||||
ioctl.mem_size = dataType->byteSize;
|
||||
} else {
|
||||
data.mem_size = 1024;
|
||||
ioctl.mem_size = 1024;
|
||||
}
|
||||
|
||||
data.data = new uint8_t[data.mem_size + 1];
|
||||
ioctl.data = new uint8_t[ioctl.mem_size + 1];
|
||||
|
||||
try {
|
||||
m.readSoe(&data);
|
||||
m.readSoe(&ioctl);
|
||||
} catch (MasterDeviceSoeException &e) {
|
||||
delete [] data.data;
|
||||
delete [] ioctl.data;
|
||||
err << "SoE read command aborted with code 0x"
|
||||
<< setfill('0') << hex << setw(4) << e.errorCode;
|
||||
throwCommandException(err);
|
||||
} catch (MasterDeviceException &e) {
|
||||
delete [] data.data;
|
||||
delete [] ioctl.data;
|
||||
throw e;
|
||||
}
|
||||
|
||||
m.close();
|
||||
|
||||
try {
|
||||
outputData(cout, dataType, data.data, data.data_size);
|
||||
outputData(cout, dataType, ioctl.data, ioctl.data_size);
|
||||
} catch (SizeException &e) {
|
||||
delete [] data.data;
|
||||
delete [] ioctl.data;
|
||||
throwCommandException(e.what());
|
||||
}
|
||||
|
||||
delete [] data.data;
|
||||
delete [] ioctl.data;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user