diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..e6dd111
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,27 @@
+#Generated from Visual Studio settings
+---
+BasedOnStyle: llvm
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: true
+ AfterStruct: true
+ AfterUnion: true
+ BeforeCatch: true
+ BeforeElse: true
+ SplitEmptyFunction: false
+ IndentBraces: false
+BreakBeforeBraces: Custom
+ColumnLimit: 0
+IndentWidth: 4
+NamespaceIndentation: All
+TabWidth: 4
+DerivePointerAlignment: true
+IndentCaseLabels: true
+AllowShortFunctionsOnASingleLine: InlineOnly
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+UseTab: Never
+...
diff --git a/knx-linux/ClassDiagram.cd b/knx-linux/ClassDiagram.cd
deleted file mode 100644
index 3781e62..0000000
--- a/knx-linux/ClassDiagram.cd
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-
-
-
- AIAAAAEAAACAAAIAgCAAAAAgABAEAAgAAAAQQABAAAA=
- C:\Users\tkunze\Source\knx\src\knx\application_program_object.h
-
-
-
-
-
- AAAAAAEAAACAAgIAABAAQAgAAAEAAAgAAAAAAABAAEA=
- C:\Users\tkunze\Source\knx\src\knx\association_table_object.h
-
-
-
-
-
- AAACACEAAAGCIAKAQCAgAACgCECAAEogAEgIAgJAAAA=
- C:\Users\tkunze\Source\knx\src\knx\device_object.h
-
-
-
-
-
- EAAAAEEACACAAgIAAhAATAgACAAAAAggAAAAAABAAAA=
- C:\Users\tkunze\Source\knx\src\knx\group_object_table_object.h
-
-
-
-
-
- AAAAAAEAAAAAAAAAACAAAAAgAAAAAAgAAAAIABBAAAA=
- C:\Users\tkunze\Source\knx\src\knx\interface_object.h
-
-
-
-
-
- AAIACIEAYACAAKIAAGAQCAAgWAIAAAgGAAAAAABgAIA=
- C:\Users\tkunze\Source\knx\src\knx\ip_parameter_object.h
-
-
-
-
-
- AAIACIACBACAAIIAAGAACAgwyAAAAAAAAgAAAAJgAAA=
- C:\Users\tkunze\Source\knx\src\knx\table_object.h
-
-
-
-
-
- sKoIAAAAQIIxC4gUUEAIAAACiQEgAjQUFCCA5yEAIBw=
- C:\Users\tkunze\Source\knx\src\knx\bau.h
-
-
-
-
-
- AAACAAAAAIAAAABAAgAAAAAAAAAgAAAAACAAAAAAAAg=
- C:\Users\tkunze\Source\knx\src\knx\bau57B0.h
-
-
-
-
-
- BACGJBAAIigAIHgAAABAghAQAAAAACgAAADAEgAAAjA=
- C:\Users\tkunze\Source\knx\src\linux_platform.h
-
-
-
-
-
- AAAGJBAAICgAIFAAAABAwhAAABAAAAgAAADAEgAAAhA=
- C:\Users\tkunze\Source\knx\src\knx\platform.h
-
-
-
-
-
- ABIAAFQgAoJwCoBAUCiCAIDAiEBgADQQAIAAAAKQABQ=
- C:\Users\tkunze\Source\knx\src\knx\bau_systemB.h
-
-
-
-
-
- AAACAAAAAIBAAABAAAAAAAAAAAAgAAAAACAAAAAAAAA=
- C:\Users\tkunze\Source\knx\src\knx\bau07B0.h
-
-
-
-
\ No newline at end of file
diff --git a/knx-linux/knx-linux-Debug.vgdbsettings b/knx-linux/knx-linux-Debug.vgdbsettings
index f447f83..dd1cd88 100644
--- a/knx-linux/knx-linux-Debug.vgdbsettings
+++ b/knx-linux/knx-linux-Debug.vgdbsettings
@@ -7,9 +7,9 @@
RemoteUnix
- localhost
- LinuxSubsystem
- Linux
+ Suzail
+ SSH
+ tkunze
false
@@ -34,15 +34,14 @@
CMakeLists.txt
*.cmake
- true
+ false
true
-
true
true
Outgoing
false
- LocalCache
+ Always
false
@@ -115,12 +114,13 @@
true
true
- Disabled
+ Silent
true
true
true
true
+ ..\.clang-format
ClangFormat
diff --git a/knx-linux/knx-linux-Release.vgdbsettings b/knx-linux/knx-linux-Release.vgdbsettings
deleted file mode 100644
index 3fbda9e..0000000
--- a/knx-linux/knx-linux-Release.vgdbsettings
+++ /dev/null
@@ -1,160 +0,0 @@
-
-
- Release
-
-
-
- RemoteUnix
-
-
- Suzail
- SSH
- tkunze
-
-
- false
-
- Suzail
- SSH
- tkunze
-
- $(ProjectDir)
- /home/tkunze/vgdb
-
- *.cpp
- *.h
- *.hpp
- *.c
- *.cc
- *.cxx
- *.mak
- Makefile
- *.txt
- *.cmake
- CMakeLists.txt
- *.cmake
-
- true
- true
- true
- true
-
- false
- false
- false
- false
- false
- $(ProjectDir)
-
-
-
- com.sysprogs.toolchain.default-gcc
-
- 0
-
-
-
- RELWITHDEBINFO
- Release
-
- false
-
- BuildMachine
- BuiltinShortcut
-
- $(ToolchainMake)
- $(ToolchainMakeArgs)
- $(BuildDir)
-
-
-
- false
-
- BuildMachine
- BuiltinShortcut
-
- $(ToolchainCMake)
-
-
- true
- false
- false
- false
- b
-
-
-
-
-
-
-
-
-
-
-
-
- Default
-
-
-
- true
-
-
-
- Unknown
-
- true
- true
- true
-
-
-
- false
-
-
-
-
-
-
- false
- false
- false
- false
- false
- false
- false
- false
- false
-
- false
- false
- false
- false
- false
- false
- true
- false
- None
- false
- false
- main
- true
- false
- false
- false
- 0
-
-
- $(TargetPath)
- 2000
-
-
- false
- Local
- false
- false
- Auto
- true
- false
-
-
\ No newline at end of file
diff --git a/knx-linux/knx-linux.vcxproj b/knx-linux/knx-linux.vcxproj
index 87f4d0f..928a1c1 100644
--- a/knx-linux/knx-linux.vcxproj
+++ b/knx-linux/knx-linux.vcxproj
@@ -110,10 +110,8 @@
-
-
diff --git a/knx-linux/knx-linux.vcxproj.filters b/knx-linux/knx-linux.vcxproj.filters
index 207d5cb..f4fef6b 100644
--- a/knx-linux/knx-linux.vcxproj.filters
+++ b/knx-linux/knx-linux.vcxproj.filters
@@ -30,10 +30,6 @@
VisualGDB settings
-
- VisualGDB settings
-
-
diff --git a/knx-linux/main.cpp b/knx-linux/main.cpp
index 828e31b..e84b3c6 100644
--- a/knx-linux/main.cpp
+++ b/knx-linux/main.cpp
@@ -25,8 +25,10 @@ void measureTemp()
lastsend = now;
int r = rand();
double currentValue = (r * 1.0) / (RAND_MAX * 1.0);
- currentValue *= (670433.28 + 273);
- currentValue -= 273;
+ currentValue *= 100;
+ currentValue -= 50;
+ // currentValue *= (670433.28 + 273);
+ // currentValue -= 273;
println(currentValue);
CURR.value(currentValue);
diff --git a/src/knx/address_table_object.h b/src/knx/address_table_object.h
index c589843..28ce2bc 100644
--- a/src/knx/address_table_object.h
+++ b/src/knx/address_table_object.h
@@ -9,18 +9,18 @@
* See section 4.10 of @cite knx:3/5/1 for further details.
* It implements realisation type 7 (see section 4.10.7 of @cite knx:3/5/1).
*/
-class AddressTableObject: public TableObject
+class AddressTableObject : public TableObject
{
-public:
+ public:
/**
* The contructor.
*
* @param platform This parameter is only passed to the custructor of TableObject an not used by this class.
*/
AddressTableObject(Platform& platform);
- void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t *data);
- uint8_t *save(uint8_t *buffer);
- uint8_t *restore(uint8_t *buffer);
+ void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
+ uint8_t* save(uint8_t* buffer);
+ uint8_t* restore(uint8_t* buffer);
/**
* returns the number of group addresses of the object.
*/
@@ -49,10 +49,12 @@ public:
* @return true if the address table contains the group address, false otherwise
*/
bool contains(uint16_t groupAddress);
-protected:
+
+ protected:
virtual void beforeStateChange(LoadState& newState);
uint8_t propertyCount();
PropertyDescription* propertyDescriptions();
-private:
- uint16_t* _groupAddresses;
+
+ private:
+ uint16_t* _groupAddresses = 0;
};
diff --git a/src/knx/apdu.h b/src/knx/apdu.h
index 6322579..4b9fcf2 100644
--- a/src/knx/apdu.h
+++ b/src/knx/apdu.h
@@ -48,6 +48,6 @@ class APDU
APDU(uint8_t* data, CemiFrame& frame);
private:
- uint8_t* _data;
+ uint8_t* _data = 0;
CemiFrame& _frame;
};
\ No newline at end of file
diff --git a/src/knx/application_layer.h b/src/knx/application_layer.h
index 46311a4..7af7262 100644
--- a/src/knx/application_layer.h
+++ b/src/knx/application_layer.h
@@ -146,6 +146,6 @@ class ApplicationLayer
uint16_t _savedAsapResponse;
AssociationTableObject& _assocTable;
BusAccessUnit& _bau;
- TransportLayer* _transportLayer;
+ TransportLayer* _transportLayer = 0;
int32_t _connectedTsap;
};
diff --git a/src/knx/application_program_object.h b/src/knx/application_program_object.h
index 22d8b3a..e7ac83f 100644
--- a/src/knx/application_program_object.h
+++ b/src/knx/application_program_object.h
@@ -2,9 +2,9 @@
#include "table_object.h"
-class ApplicationProgramObject: public TableObject
+class ApplicationProgramObject : public TableObject
{
-public:
+ public:
ApplicationProgramObject(Platform& platform);
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count);
@@ -15,9 +15,11 @@ public:
uint32_t getInt(uint32_t addr);
uint8_t* save(uint8_t* buffer);
uint8_t* restore(uint8_t* buffer);
-protected:
+
+ protected:
uint8_t propertyCount();
PropertyDescription* propertyDescriptions();
-private:
- uint8_t _programVersion[5];
+
+ private:
+ uint8_t _programVersion[5] = {0, 0, 0, 0, 0};
};
\ No newline at end of file
diff --git a/src/knx/association_table_object.h b/src/knx/association_table_object.h
index 80a133d..0021046 100644
--- a/src/knx/association_table_object.h
+++ b/src/knx/association_table_object.h
@@ -2,9 +2,9 @@
#include "table_object.h"
-class AssociationTableObject: public TableObject
+class AssociationTableObject : public TableObject
{
-public:
+ public:
AssociationTableObject(Platform& platform);
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
uint16_t entryCount();
@@ -13,10 +13,12 @@ public:
uint8_t* restore(uint8_t* buffer);
int32_t translateAsap(uint16_t asap);
-protected:
+
+ protected:
void beforeStateChange(LoadState& newState);
uint8_t propertyCount();
PropertyDescription* propertyDescriptions();
-private:
- uint16_t* _tableData;
+
+ private:
+ uint16_t* _tableData = 0;
};
\ No newline at end of file
diff --git a/src/knx/bau.h b/src/knx/bau.h
index 6753064..a6cbd8d 100644
--- a/src/knx/bau.h
+++ b/src/knx/bau.h
@@ -4,107 +4,107 @@
class BusAccessUnit
{
-public:
+ public:
virtual void groupValueReadLocalConfirm(AckType ack, uint16_t asap, Priority priority, HopCountType hopType, bool status);
virtual void groupValueReadIndication(uint16_t asap, Priority priority, HopCountType hopType);
virtual void groupValueReadResponseConfirm(AckType ack, uint16_t asap, Priority priority, HopCountType hopTtype,
- uint8_t* data, uint8_t dataLength, bool status);
+ uint8_t* data, uint8_t dataLength, bool status);
virtual void groupValueReadAppLayerConfirm(uint16_t asap, Priority priority, HopCountType hopType,
- uint8_t* data, uint8_t dataLength);
+ uint8_t* data, uint8_t dataLength);
virtual void groupValueWriteLocalConfirm(AckType ack, uint16_t asap, Priority priority, HopCountType hopType,
- uint8_t* data, uint8_t dataLength, bool status);
+ uint8_t* data, uint8_t dataLength, bool status);
virtual void groupValueWriteIndication(uint16_t asap, Priority priority, HopCountType hopType,
- uint8_t* data, uint8_t dataLength);
+ uint8_t* data, uint8_t dataLength);
virtual void individualAddressWriteLocalConfirm(AckType ack, HopCountType hopType,
- uint16_t newaddress, bool status);
+ uint16_t newaddress, bool status);
virtual void individualAddressWriteIndication(HopCountType hopType, uint16_t newaddress);
virtual void individualAddressReadLocalConfirm(AckType ack, HopCountType hopType, bool status);
virtual void individualAddressReadIndication(HopCountType hopType);
virtual void individualAddressReadResponseConfirm(AckType ack, HopCountType hopType, bool status);
virtual void individualAddressReadAppLayerConfirm(HopCountType hopType, uint16_t individualAddress);
virtual void individualAddressSerialNumberReadLocalConfirm(AckType ack, HopCountType hopType,
- uint8_t* serialNumber, bool status);
+ uint8_t* serialNumber, bool status);
virtual void individualAddressSerialNumberReadIndication(HopCountType hopType, uint8_t* serialNumber);
virtual void individualAddressSerialNumberReadResponseConfirm(AckType ack, HopCountType hopType,
- uint8_t* serialNumber, uint16_t domainAddress, bool status);
+ uint8_t* serialNumber, uint16_t domainAddress, bool status);
virtual void individualAddressSerialNumberReadAppLayerConfirm(HopCountType hopType, uint8_t* serialNumber,
- uint16_t individualAddress, uint16_t domainAddress);
+ uint16_t individualAddress, uint16_t domainAddress);
virtual void individualAddressSerialNumberWriteLocalConfirm(AckType ack, HopCountType hopType, uint8_t* serialNumber,
- uint16_t newaddress, bool status);
+ uint16_t newaddress, bool status);
virtual void individualAddressSerialNumberWriteIndication(HopCountType hopType, uint8_t* serialNumber, uint16_t newaddress);
virtual void deviceDescriptorReadLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap,
- uint8_t descriptorType, bool status);
+ uint8_t descriptorType, bool status);
virtual void deviceDescriptorReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t descriptorType);
virtual void deviceDescriptorReadResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap,
- uint8_t descriptor_type, uint8_t* device_descriptor, bool status);
+ uint8_t descriptor_type, uint8_t* device_descriptor, bool status);
virtual void deviceDescriptorReadAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap,
- uint8_t descriptortype, uint8_t* deviceDescriptor);
+ uint8_t descriptortype, uint8_t* deviceDescriptor);
virtual void restartRequestLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, bool status);
virtual void restartRequestIndication(Priority priority, HopCountType hopType, uint16_t asap);
virtual void propertyValueReadLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap,
- uint8_t objectIndex, uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, bool status);
+ uint8_t objectIndex, uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, bool status);
virtual void propertyValueReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
- uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex);
+ uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex);
virtual void propertyValueReadResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
- uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length, bool status);
+ uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length, bool status);
virtual void propertyValueReadAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
- uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length);
+ uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length);
virtual void propertyValueWriteLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
- uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length, bool status);
+ uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length, bool status);
virtual void propertyValueWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
- uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length);
+ uint8_t propertyId, uint8_t numberOfElements, uint16_t startIndex, uint8_t* data, uint8_t length);
virtual void propertyDescriptionReadLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap,
- uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool status);
+ uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool status);
virtual void propertyDescriptionReadIndication(Priority priority, HopCountType hopType, uint16_t asap,
- uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex);
+ uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex);
virtual void propertyDescriptionReadResponse(AckType ack, Priority priority, HopCountType hopType, uint16_t asap,
- uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool writeEnable, uint8_t type,
- uint16_t maxNumberOfElements, uint8_t access);
+ uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool writeEnable, uint8_t type,
+ uint16_t maxNumberOfElements, uint8_t access);
virtual void propertyDescriptionReadResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap,
- uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool writeEnable, uint8_t type,
- uint16_t maxNumberOfElements, uint8_t access, bool status);
+ uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool writeEnable, uint8_t type,
+ uint16_t maxNumberOfElements, uint8_t access, bool status);
virtual void propertyDescriptionReadAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap,
- uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool writeEnable, uint8_t type,
- uint16_t maxNumberOfElements, uint8_t access);
+ uint8_t objectIndex, uint8_t propertyId, uint8_t propertyIndex, bool writeEnable, uint8_t type,
+ uint16_t maxNumberOfElements, uint8_t access);
virtual void memoryReadLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
- uint16_t memoryAddress, bool status);
+ uint16_t memoryAddress, bool status);
virtual void memoryReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number, uint16_t memoryAddress);
virtual void memoryReadResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
- uint16_t memoryAddress, uint8_t* data, bool status);
+ uint16_t memoryAddress, uint8_t* data, bool status);
virtual void memoryReadAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
- uint16_t memoryAddress, uint8_t* data);
+ uint16_t memoryAddress, uint8_t* data);
virtual void memoryWriteLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
- uint16_t memoryAddress, uint8_t* data, bool status);
+ uint16_t memoryAddress, uint8_t* data, bool status);
virtual void memoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
- uint16_t memoryAddress, uint8_t* data);
+ uint16_t memoryAddress, uint8_t* data);
virtual void userMemoryReadLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
- uint32_t memoryAddress, bool status);
+ uint32_t memoryAddress, bool status);
virtual void userMemoryReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
- uint32_t memoryAddress);
+ uint32_t memoryAddress);
virtual void userMemoryReadResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
- uint32_t memoryAddress, uint8_t* memoryData, bool status);
+ uint32_t memoryAddress, uint8_t* memoryData, bool status);
virtual void userMemoryReadAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
- uint32_t memoryAddress, uint8_t* memoryData);
+ uint32_t memoryAddress, uint8_t* memoryData);
virtual void userMemoryWriteLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
- uint32_t memoryAddress, uint8_t* memoryData, bool status);
+ uint32_t memoryAddress, uint8_t* memoryData, bool status);
virtual void userMemoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
- uint32_t memoryAddress, uint8_t* memoryData);
+ uint32_t memoryAddress, uint8_t* memoryData);
virtual void userManufacturerInfoLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, bool status);
virtual void userManufacturerInfoIndication(Priority priority, HopCountType hopType, uint16_t asap);
virtual void userManufacturerInfoResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap,
- uint8_t* info, bool status);
+ uint8_t* info, bool status);
virtual void userManufacturerInfoAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap,
- uint8_t* info);
+ uint8_t* info);
virtual void authorizeLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint32_t key, bool status);
virtual void authorizeIndication(Priority priority, HopCountType hopType, uint16_t asap, uint32_t key);
virtual void authorizeResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t level,
- bool status);
+ bool status);
virtual void authorizeAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap, uint8_t level);
virtual void keyWriteLocalConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t level,
- uint32_t key, bool status);
+ uint32_t key, bool status);
virtual void keyWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t level,
- uint32_t key);
+ uint32_t key);
virtual void keyWriteResponseConfirm(AckType ack, Priority priority, HopCountType hopType, uint16_t asap, uint8_t level,
- bool status);
+ bool status);
virtual void keyWriteAppLayerConfirm(Priority priority, HopCountType hopType, uint16_t asap, uint8_t level);
};
diff --git a/src/knx/bau07B0.cpp b/src/knx/bau07B0.cpp
index 6381b8e..435ba5e 100644
--- a/src/knx/bau07B0.cpp
+++ b/src/knx/bau07B0.cpp
@@ -2,37 +2,33 @@
#include
#include
-
using namespace std;
-Bau07B0::Bau07B0(Platform& platform): BauSystemB(platform),
- _dlLayer(_deviceObj, _addrTable, _netLayer, _platform)
+Bau07B0::Bau07B0(Platform& platform)
+ : BauSystemB(platform),
+ _dlLayer(_deviceObj, _addrTable, _netLayer, _platform)
{
_netLayer.dataLinkLayer(_dlLayer);
-
- uint8_t descriptor[] = { 0x07, 0xb0 };
- _descriptor[0] = descriptor[0];
- _descriptor[1] = descriptor[1];
}
InterfaceObject* Bau07B0::getInterfaceObject(uint8_t idx)
{
switch (idx)
{
- case 0:
- return &_deviceObj;
- case 1:
- return &_addrTable;
- case 2:
- return &_assocTable;
- case 3:
- return &_groupObjTable;
- case 4:
- return &_appProgram;
- case 5: // would be app_program 2
- return nullptr;
- default:
- return nullptr;
+ case 0:
+ return &_deviceObj;
+ case 1:
+ return &_addrTable;
+ case 2:
+ return &_assocTable;
+ case 3:
+ return &_groupObjTable;
+ case 4:
+ return &_appProgram;
+ case 5: // would be app_program 2
+ return nullptr;
+ default:
+ return nullptr;
}
}
diff --git a/src/knx/bau07B0.h b/src/knx/bau07B0.h
index 27588cd..84d8aba 100644
--- a/src/knx/bau07B0.h
+++ b/src/knx/bau07B0.h
@@ -3,15 +3,17 @@
#include "bau_systemB.h"
#include "tpuart_data_link_layer.h"
-class Bau07B0: public BauSystemB
+class Bau07B0 : public BauSystemB
{
-public:
+ public:
Bau07B0(Platform& platform);
-protected:
+
+ protected:
InterfaceObject* getInterfaceObject(uint8_t idx);
uint8_t* descriptor();
DataLinkLayer& dataLinkLayer();
-private:
+
+ private:
TpUartDataLinkLayer _dlLayer;
- uint8_t _descriptor[2];
+ uint8_t _descriptor[2] = {0x07, 0xb0};
};
\ No newline at end of file
diff --git a/src/knx/bau57B0.cpp b/src/knx/bau57B0.cpp
index c915959..c255934 100644
--- a/src/knx/bau57B0.cpp
+++ b/src/knx/bau57B0.cpp
@@ -4,38 +4,35 @@
using namespace std;
-Bau57B0::Bau57B0(Platform& platform): BauSystemB(platform),
- _ipParameters(_deviceObj, platform),
- _dlLayer(_deviceObj, _addrTable, _ipParameters, _netLayer, _platform)
+Bau57B0::Bau57B0(Platform& platform)
+ : BauSystemB(platform),
+ _ipParameters(_deviceObj, platform),
+ _dlLayer(_deviceObj, _addrTable, _ipParameters, _netLayer, _platform)
{
_netLayer.dataLinkLayer(_dlLayer);
_memory.addSaveRestore(&_ipParameters);
-
- uint8_t descriptor[] = { 0x57, 0xb0 };
- _descriptor[0] = descriptor[0];
- _descriptor[1] = descriptor[1];
}
InterfaceObject* Bau57B0::getInterfaceObject(uint8_t idx)
{
switch (idx)
{
- case 0:
- return &_deviceObj;
- case 1:
- return &_addrTable;
- case 2:
- return &_assocTable;
- case 3:
- return &_groupObjTable;
- case 4:
- return &_appProgram;
- case 5: // would be app_program 2
- return nullptr;
- case 6:
- return &_ipParameters;
- default:
- return nullptr;
+ case 0:
+ return &_deviceObj;
+ case 1:
+ return &_addrTable;
+ case 2:
+ return &_assocTable;
+ case 3:
+ return &_groupObjTable;
+ case 4:
+ return &_appProgram;
+ case 5: // would be app_program 2
+ return nullptr;
+ case 6:
+ return &_ipParameters;
+ default:
+ return nullptr;
}
}
diff --git a/src/knx/bau57B0.h b/src/knx/bau57B0.h
index 59bfb15..297f4aa 100644
--- a/src/knx/bau57B0.h
+++ b/src/knx/bau57B0.h
@@ -4,16 +4,18 @@
#include "ip_parameter_object.h"
#include "ip_data_link_layer.h"
-class Bau57B0: public BauSystemB
+class Bau57B0 : public BauSystemB
{
-public:
+ public:
Bau57B0(Platform& platform);
-protected:
+
+ protected:
InterfaceObject* getInterfaceObject(uint8_t idx);
uint8_t* descriptor();
DataLinkLayer& dataLinkLayer();
-private:
+
+ private:
IpParameterObject _ipParameters;
IpDataLinkLayer _dlLayer;
- uint8_t _descriptor[2];
+ uint8_t _descriptor[2] = {0x57, 0xb0};
};
\ No newline at end of file
diff --git a/src/knx/bau_systemB.h b/src/knx/bau_systemB.h
index d701b74..91a0741 100644
--- a/src/knx/bau_systemB.h
+++ b/src/knx/bau_systemB.h
@@ -13,9 +13,9 @@
#include "platform.h"
#include "memory.h"
-class BauSystemB: protected BusAccessUnit
+class BauSystemB : protected BusAccessUnit
{
-public:
+ public:
BauSystemB(Platform& platform);
virtual void loop();
DeviceObject& deviceObject();
@@ -28,13 +28,14 @@ public:
void writeMemory();
void addSaveRestore(SaveRestore* obj);
void restartRequest(uint16_t asap);
-protected:
+
+ protected:
virtual DataLinkLayer& dataLinkLayer() = 0;
virtual uint8_t* descriptor() = 0;
void memoryWriteIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
- uint16_t memoryAddress, uint8_t* data) override;
+ uint16_t memoryAddress, uint8_t* data) override;
void memoryReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t number,
- uint16_t memoryAddress) override;
+ uint16_t memoryAddress) override;
void deviceDescriptorReadIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t descriptorType) override;
void restartRequestIndication(Priority priority, HopCountType hopType, uint16_t asap) override;
void authorizeIndication(Priority priority, HopCountType hopType, uint16_t asap, uint32_t key) override;
@@ -58,7 +59,6 @@ protected:
void groupValueWriteIndication(uint16_t asap, Priority priority, HopCountType hopType,
uint8_t* data, uint8_t dataLength) override;
-
virtual InterfaceObject* getInterfaceObject(uint8_t idx) = 0;
void sendNextGroupTelegram();
void updateGroupObject(GroupObject& go, uint8_t* data, uint8_t length);
diff --git a/src/knx/cemi_frame.h b/src/knx/cemi_frame.h
index 8a2ed60..f8f69e6 100644
--- a/src/knx/cemi_frame.h
+++ b/src/knx/cemi_frame.h
@@ -15,18 +15,19 @@
class CemiFrame
{
friend class DataLinkLayer;
-public:
+
+ public:
CemiFrame(uint8_t* data, uint16_t length);
CemiFrame(uint8_t apduLength);
CemiFrame(const CemiFrame& other);
- CemiFrame& operator= (CemiFrame other);
+ CemiFrame& operator=(CemiFrame other);
MessageCode messageCode() const;
void messageCode(MessageCode value);
uint16_t totalLenght() const;
uint16_t telegramLengthtTP() const;
void fillTelegramTP(uint8_t* data);
-
+
FrameFormat frameType() const;
void frameType(FrameFormat value);
Repetition repetition() const;
@@ -49,15 +50,16 @@ public:
NPDU& npdu();
TPDU& tpdu();
APDU& apdu();
-
+
uint8_t calcCRC(uint8_t* buffer, uint16_t len);
bool valid() const;
-private:
- uint8_t buffer[0xff + NPDU_LPDU_DIFF]; //only valid of add info is zero
- uint8_t* _data;
- uint8_t* _ctrl1;
+
+ private:
+ uint8_t buffer[0xff + NPDU_LPDU_DIFF] = {0}; //only valid of add info is zero
+ uint8_t* _data = 0;
+ uint8_t* _ctrl1 = 0;
NPDU _npdu;
TPDU _tpdu;
APDU _apdu;
- uint16_t _length; // only set if created from byte array
+ uint16_t _length = 0; // only set if created from byte array
};
\ No newline at end of file
diff --git a/src/knx/data_link_layer.h b/src/knx/data_link_layer.h
index 74a3b50..c1bd908 100644
--- a/src/knx/data_link_layer.h
+++ b/src/knx/data_link_layer.h
@@ -8,21 +8,22 @@
class DataLinkLayer
{
-public:
- DataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, NetworkLayer& layer,
- Platform& platform);
+ public:
+ DataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, NetworkLayer& layer,
+ Platform& platform);
// from network layer
- void dataRequest(AckType ack, AddressType addrType, uint16_t destinationAddr, FrameFormat format,
- Priority priority, NPDU& npdu);
+ void dataRequest(AckType ack, AddressType addrType, uint16_t destinationAddr, FrameFormat format,
+ Priority priority, NPDU& npdu);
void systemBroadcastRequest(AckType ack, FrameFormat format, Priority priority, NPDU& npdu);
virtual void loop() = 0;
virtual void enabled(bool value) = 0;
virtual bool enabled() const = 0;
-protected:
+
+ protected:
void frameRecieved(CemiFrame& frame);
void dataConReceived(CemiFrame& frame, bool success);
- bool sendTelegram(NPDU &npdu, AckType ack, uint16_t destinationAddr, AddressType addrType, FrameFormat format, Priority priority);
+ bool sendTelegram(NPDU& npdu, AckType ack, uint16_t destinationAddr, AddressType addrType, FrameFormat format, Priority priority);
virtual bool sendFrame(CemiFrame& frame) = 0;
uint8_t* frameData(CemiFrame& frame);
DeviceObject& _deviceObject;
diff --git a/src/knx/device_object.cpp b/src/knx/device_object.cpp
index 585a657..1784f62 100644
--- a/src/knx/device_object.cpp
+++ b/src/knx/device_object.cpp
@@ -35,7 +35,7 @@ void DeviceObject::readProperty(PropertyID propertyId, uint32_t start, uint32_t&
*data = _prgMode;
break;
case PID_MAX_APDU_LENGTH:
- pushWord(15, data);
+ pushWord(254, data);
break;
case PID_SUBNET_ADDR:
*data = ((_ownAddress >> 8) & 0xff);
diff --git a/src/knx/device_object.h b/src/knx/device_object.h
index dcc594c..6d66133 100644
--- a/src/knx/device_object.h
+++ b/src/knx/device_object.h
@@ -39,13 +39,13 @@ protected:
uint8_t propertyCount();
PropertyDescription* propertyDescriptions();
private:
- uint8_t _deviceControl;
- uint8_t _routingCount;
- uint8_t _prgMode;
- uint16_t _ownAddress;
+ uint8_t _deviceControl = 0;
+ uint8_t _routingCount = 0;
+ uint8_t _prgMode = 0;
+ uint16_t _ownAddress = 0;
uint16_t _manufacturerId = 0xfa; //Default to KNXA
- uint32_t _bauNumber;
- char _orderNumber[10];
- uint8_t _hardwareType[6];
- uint16_t _version;
+ uint32_t _bauNumber = 0;
+ char _orderNumber[10] = "";
+ uint8_t _hardwareType[6] = { 0, 0, 0, 0, 0, 0};
+ uint16_t _version = 0;
};
\ No newline at end of file
diff --git a/src/knx/dptconvert.cpp b/src/knx/dptconvert.cpp
index e000c9a..f499585 100644
--- a/src/knx/dptconvert.cpp
+++ b/src/knx/dptconvert.cpp
@@ -1794,7 +1794,11 @@ void float16ToPayload(uint8_t* payload, int payload_length, int index, double va
}
value *= 100.0;
- unsigned short exponent = ceil(log2(value) - 11.0);
+ unsigned short exponent = 0;
+
+ if(value > 2048)
+ exponent = ceil(log2(value) - 11.0);
+
short mantissa = roundf(value / (1 << exponent));
if (wasNegative)
diff --git a/src/knx/dptconvert.h b/src/knx/dptconvert.h
index 98d7192..37df062 100644
--- a/src/knx/dptconvert.h
+++ b/src/knx/dptconvert.h
@@ -36,110 +36,110 @@
/**
* Converts the KNX Payload given by the specific DPT and puts the value in the KNXValue struc
*/
-int KNX_Decode_Value(uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int KNX_Decode_Value(uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
/**
* Converts the KNXValue struct to the KNX Payload as the specific DPT
*/
-int KNX_Encode_Value(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
+int KNX_Encode_Value(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
//KNX to internal
-int busValueToBinary(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToBinaryControl(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToStepControl(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToCharacter(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToUnsigned8(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToSigned8(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToStatusAndMode(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToUnsigned16(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToTimePeriod(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToSigned16(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToTimeDelta(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToFloat16(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToTime(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToDate(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToUnsigned32(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToSigned32(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToLongTimePeriod(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToFloat32(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToAccess(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToString(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToScene(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToSceneControl(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToSceneInfo(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToSceneConfig(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToDateTime(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToUnicode(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToSigned64(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToAlarmInfo(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToSerialNumber(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToVersion(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToScaling(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToTariff(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToLocale(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToRGB(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToFlaggedScaling(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
-int busValueToActiveEnergy(const uint8_t *payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToBinary(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToBinaryControl(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToStepControl(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToCharacter(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToUnsigned8(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToSigned8(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToStatusAndMode(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToUnsigned16(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToTimePeriod(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToSigned16(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToTimeDelta(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToFloat16(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToTime(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToDate(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToUnsigned32(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToSigned32(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToLongTimePeriod(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToFloat32(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToAccess(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToString(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToScene(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToSceneControl(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToSceneInfo(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToSceneConfig(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToDateTime(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToUnicode(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToSigned64(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToAlarmInfo(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToSerialNumber(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToVersion(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToScaling(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToTariff(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToLocale(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToRGB(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToFlaggedScaling(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
+int busValueToActiveEnergy(const uint8_t* payload, int payload_length, const Dpt& datatype, KNXValue& value);
//Internal to KNX
-int valueToBusValueBinary(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueBinaryControl(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueStepControl(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueCharacter(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueUnsigned8(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueSigned8(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueStatusAndMode(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueUnsigned16(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueTimePeriod(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueSigned16(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueTimeDelta(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueFloat16(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueTime(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueDate(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueUnsigned32(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueSigned32(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueLongTimePeriod(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueFloat32(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueAccess(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueString(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueScene(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueSceneControl(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueSceneInfo(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueSceneConfig(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueDateTime(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueUnicode(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueSigned64(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueAlarmInfo(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueSerialNumber(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueVersion(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueScaling(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueTariff(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueLocale(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueRGB(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueFlaggedScaling(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
-int valueToBusValueActiveEnergy(const KNXValue& value, uint8_t *payload, int payload_length, const Dpt& datatype);
+int valueToBusValueBinary(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueBinaryControl(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueStepControl(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueCharacter(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueUnsigned8(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueSigned8(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueStatusAndMode(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueUnsigned16(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueTimePeriod(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueSigned16(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueTimeDelta(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueFloat16(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueTime(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueDate(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueUnsigned32(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueSigned32(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueLongTimePeriod(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueFloat32(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueAccess(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueString(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueScene(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueSceneControl(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueSceneInfo(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueSceneConfig(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueDateTime(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueUnicode(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueSigned64(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueAlarmInfo(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueSerialNumber(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueVersion(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueScaling(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueTariff(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueLocale(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueRGB(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueFlaggedScaling(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
+int valueToBusValueActiveEnergy(const KNXValue& value, uint8_t* payload, int payload_length, const Dpt& datatype);
//Payload manipulation
-bool bitFromPayload(const uint8_t *payload, int index);
-uint8_t unsigned8FromPayload(const uint8_t *payload, int index);
-int8_t signed8FromPayload(const uint8_t *payload, int index);
-uint16_t unsigned16FromPayload(const uint8_t *payload, int index);
-int16_t signed16FromPayload(const uint8_t *payload, int index);
-uint32_t unsigned32FromPayload(const uint8_t *payload, int index);
-int32_t signed32FromPayload(const uint8_t *payload, int index);
-double float16FromPayload(const uint8_t *payload, int index);
-float float32FromPayload(const uint8_t *payload, int index);
-int64_t signed64FromPayload(const uint8_t *payload, int index);
-uint8_t bcdFromPayload(const uint8_t *payload, int index);
+bool bitFromPayload(const uint8_t* payload, int index);
+uint8_t unsigned8FromPayload(const uint8_t* payload, int index);
+int8_t signed8FromPayload(const uint8_t* payload, int index);
+uint16_t unsigned16FromPayload(const uint8_t* payload, int index);
+int16_t signed16FromPayload(const uint8_t* payload, int index);
+uint32_t unsigned32FromPayload(const uint8_t* payload, int index);
+int32_t signed32FromPayload(const uint8_t* payload, int index);
+double float16FromPayload(const uint8_t* payload, int index);
+float float32FromPayload(const uint8_t* payload, int index);
+int64_t signed64FromPayload(const uint8_t* payload, int index);
+uint8_t bcdFromPayload(const uint8_t* payload, int index);
-void bitToPayload(uint8_t *payload, int payload_length, int index, bool value);
-void unsigned8ToPayload(uint8_t *payload, int payload_length, int index, uint8_t value, uint8_t mask); //mask 0xFF
-void signed8ToPayload(uint8_t *payload, int payload_length, int index, int8_t value, uint8_t mask); //mask 0xFF
-void unsigned16ToPayload(uint8_t *payload, int payload_length, int index, uint16_t value, uint16_t mask); //mask 0xFFFF
-void signed16ToPayload(uint8_t *payload, int payload_length, int index, int16_t value, uint16_t mask); //mask 0xFFFF
-void unsigned32ToPayload(uint8_t *payload, int payload_length, int index, uint32_t value, uint32_t mask); //mask = 0xFFFFFFFF
-void signed32ToPayload(uint8_t *payload, int payload_length, int index, int32_t value, uint32_t mask); //mask = 0xFFFFFFFF
-void float16ToPayload(uint8_t *payload, int payload_length, int index, double value, uint16_t mask); //mask = 0xFFFF
-void float32ToPayload(uint8_t *payload, int payload_length, int index, double value, uint32_t mask); //mask = 0xFFFFFFFF
-void signed64ToPayload(uint8_t *payload, int payload_length, int index, int64_t value, uint64_t mask); //mask = UINT64_C(0xFFFFFFFFFFFFFFFF)
-void bcdToPayload(uint8_t *payload, int payload_length, int index, uint8_t value);
\ No newline at end of file
+void bitToPayload(uint8_t* payload, int payload_length, int index, bool value);
+void unsigned8ToPayload(uint8_t* payload, int payload_length, int index, uint8_t value, uint8_t mask); //mask 0xFF
+void signed8ToPayload(uint8_t* payload, int payload_length, int index, int8_t value, uint8_t mask); //mask 0xFF
+void unsigned16ToPayload(uint8_t* payload, int payload_length, int index, uint16_t value, uint16_t mask); //mask 0xFFFF
+void signed16ToPayload(uint8_t* payload, int payload_length, int index, int16_t value, uint16_t mask); //mask 0xFFFF
+void unsigned32ToPayload(uint8_t* payload, int payload_length, int index, uint32_t value, uint32_t mask); //mask = 0xFFFFFFFF
+void signed32ToPayload(uint8_t* payload, int payload_length, int index, int32_t value, uint32_t mask); //mask = 0xFFFFFFFF
+void float16ToPayload(uint8_t* payload, int payload_length, int index, double value, uint16_t mask); //mask = 0xFFFF
+void float32ToPayload(uint8_t* payload, int payload_length, int index, double value, uint32_t mask); //mask = 0xFFFFFFFF
+void signed64ToPayload(uint8_t* payload, int payload_length, int index, int64_t value, uint64_t mask); //mask = UINT64_C(0xFFFFFFFFFFFFFFFF)
+void bcdToPayload(uint8_t* payload, int payload_length, int index, uint8_t value);
\ No newline at end of file
diff --git a/src/knx/group_object.h b/src/knx/group_object.h
index 372d69e..0e71b96 100644
--- a/src/knx/group_object.h
+++ b/src/knx/group_object.h
@@ -9,7 +9,7 @@ class GroupObjectTableObject;
enum ComFlag
{
- Updated = 0, //!< Group object was updated
+ Updated = 0, //!< Group object was updated
ReadRequest = 1, //!< Read was requested but was not processed
WriteRequest = 2, //!< Write was requested but was not processed
Transmitting = 3, //!< Group Object is processed a the moment (read or write)
@@ -19,12 +19,11 @@ enum ComFlag
class GroupObject;
-
#ifdef __linux__
#include
typedef std::function GroupObjectUpdatedHandler;
#else
-typedef void(*GroupObjectUpdatedHandler)(GroupObject& go);
+typedef void (*GroupObjectUpdatedHandler)(GroupObject& go);
#endif
/**
@@ -33,7 +32,8 @@ typedef void(*GroupObjectUpdatedHandler)(GroupObject& go);
class GroupObject
{
friend class GroupObjectTableObject;
-public:
+
+ public:
/**
* The constructor.
*/
@@ -41,7 +41,7 @@ public:
/**
* The copy constructor.
*/
- GroupObject(const GroupObject& other);
+ GroupObject(const GroupObject& other);
/**
* The destructor.
*/
@@ -71,12 +71,12 @@ public:
* Check if the communication flag (C) was set. (K-flag in german)
*/
bool communicationEnable();
-
+
/**
* Get the priority of the group object.
*/
Priority priority();
-
+
/**
* Return the current state of the group object. See ::ComFlag
*/
@@ -206,10 +206,10 @@ public:
size_t asapValueSize(uint8_t code);
GroupObjectUpdatedHandler _updateHandler;
size_t goSize();
- uint16_t _asap;
- ComFlag _commFlag;
- uint8_t* _data;
- uint8_t _dataLength;
- GroupObjectTableObject* _table;
+ uint16_t _asap = 0;
+ ComFlag _commFlag = Ok;
+ uint8_t* _data = 0;
+ uint8_t _dataLength = 0;
+ GroupObjectTableObject* _table = 0;
Dpt _datapointType;
};
diff --git a/src/knx/group_object_table_object.h b/src/knx/group_object_table_object.h
index 44d1057..bd9bdd3 100644
--- a/src/knx/group_object_table_object.h
+++ b/src/knx/group_object_table_object.h
@@ -3,11 +3,11 @@
#include "table_object.h"
#include "group_object.h"
-class GroupObjectTableObject: public TableObject
+class GroupObjectTableObject : public TableObject
{
friend class GroupObject;
-public:
+ public:
GroupObjectTableObject(Platform& platform);
virtual ~GroupObjectTableObject();
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
@@ -18,11 +18,13 @@ public:
virtual uint8_t* save(uint8_t* buffer);
virtual uint8_t* restore(uint8_t* buffer);
-protected:
+
+ protected:
virtual void beforeStateChange(LoadState& newState);
uint8_t propertyCount();
PropertyDescription* propertyDescriptions();
-private:
+
+ private:
void freeGroupObjects();
bool initGroupObjects();
uint16_t* _tableData = 0;
diff --git a/src/knx/interface_object.h b/src/knx/interface_object.h
index e1fcb72..1452eca 100644
--- a/src/knx/interface_object.h
+++ b/src/knx/interface_object.h
@@ -53,9 +53,9 @@ enum ObjectType
/**
* This class represents and interface object. See section 4 of @cite knx:3/4/1.
*/
-class InterfaceObject: public SaveRestore
+class InterfaceObject : public SaveRestore
{
-public:
+ public:
/**
* Destructor
*/
@@ -112,9 +112,10 @@ public:
*
* @param[out] access the ::AccessLevel necessary to read/write the property.
*/
-
+
void readPropertyDescription(uint8_t& propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access);
-protected:
+
+ protected:
/**
* Returns the number of properties the interface object has.
*/
diff --git a/src/knx/ip_data_link_layer.h b/src/knx/ip_data_link_layer.h
index 4ad86af..ddb1baa 100644
--- a/src/knx/ip_data_link_layer.h
+++ b/src/knx/ip_data_link_layer.h
@@ -4,17 +4,19 @@
#include "data_link_layer.h"
#include "ip_parameter_object.h"
-class IpDataLinkLayer: public DataLinkLayer
+class IpDataLinkLayer : public DataLinkLayer
{
using DataLinkLayer::_deviceObject;
-public:
- IpDataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, IpParameterObject& ipParam, NetworkLayer& layer,
- Platform& platform);
+
+ public:
+ IpDataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, IpParameterObject& ipParam, NetworkLayer& layer,
+ Platform& platform);
void loop();
void enabled(bool value);
bool enabled() const;
-private:
+
+ private:
bool _enabled = false;
bool sendFrame(CemiFrame& frame);
bool sendBytes(uint8_t* buffer, uint16_t length);
diff --git a/src/knx/ip_parameter_object.h b/src/knx/ip_parameter_object.h
index efd272b..4b23e34 100644
--- a/src/knx/ip_parameter_object.h
+++ b/src/knx/ip_parameter_object.h
@@ -4,9 +4,9 @@
#include "device_object.h"
#include "platform.h"
-class IpParameterObject: public InterfaceObject
+class IpParameterObject : public InterfaceObject
{
-public:
+ public:
IpParameterObject(DeviceObject& deviceObject, Platform& platform);
void readProperty(PropertyID id, uint32_t start, uint32_t& count, uint8_t* data);
void writeProperty(PropertyID id, uint8_t start, uint8_t* data, uint8_t count);
@@ -17,10 +17,12 @@ public:
uint32_t multicastAddress() const;
uint8_t ttl() const { return _ttl; }
-protected:
+
+ protected:
uint8_t propertyCount();
PropertyDescription* propertyDescriptions();
-private:
+
+ private:
uint16_t _projectInstallationId = 0;
uint8_t _ipAssignmentMethod = 0;
uint8_t _ipCapabilities = 0;
@@ -29,7 +31,7 @@ private:
uint32_t _defaultGateway = 0;
uint32_t _multicastAddress = 0;
uint8_t _ttl = 60;
- char _friendlyName[30] = { 0 };
+ char _friendlyName[30] = {0};
DeviceObject& _deviceObject;
Platform& _platform;
diff --git a/src/knx/memory.h b/src/knx/memory.h
index f13ccae..b9831ec 100644
--- a/src/knx/memory.h
+++ b/src/knx/memory.h
@@ -18,7 +18,7 @@ public:
private:
Platform& _platform;
bool _modified = false;
- SaveRestore* _saveRestores[MAXSAVE];
+ SaveRestore* _saveRestores[MAXSAVE] = {0};
int _saveCount = 0;
uint8_t* _data = 0;
};
diff --git a/src/knx/network_layer.h b/src/knx/network_layer.h
index cc94b31..2386469 100644
--- a/src/knx/network_layer.h
+++ b/src/knx/network_layer.h
@@ -8,20 +8,20 @@ class DataLinkLayer;
class NetworkLayer
{
-public:
+ public:
NetworkLayer(TransportLayer& layer);
-
+
void dataLinkLayer(DataLinkLayer& layer);
uint8_t hopCount() const;
void hopCount(uint8_t value);
// from data link layer
void dataIndication(AckType ack, AddressType addType, uint16_t destination, FrameFormat format, NPDU& npdu,
- Priority priority, uint16_t source);
+ Priority priority, uint16_t source);
void dataConfirm(AckType ack, AddressType addressType, uint16_t destination, FrameFormat format, Priority priority,
- uint16_t source, NPDU& npdu, bool status);
+ uint16_t source, NPDU& npdu, bool status);
void systemBroadcastIndication(AckType ack, FrameFormat format, NPDU& npdu,
- Priority priority, uint16_t source);
+ Priority priority, uint16_t source);
void systemBroadcastConfirm(AckType ack, FrameFormat format, Priority priority, uint16_t source, NPDU& npdu, bool status);
// from transport layer
@@ -30,9 +30,9 @@ public:
void dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu);
void dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, TPDU& tpdu);
-private:
- void sendDataRequest(TPDU &tpdu, HopCountType hopType, AckType ack, uint16_t destination, Priority priority, AddressType addrType);
+ private:
+ void sendDataRequest(TPDU& tpdu, HopCountType hopType, AckType ack, uint16_t destination, Priority priority, AddressType addrType);
uint8_t _hopCount = 6;
- DataLinkLayer* _dataLinkLayer;
+ DataLinkLayer* _dataLinkLayer = 0;
TransportLayer& _transportLayer;
};
diff --git a/src/knx/npdu.h b/src/knx/npdu.h
index b069809..72f6164 100644
--- a/src/knx/npdu.h
+++ b/src/knx/npdu.h
@@ -22,6 +22,6 @@ class NPDU
NPDU(uint8_t* data, CemiFrame& frame);
private:
- uint8_t* _data;
+ uint8_t* _data = 0;
CemiFrame& _frame;
};
\ No newline at end of file
diff --git a/src/knx/platform.cpp b/src/knx/platform.cpp
index 496ef6f..53eeaa9 100644
--- a/src/knx/platform.cpp
+++ b/src/knx/platform.cpp
@@ -31,9 +31,10 @@ void Platform::freeMemory(uint8_t* ptr)
Platform::Platform()
{
- // allocate memory to have a memory reference, substract a bit
- _memoryReference = (uint8_t*)malloc(1) - 1024;
+ // allocate memory to have a memory reference, substract a bit
+ _memoryReference = (uint8_t*)malloc(1);
free(_memoryReference);
- print("MemRef: ");
+ _memoryReference -= 1024;
+ print("MemRef: ");
println((long unsigned int)_memoryReference, HEX);
}
diff --git a/src/knx/save_restore.h b/src/knx/save_restore.h
index 31bba83..f87091d 100644
--- a/src/knx/save_restore.h
+++ b/src/knx/save_restore.h
@@ -6,7 +6,7 @@
*/
class SaveRestore
{
-public:
+ public:
/**
* This method is called when the object should save its state to the buffer.
*
diff --git a/src/knx/tpdu.h b/src/knx/tpdu.h
index 0760d53..b3fe767 100644
--- a/src/knx/tpdu.h
+++ b/src/knx/tpdu.h
@@ -31,6 +31,6 @@ class TPDU
TPDU(uint8_t* data, CemiFrame& frame);
private:
- uint8_t* _data;
+ uint8_t* _data = 0;
CemiFrame& _frame;
};
diff --git a/src/knx/tpuart_data_link_layer.cpp b/src/knx/tpuart_data_link_layer.cpp
index 498ce17..0715163 100644
--- a/src/knx/tpuart_data_link_layer.cpp
+++ b/src/knx/tpuart_data_link_layer.cpp
@@ -51,37 +51,40 @@
#define SUCCESS 0x80
// control services, device specific
-#define U_RESET_IND 0x03
-#define U_STATE_IND 0x07
-#define SLAVE_COLLISION 0x80
-#define RECEIVE_ERROR 0x40
-#define TRANSMIT_ERROR 0x20
-#define PROTOCOL_ERROR 0x10
-#define TEMPERATURE_WARNING 0x08
-#define U_FRAME_STATE_IND 0x13
-#define U_FRAME_STATE_MASK 0x17
-#define PARITY_BIT_ERROR 0x80
+#define U_RESET_IND 0x03
+#define U_STATE_IND 0x07
+#define SLAVE_COLLISION 0x80
+#define RECEIVE_ERROR 0x40
+#define TRANSMIT_ERROR 0x20
+#define PROTOCOL_ERROR 0x10
+#define TEMPERATURE_WARNING 0x08
+#define U_FRAME_STATE_IND 0x13
+#define U_FRAME_STATE_MASK 0x17
+#define PARITY_BIT_ERROR 0x80
#define CHECKSUM_LENGTH_ERROR 0x40
-#define TIMING_ERROR 0x20
-#define U_CONFIGURE_IND 0x01
-#define U_CONFIGURE_MASK 0x83
-#define AUTO_ACKNOWLEDGE 0x20
-#define AUTO_POLLING 0x10
-#define CRC_CCITT 0x80
+#define TIMING_ERROR 0x20
+#define U_CONFIGURE_IND 0x01
+#define U_CONFIGURE_MASK 0x83
+#define AUTO_ACKNOWLEDGE 0x20
+#define AUTO_POLLING 0x10
+#define CRC_CCITT 0x80
#define FRAME_END_WITH_MARKER 0x40
-#define U_FRAME_END_IND 0xCB
-#define U_STOP_MODE_IND 0x2B
-#define U_SYSTEM_STAT_IND 0x4B
+#define U_FRAME_END_IND 0xCB
+#define U_STOP_MODE_IND 0x2B
+#define U_SYSTEM_STAT_IND 0x4B
//loop states
-#define IDLE 0
-#define RX_FIRST_BYTE 1
-#define RX_L_DATA 2
-#define RX_WAIT_DATA_CON 3
-#define TX_FRAME 4
+#define IDLE 0
+#define RX_FIRST_BYTE 1
+#define RX_L_DATA 2
+#define RX_WAIT_DATA_CON 3
+#define TX_FRAME 4
+#define BYTE_TIMEOUT 3 //milli seconds
+#define CONFIRM_TIMEOUT 500 //milli seconds
-void TpUartDataLinkLayer::loop(){
+void TpUartDataLinkLayer::loop()
+{
_receiveBuffer[0] = 0x29;
_receiveBuffer[1] = 0;
@@ -91,224 +94,272 @@ void TpUartDataLinkLayer::loop(){
if (!_enabled)
return;
- switch(_loopState){
- case IDLE:
- if(_platform.uartAvailable()){
- _loopState = RX_FIRST_BYTE;
- }
- else{
- if(!_waitConfirm && !isTxQueueEmpty()){
- loadNextTxFrame();
- _waitConfirm = true;
- _waitConfirmStartTime = _platform.millis();
- _loopState = TX_FRAME;
+ switch (_loopState)
+ {
+ case IDLE:
+ if (_platform.uartAvailable())
+ {
+ _loopState = RX_FIRST_BYTE;
+ }
+ else
+ {
+ if (!_waitConfirm && !isTxQueueEmpty())
+ {
+ loadNextTxFrame();
+ _waitConfirm = true;
+ _waitConfirmStartTime = _platform.millis();
+ _loopState = TX_FRAME;
+ }
}
- }
- break;
- case TX_FRAME:
- if(sendSingleFrameByte() == false){
- _loopState = IDLE;
- }
- break;
- case RX_FIRST_BYTE:
- rxByte =_platform.readUart();
- _lastByteRxTime = _platform.millis();
- _RxByteCnt = 0;
- _xorSum = 0;
- if ((rxByte & L_DATA_MASK) == L_DATA_STANDARD_IND){
- buffer[_RxByteCnt++]=rxByte;
- _xorSum ^= rxByte;
- _RxByteCnt++; //convert to L_DATA_EXTENDED
- _convert = true;
- _loopState=RX_L_DATA;
break;
- }
- else if ((rxByte & L_DATA_MASK) == L_DATA_EXTENDED_IND){
- buffer[_RxByteCnt++]=rxByte;
- _xorSum ^= rxByte;
- _convert = false;
- _loopState=RX_L_DATA;
+ case TX_FRAME:
+ if (sendSingleFrameByte() == false)
+ {
+ _loopState = IDLE;
+ }
break;
- }
- else if ((rxByte & L_DATA_CON_MASK) == L_DATA_CON){
- println("got unexpected L_DATA_CON");
- }
- else if (rxByte == L_POLL_DATA_IND){
- // not sure if this can happen
- println("got L_POLL_DATA_IND");
- }
- else if ((rxByte & L_ACKN_MASK) == L_ACKN_IND){
-
- // this can only happen in bus monitor mode
- println("got L_ACKN_IND");
- }
- else if (rxByte == U_RESET_IND){
- println("got U_RESET_IND");
- }
- else if((rxByte & U_STATE_IND) == U_STATE_IND){
- print("got U_STATE_IND: 0x");
- print(rxByte, HEX);
- println();
- }
- else if((rxByte & U_FRAME_STATE_MASK) == U_FRAME_STATE_IND){
- print("got U_FRAME_STATE_IND: 0x");
- print(rxByte, HEX);
- println();
- }
- else if((rxByte & U_CONFIGURE_MASK) == U_CONFIGURE_IND){
- print("got U_CONFIGURE_IND: 0x");
- print(rxByte, HEX);
- println();
- }
- else if(rxByte == U_FRAME_END_IND){
- println("got U_FRAME_END_IND");
- }
- else if(rxByte == U_STOP_MODE_IND){
- println("got U_STOP_MODE_IND");
- }
- else if(rxByte == U_SYSTEM_STAT_IND){
- print("got U_SYSTEM_STAT_IND: 0x");
- while (true){
- int tmp = _platform.readUart();
- if (tmp < 0)
- continue;
-
- print(tmp, HEX);
+ case RX_FIRST_BYTE:
+ rxByte = _platform.readUart();
+ _lastByteRxTime = _platform.millis();
+ _RxByteCnt = 0;
+ _xorSum = 0;
+ if ((rxByte & L_DATA_MASK) == L_DATA_STANDARD_IND)
+ {
+ buffer[_RxByteCnt++] = rxByte;
+ _xorSum ^= rxByte;
+ _RxByteCnt++; //convert to L_DATA_EXTENDED
+ _convert = true;
+ _loopState = RX_L_DATA;
break;
}
- println();
- }
- else{
- print("got UNEXPECTED: 0x");
- print(rxByte, HEX);
- println();
- }
- _loopState = IDLE;
- break;
- case RX_L_DATA:
- if (_platform.millis() - _lastByteRxTime > BYTE_TIMEOUT){
- _RxByteCnt = 0;
+ else if ((rxByte & L_DATA_MASK) == L_DATA_EXTENDED_IND)
+ {
+ buffer[_RxByteCnt++] = rxByte;
+ _xorSum ^= rxByte;
+ _convert = false;
+ _loopState = RX_L_DATA;
+ break;
+ }
+ else if ((rxByte & L_DATA_CON_MASK) == L_DATA_CON)
+ {
+ println("got unexpected L_DATA_CON");
+ }
+ else if (rxByte == L_POLL_DATA_IND)
+ {
+ // not sure if this can happen
+ println("got L_POLL_DATA_IND");
+ }
+ else if ((rxByte & L_ACKN_MASK) == L_ACKN_IND)
+ {
+ // this can only happen in bus monitor mode
+ println("got L_ACKN_IND");
+ }
+ else if (rxByte == U_RESET_IND)
+ {
+ println("got U_RESET_IND");
+ }
+ else if ((rxByte & U_STATE_IND) == U_STATE_IND)
+ {
+ print("got U_STATE_IND: 0x");
+ print(rxByte, HEX);
+ println();
+ }
+ else if ((rxByte & U_FRAME_STATE_MASK) == U_FRAME_STATE_IND)
+ {
+ print("got U_FRAME_STATE_IND: 0x");
+ print(rxByte, HEX);
+ println();
+ }
+ else if ((rxByte & U_CONFIGURE_MASK) == U_CONFIGURE_IND)
+ {
+ print("got U_CONFIGURE_IND: 0x");
+ print(rxByte, HEX);
+ println();
+ }
+ else if (rxByte == U_FRAME_END_IND)
+ {
+ println("got U_FRAME_END_IND");
+ }
+ else if (rxByte == U_STOP_MODE_IND)
+ {
+ println("got U_STOP_MODE_IND");
+ }
+ else if (rxByte == U_SYSTEM_STAT_IND)
+ {
+ print("got U_SYSTEM_STAT_IND: 0x");
+ while (true)
+ {
+ int tmp = _platform.readUart();
+ if (tmp < 0)
+ continue;
+
+ print(tmp, HEX);
+ break;
+ }
+ println();
+ }
+ else
+ {
+ print("got UNEXPECTED: 0x");
+ print(rxByte, HEX);
+ println();
+ }
_loopState = IDLE;
- println("Timeout during RX_L_DATA");
break;
- }
- if(!_platform.uartAvailable()) break;
- _lastByteRxTime = _platform.millis();
- rxByte =_platform.readUart();
-
- if(_RxByteCnt == MAX_KNX_TELEGRAM_SIZE){
- _loopState = IDLE;
- println("invalid telegram size");
- }
- else{
- buffer[_RxByteCnt++]=rxByte;
- }
-
- if(_RxByteCnt==7){ //Destination Address + payload available
- _xorSum ^= rxByte;
- //check if echo
- if (!((buffer[0]^_sendBuffer[0])&~0x20) && !memcmp(buffer+2,_sendBuffer+1,5)){ //ignore repeated bit of control byte
- _isEcho = true;
+ case RX_L_DATA:
+ if (_platform.millis() - _lastByteRxTime > BYTE_TIMEOUT)
+ {
+ _RxByteCnt = 0;
+ _loopState = IDLE;
+ println("Timeout during RX_L_DATA");
+ break;
}
- else{
- _isEcho = false;
+ if (!_platform.uartAvailable())
+ break;
+ _lastByteRxTime = _platform.millis();
+ rxByte = _platform.readUart();
+
+ if (_RxByteCnt == MAX_KNX_TELEGRAM_SIZE)
+ {
+ _loopState = IDLE;
+ println("invalid telegram size");
+ }
+ else
+ {
+ buffer[_RxByteCnt++] = rxByte;
}
- //convert into Extended.ind
- if(_convert){
- uint8_t payloadLength = buffer[6] & 0x0F;
- buffer[1] = buffer[6] & 0xF0;
- buffer[6] = payloadLength;
- }
-
- if(!_isEcho){
- uint8_t c = 0x10;
- //ceck if individual or group address
- if ((buffer[6] & 0x80) == 0){ //individual
- if(_deviceObject.induvidualAddress() == getWord(buffer + 4)){
- c |= 0x01;
- }
+ if (_RxByteCnt == 7)
+ {
+ //Destination Address + payload available
+ _xorSum ^= rxByte;
+ //check if echo
+ if (!((buffer[0] ^ _sendBuffer[0]) & ~0x20) && !memcmp(buffer + 2, _sendBuffer + 1, 5))
+ { //ignore repeated bit of control byte
+ _isEcho = true;
}
- else{ //group
- if(_groupAddressTable.contains(getWord(buffer + 4)) || getWord(buffer + 4) == 0){
- c |= 0x01;
- }
+ else
+ {
+ _isEcho = false;
}
- _platform.writeUart(c);
- }
- }
- else if(_RxByteCnt == buffer[6]+7+2){ //complete Frame received, payloadLength+1 for TCPI +1 for CRC
- if(rxByte == (uint8_t)(~_xorSum)){ //check if crc is correct
- if(_isEcho && _sendBuffer != NULL){ //check if it is realy an echo, rx_crc = tx_crc
- if(rxByte == _sendBuffer[_sendBufferLength-1])
- _isEcho = true;
+
+ //convert into Extended.ind
+ if (_convert)
+ {
+ uint8_t payloadLength = buffer[6] & 0x0F;
+ buffer[1] = buffer[6] & 0xF0;
+ buffer[6] = payloadLength;
+ }
+
+ if (!_isEcho)
+ {
+ uint8_t c = 0x10;
+ //ceck if individual or group address
+ if ((buffer[6] & 0x80) == 0)
+ {
+ //individual
+ if (_deviceObject.induvidualAddress() == getWord(buffer + 4))
+ {
+ c |= 0x01;
+ }
+ }
else
- _isEcho = false;
- }
- if(_isEcho){
- _loopState = RX_WAIT_DATA_CON;
- }
- else{
- frameBytesReceived(_receiveBuffer, _RxByteCnt+2);
- _loopState=IDLE;
+ {
+ //group
+ if (_groupAddressTable.contains(getWord(buffer + 4)) || getWord(buffer + 4) == 0)
+ {
+ c |= 0x01;
+ }
+ }
+ _platform.writeUart(c);
}
}
- else{
- println("frame with invalid crc ignored");
- _loopState=IDLE;
+ else if (_RxByteCnt == buffer[6] + 7 + 2)
+ {
+ //complete Frame received, payloadLength+1 for TCPI +1 for CRC
+ if (rxByte == (uint8_t)(~_xorSum))
+ {
+ //check if crc is correct
+ if (_isEcho && _sendBuffer != NULL)
+ {
+ //check if it is realy an echo, rx_crc = tx_crc
+ if (rxByte == _sendBuffer[_sendBufferLength - 1])
+ _isEcho = true;
+ else
+ _isEcho = false;
+ }
+ if (_isEcho)
+ {
+ _loopState = RX_WAIT_DATA_CON;
+ }
+ else
+ {
+ frameBytesReceived(_receiveBuffer, _RxByteCnt + 2);
+ _loopState = IDLE;
+ }
+ }
+ else
+ {
+ println("frame with invalid crc ignored");
+ _loopState = IDLE;
+ }
}
- }
- else{
- _xorSum ^= rxByte;
- }
- break;
- case RX_WAIT_DATA_CON:
- if(!_platform.uartAvailable()) break;
- rxByte =_platform.readUart();
- _lastByteRxTime = _platform.millis();
- if ((rxByte & L_DATA_CON_MASK) == L_DATA_CON){
- //println("L_DATA_CON received");
- dataConBytesReceived(_receiveBuffer, _RxByteCnt+2, ((rxByte & SUCCESS) > 0));
- _waitConfirm = false;
- delete[] _sendBuffer;
- _sendBuffer = 0;
- _sendBufferLength = 0;
- _loopState=IDLE;
- }
- else{
- //should not happen
- println("expected L_DATA_CON not received");
- dataConBytesReceived(_receiveBuffer, _RxByteCnt+2, false);
- _waitConfirm = false;
- delete[] _sendBuffer;
- _sendBuffer = 0;
- _sendBufferLength = 0;
- _loopState=IDLE;
- }
- break;
- default:
- break;
+ else
+ {
+ _xorSum ^= rxByte;
+ }
+ break;
+ case RX_WAIT_DATA_CON:
+ if (!_platform.uartAvailable())
+ break;
+ rxByte = _platform.readUart();
+ _lastByteRxTime = _platform.millis();
+ if ((rxByte & L_DATA_CON_MASK) == L_DATA_CON)
+ {
+ //println("L_DATA_CON received");
+ dataConBytesReceived(_receiveBuffer, _RxByteCnt + 2, ((rxByte & SUCCESS) > 0));
+ _waitConfirm = false;
+ delete[] _sendBuffer;
+ _sendBuffer = 0;
+ _sendBufferLength = 0;
+ _loopState = IDLE;
+ }
+ else
+ {
+ //should not happen
+ println("expected L_DATA_CON not received");
+ dataConBytesReceived(_receiveBuffer, _RxByteCnt + 2, false);
+ _waitConfirm = false;
+ delete[] _sendBuffer;
+ _sendBuffer = 0;
+ _sendBufferLength = 0;
+ _loopState = IDLE;
+ }
+ break;
+ default:
+ break;
}
- if(_waitConfirm){
- if (_platform.millis() - _waitConfirmStartTime > CONFIRM_TIMEOUT){
+ if (_waitConfirm)
+ {
+ if (_platform.millis() - _waitConfirmStartTime > CONFIRM_TIMEOUT)
+ {
println("L_DATA_CON not received within expected time");
uint8_t cemiBuffer[MAX_KNX_TELEGRAM_SIZE];
cemiBuffer[0] = 0x29;
cemiBuffer[1] = 0;
- memcpy((cemiBuffer+2),_sendBuffer,_sendBufferLength);
- dataConBytesReceived(cemiBuffer, _sendBufferLength+2, false);
+ memcpy((cemiBuffer + 2), _sendBuffer, _sendBufferLength);
+ dataConBytesReceived(cemiBuffer, _sendBufferLength + 2, false);
_waitConfirm = false;
delete[] _sendBuffer;
_sendBuffer = 0;
_sendBufferLength = 0;
- if(_loopState == RX_WAIT_DATA_CON)
- _loopState=IDLE;
+ if (_loopState == RX_WAIT_DATA_CON)
+ _loopState = IDLE;
}
}
}
-
bool TpUartDataLinkLayer::sendFrame(CemiFrame& frame)
{
if (!_enabled)
@@ -318,7 +369,6 @@ bool TpUartDataLinkLayer::sendFrame(CemiFrame& frame)
return true;
}
-
void TpUartDataLinkLayer::resetChip()
{
uint8_t cmd = U_RESET_REQ;
@@ -345,13 +395,12 @@ void TpUartDataLinkLayer::stopChip()
#endif
}
-
TpUartDataLinkLayer::TpUartDataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab,
- NetworkLayer& layer, Platform& platform) : DataLinkLayer(devObj, addrTab, layer, platform)
+ NetworkLayer& layer, Platform& platform)
+ : DataLinkLayer(devObj, addrTab, layer, platform)
{
}
-
void TpUartDataLinkLayer::frameBytesReceived(uint8_t* buffer, uint16_t length)
{
//printHex("=>", buffer, length);
@@ -364,8 +413,7 @@ void TpUartDataLinkLayer::dataConBytesReceived(uint8_t* buffer, uint16_t length,
{
//printHex("=>", buffer, length);
CemiFrame frame(buffer, length);
- dataConReceived(frame,success);
-
+ dataConReceived(frame, success);
}
void TpUartDataLinkLayer::enabled(bool value)
@@ -394,14 +442,16 @@ bool TpUartDataLinkLayer::enabled() const
return _enabled;
}
-
-bool TpUartDataLinkLayer::sendSingleFrameByte(){
+bool TpUartDataLinkLayer::sendSingleFrameByte()
+{
uint8_t cmd[2];
uint8_t idx = _TxByteCnt / 64;
- if(_sendBuffer == NULL) return false;
+ if (_sendBuffer == NULL)
+ return false;
- if(_TxByteCnt < _sendBufferLength){
+ if (_TxByteCnt < _sendBufferLength)
+ {
if (idx != _oldIdx)
{
_oldIdx = idx;
@@ -420,13 +470,15 @@ bool TpUartDataLinkLayer::sendSingleFrameByte(){
_TxByteCnt++;
return true;
}
- else{
- _TxByteCnt=0;
+ else
+ {
+ _TxByteCnt = 0;
return false;
}
}
-void TpUartDataLinkLayer::addFrameTxQueue(CemiFrame& frame){
+void TpUartDataLinkLayer::addFrameTxQueue(CemiFrame& frame)
+{
_tx_queue_frame_t* tx_frame = new _tx_queue_frame_t;
tx_frame->length = frame.telegramLengthtTP();
@@ -434,35 +486,40 @@ void TpUartDataLinkLayer::addFrameTxQueue(CemiFrame& frame){
tx_frame->next = NULL;
frame.fillTelegramTP(tx_frame->data);
- if (_tx_queue.back == NULL) {
+ if (_tx_queue.back == NULL)
+ {
_tx_queue.front = _tx_queue.back = tx_frame;
}
- else{
+ else
+ {
_tx_queue.back->next = tx_frame;
_tx_queue.back = tx_frame;
}
}
-bool TpUartDataLinkLayer::isTxQueueEmpty(){
- if (_tx_queue.front == NULL){
- return true;
+bool TpUartDataLinkLayer::isTxQueueEmpty()
+{
+ if (_tx_queue.front == NULL)
+ {
+ return true;
}
return false;
}
+void TpUartDataLinkLayer::loadNextTxFrame()
+{
+ if (_tx_queue.front == NULL)
+ {
+ return;
+ }
+ _tx_queue_frame_t* tx_frame = _tx_queue.front;
+ _sendBuffer = tx_frame->data;
+ _sendBufferLength = tx_frame->length;
+ _tx_queue.front = tx_frame->next;
-void TpUartDataLinkLayer::loadNextTxFrame(){
- if (_tx_queue.front == NULL) {
- return;
- }
- _tx_queue_frame_t* tx_frame = _tx_queue.front;
- _sendBuffer = tx_frame->data;
- _sendBufferLength = tx_frame->length;
- _tx_queue.front = tx_frame->next;
-
- if (_tx_queue.front == NULL){
- _tx_queue.back = NULL;
- }
- delete tx_frame;
+ if (_tx_queue.front == NULL)
+ {
+ _tx_queue.back = NULL;
+ }
+ delete tx_frame;
}
-
diff --git a/src/knx/tpuart_data_link_layer.h b/src/knx/tpuart_data_link_layer.h
index fe1ccfe..6c080e5 100644
--- a/src/knx/tpuart_data_link_layer.h
+++ b/src/knx/tpuart_data_link_layer.h
@@ -3,24 +3,23 @@
#include
#include "data_link_layer.h"
-#define MAX_KNX_TELEGRAM_SIZE 263
-#define BYTE_TIMEOUT 3 //milli seconds
-#define CONFIRM_TIMEOUT 500 //milli seconds
+#define MAX_KNX_TELEGRAM_SIZE 263
-
-class TpUartDataLinkLayer: public DataLinkLayer
+class TpUartDataLinkLayer : public DataLinkLayer
{
using DataLinkLayer::_deviceObject;
- using DataLinkLayer::_platform;
using DataLinkLayer::_groupAddressTable;
-public:
+ using DataLinkLayer::_platform;
+
+ public:
TpUartDataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, NetworkLayer& layer,
- Platform& platform);
+ Platform& platform);
void loop();
void enabled(bool value);
bool enabled() const;
-private:
+
+ private:
bool _enabled = false;
bool _waitConfirm = false;
uint8_t* _sendBuffer = 0;
@@ -33,20 +32,22 @@ private:
bool _isEcho = false;
bool _isAddressed = false;
bool _convert = false;
- uint8_t _xorSum=0;
+ uint8_t _xorSum = 0;
uint32_t _lastByteRxTime;
uint32_t _waitConfirmStartTime;
- struct _tx_queue_frame_t{
- uint8_t *data;
+ struct _tx_queue_frame_t
+ {
+ uint8_t* data;
uint16_t length;
- _tx_queue_frame_t *next;
+ _tx_queue_frame_t* next;
};
- struct _tx_queue_t {
- _tx_queue_frame_t *front=NULL;
- _tx_queue_frame_t *back=NULL;
- }_tx_queue;
+ struct _tx_queue_t
+ {
+ _tx_queue_frame_t* front = NULL;
+ _tx_queue_frame_t* back = NULL;
+ } _tx_queue;
void addFrameTxQueue(CemiFrame& frame);
bool isTxQueueEmpty();
@@ -58,4 +59,3 @@ private:
void resetChip();
void stopChip();
};
-
diff --git a/src/linux_platform.h b/src/linux_platform.h
index 404325b..4881d8a 100644
--- a/src/linux_platform.h
+++ b/src/linux_platform.h
@@ -51,15 +51,15 @@ public:
void cmdlineArgs(int argc, char** argv);
private:
- uint32_t _multicastAddr;
- uint16_t _port;
+ uint32_t _multicastAddr = -1;
+ uint16_t _port = -1;
int _socketFd = -1;
void doMemoryMapping();
- uint8_t* _mappedFile;
+ uint8_t* _mappedFile = 0;
int _fd = -1;
uint8_t* _currentMaxMem = 0;
std::string _flashFilePath = "flash.bin";
- char** _args;
+ char** _args = 0;
};
#endif
\ No newline at end of file