Bugfix/bacnet real endian simplify (#89)
* Remove dependence on endian define * Make use of existing big_endian function if BACNET_BIG_ENDIAN is not defined * Add efficient endian macro option if available Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
@@ -2023,6 +2023,20 @@ int encode_context_real(uint8_t *apdu, uint8_t tag_number, float value)
|
||||
return len;
|
||||
}
|
||||
|
||||
int decode_context_real(uint8_t *apdu, uint8_t tag_number, float *real_value)
|
||||
{
|
||||
uint32_t len_value;
|
||||
int len = 0;
|
||||
|
||||
if (decode_is_context_tag(&apdu[len], tag_number)) {
|
||||
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
len += decode_real(&apdu[len], real_value);
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
#if BACNET_USE_DOUBLE
|
||||
/* from clause 20.2.7 Encoding of a Double Precision Real Number Value */
|
||||
/* and 20.2.1 General Rules for Encoding BACnet Tags */
|
||||
@@ -2050,6 +2064,20 @@ int encode_context_double(uint8_t *apdu, uint8_t tag_number, double value)
|
||||
|
||||
return len;
|
||||
}
|
||||
int decode_context_double(
|
||||
uint8_t *apdu, uint8_t tag_number, double *double_value)
|
||||
{
|
||||
uint32_t len_value;
|
||||
int len = 0;
|
||||
|
||||
if (decode_is_context_tag(&apdu[len], tag_number)) {
|
||||
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
len += decode_double(&apdu[len], double_value);
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* from clause 20.2.13 Encoding of a Time Value */
|
||||
|
||||
Reference in New Issue
Block a user