move uninitialzed out of ComFlagEx enum

This commit is contained in:
Thomas Kunze 2024-08-09 22:37:58 +02:00
parent 1ba39e207f
commit e988c431fd
2 changed files with 11 additions and 20 deletions

View File

@ -12,8 +12,8 @@ GroupObjectTableObject* GroupObject::_table = 0;
GroupObject::GroupObject() GroupObject::GroupObject()
{ {
_data = 0; _data = 0;
_commFlagEx.uninitialized = true; _uninitialized = true;
_commFlagEx.commFlag = Uninitialized; _commFlag = Uninitialized;
_dataLength = 0; _dataLength = 0;
#ifndef SMALL_GROUPOBJECT #ifndef SMALL_GROUPOBJECT
_updateHandler = 0; _updateHandler = 0;
@ -64,7 +64,7 @@ bool GroupObject::readEnable()
return false; return false;
// we forbid reading of new (uninitialized) go // we forbid reading of new (uninitialized) go
if (_commFlagEx.uninitialized) if (_uninitialized)
return false; return false;
return bitRead(ntohs(_table->_tableData[_asap]), 11) > 0; return bitRead(ntohs(_table->_tableData[_asap]), 11) > 0;
@ -161,20 +161,20 @@ size_t GroupObject::asapValueSize(uint8_t code) const
ComFlag GroupObject::commFlag() ComFlag GroupObject::commFlag()
{ {
return _commFlagEx.commFlag; return _commFlag;
} }
void GroupObject::commFlag(ComFlag value) void GroupObject::commFlag(ComFlag value)
{ {
_commFlagEx.commFlag = value; _commFlag = value;
if (value == WriteRequest || value == Updated || value == Ok) if (value == WriteRequest || value == Updated || value == Ok)
_commFlagEx.uninitialized = false; _uninitialized = false;
} }
bool GroupObject::initialized() bool GroupObject::initialized()
{ {
return !_commFlagEx.uninitialized; return !_uninitialized;
} }
void GroupObject::requestObjectRead() void GroupObject::requestObjectRead()
@ -300,7 +300,7 @@ void GroupObject::valueNoSend(const KNXValue& value)
void GroupObject::valueNoSend(const KNXValue& value, const Dpt& type) void GroupObject::valueNoSend(const KNXValue& value, const Dpt& type)
{ {
if (_commFlagEx.uninitialized) if (_uninitialized)
commFlag(Ok); commFlag(Ok);
KNX_Encode_Value(value, _data, _dataLength, type); KNX_Encode_Value(value, _data, _dataLength, type);
@ -308,7 +308,7 @@ void GroupObject::valueNoSend(const KNXValue& value, const Dpt& type)
bool GroupObject::valueNoSendCompare(const KNXValue& value, const Dpt& type) bool GroupObject::valueNoSendCompare(const KNXValue& value, const Dpt& type)
{ {
if (_commFlagEx.uninitialized) if (_uninitialized)
{ {
// always set first value // always set first value
this->valueNoSend(value, type); this->valueNoSend(value, type);

View File

@ -18,16 +18,6 @@ enum ComFlag : uint8_t
Uninitialized = 6 //!< uninitialized Group Object, its value is not valid Uninitialized = 6 //!< uninitialized Group Object, its value is not valid
}; };
// extended ComFlag: Uninitialized it not handled correctly as ComFlag
// it might be in state Transmitting during a ReadRequest on startup while value is still not valid
// we use MSB to store Uninitialized and keep the size of GroupObject the same saving memory ressources
// the old Uninitialized handling is still there for compatibility reasons.
struct ComFlagEx
{
bool uninitialized : 1;
ComFlag commFlag : 7;
};
class GroupObject; class GroupObject;
#ifndef HAS_FUNCTIONAL #ifndef HAS_FUNCTIONAL
@ -278,7 +268,8 @@ class GroupObject
size_t asapValueSize(uint8_t code) const; size_t asapValueSize(uint8_t code) const;
size_t goSize(); size_t goSize();
uint16_t _asap = 0; uint16_t _asap = 0;
ComFlagEx _commFlagEx; bool _uninitialized : 1;
ComFlag _commFlag : 7;
uint8_t* _data = 0; uint8_t* _data = 0;
uint8_t _dataLength = 0; uint8_t _dataLength = 0;
#ifndef SMALL_GROUPOBJECT #ifndef SMALL_GROUPOBJECT