mirror of
https://github.com/thelsing/knx.git
synced 2025-08-31 13:47:01 +02:00
commit
a7f237f391
27
.clang-format
Normal file
27
.clang-format
Normal 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
|
||||
...
|
@ -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>
|
@ -7,9 +7,9 @@
|
||||
<PathStyle>RemoteUnix</PathStyle>
|
||||
</CustomSourceDirectories>
|
||||
<BuildHost>
|
||||
<HostName>localhost</HostName>
|
||||
<Transport>LinuxSubsystem</Transport>
|
||||
<UserName>Linux</UserName>
|
||||
<HostName>Suzail</HostName>
|
||||
<Transport>SSH</Transport>
|
||||
<UserName>tkunze</UserName>
|
||||
</BuildHost>
|
||||
<MainSourceTransferCommand>
|
||||
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
|
||||
@ -34,15 +34,14 @@
|
||||
<string>CMakeLists.txt</string>
|
||||
<string>*.cmake</string>
|
||||
</FileMasks>
|
||||
<TransferNewFilesOnly>true</TransferNewFilesOnly>
|
||||
<TransferNewFilesOnly>false</TransferNewFilesOnly>
|
||||
<IncludeSubdirectories>true</IncludeSubdirectories>
|
||||
<SelectedDirectories />
|
||||
<DeleteDisappearedFiles>true</DeleteDisappearedFiles>
|
||||
<ApplyGlobalExclusionList>true</ApplyGlobalExclusionList>
|
||||
<Extension>
|
||||
<Direction>Outgoing</Direction>
|
||||
<SkipMountPoints>false</SkipMountPoints>
|
||||
<OverwriteTrigger>LocalCache</OverwriteTrigger>
|
||||
<OverwriteTrigger>Always</OverwriteTrigger>
|
||||
</Extension>
|
||||
</MainSourceTransferCommand>
|
||||
<AllowChangingHostForMainCommands>false</AllowChangingHostForMainCommands>
|
||||
@ -115,12 +114,13 @@
|
||||
<HideErrorsInSystemHeaders>true</HideErrorsInSystemHeaders>
|
||||
<SupportLightweightReferenceAnalysis>true</SupportLightweightReferenceAnalysis>
|
||||
<DiscoverySettings>
|
||||
<Mode>Disabled</Mode>
|
||||
<Mode>Silent</Mode>
|
||||
<SearchInProjectDir>true</SearchInProjectDir>
|
||||
<SearchInSourceDirs>true</SearchInSourceDirs>
|
||||
<SearchInIncludeSubdirs>true</SearchInIncludeSubdirs>
|
||||
</DiscoverySettings>
|
||||
<CheckForClangFormatFiles>true</CheckForClangFormatFiles>
|
||||
<ExplicitClangFormatFile>..\.clang-format</ExplicitClangFormatFile>
|
||||
<FormattingEngine>ClangFormat</FormattingEngine>
|
||||
</ExtraSettings>
|
||||
<CodeAnalyzerSettings>
|
||||
|
@ -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>
|
@ -110,10 +110,8 @@
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ClassDiagram.cd" />
|
||||
<None Include="CMakeLists.txt" />
|
||||
<None Include="knx-linux-Debug.vgdbsettings" />
|
||||
<None Include="knx-linux-Release.vgdbsettings" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\knx\address_table_object.cpp" />
|
||||
|
@ -30,10 +30,6 @@
|
||||
<None Include="knx-linux-Debug.vgdbsettings">
|
||||
<Filter>VisualGDB settings</Filter>
|
||||
</None>
|
||||
<None Include="knx-linux-Release.vgdbsettings">
|
||||
<Filter>VisualGDB settings</Filter>
|
||||
</None>
|
||||
<None Include="ClassDiagram.cd" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\linux_platform.h">
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -48,6 +48,6 @@ class APDU
|
||||
APDU(uint8_t* data, CemiFrame& frame);
|
||||
|
||||
private:
|
||||
uint8_t* _data;
|
||||
uint8_t* _data = 0;
|
||||
CemiFrame& _frame;
|
||||
};
|
@ -146,6 +146,6 @@ class ApplicationLayer
|
||||
uint16_t _savedAsapResponse;
|
||||
AssociationTableObject& _assocTable;
|
||||
BusAccessUnit& _bau;
|
||||
TransportLayer* _transportLayer;
|
||||
TransportLayer* _transportLayer = 0;
|
||||
int32_t _connectedTsap;
|
||||
};
|
||||
|
@ -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};
|
||||
};
|
@ -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;
|
||||
};
|
@ -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);
|
||||
};
|
||||
|
@ -2,37 +2,33 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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};
|
||||
};
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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};
|
||||
};
|
@ -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);
|
||||
|
@ -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
|
||||
};
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
};
|
@ -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)
|
||||
|
@ -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);
|
||||
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);
|
@ -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 <functional>
|
||||
typedef std::function<void(GroupObject&)> 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;
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -22,6 +22,6 @@ class NPDU
|
||||
NPDU(uint8_t* data, CemiFrame& frame);
|
||||
|
||||
private:
|
||||
uint8_t* _data;
|
||||
uint8_t* _data = 0;
|
||||
CemiFrame& _frame;
|
||||
};
|
@ -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);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
class SaveRestore
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* This method is called when the object should save its state to the buffer.
|
||||
*
|
||||
|
@ -31,6 +31,6 @@ class TPDU
|
||||
TPDU(uint8_t* data, CemiFrame& frame);
|
||||
|
||||
private:
|
||||
uint8_t* _data;
|
||||
uint8_t* _data = 0;
|
||||
CemiFrame& _frame;
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -3,24 +3,23 @@
|
||||
#include <stdint.h>
|
||||
#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();
|
||||
};
|
||||
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user