Merge pull request #2 from thelsing/master

update from master
This commit is contained in:
Bernator 2019-07-22 19:01:27 +02:00 committed by GitHub
commit a7f237f391
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 671 additions and 828 deletions

27
.clang-format Normal file
View File

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

View File

@ -1,95 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="ApplicationProgramObject" Collapsed="true">
<Position X="4" Y="4.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AIAAAAEAAACAAAIAgCAAAAAgABAEAAgAAAAQQABAAAA=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\application_program_object.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="AssociationTableObject" Collapsed="true">
<Position X="5.75" Y="4.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAEAAACAAgIAABAAQAgAAAEAAAgAAAAAAABAAEA=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\association_table_object.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="DeviceObject" Collapsed="true">
<Position X="0.5" Y="4.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAACACEAAAGCIAKAQCAgAACgCECAAEogAEgIAgJAAAA=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\device_object.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="GroupObjectTableObject" Collapsed="true">
<Position X="7.5" Y="4.25" Width="1.5" />
<TypeIdentifier>
<HashCode>EAAAAEEACACAAgIAAhAATAgACAAAAAggAAAAAABAAAA=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\group_object_table_object.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="InterfaceObject" Collapsed="true">
<Position X="2" Y="1.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAEAAAAAAAAAACAAAAAgAAAAAAgAAAAIABBAAAA=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\interface_object.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="IpParameterObject" Collapsed="true">
<Position X="2.75" Y="2.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAIACIEAYACAAKIAAGAQCAAgWAIAAAgGAAAAAABgAIA=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\ip_parameter_object.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="TableObject" Collapsed="true">
<Position X="4.25" Y="0.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAIACIACBACAAIIAAGAACAgwyAAAAAAAAgAAAAJgAAA=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\table_object.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="BusAccessUnit" Collapsed="true">
<Position X="6.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>sKoIAAAAQIIxC4gUUEAIAAACiQEgAjQUFCCA5yEAIBw=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\bau.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="Bau57B0" Collapsed="true">
<Position X="5.75" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAACAAAAAIAAAABAAgAAAAAAAAAgAAAAACAAAAAAAAg=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\bau57B0.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="LinuxPlatform" Collapsed="true">
<Position X="9.75" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>BACGJBAAIigAIHgAAABAghAQAAAAACgAAADAEgAAAjA=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\linux_platform.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="Platform" Collapsed="true">
<Position X="9.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAGJBAAICgAIFAAAABAwhAAABAAAAgAAADAEgAAAhA=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\platform.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="BauSystemB" Collapsed="true">
<Position X="6.75" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>ABIAAFQgAoJwCoBAUCiCAIDAiEBgADQQAIAAAAKQABQ=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\bau_systemB.h</FileName>
</TypeIdentifier>
</Class>
<Class Name="Bau07B0" Collapsed="true">
<Position X="7.5" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAACAAAAAIBAAABAAAAAAAAAAAAgAAAAACAAAAAAAAA=</HashCode>
<FileName>C:\Users\tkunze\Source\knx\src\knx\bau07B0.h</FileName>
</TypeIdentifier>
</Class>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

View File

@ -7,9 +7,9 @@
<PathStyle>RemoteUnix</PathStyle> <PathStyle>RemoteUnix</PathStyle>
</CustomSourceDirectories> </CustomSourceDirectories>
<BuildHost> <BuildHost>
<HostName>localhost</HostName> <HostName>Suzail</HostName>
<Transport>LinuxSubsystem</Transport> <Transport>SSH</Transport>
<UserName>Linux</UserName> <UserName>tkunze</UserName>
</BuildHost> </BuildHost>
<MainSourceTransferCommand> <MainSourceTransferCommand>
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList> <SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
@ -34,15 +34,14 @@
<string>CMakeLists.txt</string> <string>CMakeLists.txt</string>
<string>*.cmake</string> <string>*.cmake</string>
</FileMasks> </FileMasks>
<TransferNewFilesOnly>true</TransferNewFilesOnly> <TransferNewFilesOnly>false</TransferNewFilesOnly>
<IncludeSubdirectories>true</IncludeSubdirectories> <IncludeSubdirectories>true</IncludeSubdirectories>
<SelectedDirectories />
<DeleteDisappearedFiles>true</DeleteDisappearedFiles> <DeleteDisappearedFiles>true</DeleteDisappearedFiles>
<ApplyGlobalExclusionList>true</ApplyGlobalExclusionList> <ApplyGlobalExclusionList>true</ApplyGlobalExclusionList>
<Extension> <Extension>
<Direction>Outgoing</Direction> <Direction>Outgoing</Direction>
<SkipMountPoints>false</SkipMountPoints> <SkipMountPoints>false</SkipMountPoints>
<OverwriteTrigger>LocalCache</OverwriteTrigger> <OverwriteTrigger>Always</OverwriteTrigger>
</Extension> </Extension>
</MainSourceTransferCommand> </MainSourceTransferCommand>
<AllowChangingHostForMainCommands>false</AllowChangingHostForMainCommands> <AllowChangingHostForMainCommands>false</AllowChangingHostForMainCommands>
@ -115,12 +114,13 @@
<HideErrorsInSystemHeaders>true</HideErrorsInSystemHeaders> <HideErrorsInSystemHeaders>true</HideErrorsInSystemHeaders>
<SupportLightweightReferenceAnalysis>true</SupportLightweightReferenceAnalysis> <SupportLightweightReferenceAnalysis>true</SupportLightweightReferenceAnalysis>
<DiscoverySettings> <DiscoverySettings>
<Mode>Disabled</Mode> <Mode>Silent</Mode>
<SearchInProjectDir>true</SearchInProjectDir> <SearchInProjectDir>true</SearchInProjectDir>
<SearchInSourceDirs>true</SearchInSourceDirs> <SearchInSourceDirs>true</SearchInSourceDirs>
<SearchInIncludeSubdirs>true</SearchInIncludeSubdirs> <SearchInIncludeSubdirs>true</SearchInIncludeSubdirs>
</DiscoverySettings> </DiscoverySettings>
<CheckForClangFormatFiles>true</CheckForClangFormatFiles> <CheckForClangFormatFiles>true</CheckForClangFormatFiles>
<ExplicitClangFormatFile>..\.clang-format</ExplicitClangFormatFile>
<FormattingEngine>ClangFormat</FormattingEngine> <FormattingEngine>ClangFormat</FormattingEngine>
</ExtraSettings> </ExtraSettings>
<CodeAnalyzerSettings> <CodeAnalyzerSettings>

View File

@ -1,160 +0,0 @@
<?xml version="1.0"?>
<VisualGDBProjectSettings2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ConfigurationName>Release</ConfigurationName>
<Project xsi:type="com.visualgdb.project.linux">
<CustomSourceDirectories>
<Directories />
<PathStyle>RemoteUnix</PathStyle>
</CustomSourceDirectories>
<BuildHost>
<HostName>Suzail</HostName>
<Transport>SSH</Transport>
<UserName>tkunze</UserName>
</BuildHost>
<MainSourceTransferCommand>
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
<RemoteHost>
<HostName>Suzail</HostName>
<Transport>SSH</Transport>
<UserName>tkunze</UserName>
</RemoteHost>
<LocalDirectory>$(ProjectDir)</LocalDirectory>
<RemoteDirectory>/home/tkunze/vgdb</RemoteDirectory>
<FileMasks>
<string>*.cpp</string>
<string>*.h</string>
<string>*.hpp</string>
<string>*.c</string>
<string>*.cc</string>
<string>*.cxx</string>
<string>*.mak</string>
<string>Makefile</string>
<string>*.txt</string>
<string>*.cmake</string>
<string>CMakeLists.txt</string>
<string>*.cmake</string>
</FileMasks>
<TransferNewFilesOnly>true</TransferNewFilesOnly>
<IncludeSubdirectories>true</IncludeSubdirectories>
<DeleteDisappearedFiles>true</DeleteDisappearedFiles>
<ApplyGlobalExclusionList>true</ApplyGlobalExclusionList>
</MainSourceTransferCommand>
<AllowChangingHostForMainCommands>false</AllowChangingHostForMainCommands>
<SkipBuildIfNoSourceFilesChanged>false</SkipBuildIfNoSourceFilesChanged>
<IgnoreFileTransferErrors>false</IgnoreFileTransferErrors>
<RemoveRemoteDirectoryOnClean>false</RemoveRemoteDirectoryOnClean>
<SkipDeploymentTests>false</SkipDeploymentTests>
<MainSourceDirectoryForLocalBuilds>$(ProjectDir)</MainSourceDirectoryForLocalBuilds>
</Project>
<Build xsi:type="com.visualgdb.build.cmake">
<ToolchainID>
<ID>com.sysprogs.toolchain.default-gcc</ID>
<Version>
<Revision>0</Revision>
</Version>
</ToolchainID>
<RelativeSourceDirectory />
<ConfigurationType>RELWITHDEBINFO</ConfigurationType>
<BinaryDirectory>Release</BinaryDirectory>
<MakeCommandTemplate>
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
<RemoteHost>
<HostName>BuildMachine</HostName>
<Transport>BuiltinShortcut</Transport>
</RemoteHost>
<Command>$(ToolchainMake)</Command>
<Arguments>$(ToolchainMakeArgs)</Arguments>
<WorkingDirectory>$(BuildDir)</WorkingDirectory>
<BackgroundMode xsi:nil="true" />
</MakeCommandTemplate>
<CMakeCommand>
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
<RemoteHost>
<HostName>BuildMachine</HostName>
<Transport>BuiltinShortcut</Transport>
</RemoteHost>
<Command>$(ToolchainCMake)</Command>
<BackgroundMode xsi:nil="true" />
</CMakeCommand>
<UpdateSourcesInCMakeFile>true</UpdateSourcesInCMakeFile>
<ExportCompileCommands>false</ExportCompileCommands>
<DisableToolchainFile>false</DisableToolchainFile>
<DeployAsRoot>false</DeployAsRoot>
<CleanMode>b</CleanMode>
</Build>
<CustomBuild>
<PreSyncActions />
<PreBuildActions />
<PostBuildActions />
<PreCleanActions />
<PostCleanActions />
</CustomBuild>
<CustomDebug>
<PreDebugActions />
<PostDebugActions />
<DebugStopActions />
<BreakMode>Default</BreakMode>
</CustomDebug>
<CustomShortcuts>
<Shortcuts />
<ShowMessageAfterExecuting>true</ShowMessageAfterExecuting>
</CustomShortcuts>
<UserDefinedVariables />
<CodeSense>
<Enabled>Unknown</Enabled>
<ExtraSettings>
<HideErrorsInSystemHeaders>true</HideErrorsInSystemHeaders>
<SupportLightweightReferenceAnalysis>true</SupportLightweightReferenceAnalysis>
<CheckForClangFormatFiles>true</CheckForClangFormatFiles>
<FormattingEngine xsi:nil="true" />
</ExtraSettings>
<CodeAnalyzerSettings>
<Enabled>false</Enabled>
</CodeAnalyzerSettings>
</CodeSense>
<Debug xsi:type="com.visualgdb.debug.remote">
<AdditionalStartupCommands />
<AdditionalGDBSettings>
<Features>
<DisableAutoDetection>false</DisableAutoDetection>
<UseFrameParameter>false</UseFrameParameter>
<SimpleValuesFlagSupported>false</SimpleValuesFlagSupported>
<ListLocalsSupported>false</ListLocalsSupported>
<ByteLevelMemoryCommandsAvailable>false</ByteLevelMemoryCommandsAvailable>
<ThreadInfoSupported>false</ThreadInfoSupported>
<PendingBreakpointsSupported>false</PendingBreakpointsSupported>
<SupportTargetCommand>false</SupportTargetCommand>
<ReliableBreakpointNotifications>false</ReliableBreakpointNotifications>
</Features>
<EnableSmartStepping>false</EnableSmartStepping>
<FilterSpuriousStoppedNotifications>false</FilterSpuriousStoppedNotifications>
<ForceSingleThreadedMode>false</ForceSingleThreadedMode>
<UseAppleExtensions>false</UseAppleExtensions>
<CanAcceptCommandsWhileRunning>false</CanAcceptCommandsWhileRunning>
<MakeLogFile>false</MakeLogFile>
<IgnoreModuleEventsWhileStepping>true</IgnoreModuleEventsWhileStepping>
<UseRelativePathsOnly>false</UseRelativePathsOnly>
<ExitAction>None</ExitAction>
<DisableDisassembly>false</DisableDisassembly>
<ExamineMemoryWithXCommand>false</ExamineMemoryWithXCommand>
<StepIntoNewInstanceEntry>main</StepIntoNewInstanceEntry>
<ExamineRegistersInRawFormat>true</ExamineRegistersInRawFormat>
<DisableSignals>false</DisableSignals>
<EnableAsyncExecutionMode>false</EnableAsyncExecutionMode>
<EnableNonStopMode>false</EnableNonStopMode>
<MaxBreakpointLimit>0</MaxBreakpointLimit>
</AdditionalGDBSettings>
<LaunchGDBSettings xsi:type="GDBLaunchParametersNewInstance">
<DebuggedProgram>$(TargetPath)</DebuggedProgram>
<GDBServerPort>2000</GDBServerPort>
<ProgramArguments />
</LaunchGDBSettings>
<GenerateCtrlBreakInsteadOfCtrlC>false</GenerateCtrlBreakInsteadOfCtrlC>
<X11WindowMode>Local</X11WindowMode>
<KeepConsoleAfterExit>false</KeepConsoleAfterExit>
<RunGDBUnderSudo>false</RunGDBUnderSudo>
<DeploymentMode>Auto</DeploymentMode>
<DeployWhenLaunchedWithoutDebugging>true</DeployWhenLaunchedWithoutDebugging>
<SuppressTTYCreation>false</SuppressTTYCreation>
</Debug>
</VisualGDBProjectSettings2>

View File

@ -110,10 +110,8 @@
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
<ItemGroup> <ItemGroup>
<None Include="ClassDiagram.cd" />
<None Include="CMakeLists.txt" /> <None Include="CMakeLists.txt" />
<None Include="knx-linux-Debug.vgdbsettings" /> <None Include="knx-linux-Debug.vgdbsettings" />
<None Include="knx-linux-Release.vgdbsettings" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\src\knx\address_table_object.cpp" /> <ClCompile Include="..\src\knx\address_table_object.cpp" />

View File

@ -30,10 +30,6 @@
<None Include="knx-linux-Debug.vgdbsettings"> <None Include="knx-linux-Debug.vgdbsettings">
<Filter>VisualGDB settings</Filter> <Filter>VisualGDB settings</Filter>
</None> </None>
<None Include="knx-linux-Release.vgdbsettings">
<Filter>VisualGDB settings</Filter>
</None>
<None Include="ClassDiagram.cd" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\src\linux_platform.h"> <ClInclude Include="..\src\linux_platform.h">

View File

@ -25,8 +25,10 @@ void measureTemp()
lastsend = now; lastsend = now;
int r = rand(); int r = rand();
double currentValue = (r * 1.0) / (RAND_MAX * 1.0); double currentValue = (r * 1.0) / (RAND_MAX * 1.0);
currentValue *= (670433.28 + 273); currentValue *= 100;
currentValue -= 273; currentValue -= 50;
// currentValue *= (670433.28 + 273);
// currentValue -= 273;
println(currentValue); println(currentValue);
CURR.value(currentValue); CURR.value(currentValue);

View File

@ -49,10 +49,12 @@ public:
* @return true if the address table contains the group address, false otherwise * @return true if the address table contains the group address, false otherwise
*/ */
bool contains(uint16_t groupAddress); bool contains(uint16_t groupAddress);
protected: protected:
virtual void beforeStateChange(LoadState& newState); virtual void beforeStateChange(LoadState& newState);
uint8_t propertyCount(); uint8_t propertyCount();
PropertyDescription* propertyDescriptions(); PropertyDescription* propertyDescriptions();
private: private:
uint16_t* _groupAddresses; uint16_t* _groupAddresses = 0;
}; };

View File

@ -48,6 +48,6 @@ class APDU
APDU(uint8_t* data, CemiFrame& frame); APDU(uint8_t* data, CemiFrame& frame);
private: private:
uint8_t* _data; uint8_t* _data = 0;
CemiFrame& _frame; CemiFrame& _frame;
}; };

View File

@ -146,6 +146,6 @@ class ApplicationLayer
uint16_t _savedAsapResponse; uint16_t _savedAsapResponse;
AssociationTableObject& _assocTable; AssociationTableObject& _assocTable;
BusAccessUnit& _bau; BusAccessUnit& _bau;
TransportLayer* _transportLayer; TransportLayer* _transportLayer = 0;
int32_t _connectedTsap; int32_t _connectedTsap;
}; };

View File

@ -15,9 +15,11 @@ public:
uint32_t getInt(uint32_t addr); uint32_t getInt(uint32_t addr);
uint8_t* save(uint8_t* buffer); uint8_t* save(uint8_t* buffer);
uint8_t* restore(uint8_t* buffer); uint8_t* restore(uint8_t* buffer);
protected: protected:
uint8_t propertyCount(); uint8_t propertyCount();
PropertyDescription* propertyDescriptions(); PropertyDescription* propertyDescriptions();
private: private:
uint8_t _programVersion[5]; uint8_t _programVersion[5] = {0, 0, 0, 0, 0};
}; };

View File

@ -13,10 +13,12 @@ public:
uint8_t* restore(uint8_t* buffer); uint8_t* restore(uint8_t* buffer);
int32_t translateAsap(uint16_t asap); int32_t translateAsap(uint16_t asap);
protected: protected:
void beforeStateChange(LoadState& newState); void beforeStateChange(LoadState& newState);
uint8_t propertyCount(); uint8_t propertyCount();
PropertyDescription* propertyDescriptions(); PropertyDescription* propertyDescriptions();
private: private:
uint16_t* _tableData; uint16_t* _tableData = 0;
}; };

View File

@ -2,17 +2,13 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
using namespace std; using namespace std;
Bau07B0::Bau07B0(Platform& platform): BauSystemB(platform), Bau07B0::Bau07B0(Platform& platform)
: BauSystemB(platform),
_dlLayer(_deviceObj, _addrTable, _netLayer, _platform) _dlLayer(_deviceObj, _addrTable, _netLayer, _platform)
{ {
_netLayer.dataLinkLayer(_dlLayer); _netLayer.dataLinkLayer(_dlLayer);
uint8_t descriptor[] = { 0x07, 0xb0 };
_descriptor[0] = descriptor[0];
_descriptor[1] = descriptor[1];
} }
InterfaceObject* Bau07B0::getInterfaceObject(uint8_t idx) InterfaceObject* Bau07B0::getInterfaceObject(uint8_t idx)

View File

@ -7,11 +7,13 @@ class Bau07B0: public BauSystemB
{ {
public: public:
Bau07B0(Platform& platform); Bau07B0(Platform& platform);
protected: protected:
InterfaceObject* getInterfaceObject(uint8_t idx); InterfaceObject* getInterfaceObject(uint8_t idx);
uint8_t* descriptor(); uint8_t* descriptor();
DataLinkLayer& dataLinkLayer(); DataLinkLayer& dataLinkLayer();
private: private:
TpUartDataLinkLayer _dlLayer; TpUartDataLinkLayer _dlLayer;
uint8_t _descriptor[2]; uint8_t _descriptor[2] = {0x07, 0xb0};
}; };

View File

@ -4,16 +4,13 @@
using namespace std; using namespace std;
Bau57B0::Bau57B0(Platform& platform): BauSystemB(platform), Bau57B0::Bau57B0(Platform& platform)
: BauSystemB(platform),
_ipParameters(_deviceObj, platform), _ipParameters(_deviceObj, platform),
_dlLayer(_deviceObj, _addrTable, _ipParameters, _netLayer, _platform) _dlLayer(_deviceObj, _addrTable, _ipParameters, _netLayer, _platform)
{ {
_netLayer.dataLinkLayer(_dlLayer); _netLayer.dataLinkLayer(_dlLayer);
_memory.addSaveRestore(&_ipParameters); _memory.addSaveRestore(&_ipParameters);
uint8_t descriptor[] = { 0x57, 0xb0 };
_descriptor[0] = descriptor[0];
_descriptor[1] = descriptor[1];
} }
InterfaceObject* Bau57B0::getInterfaceObject(uint8_t idx) InterfaceObject* Bau57B0::getInterfaceObject(uint8_t idx)

View File

@ -8,12 +8,14 @@ class Bau57B0: public BauSystemB
{ {
public: public:
Bau57B0(Platform& platform); Bau57B0(Platform& platform);
protected: protected:
InterfaceObject* getInterfaceObject(uint8_t idx); InterfaceObject* getInterfaceObject(uint8_t idx);
uint8_t* descriptor(); uint8_t* descriptor();
DataLinkLayer& dataLinkLayer(); DataLinkLayer& dataLinkLayer();
private: private:
IpParameterObject _ipParameters; IpParameterObject _ipParameters;
IpDataLinkLayer _dlLayer; IpDataLinkLayer _dlLayer;
uint8_t _descriptor[2]; uint8_t _descriptor[2] = {0x57, 0xb0};
}; };

View File

@ -28,6 +28,7 @@ public:
void writeMemory(); void writeMemory();
void addSaveRestore(SaveRestore* obj); void addSaveRestore(SaveRestore* obj);
void restartRequest(uint16_t asap); void restartRequest(uint16_t asap);
protected: protected:
virtual DataLinkLayer& dataLinkLayer() = 0; virtual DataLinkLayer& dataLinkLayer() = 0;
virtual uint8_t* descriptor() = 0; virtual uint8_t* descriptor() = 0;
@ -58,7 +59,6 @@ protected:
void groupValueWriteIndication(uint16_t asap, Priority priority, HopCountType hopType, void groupValueWriteIndication(uint16_t asap, Priority priority, HopCountType hopType,
uint8_t* data, uint8_t dataLength) override; uint8_t* data, uint8_t dataLength) override;
virtual InterfaceObject* getInterfaceObject(uint8_t idx) = 0; virtual InterfaceObject* getInterfaceObject(uint8_t idx) = 0;
void sendNextGroupTelegram(); void sendNextGroupTelegram();
void updateGroupObject(GroupObject& go, uint8_t* data, uint8_t length); void updateGroupObject(GroupObject& go, uint8_t* data, uint8_t length);

View File

@ -15,6 +15,7 @@
class CemiFrame class CemiFrame
{ {
friend class DataLinkLayer; friend class DataLinkLayer;
public: public:
CemiFrame(uint8_t* data, uint16_t length); CemiFrame(uint8_t* data, uint16_t length);
CemiFrame(uint8_t apduLength); CemiFrame(uint8_t apduLength);
@ -52,12 +53,13 @@ public:
uint8_t calcCRC(uint8_t* buffer, uint16_t len); uint8_t calcCRC(uint8_t* buffer, uint16_t len);
bool valid() const; bool valid() const;
private: private:
uint8_t buffer[0xff + NPDU_LPDU_DIFF]; //only valid of add info is zero uint8_t buffer[0xff + NPDU_LPDU_DIFF] = {0}; //only valid of add info is zero
uint8_t* _data; uint8_t* _data = 0;
uint8_t* _ctrl1; uint8_t* _ctrl1 = 0;
NPDU _npdu; NPDU _npdu;
TPDU _tpdu; TPDU _tpdu;
APDU _apdu; APDU _apdu;
uint16_t _length; // only set if created from byte array uint16_t _length = 0; // only set if created from byte array
}; };

View File

@ -19,6 +19,7 @@ public:
virtual void loop() = 0; virtual void loop() = 0;
virtual void enabled(bool value) = 0; virtual void enabled(bool value) = 0;
virtual bool enabled() const = 0; virtual bool enabled() const = 0;
protected: protected:
void frameRecieved(CemiFrame& frame); void frameRecieved(CemiFrame& frame);
void dataConReceived(CemiFrame& frame, bool success); void dataConReceived(CemiFrame& frame, bool success);

View File

@ -35,7 +35,7 @@ void DeviceObject::readProperty(PropertyID propertyId, uint32_t start, uint32_t&
*data = _prgMode; *data = _prgMode;
break; break;
case PID_MAX_APDU_LENGTH: case PID_MAX_APDU_LENGTH:
pushWord(15, data); pushWord(254, data);
break; break;
case PID_SUBNET_ADDR: case PID_SUBNET_ADDR:
*data = ((_ownAddress >> 8) & 0xff); *data = ((_ownAddress >> 8) & 0xff);

View File

@ -39,13 +39,13 @@ protected:
uint8_t propertyCount(); uint8_t propertyCount();
PropertyDescription* propertyDescriptions(); PropertyDescription* propertyDescriptions();
private: private:
uint8_t _deviceControl; uint8_t _deviceControl = 0;
uint8_t _routingCount; uint8_t _routingCount = 0;
uint8_t _prgMode; uint8_t _prgMode = 0;
uint16_t _ownAddress; uint16_t _ownAddress = 0;
uint16_t _manufacturerId = 0xfa; //Default to KNXA uint16_t _manufacturerId = 0xfa; //Default to KNXA
uint32_t _bauNumber; uint32_t _bauNumber = 0;
char _orderNumber[10]; char _orderNumber[10] = "";
uint8_t _hardwareType[6]; uint8_t _hardwareType[6] = { 0, 0, 0, 0, 0, 0};
uint16_t _version; uint16_t _version = 0;
}; };

View File

@ -1794,7 +1794,11 @@ void float16ToPayload(uint8_t* payload, int payload_length, int index, double va
} }
value *= 100.0; 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)); short mantissa = roundf(value / (1 << exponent));
if (wasNegative) if (wasNegative)

View File

@ -19,7 +19,6 @@ enum ComFlag
class GroupObject; class GroupObject;
#ifdef __linux__ #ifdef __linux__
#include <functional> #include <functional>
typedef std::function<void(GroupObject&)> GroupObjectUpdatedHandler; typedef std::function<void(GroupObject&)> GroupObjectUpdatedHandler;
@ -33,6 +32,7 @@ typedef void(*GroupObjectUpdatedHandler)(GroupObject& go);
class GroupObject class GroupObject
{ {
friend class GroupObjectTableObject; friend class GroupObjectTableObject;
public: public:
/** /**
* The constructor. * The constructor.
@ -206,10 +206,10 @@ public:
size_t asapValueSize(uint8_t code); size_t asapValueSize(uint8_t code);
GroupObjectUpdatedHandler _updateHandler; GroupObjectUpdatedHandler _updateHandler;
size_t goSize(); size_t goSize();
uint16_t _asap; uint16_t _asap = 0;
ComFlag _commFlag; ComFlag _commFlag = Ok;
uint8_t* _data; uint8_t* _data = 0;
uint8_t _dataLength; uint8_t _dataLength = 0;
GroupObjectTableObject* _table; GroupObjectTableObject* _table = 0;
Dpt _datapointType; Dpt _datapointType;
}; };

View File

@ -18,10 +18,12 @@ public:
virtual uint8_t* save(uint8_t* buffer); virtual uint8_t* save(uint8_t* buffer);
virtual uint8_t* restore(uint8_t* buffer); virtual uint8_t* restore(uint8_t* buffer);
protected: protected:
virtual void beforeStateChange(LoadState& newState); virtual void beforeStateChange(LoadState& newState);
uint8_t propertyCount(); uint8_t propertyCount();
PropertyDescription* propertyDescriptions(); PropertyDescription* propertyDescriptions();
private: private:
void freeGroupObjects(); void freeGroupObjects();
bool initGroupObjects(); bool initGroupObjects();

View File

@ -114,6 +114,7 @@ public:
*/ */
void readPropertyDescription(uint8_t& propertyId, uint8_t& propertyIndex, bool& writeEnable, uint8_t& type, uint16_t& numberOfElements, uint8_t& access); 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. * Returns the number of properties the interface object has.

View File

@ -7,6 +7,7 @@
class IpDataLinkLayer : public DataLinkLayer class IpDataLinkLayer : public DataLinkLayer
{ {
using DataLinkLayer::_deviceObject; using DataLinkLayer::_deviceObject;
public: public:
IpDataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, IpParameterObject& ipParam, NetworkLayer& layer, IpDataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, IpParameterObject& ipParam, NetworkLayer& layer,
Platform& platform); Platform& platform);
@ -14,6 +15,7 @@ public:
void loop(); void loop();
void enabled(bool value); void enabled(bool value);
bool enabled() const; bool enabled() const;
private: private:
bool _enabled = false; bool _enabled = false;
bool sendFrame(CemiFrame& frame); bool sendFrame(CemiFrame& frame);

View File

@ -17,9 +17,11 @@ public:
uint32_t multicastAddress() const; uint32_t multicastAddress() const;
uint8_t ttl() const { return _ttl; } uint8_t ttl() const { return _ttl; }
protected: protected:
uint8_t propertyCount(); uint8_t propertyCount();
PropertyDescription* propertyDescriptions(); PropertyDescription* propertyDescriptions();
private: private:
uint16_t _projectInstallationId = 0; uint16_t _projectInstallationId = 0;
uint8_t _ipAssignmentMethod = 0; uint8_t _ipAssignmentMethod = 0;

View File

@ -18,7 +18,7 @@ public:
private: private:
Platform& _platform; Platform& _platform;
bool _modified = false; bool _modified = false;
SaveRestore* _saveRestores[MAXSAVE]; SaveRestore* _saveRestores[MAXSAVE] = {0};
int _saveCount = 0; int _saveCount = 0;
uint8_t* _data = 0; uint8_t* _data = 0;
}; };

View File

@ -33,6 +33,6 @@ public:
private: private:
void sendDataRequest(TPDU& tpdu, HopCountType hopType, AckType ack, uint16_t destination, Priority priority, AddressType addrType); void sendDataRequest(TPDU& tpdu, HopCountType hopType, AckType ack, uint16_t destination, Priority priority, AddressType addrType);
uint8_t _hopCount = 6; uint8_t _hopCount = 6;
DataLinkLayer* _dataLinkLayer; DataLinkLayer* _dataLinkLayer = 0;
TransportLayer& _transportLayer; TransportLayer& _transportLayer;
}; };

View File

@ -22,6 +22,6 @@ class NPDU
NPDU(uint8_t* data, CemiFrame& frame); NPDU(uint8_t* data, CemiFrame& frame);
private: private:
uint8_t* _data; uint8_t* _data = 0;
CemiFrame& _frame; CemiFrame& _frame;
}; };

View File

@ -32,8 +32,9 @@ void Platform::freeMemory(uint8_t* ptr)
Platform::Platform() Platform::Platform()
{ {
// allocate memory to have a memory reference, substract a bit // allocate memory to have a memory reference, substract a bit
_memoryReference = (uint8_t*)malloc(1) - 1024; _memoryReference = (uint8_t*)malloc(1);
free(_memoryReference); free(_memoryReference);
_memoryReference -= 1024;
print("MemRef: "); print("MemRef: ");
println((long unsigned int)_memoryReference, HEX); println((long unsigned int)_memoryReference, HEX);
} }

View File

@ -31,6 +31,6 @@ class TPDU
TPDU(uint8_t* data, CemiFrame& frame); TPDU(uint8_t* data, CemiFrame& frame);
private: private:
uint8_t* _data; uint8_t* _data = 0;
CemiFrame& _frame; CemiFrame& _frame;
}; };

View File

@ -80,8 +80,11 @@
#define RX_WAIT_DATA_CON 3 #define RX_WAIT_DATA_CON 3
#define TX_FRAME 4 #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[0] = 0x29;
_receiveBuffer[1] = 0; _receiveBuffer[1] = 0;
@ -91,13 +94,17 @@ void TpUartDataLinkLayer::loop(){
if (!_enabled) if (!_enabled)
return; return;
switch(_loopState){ switch (_loopState)
{
case IDLE: case IDLE:
if(_platform.uartAvailable()){ if (_platform.uartAvailable())
{
_loopState = RX_FIRST_BYTE; _loopState = RX_FIRST_BYTE;
} }
else{ else
if(!_waitConfirm && !isTxQueueEmpty()){ {
if (!_waitConfirm && !isTxQueueEmpty())
{
loadNextTxFrame(); loadNextTxFrame();
_waitConfirm = true; _waitConfirm = true;
_waitConfirmStartTime = _platform.millis(); _waitConfirmStartTime = _platform.millis();
@ -106,7 +113,8 @@ void TpUartDataLinkLayer::loop(){
} }
break; break;
case TX_FRAME: case TX_FRAME:
if(sendSingleFrameByte() == false){ if (sendSingleFrameByte() == false)
{
_loopState = IDLE; _loopState = IDLE;
} }
break; break;
@ -115,7 +123,8 @@ void TpUartDataLinkLayer::loop(){
_lastByteRxTime = _platform.millis(); _lastByteRxTime = _platform.millis();
_RxByteCnt = 0; _RxByteCnt = 0;
_xorSum = 0; _xorSum = 0;
if ((rxByte & L_DATA_MASK) == L_DATA_STANDARD_IND){ if ((rxByte & L_DATA_MASK) == L_DATA_STANDARD_IND)
{
buffer[_RxByteCnt++] = rxByte; buffer[_RxByteCnt++] = rxByte;
_xorSum ^= rxByte; _xorSum ^= rxByte;
_RxByteCnt++; //convert to L_DATA_EXTENDED _RxByteCnt++; //convert to L_DATA_EXTENDED
@ -123,52 +132,63 @@ void TpUartDataLinkLayer::loop(){
_loopState = RX_L_DATA; _loopState = RX_L_DATA;
break; break;
} }
else if ((rxByte & L_DATA_MASK) == L_DATA_EXTENDED_IND){ else if ((rxByte & L_DATA_MASK) == L_DATA_EXTENDED_IND)
{
buffer[_RxByteCnt++] = rxByte; buffer[_RxByteCnt++] = rxByte;
_xorSum ^= rxByte; _xorSum ^= rxByte;
_convert = false; _convert = false;
_loopState = RX_L_DATA; _loopState = RX_L_DATA;
break; break;
} }
else if ((rxByte & L_DATA_CON_MASK) == L_DATA_CON){ else if ((rxByte & L_DATA_CON_MASK) == L_DATA_CON)
{
println("got unexpected L_DATA_CON"); println("got unexpected L_DATA_CON");
} }
else if (rxByte == L_POLL_DATA_IND){ else if (rxByte == L_POLL_DATA_IND)
{
// not sure if this can happen // not sure if this can happen
println("got L_POLL_DATA_IND"); println("got L_POLL_DATA_IND");
} }
else if ((rxByte & L_ACKN_MASK) == L_ACKN_IND){ else if ((rxByte & L_ACKN_MASK) == L_ACKN_IND)
{
// this can only happen in bus monitor mode // this can only happen in bus monitor mode
println("got L_ACKN_IND"); println("got L_ACKN_IND");
} }
else if (rxByte == U_RESET_IND){ else if (rxByte == U_RESET_IND)
{
println("got U_RESET_IND"); println("got U_RESET_IND");
} }
else if((rxByte & U_STATE_IND) == U_STATE_IND){ else if ((rxByte & U_STATE_IND) == U_STATE_IND)
{
print("got U_STATE_IND: 0x"); print("got U_STATE_IND: 0x");
print(rxByte, HEX); print(rxByte, HEX);
println(); println();
} }
else if((rxByte & U_FRAME_STATE_MASK) == U_FRAME_STATE_IND){ else if ((rxByte & U_FRAME_STATE_MASK) == U_FRAME_STATE_IND)
{
print("got U_FRAME_STATE_IND: 0x"); print("got U_FRAME_STATE_IND: 0x");
print(rxByte, HEX); print(rxByte, HEX);
println(); println();
} }
else if((rxByte & U_CONFIGURE_MASK) == U_CONFIGURE_IND){ else if ((rxByte & U_CONFIGURE_MASK) == U_CONFIGURE_IND)
{
print("got U_CONFIGURE_IND: 0x"); print("got U_CONFIGURE_IND: 0x");
print(rxByte, HEX); print(rxByte, HEX);
println(); println();
} }
else if(rxByte == U_FRAME_END_IND){ else if (rxByte == U_FRAME_END_IND)
{
println("got U_FRAME_END_IND"); println("got U_FRAME_END_IND");
} }
else if(rxByte == U_STOP_MODE_IND){ else if (rxByte == U_STOP_MODE_IND)
{
println("got U_STOP_MODE_IND"); println("got U_STOP_MODE_IND");
} }
else if(rxByte == U_SYSTEM_STAT_IND){ else if (rxByte == U_SYSTEM_STAT_IND)
{
print("got U_SYSTEM_STAT_IND: 0x"); print("got U_SYSTEM_STAT_IND: 0x");
while (true){ while (true)
{
int tmp = _platform.readUart(); int tmp = _platform.readUart();
if (tmp < 0) if (tmp < 0)
continue; continue;
@ -178,7 +198,8 @@ void TpUartDataLinkLayer::loop(){
} }
println(); println();
} }
else{ else
{
print("got UNEXPECTED: 0x"); print("got UNEXPECTED: 0x");
print(rxByte, HEX); print(rxByte, HEX);
println(); println();
@ -186,87 +207,115 @@ void TpUartDataLinkLayer::loop(){
_loopState = IDLE; _loopState = IDLE;
break; break;
case RX_L_DATA: case RX_L_DATA:
if (_platform.millis() - _lastByteRxTime > BYTE_TIMEOUT){ if (_platform.millis() - _lastByteRxTime > BYTE_TIMEOUT)
{
_RxByteCnt = 0; _RxByteCnt = 0;
_loopState = IDLE; _loopState = IDLE;
println("Timeout during RX_L_DATA"); println("Timeout during RX_L_DATA");
break; break;
} }
if(!_platform.uartAvailable()) break; if (!_platform.uartAvailable())
break;
_lastByteRxTime = _platform.millis(); _lastByteRxTime = _platform.millis();
rxByte = _platform.readUart(); rxByte = _platform.readUart();
if(_RxByteCnt == MAX_KNX_TELEGRAM_SIZE){ if (_RxByteCnt == MAX_KNX_TELEGRAM_SIZE)
{
_loopState = IDLE; _loopState = IDLE;
println("invalid telegram size"); println("invalid telegram size");
} }
else{ else
{
buffer[_RxByteCnt++] = rxByte; buffer[_RxByteCnt++] = rxByte;
} }
if(_RxByteCnt==7){ //Destination Address + payload available if (_RxByteCnt == 7)
{
//Destination Address + payload available
_xorSum ^= rxByte; _xorSum ^= rxByte;
//check if echo //check if echo
if (!((buffer[0]^_sendBuffer[0])&~0x20) && !memcmp(buffer+2,_sendBuffer+1,5)){ //ignore repeated bit of control byte if (!((buffer[0] ^ _sendBuffer[0]) & ~0x20) && !memcmp(buffer + 2, _sendBuffer + 1, 5))
{ //ignore repeated bit of control byte
_isEcho = true; _isEcho = true;
} }
else{ else
{
_isEcho = false; _isEcho = false;
} }
//convert into Extended.ind //convert into Extended.ind
if(_convert){ if (_convert)
{
uint8_t payloadLength = buffer[6] & 0x0F; uint8_t payloadLength = buffer[6] & 0x0F;
buffer[1] = buffer[6] & 0xF0; buffer[1] = buffer[6] & 0xF0;
buffer[6] = payloadLength; buffer[6] = payloadLength;
} }
if(!_isEcho){ if (!_isEcho)
{
uint8_t c = 0x10; uint8_t c = 0x10;
//ceck if individual or group address //ceck if individual or group address
if ((buffer[6] & 0x80) == 0){ //individual if ((buffer[6] & 0x80) == 0)
if(_deviceObject.induvidualAddress() == getWord(buffer + 4)){ {
//individual
if (_deviceObject.induvidualAddress() == getWord(buffer + 4))
{
c |= 0x01; c |= 0x01;
} }
} }
else{ //group else
if(_groupAddressTable.contains(getWord(buffer + 4)) || getWord(buffer + 4) == 0){ {
//group
if (_groupAddressTable.contains(getWord(buffer + 4)) || getWord(buffer + 4) == 0)
{
c |= 0x01; c |= 0x01;
} }
} }
_platform.writeUart(c); _platform.writeUart(c);
} }
} }
else if(_RxByteCnt == buffer[6]+7+2){ //complete Frame received, payloadLength+1 for TCPI +1 for CRC else if (_RxByteCnt == buffer[6] + 7 + 2)
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 //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]) if (rxByte == _sendBuffer[_sendBufferLength - 1])
_isEcho = true; _isEcho = true;
else else
_isEcho = false; _isEcho = false;
} }
if(_isEcho){ if (_isEcho)
{
_loopState = RX_WAIT_DATA_CON; _loopState = RX_WAIT_DATA_CON;
} }
else{ else
{
frameBytesReceived(_receiveBuffer, _RxByteCnt + 2); frameBytesReceived(_receiveBuffer, _RxByteCnt + 2);
_loopState = IDLE; _loopState = IDLE;
} }
} }
else{ else
{
println("frame with invalid crc ignored"); println("frame with invalid crc ignored");
_loopState = IDLE; _loopState = IDLE;
} }
} }
else{ else
{
_xorSum ^= rxByte; _xorSum ^= rxByte;
} }
break; break;
case RX_WAIT_DATA_CON: case RX_WAIT_DATA_CON:
if(!_platform.uartAvailable()) break; if (!_platform.uartAvailable())
break;
rxByte = _platform.readUart(); rxByte = _platform.readUart();
_lastByteRxTime = _platform.millis(); _lastByteRxTime = _platform.millis();
if ((rxByte & L_DATA_CON_MASK) == L_DATA_CON){ if ((rxByte & L_DATA_CON_MASK) == L_DATA_CON)
{
//println("L_DATA_CON received"); //println("L_DATA_CON received");
dataConBytesReceived(_receiveBuffer, _RxByteCnt + 2, ((rxByte & SUCCESS) > 0)); dataConBytesReceived(_receiveBuffer, _RxByteCnt + 2, ((rxByte & SUCCESS) > 0));
_waitConfirm = false; _waitConfirm = false;
@ -275,7 +324,8 @@ void TpUartDataLinkLayer::loop(){
_sendBufferLength = 0; _sendBufferLength = 0;
_loopState = IDLE; _loopState = IDLE;
} }
else{ else
{
//should not happen //should not happen
println("expected L_DATA_CON not received"); println("expected L_DATA_CON not received");
dataConBytesReceived(_receiveBuffer, _RxByteCnt + 2, false); dataConBytesReceived(_receiveBuffer, _RxByteCnt + 2, false);
@ -290,8 +340,10 @@ void TpUartDataLinkLayer::loop(){
break; break;
} }
if(_waitConfirm){ if (_waitConfirm)
if (_platform.millis() - _waitConfirmStartTime > CONFIRM_TIMEOUT){ {
if (_platform.millis() - _waitConfirmStartTime > CONFIRM_TIMEOUT)
{
println("L_DATA_CON not received within expected time"); println("L_DATA_CON not received within expected time");
uint8_t cemiBuffer[MAX_KNX_TELEGRAM_SIZE]; uint8_t cemiBuffer[MAX_KNX_TELEGRAM_SIZE];
cemiBuffer[0] = 0x29; cemiBuffer[0] = 0x29;
@ -308,7 +360,6 @@ void TpUartDataLinkLayer::loop(){
} }
} }
bool TpUartDataLinkLayer::sendFrame(CemiFrame& frame) bool TpUartDataLinkLayer::sendFrame(CemiFrame& frame)
{ {
if (!_enabled) if (!_enabled)
@ -318,7 +369,6 @@ bool TpUartDataLinkLayer::sendFrame(CemiFrame& frame)
return true; return true;
} }
void TpUartDataLinkLayer::resetChip() void TpUartDataLinkLayer::resetChip()
{ {
uint8_t cmd = U_RESET_REQ; uint8_t cmd = U_RESET_REQ;
@ -345,13 +395,12 @@ void TpUartDataLinkLayer::stopChip()
#endif #endif
} }
TpUartDataLinkLayer::TpUartDataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, 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) void TpUartDataLinkLayer::frameBytesReceived(uint8_t* buffer, uint16_t length)
{ {
//printHex("=>", buffer, length); //printHex("=>", buffer, length);
@ -365,7 +414,6 @@ void TpUartDataLinkLayer::dataConBytesReceived(uint8_t* buffer, uint16_t length,
//printHex("=>", buffer, length); //printHex("=>", buffer, length);
CemiFrame frame(buffer, length); CemiFrame frame(buffer, length);
dataConReceived(frame, success); dataConReceived(frame, success);
} }
void TpUartDataLinkLayer::enabled(bool value) void TpUartDataLinkLayer::enabled(bool value)
@ -394,14 +442,16 @@ bool TpUartDataLinkLayer::enabled() const
return _enabled; return _enabled;
} }
bool TpUartDataLinkLayer::sendSingleFrameByte()
bool TpUartDataLinkLayer::sendSingleFrameByte(){ {
uint8_t cmd[2]; uint8_t cmd[2];
uint8_t idx = _TxByteCnt / 64; uint8_t idx = _TxByteCnt / 64;
if(_sendBuffer == NULL) return false; if (_sendBuffer == NULL)
return false;
if(_TxByteCnt < _sendBufferLength){ if (_TxByteCnt < _sendBufferLength)
{
if (idx != _oldIdx) if (idx != _oldIdx)
{ {
_oldIdx = idx; _oldIdx = idx;
@ -420,13 +470,15 @@ bool TpUartDataLinkLayer::sendSingleFrameByte(){
_TxByteCnt++; _TxByteCnt++;
return true; return true;
} }
else{ else
{
_TxByteCnt = 0; _TxByteCnt = 0;
return false; return false;
} }
} }
void TpUartDataLinkLayer::addFrameTxQueue(CemiFrame& frame){ void TpUartDataLinkLayer::addFrameTxQueue(CemiFrame& frame)
{
_tx_queue_frame_t* tx_frame = new _tx_queue_frame_t; _tx_queue_frame_t* tx_frame = new _tx_queue_frame_t;
tx_frame->length = frame.telegramLengthtTP(); tx_frame->length = frame.telegramLengthtTP();
@ -434,25 +486,30 @@ void TpUartDataLinkLayer::addFrameTxQueue(CemiFrame& frame){
tx_frame->next = NULL; tx_frame->next = NULL;
frame.fillTelegramTP(tx_frame->data); frame.fillTelegramTP(tx_frame->data);
if (_tx_queue.back == NULL) { if (_tx_queue.back == NULL)
{
_tx_queue.front = _tx_queue.back = tx_frame; _tx_queue.front = _tx_queue.back = tx_frame;
} }
else{ else
{
_tx_queue.back->next = tx_frame; _tx_queue.back->next = tx_frame;
_tx_queue.back = tx_frame; _tx_queue.back = tx_frame;
} }
} }
bool TpUartDataLinkLayer::isTxQueueEmpty(){ bool TpUartDataLinkLayer::isTxQueueEmpty()
if (_tx_queue.front == NULL){ {
if (_tx_queue.front == NULL)
{
return true; return true;
} }
return false; return false;
} }
void TpUartDataLinkLayer::loadNextTxFrame()
void TpUartDataLinkLayer::loadNextTxFrame(){ {
if (_tx_queue.front == NULL) { if (_tx_queue.front == NULL)
{
return; return;
} }
_tx_queue_frame_t* tx_frame = _tx_queue.front; _tx_queue_frame_t* tx_frame = _tx_queue.front;
@ -460,9 +517,9 @@ void TpUartDataLinkLayer::loadNextTxFrame(){
_sendBufferLength = tx_frame->length; _sendBufferLength = tx_frame->length;
_tx_queue.front = tx_frame->next; _tx_queue.front = tx_frame->next;
if (_tx_queue.front == NULL){ if (_tx_queue.front == NULL)
{
_tx_queue.back = NULL; _tx_queue.back = NULL;
} }
delete tx_frame; delete tx_frame;
} }

View File

@ -4,15 +4,13 @@
#include "data_link_layer.h" #include "data_link_layer.h"
#define MAX_KNX_TELEGRAM_SIZE 263 #define MAX_KNX_TELEGRAM_SIZE 263
#define BYTE_TIMEOUT 3 //milli seconds
#define CONFIRM_TIMEOUT 500 //milli seconds
class TpUartDataLinkLayer : public DataLinkLayer class TpUartDataLinkLayer : public DataLinkLayer
{ {
using DataLinkLayer::_deviceObject; using DataLinkLayer::_deviceObject;
using DataLinkLayer::_platform;
using DataLinkLayer::_groupAddressTable; using DataLinkLayer::_groupAddressTable;
using DataLinkLayer::_platform;
public: public:
TpUartDataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, NetworkLayer& layer, TpUartDataLinkLayer(DeviceObject& devObj, AddressTableObject& addrTab, NetworkLayer& layer,
Platform& platform); Platform& platform);
@ -20,6 +18,7 @@ public:
void loop(); void loop();
void enabled(bool value); void enabled(bool value);
bool enabled() const; bool enabled() const;
private: private:
bool _enabled = false; bool _enabled = false;
bool _waitConfirm = false; bool _waitConfirm = false;
@ -37,13 +36,15 @@ private:
uint32_t _lastByteRxTime; uint32_t _lastByteRxTime;
uint32_t _waitConfirmStartTime; uint32_t _waitConfirmStartTime;
struct _tx_queue_frame_t{ struct _tx_queue_frame_t
{
uint8_t* data; uint8_t* data;
uint16_t length; uint16_t length;
_tx_queue_frame_t* next; _tx_queue_frame_t* next;
}; };
struct _tx_queue_t { struct _tx_queue_t
{
_tx_queue_frame_t* front = NULL; _tx_queue_frame_t* front = NULL;
_tx_queue_frame_t* back = NULL; _tx_queue_frame_t* back = NULL;
} _tx_queue; } _tx_queue;
@ -58,4 +59,3 @@ private:
void resetChip(); void resetChip();
void stopChip(); void stopChip();
}; };

View File

@ -51,15 +51,15 @@ public:
void cmdlineArgs(int argc, char** argv); void cmdlineArgs(int argc, char** argv);
private: private:
uint32_t _multicastAddr; uint32_t _multicastAddr = -1;
uint16_t _port; uint16_t _port = -1;
int _socketFd = -1; int _socketFd = -1;
void doMemoryMapping(); void doMemoryMapping();
uint8_t* _mappedFile; uint8_t* _mappedFile = 0;
int _fd = -1; int _fd = -1;
uint8_t* _currentMaxMem = 0; uint8_t* _currentMaxMem = 0;
std::string _flashFilePath = "flash.bin"; std::string _flashFilePath = "flash.bin";
char** _args; char** _args = 0;
}; };
#endif #endif