remove unnecessary union, initialize all fields of dtlf_t
This commit is contained in:
@@ -311,14 +311,14 @@ result_t getFieldLength(const SingleDataField *field, dtlf_t *length) {
|
|||||||
// adjust bit count for non-existent 24 bit KNX type
|
// adjust bit count for non-existent 24 bit KNX type
|
||||||
bitCnt = 32;
|
bitCnt = 32;
|
||||||
}
|
}
|
||||||
*length = {{
|
*length = {
|
||||||
.hasDivisor = nt->getDivisor() != 1,
|
.hasDivisor = nt->getDivisor() != 1,
|
||||||
.isFloat = dt->hasFlag(EXP),
|
.isFloat = dt->hasFlag(EXP),
|
||||||
.isSigned = dt->hasFlag(SIG),
|
.isSigned = dt->hasFlag(SIG),
|
||||||
.lastValueSent = false,
|
.lastValueSent = false,
|
||||||
.length = static_cast<uint8_t>(bitCnt/8),
|
.length = static_cast<uint8_t>(bitCnt/8),
|
||||||
.lastValue = 0,
|
.lastValue = 0,
|
||||||
}};
|
};
|
||||||
return RESULT_OK;
|
return RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,20 +82,17 @@ enum apci_t {
|
|||||||
#define FLAG_WRITE 0x800000
|
#define FLAG_WRITE 0x800000
|
||||||
|
|
||||||
/** datatype length flags (byte length on KNX in bits 0-3, extra info in higher bits). */
|
/** datatype length flags (byte length on KNX in bits 0-3, extra info in higher bits). */
|
||||||
typedef union {
|
typedef struct {
|
||||||
struct {
|
|
||||||
bool hasDivisor: 1;
|
bool hasDivisor: 1;
|
||||||
bool isFloat: 1;
|
bool isFloat: 1;
|
||||||
bool isSigned: 1;
|
bool isSigned: 1;
|
||||||
bool lastValueSent: 1;
|
bool lastValueSent: 1;
|
||||||
uint8_t length; // 0 for 1-6 bits, number of bytes otherwise
|
uint8_t length; // 0 for 1-6 bits, number of bytes otherwise
|
||||||
uint32_t lastValue;
|
uint32_t lastValue;
|
||||||
};
|
|
||||||
uint64_t value;
|
|
||||||
} dtlf_t;
|
} dtlf_t;
|
||||||
|
|
||||||
#define DTLF_1BIT dtlf_t{.length = 0}
|
#define DTLF_1BIT dtlf_t{.hasDivisor = false, .isFloat = false, .isSigned = false, .lastValueSent = false, .length = 0, .lastValue = 0}
|
||||||
#define DTLF_8BIT dtlf_t{.length = 1}
|
#define DTLF_8BIT dtlf_t{.hasDivisor = false, .isFloat = false, .isSigned = false, .lastValueSent = false, .length = 1, .lastValue = 0}
|
||||||
|
|
||||||
/** type for global values not associated with an ebus message. */
|
/** type for global values not associated with an ebus message. */
|
||||||
enum global_t {
|
enum global_t {
|
||||||
|
|||||||
Reference in New Issue
Block a user