diff --git a/bau_systemB.cpp b/bau_systemB.cpp index 39cdb70..77d369c 100644 --- a/bau_systemB.cpp +++ b/bau_systemB.cpp @@ -92,6 +92,11 @@ void BauSystemB::readMemory() _memory.readMemory(); } +void BauSystemB::writeMemory() +{ + _memory.writeMemory(); +} + DeviceObject& BauSystemB::deviceObject() { return _deviceObj; diff --git a/bau_systemB.h b/bau_systemB.h index a3e430f..5d3f048 100644 --- a/bau_systemB.h +++ b/bau_systemB.h @@ -25,6 +25,7 @@ public: bool enabled(); void enabled(bool value); void readMemory(); + void writeMemory(); void addSaveRestore(SaveRestore* obj); protected: virtual DataLinkLayer& dataLinkLayer() = 0; diff --git a/bits.cpp b/bits.cpp index 774a48b..0c867ec 100644 --- a/bits.cpp +++ b/bits.cpp @@ -251,15 +251,4 @@ void println(void) printf("\n"); } -#endif - -void printHex(const char* suffix, const uint8_t *data, size_t length) -{ - _print(suffix); - for (size_t i = 0; i < length; i++) { - if (data[i] < 0x10) { _print("0"); } - _print(data[i], HEX); - _print(" "); - } - _print("\n"); -} \ No newline at end of file +#endif \ No newline at end of file diff --git a/group_object.cpp b/group_object.cpp index 3cff9eb..ba6a6ec 100644 --- a/group_object.cpp +++ b/group_object.cpp @@ -142,7 +142,7 @@ void GroupObject::commFlag(ComFlag value) _commFlag = value; } -int32_t GroupObject::objectReadFloat() +int32_t GroupObject::objectReadFloatDpt9() { uint16_t dptValue = getWord(_data); return dptFromFloat(dptValue); @@ -164,7 +164,7 @@ void GroupObject::objectWritten() } -void GroupObject::objectWriteFloat(int32_t value) +void GroupObject::objectWriteFloatDpt9(int32_t value) { uint16_t dptValue = dptToFloat(value); pushWord(dptValue, _data); @@ -172,7 +172,7 @@ void GroupObject::objectWriteFloat(int32_t value) } -void GroupObject::objectUpdateFloat(int32_t value) +void GroupObject::objectUpdateFloatDpt9(int32_t value) { uint16_t dptValue = dptToFloat(value); pushWord(dptValue, _data); @@ -189,3 +189,55 @@ size_t GroupObject::sizeInTelegram() uint8_t code = lowByte(ntohs(_table->_tableData[_asap])); return asapValueSize(code); } + + +void GroupObject::objectWrite(bool value) +{ + objectWrite((uint8_t)value); +} + + +void GroupObject::objectWrite(uint8_t value) +{ + pushByte(value, _data); + objectWritten(); +} + + +void GroupObject::objectWrite(uint16_t value) +{ + pushWord(value, _data); + objectWritten(); +} + + +void GroupObject::objectWrite(uint32_t value) +{ + pushInt(value, _data); + objectWritten(); +} + + +void GroupObject::objectWrite(int8_t value) +{ + objectWrite((uint8_t)value); +} + + +void GroupObject::objectWrite(int16_t value) +{ + objectWrite((uint16_t)value); +} + + +void GroupObject::objectWrite(int32_t value) +{ + objectWrite((uint32_t)value); +} + + +void GroupObject::objectWrite(float value) +{ + uint32_t tmp = value * 100; + objectWriteFloatDpt9(tmp); +} diff --git a/group_object.h b/group_object.h index 1f35b75..87248d2 100644 --- a/group_object.h +++ b/group_object.h @@ -45,7 +45,7 @@ public: * @return The value of the com-object in 1/100. INVALID_DPT_FLOAT is returned * for the DPT9 "invalid data" value. */ - int32_t objectReadFloat(); + int32_t objectReadFloatDpt9(); bool objectReadBool(); /** * Request the read of a communication object. Calling this function triggers the @@ -79,7 +79,15 @@ public: * @param value - the new value of the communication object in 1/100. * Use INVALID_DPT_FLOAT for the DPT9 "invalid data" value. */ - void objectWriteFloat(int32_t value); + void objectWriteFloatDpt9(int32_t value); + void objectWrite(bool value); + void objectWrite(uint8_t value); + void objectWrite(uint16_t value); + void objectWrite(uint32_t value); + void objectWrite(int8_t value); + void objectWrite(int16_t value); + void objectWrite(int32_t value); + void objectWrite(float value); /** * Set the value of a communication object and mark the communication object @@ -93,7 +101,7 @@ public: * @param value - the new value of the communication object in 1/100. * Use INVALID_DPT_FLOAT for the DPT9 "invalid data" value. */ - void objectUpdateFloat(int32_t value); + void objectUpdateFloatDpt9(int32_t value); size_t valueSize(); size_t asapValueSize(uint8_t code); diff --git a/ip_data_link_layer.cpp b/ip_data_link_layer.cpp index f5a261c..4d42c3b 100644 --- a/ip_data_link_layer.cpp +++ b/ip_data_link_layer.cpp @@ -72,6 +72,8 @@ void IpDataLinkLayer::loop() void IpDataLinkLayer::enabled(bool value) { + _print("own address: "); + _println(_deviceObject.induvidualAddress()); if (value && !_enabled) { _platform.setupMultiCast(_ipParameters.multicastAddress(), KNXIP_MULTICAST_PORT); diff --git a/memory.cpp b/memory.cpp index b7fb96d..975ecc0 100644 --- a/memory.cpp +++ b/memory.cpp @@ -18,7 +18,7 @@ void Memory::readMemory() { _data = _platform.getEepromBuffer(512); - if (_data[0] != 0xDE || _data[1] != 0xAD || _data[2] != 0xAF || _data[3] != 0xFE) + if (_data[0] != 0x00 || _data[1] != 0xAD || _data[2] != 0xAF || _data[3] != 0xFE) return; uint8_t* buffer = _data + 4; @@ -31,7 +31,7 @@ void Memory::readMemory() void Memory::writeMemory() { - _data[0] = 0xDE; + _data[0] = 0x00; _data[1] = 0xAD; _data[2] = 0xAF; _data[3] = 0xFE; diff --git a/table_object.cpp b/table_object.cpp index 8b25fee..eaa014f 100644 --- a/table_object.cpp +++ b/table_object.cpp @@ -123,6 +123,9 @@ bool TableObject::allocTable(uint32_t size, bool doFill, uint8_t fillByte) _size = 0; } + if (size == 0) + return true; + _data = (uint8_t*)malloc(size); if (!_data) return false;