serveral small things

This commit is contained in:
Thomas Kunze 2018-09-15 00:21:25 +02:00
parent f50f03ad6e
commit fd2334a4af
8 changed files with 80 additions and 20 deletions

View File

@ -92,6 +92,11 @@ void BauSystemB::readMemory()
_memory.readMemory(); _memory.readMemory();
} }
void BauSystemB::writeMemory()
{
_memory.writeMemory();
}
DeviceObject& BauSystemB::deviceObject() DeviceObject& BauSystemB::deviceObject()
{ {
return _deviceObj; return _deviceObj;

View File

@ -25,6 +25,7 @@ public:
bool enabled(); bool enabled();
void enabled(bool value); void enabled(bool value);
void readMemory(); void readMemory();
void writeMemory();
void addSaveRestore(SaveRestore* obj); void addSaveRestore(SaveRestore* obj);
protected: protected:
virtual DataLinkLayer& dataLinkLayer() = 0; virtual DataLinkLayer& dataLinkLayer() = 0;

View File

@ -252,14 +252,3 @@ void println(void)
} }
#endif #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");
}

View File

@ -142,7 +142,7 @@ void GroupObject::commFlag(ComFlag value)
_commFlag = value; _commFlag = value;
} }
int32_t GroupObject::objectReadFloat() int32_t GroupObject::objectReadFloatDpt9()
{ {
uint16_t dptValue = getWord(_data); uint16_t dptValue = getWord(_data);
return dptFromFloat(dptValue); 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); uint16_t dptValue = dptToFloat(value);
pushWord(dptValue, _data); 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); uint16_t dptValue = dptToFloat(value);
pushWord(dptValue, _data); pushWord(dptValue, _data);
@ -189,3 +189,55 @@ size_t GroupObject::sizeInTelegram()
uint8_t code = lowByte(ntohs(_table->_tableData[_asap])); uint8_t code = lowByte(ntohs(_table->_tableData[_asap]));
return asapValueSize(code); 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);
}

View File

@ -45,7 +45,7 @@ public:
* @return The value of the com-object in 1/100. INVALID_DPT_FLOAT is returned * @return The value of the com-object in 1/100. INVALID_DPT_FLOAT is returned
* for the DPT9 "invalid data" value. * for the DPT9 "invalid data" value.
*/ */
int32_t objectReadFloat(); int32_t objectReadFloatDpt9();
bool objectReadBool(); bool objectReadBool();
/** /**
* Request the read of a communication object. Calling this function triggers the * 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. * @param value - the new value of the communication object in 1/100.
* Use INVALID_DPT_FLOAT for the DPT9 "invalid data" value. * 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 * 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. * @param value - the new value of the communication object in 1/100.
* Use INVALID_DPT_FLOAT for the DPT9 "invalid data" value. * 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 valueSize();
size_t asapValueSize(uint8_t code); size_t asapValueSize(uint8_t code);

View File

@ -72,6 +72,8 @@ void IpDataLinkLayer::loop()
void IpDataLinkLayer::enabled(bool value) void IpDataLinkLayer::enabled(bool value)
{ {
_print("own address: ");
_println(_deviceObject.induvidualAddress());
if (value && !_enabled) if (value && !_enabled)
{ {
_platform.setupMultiCast(_ipParameters.multicastAddress(), KNXIP_MULTICAST_PORT); _platform.setupMultiCast(_ipParameters.multicastAddress(), KNXIP_MULTICAST_PORT);

View File

@ -18,7 +18,7 @@ void Memory::readMemory()
{ {
_data = _platform.getEepromBuffer(512); _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; return;
uint8_t* buffer = _data + 4; uint8_t* buffer = _data + 4;
@ -31,7 +31,7 @@ void Memory::readMemory()
void Memory::writeMemory() void Memory::writeMemory()
{ {
_data[0] = 0xDE; _data[0] = 0x00;
_data[1] = 0xAD; _data[1] = 0xAD;
_data[2] = 0xAF; _data[2] = 0xAF;
_data[3] = 0xFE; _data[3] = 0xFE;

View File

@ -123,6 +123,9 @@ bool TableObject::allocTable(uint32_t size, bool doFill, uint8_t fillByte)
_size = 0; _size = 0;
} }
if (size == 0)
return true;
_data = (uint8_t*)malloc(size); _data = (uint8_t*)malloc(size);
if (!_data) if (!_data)
return false; return false;