mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-26 22:37:00 +02:00
in a fixed size array with an unitialized union type a uint64_t value can have a default value
This commit is contained in:
parent
04db808920
commit
9073d2a82c
2 changed files with 4 additions and 1 deletions
|
@ -80,6 +80,7 @@ class Inverter {
|
||||||
RECORDTYPE *record; // pointer for values
|
RECORDTYPE *record; // pointer for values
|
||||||
uint16_t chMaxPwr[4]; // maximum power of the modules (Wp)
|
uint16_t chMaxPwr[4]; // maximum power of the modules (Wp)
|
||||||
char chName[4][MAX_NAME_LENGTH]; // human readable name for channel
|
char chName[4][MAX_NAME_LENGTH]; // human readable name for channel
|
||||||
|
bool initialized; // needed to check if the inverter was correctly added (ESP32 specific - union types are never null)
|
||||||
|
|
||||||
Inverter() {
|
Inverter() {
|
||||||
ts = 0;
|
ts = 0;
|
||||||
|
@ -87,6 +88,7 @@ class Inverter {
|
||||||
powerLimit[1] = 0x0000; //
|
powerLimit[1] = 0x0000; //
|
||||||
devControlRequest = false;
|
devControlRequest = false;
|
||||||
devControlCmd = 0xff;
|
devControlCmd = 0xff;
|
||||||
|
initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
~Inverter() {
|
~Inverter() {
|
||||||
|
@ -101,6 +103,7 @@ class Inverter {
|
||||||
memset(name, 0, MAX_NAME_LENGTH);
|
memset(name, 0, MAX_NAME_LENGTH);
|
||||||
memset(chName, 0, MAX_NAME_LENGTH * 4);
|
memset(chName, 0, MAX_NAME_LENGTH * 4);
|
||||||
memset(record, 0, sizeof(RECORDTYPE) * listLen);
|
memset(record, 0, sizeof(RECORDTYPE) * listLen);
|
||||||
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getPosByChFld(uint8_t channel, uint8_t fieldId) {
|
uint8_t getPosByChFld(uint8_t channel, uint8_t fieldId) {
|
||||||
|
|
|
@ -91,7 +91,7 @@ class HmSystem {
|
||||||
|
|
||||||
INVERTERTYPE *getInverterByPos(uint8_t pos, bool check = true) {
|
INVERTERTYPE *getInverterByPos(uint8_t pos, bool check = true) {
|
||||||
DPRINTLN(DBG_VERBOSE, F("hmSystem.h:getInverterByPos"));
|
DPRINTLN(DBG_VERBOSE, F("hmSystem.h:getInverterByPos"));
|
||||||
if((mInverter[pos].serial.u64 != 0ULL) || false == check)
|
if((mInverter[pos].initialized && mInverter[pos].serial.u64 != 0ULL) || false == check)
|
||||||
return &mInverter[pos];
|
return &mInverter[pos];
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue