Skip to content

Commit

Permalink
Merge pull request #101 from dvlemplgk/module-read
Browse files Browse the repository at this point in the history
ModuleRead: add plausibility check for CNF MMEs
  • Loading branch information
ch-aurich authored Dec 13, 2017
2 parents 2208779 + 0b12291 commit e5b3663
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions plc/ModuleRead.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,16 @@ signed ModuleRead (struct plc * plc, struct _file_ * file, uint16_t source, uint
return (-1);
}
channel->timeout = PLC_MODULE_READ_TIMEOUT;
if (ReadMME (plc, 0, (VS_MODULE_OPERATION | MMTYPE_CNF)) <= 0)
{
error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD);
return (-1);
}
do {
if (ReadMME (plc, 0, (VS_MODULE_OPERATION | MMTYPE_CNF)) <= 0)
{
error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD);
return (-1);
}
} while (confirm->MODULE_SPEC.MOD_OP != HTOLE16 (source) ||
confirm->MODULE_SPEC.MODULE_ID != HTOLE16 (module) ||
confirm->MODULE_SPEC.MODULE_SUB_ID != HTOLE16 (submodule) ||
confirm->MODULE_SPEC.MODULE_OFFSET != HTOLE32 (offset));
channel->timeout = timer;

#if 0
Expand Down

0 comments on commit e5b3663

Please sign in to comment.