Bugfix/read range trend log buffer (#947)
* Fixed ReadRange app to read and pretty-print a Trend Log log-buffer
This commit is contained in:
+39
-5
@@ -1274,6 +1274,41 @@ int bacnet_boolean_application_decode(
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode a context boolean value.
|
||||
* @param apdu Pointer to the encode buffer.
|
||||
* @param apdu_size Number of bytes in the buffer.
|
||||
* @param boolean_value Pointer to a boolean variable
|
||||
* @note The Boolean datatype differs from the other datatypes
|
||||
* in that the encoding of a context-tagged Boolean value is not the
|
||||
* same as the encoding of an application-tagged Boolean value.
|
||||
* This is done so that the application-tagged value may be encoded
|
||||
* in a single octet, without a contents octet. While this same encoding
|
||||
* could have been used for the context-tagged case, doing
|
||||
* so would require that the context be known in order to distinguish
|
||||
* between a length or a value in the length/value/type field.
|
||||
* This was considered to be undesirable.
|
||||
* @return number of bytes decoded, or 0 if errors occur
|
||||
*/
|
||||
int bacnet_boolean_context_value_decode(
|
||||
const uint8_t *apdu, uint32_t apdu_size, bool *boolean_value)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
if (apdu && (apdu_size > 0)) {
|
||||
if (boolean_value) {
|
||||
if (apdu[0]) {
|
||||
*boolean_value = true;
|
||||
} else {
|
||||
*boolean_value = false;
|
||||
}
|
||||
}
|
||||
len = 1;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode the Boolean Value when context encoded
|
||||
* From clause 20.2.3 Encoding of a Boolean Value
|
||||
@@ -1314,11 +1349,10 @@ int bacnet_boolean_context_decode(
|
||||
if (len > 0) {
|
||||
if (tag.context && (tag.number == tag_value)) {
|
||||
apdu_len = len;
|
||||
if (apdu_len < apdu_size) {
|
||||
if (boolean_value) {
|
||||
*boolean_value = decode_context_boolean(&apdu[apdu_len]);
|
||||
}
|
||||
apdu_len++;
|
||||
len = bacnet_boolean_context_value_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, boolean_value);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
apdu_len = BACNET_STATUS_ERROR;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user