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();
}
void BauSystemB::writeMemory()
{
_memory.writeMemory();
}
DeviceObject& BauSystemB::deviceObject()
{
return _deviceObj;

View File

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

View File

@ -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");
}
#endif

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;