Skip to content

Commit

Permalink
Check if slave part is available on match
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian S committed Jan 20, 2020
1 parent 54e4250 commit 416de2f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/main/java/de/csdev/ebus/command/EBusCommandRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,21 @@ public boolean matchesCommand(IEBusCommandMethod command, ByteBuffer data) {

int computedSlaveLen = EBusCommandUtils.getSlaveDataLength(command);
int slaveLenPos = masterTelegram.limit() + 1;
int slaveLen = data.get(slaveLenPos);

if (slaveLen != computedSlaveLen) {
if (logger.isTraceEnabled()) {
logger.trace("Skip matching command due to invalid response data length ... [{}]",
EBusCommandUtils.getFullId(command));
logger.trace("DATA: {}", EBusUtils.toHexDumpString(data));
}
// only check if the slave part is included in the data bytes
if (slaveLenPos <= data.limit()) {

return false;
int slaveLen = data.get(slaveLenPos);

if (slaveLen != computedSlaveLen) {
if (logger.isTraceEnabled()) {
logger.trace("Skip matching command due to invalid response data length ... [{}]",
EBusCommandUtils.getFullId(command));
logger.trace("DATA: {}", EBusUtils.toHexDumpString(data));
}

return false;
}
}

}
Expand Down

0 comments on commit 416de2f

Please sign in to comment.