Skip to content

Commit

Permalink
fix(cbus): fixed detection of monitored sal
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Jul 29, 2022
1 parent 8f8633a commit a82e700
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions plc4go/protocols/cbus/readwrite/model/EncodedReply.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,16 @@ void closestFitIsAStatusRequestButWeDonTHaveAnyBytesBeforeThat() throws Exceptio
assertMessageMatches(bytes, msg);
}

@Test
void ownSal() throws Exception {
byte[] bytes = "003809AF10\r\n".getBytes(StandardCharsets.UTF_8);
ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
cBusOptions = C_BUS_OPTIONS_WITH_SRCHK;
CBusMessage msg = CBusMessage.staticParse(readBufferByteBased, true, requestContext, cBusOptions);
assertThat(msg).isNotNull();
System.out.println(msg);
System.out.println(((ReplyEncodedReply) ((ReplyOrConfirmationReply) ((CBusMessageToClient) msg).getReply()).getReply()).getEncodedReply());

assertMessageMatches(bytes, msg);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@
[type EncodedReply(CBusOptions cBusOptions, RequestContext requestContext)
[peek byte peekedByte ]
// TODO: if we reliable can detect this with the mask we don't need the request context anymore
[virtual bit isMonitoredSAL '(peekedByte & 0x3F) == 0x05' ]
[virtual bit isMonitoredSAL '(peekedByte & 0x3F) == 0x05 || peekedByte == 0x00 || (peekedByte & 0xF8) == 0x00'] // First check if it is in long mode, second for short mode, third for bridged short mode
[virtual bit isCalCommand '(peekedByte & 0x3F) == 0x06 || requestContext.sendCalCommandBefore' ] // The 0x3F and 0x06 doesn't seem to work always
[virtual bit isStandardFormatStatus '(peekedByte & 0xC0) == 0xC0 && !cBusOptions.exstat' ]
[virtual bit isExtendedFormatStatus '(peekedByte & 0xE0) == 0xE0 && (cBusOptions.exstat || requestContext.sendStatusRequestLevelBefore)']
Expand Down

0 comments on commit a82e700

Please sign in to comment.