1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

node-modbus: Improve _read and _write loop

Signed-off-by: Philipp Jungkamp <Philipp.Jungkamp@opal-rt.com>
This commit is contained in:
Philipp Jungkamp 2023-08-23 14:43:42 +02:00 committed by Steffen Vogel
parent a95c4af822
commit 2a82e7b388

View file

@ -514,11 +514,12 @@ int ModbusNode::_read(struct Sample *smps[], unsigned cnt)
for (unsigned int i = 0; i < cnt; ++i) {
auto smp = smps[i];
smp->length = num_in_signals;
smp->flags |= (int) SampleFlags::HAS_DATA;
assert(smp->length <= smp->capacity);
for (auto &mapping : in_mappings) {
smp->length = num_in_signals;
assert(smp->length <= smp->capacity);
if (auto ret = readBlock(mapping, smp->data, smp->length))
return ret;
}
@ -587,8 +588,9 @@ int ModbusNode::_write(struct Sample *smps[], unsigned cnt)
for (unsigned int i = 0; i < cnt; ++i) {
auto smp = smps[i];
assert(smp->length == num_out_signals);
for (auto &mapping : out_mappings) {
assert(smp->length == num_out_signals);
if (auto ret = writeBlock(mapping, smp->data, smp->length))
return ret;
}