mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
some progress with python wrapper
This commit is contained in:
parent
7a77b1e29a
commit
405aab0e5e
4
.gitmodules
vendored
Normal file
4
.gitmodules
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[submodule "knxPython/pybind11"]
|
||||||
|
path = knxPython/pybind11
|
||||||
|
url = https://github.com/pybind/pybind11.git
|
||||||
|
branch = stable
|
@ -4,8 +4,8 @@
|
|||||||
cmake_minimum_required(VERSION 2.7)
|
cmake_minimum_required(VERSION 2.7)
|
||||||
project(knx)
|
project(knx)
|
||||||
|
|
||||||
set(LIBRARIES_FROM_REFERENCES "")
|
add_subdirectory(pybind11)
|
||||||
add_library(knx SHARED ../src/knx/address_table_object.cpp ../src/knx/apdu.cpp ../src/knx/application_layer.cpp ../src/knx/application_program_object.cpp ../src/knx/association_table_object.cpp ../src/knx/bau.cpp ../src/knx/bau07B0.cpp ../src/knx/bau57B0.cpp ../src/knx/bau_systemB.cpp ../src/knx/bits.cpp ../src/knx/cemi_frame.cpp ../src/knx/datapoint_types.cpp ../src/knx/data_link_layer.cpp ../src/knx/device_object.cpp ../src/knx/group_object.cpp ../src/knx/group_object_table_object.cpp ../src/knx/interface_object.cpp ../src/knx/ip_data_link_layer.cpp ../src/knx/ip_parameter_object.cpp ../src/knx/memory.cpp ../src/knx/network_layer.cpp ../src/knx/npdu.cpp ../src/knx/platform.cpp ../src/knx/table_object.cpp ../src/knx/tpdu.cpp ../src/knx/tpuart_data_link_layer.cpp ../src/knx/transport_layer.cpp ../src/linux_platform.cpp knxmodule.cpp)
|
|
||||||
target_link_libraries(knx python3.5m "${LIBRARIES_FROM_REFERENCES}")
|
pybind11_add_module(knx ../src/knx/address_table_object.cpp ../src/knx/apdu.cpp ../src/knx/application_layer.cpp ../src/knx/application_program_object.cpp ../src/knx/association_table_object.cpp ../src/knx/bau.cpp ../src/knx/bau07B0.cpp ../src/knx/bau57B0.cpp ../src/knx/bau_systemB.cpp ../src/knx/bits.cpp ../src/knx/cemi_frame.cpp ../src/knx/datapoint_types.cpp ../src/knx/data_link_layer.cpp ../src/knx/device_object.cpp ../src/knx/group_object.cpp ../src/knx/group_object_table_object.cpp ../src/knx/interface_object.cpp ../src/knx/ip_data_link_layer.cpp ../src/knx/ip_parameter_object.cpp ../src/knx/memory.cpp ../src/knx/network_layer.cpp ../src/knx/npdu.cpp ../src/knx/platform.cpp ../src/knx/table_object.cpp ../src/knx/tpdu.cpp ../src/knx/tpuart_data_link_layer.cpp ../src/knx/transport_layer.cpp ../src/linux_platform.cpp knxmodule.cpp)
|
||||||
include_directories(/usr/include/python3.5m ../src)
|
|
||||||
SET_TARGET_PROPERTIES(knx PROPERTIES PREFIX "")
|
include_directories(../src)
|
@ -862,7 +862,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// --- Include directories begin --- //
|
// --- Include directories begin --- //
|
||||||
///usr/include/python3.5m
|
///usr/include/python3.5dm
|
||||||
|
///usr/include/python3.5
|
||||||
///usr/include/c++/6
|
///usr/include/c++/6
|
||||||
///usr/include/x86_64-linux-gnu/c++/6
|
///usr/include/x86_64-linux-gnu/c++/6
|
||||||
///usr/include/c++/6/backward
|
///usr/include/c++/6/backward
|
||||||
@ -871,6 +872,8 @@
|
|||||||
///usr/lib/gcc/x86_64-linux-gnu/6/include-fixed
|
///usr/lib/gcc/x86_64-linux-gnu/6/include-fixed
|
||||||
///usr/include/x86_64-linux-gnu
|
///usr/include/x86_64-linux-gnu
|
||||||
///usr/include
|
///usr/include
|
||||||
|
//../src
|
||||||
|
//pybind11\include
|
||||||
// --- Include directories end --- //
|
// --- Include directories end --- //
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,13 +4,41 @@
|
|||||||
<Project xsi:type="com.visualgdb.project.linux">
|
<Project xsi:type="com.visualgdb.project.linux">
|
||||||
<CustomSourceDirectories>
|
<CustomSourceDirectories>
|
||||||
<Directories />
|
<Directories />
|
||||||
<PathStyle>RemoteUnix</PathStyle>
|
<PathStyle>Win10LXSS</PathStyle>
|
||||||
</CustomSourceDirectories>
|
</CustomSourceDirectories>
|
||||||
<BuildHost>
|
<BuildHost>
|
||||||
<HostName>localhost</HostName>
|
<HostName>Suzail</HostName>
|
||||||
<Transport>LinuxSubsystem</Transport>
|
<Transport>SSH</Transport>
|
||||||
<UserName>Linux</UserName>
|
<UserName>tkunze</UserName>
|
||||||
</BuildHost>
|
</BuildHost>
|
||||||
|
<MainSourceTransferCommand>
|
||||||
|
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
|
||||||
|
<RemoteHost>
|
||||||
|
<HostName>Suzail</HostName>
|
||||||
|
<Transport>SSH</Transport>
|
||||||
|
<UserName>tkunze</UserName>
|
||||||
|
</RemoteHost>
|
||||||
|
<LocalDirectory>$(ProjectDir)\..</LocalDirectory>
|
||||||
|
<RemoteDirectory>/tmp/VisualGDB/$(ProjectDirUnixStyle)/..</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>*.py</string>
|
||||||
|
</FileMasks>
|
||||||
|
<TransferNewFilesOnly>true</TransferNewFilesOnly>
|
||||||
|
<IncludeSubdirectories>true</IncludeSubdirectories>
|
||||||
|
<SelectedDirectories />
|
||||||
|
<DeleteDisappearedFiles>false</DeleteDisappearedFiles>
|
||||||
|
<ApplyGlobalExclusionList>true</ApplyGlobalExclusionList>
|
||||||
|
</MainSourceTransferCommand>
|
||||||
<AllowChangingHostForMainCommands>false</AllowChangingHostForMainCommands>
|
<AllowChangingHostForMainCommands>false</AllowChangingHostForMainCommands>
|
||||||
<SkipBuildIfNoSourceFilesChanged>false</SkipBuildIfNoSourceFilesChanged>
|
<SkipBuildIfNoSourceFilesChanged>false</SkipBuildIfNoSourceFilesChanged>
|
||||||
<IgnoreFileTransferErrors>false</IgnoreFileTransferErrors>
|
<IgnoreFileTransferErrors>false</IgnoreFileTransferErrors>
|
||||||
@ -25,18 +53,17 @@
|
|||||||
<Revision>0</Revision>
|
<Revision>0</Revision>
|
||||||
</Version>
|
</Version>
|
||||||
</ToolchainID>
|
</ToolchainID>
|
||||||
<RelativeSourceDirectory />
|
<RelativeSourceDirectory>knxPython</RelativeSourceDirectory>
|
||||||
<ConfigurationType>DEBUG</ConfigurationType>
|
<ConfigurationType>DEBUG</ConfigurationType>
|
||||||
<BinaryDirectory>Debug</BinaryDirectory>
|
<BinaryDirectory>Debug</BinaryDirectory>
|
||||||
<MainCMakeTarget>knx</MainCMakeTarget>
|
|
||||||
<MakeCommandTemplate>
|
<MakeCommandTemplate>
|
||||||
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
|
<SkipWhenRunningCommandList>false</SkipWhenRunningCommandList>
|
||||||
<RemoteHost>
|
<RemoteHost>
|
||||||
<HostName>BuildMachine</HostName>
|
<HostName>BuildMachine</HostName>
|
||||||
<Transport>BuiltinShortcut</Transport>
|
<Transport>BuiltinShortcut</Transport>
|
||||||
</RemoteHost>
|
</RemoteHost>
|
||||||
<Command>ninja</Command>
|
<Command>$(ToolchainMake)</Command>
|
||||||
<Arguments />
|
<Arguments>$(ToolchainMakeArgs)</Arguments>
|
||||||
<WorkingDirectory>$(BuildDir)</WorkingDirectory>
|
<WorkingDirectory>$(BuildDir)</WorkingDirectory>
|
||||||
<BackgroundMode xsi:nil="true" />
|
<BackgroundMode xsi:nil="true" />
|
||||||
</MakeCommandTemplate>
|
</MakeCommandTemplate>
|
||||||
@ -49,10 +76,10 @@
|
|||||||
<Command>$(ToolchainCMake)</Command>
|
<Command>$(ToolchainCMake)</Command>
|
||||||
<BackgroundMode xsi:nil="true" />
|
<BackgroundMode xsi:nil="true" />
|
||||||
</CMakeCommand>
|
</CMakeCommand>
|
||||||
<UpdateSourcesInCMakeFile>true</UpdateSourcesInCMakeFile>
|
<UpdateSourcesInCMakeFile>false</UpdateSourcesInCMakeFile>
|
||||||
|
<ExplicitDebugTarget>$(BuildDir)/main.py</ExplicitDebugTarget>
|
||||||
<ExportCompileCommands>false</ExportCompileCommands>
|
<ExportCompileCommands>false</ExportCompileCommands>
|
||||||
<DisableToolchainFile>false</DisableToolchainFile>
|
<DisableToolchainFile>false</DisableToolchainFile>
|
||||||
<CMakeMakefileType>Ninja</CMakeMakefileType>
|
|
||||||
<DeployAsRoot>false</DeployAsRoot>
|
<DeployAsRoot>false</DeployAsRoot>
|
||||||
</Build>
|
</Build>
|
||||||
<CustomBuild>
|
<CustomBuild>
|
||||||
@ -93,14 +120,14 @@
|
|||||||
<AdditionalGDBSettings>
|
<AdditionalGDBSettings>
|
||||||
<Features>
|
<Features>
|
||||||
<DisableAutoDetection>false</DisableAutoDetection>
|
<DisableAutoDetection>false</DisableAutoDetection>
|
||||||
<UseFrameParameter>false</UseFrameParameter>
|
<UseFrameParameter>true</UseFrameParameter>
|
||||||
<SimpleValuesFlagSupported>false</SimpleValuesFlagSupported>
|
<SimpleValuesFlagSupported>true</SimpleValuesFlagSupported>
|
||||||
<ListLocalsSupported>false</ListLocalsSupported>
|
<ListLocalsSupported>true</ListLocalsSupported>
|
||||||
<ByteLevelMemoryCommandsAvailable>false</ByteLevelMemoryCommandsAvailable>
|
<ByteLevelMemoryCommandsAvailable>true</ByteLevelMemoryCommandsAvailable>
|
||||||
<ThreadInfoSupported>false</ThreadInfoSupported>
|
<ThreadInfoSupported>true</ThreadInfoSupported>
|
||||||
<PendingBreakpointsSupported>false</PendingBreakpointsSupported>
|
<PendingBreakpointsSupported>true</PendingBreakpointsSupported>
|
||||||
<SupportTargetCommand>false</SupportTargetCommand>
|
<SupportTargetCommand>true</SupportTargetCommand>
|
||||||
<ReliableBreakpointNotifications>false</ReliableBreakpointNotifications>
|
<ReliableBreakpointNotifications>true</ReliableBreakpointNotifications>
|
||||||
</Features>
|
</Features>
|
||||||
<EnableSmartStepping>false</EnableSmartStepping>
|
<EnableSmartStepping>false</EnableSmartStepping>
|
||||||
<FilterSpuriousStoppedNotifications>false</FilterSpuriousStoppedNotifications>
|
<FilterSpuriousStoppedNotifications>false</FilterSpuriousStoppedNotifications>
|
||||||
@ -121,9 +148,10 @@
|
|||||||
<MaxBreakpointLimit>0</MaxBreakpointLimit>
|
<MaxBreakpointLimit>0</MaxBreakpointLimit>
|
||||||
</AdditionalGDBSettings>
|
</AdditionalGDBSettings>
|
||||||
<LaunchGDBSettings xsi:type="GDBLaunchParametersPython">
|
<LaunchGDBSettings xsi:type="GDBLaunchParametersPython">
|
||||||
<DebuggedProgram>$(SourceDir)/main.py</DebuggedProgram>
|
<DebuggedProgram>$(TargetPath)</DebuggedProgram>
|
||||||
<GDBServerPort>2000</GDBServerPort>
|
<GDBServerPort>2000</GDBServerPort>
|
||||||
<ProgramArguments />
|
<ProgramArguments />
|
||||||
|
<WorkingDirectory>$(BuildDir)/Debug</WorkingDirectory>
|
||||||
<ProgramEnvironment>PYTHONPATH=%PYTHONPATH%:$(SourceDir)/$(ConfigurationName)</ProgramEnvironment>
|
<ProgramEnvironment>PYTHONPATH=%PYTHONPATH%:$(SourceDir)/$(ConfigurationName)</ProgramEnvironment>
|
||||||
<PythonExecutable>python3</PythonExecutable>
|
<PythonExecutable>python3</PythonExecutable>
|
||||||
<StepAndBreakpointSupport>true</StepAndBreakpointSupport>
|
<StepAndBreakpointSupport>true</StepAndBreakpointSupport>
|
||||||
@ -131,10 +159,12 @@
|
|||||||
<StopAtFirstPythonStatement>false</StopAtFirstPythonStatement>
|
<StopAtFirstPythonStatement>false</StopAtFirstPythonStatement>
|
||||||
</LaunchGDBSettings>
|
</LaunchGDBSettings>
|
||||||
<GenerateCtrlBreakInsteadOfCtrlC>false</GenerateCtrlBreakInsteadOfCtrlC>
|
<GenerateCtrlBreakInsteadOfCtrlC>false</GenerateCtrlBreakInsteadOfCtrlC>
|
||||||
|
<DeploymentTargetPath />
|
||||||
<X11WindowMode>Local</X11WindowMode>
|
<X11WindowMode>Local</X11WindowMode>
|
||||||
<KeepConsoleAfterExit>false</KeepConsoleAfterExit>
|
<KeepConsoleAfterExit>false</KeepConsoleAfterExit>
|
||||||
<RunGDBUnderSudo>false</RunGDBUnderSudo>
|
<RunGDBUnderSudo>false</RunGDBUnderSudo>
|
||||||
<DeploymentMode>Auto</DeploymentMode>
|
<DeploymentMode>Auto</DeploymentMode>
|
||||||
|
<LdLibraryPath />
|
||||||
<DeployWhenLaunchedWithoutDebugging>true</DeployWhenLaunchedWithoutDebugging>
|
<DeployWhenLaunchedWithoutDebugging>true</DeployWhenLaunchedWithoutDebugging>
|
||||||
<SuppressTTYCreation>false</SuppressTTYCreation>
|
<SuppressTTYCreation>false</SuppressTTYCreation>
|
||||||
</Debug>
|
</Debug>
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<NMakeIncludeSearchPath>$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\include\python3.5m;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\include\c++\6;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\include\x86_64-linux-gnu\c++\6;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\include\c++\6\backward;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\lib\gcc\x86_64-linux-gnu\6\include;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\local\include;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\lib\gcc\x86_64-linux-gnu\6\include-fixed;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\include\x86_64-linux-gnu;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\include;..\src;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
|
<NMakeIncludeSearchPath>$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\include\python3.5dm;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\include\python3.5;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\include\c++\6;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\include\x86_64-linux-gnu\c++\6;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\include\c++\6\backward;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\lib\gcc\x86_64-linux-gnu\6\include;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\local\include;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\lib\gcc\x86_64-linux-gnu\6\include-fixed;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\include\x86_64-linux-gnu;$(LOCALAPPDATA)\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\usr\include;..\..\src;..\pybind11\include;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
|
||||||
<NMakeForcedIncludes>$(ProjectDir)\gcc_Debug.h;$(VISUALGDB_DIR)\gcc_compat.h;$(NMakeForcedIncludes)</NMakeForcedIncludes>
|
<NMakeForcedIncludes>$(ProjectDir)\gcc_Debug.h;$(VISUALGDB_DIR)\gcc_compat.h;$(NMakeForcedIncludes)</NMakeForcedIncludes>
|
||||||
<NMakeBuildCommandLine>"$(VISUALGDB_DIR)\VisualGDB.exe" /build "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)"</NMakeBuildCommandLine>
|
<NMakeBuildCommandLine>"$(VISUALGDB_DIR)\VisualGDB.exe" /build "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)"</NMakeBuildCommandLine>
|
||||||
<NMakeCleanCommandLine>"$(VISUALGDB_DIR)\VisualGDB.exe" /clean "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)"</NMakeCleanCommandLine>
|
<NMakeCleanCommandLine>"$(VISUALGDB_DIR)\VisualGDB.exe" /clean "$(ProjectPath)" "/solution:$(SolutionPath)" "/config:$(Configuration)" "/platform:$(Platform)"</NMakeCleanCommandLine>
|
||||||
|
@ -1,174 +1,158 @@
|
|||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl_bind.h>
|
||||||
|
|
||||||
|
namespace py = pybind11;
|
||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <pthread.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <thread>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "linux_platform.h"
|
#include "linux_platform.h"
|
||||||
#include "knx/bau57B0.h"
|
#include "knx/bau57B0.h"
|
||||||
#include "knx/group_object_table_object.h"
|
#include "knx/group_object_table_object.h"
|
||||||
|
|
||||||
|
|
||||||
LinuxPlatform platfrom;
|
LinuxPlatform platform;
|
||||||
Bau57B0 bau(platfrom);
|
Bau57B0 bau(platform);
|
||||||
|
|
||||||
#if 1 // this code will go to python later
|
#if 1 // this code will go to python later
|
||||||
float currentValue = 0;
|
//float currentValue = 0;
|
||||||
float maxValue = 0;
|
//float maxValue = 0;
|
||||||
float minValue = RAND_MAX;
|
//float minValue = RAND_MAX;
|
||||||
long lastsend = 0;
|
//long lastsend = 0;
|
||||||
|
//
|
||||||
|
//GroupObject groupObjects[]
|
||||||
|
//{
|
||||||
|
// GroupObject(2),
|
||||||
|
// GroupObject(2),
|
||||||
|
// GroupObject(2),
|
||||||
|
// GroupObject(1)
|
||||||
|
//}
|
||||||
|
//;
|
||||||
|
//#define CURR groupObjects[0]
|
||||||
|
//#define MAX groupObjects[1]
|
||||||
|
//#define MIN groupObjects[2]
|
||||||
|
//#define RESET groupObjects[3]
|
||||||
|
//
|
||||||
|
//void measureTemp()
|
||||||
|
//{
|
||||||
|
// long now = platform.millis();
|
||||||
|
// if ((now - lastsend) < 2000)
|
||||||
|
// return;
|
||||||
|
//
|
||||||
|
// lastsend = now;
|
||||||
|
// int r = rand();
|
||||||
|
// currentValue = (r * 1.0) / (RAND_MAX * 1.0);
|
||||||
|
// currentValue *= 100 * 100;
|
||||||
|
//
|
||||||
|
// CURR.objectWrite(currentValue);
|
||||||
|
//
|
||||||
|
// if (currentValue > maxValue)
|
||||||
|
// {
|
||||||
|
// maxValue = currentValue;
|
||||||
|
// MAX.objectWrite(maxValue);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (currentValue < minValue)
|
||||||
|
// {
|
||||||
|
// minValue = currentValue;
|
||||||
|
// MIN.objectWrite(minValue);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
GroupObject groupObjects[]
|
//void resetCallback(GroupObject& go)
|
||||||
{
|
//{
|
||||||
GroupObject(2),
|
// if (go.objectReadBool())
|
||||||
GroupObject(2),
|
// {
|
||||||
GroupObject(2),
|
// maxValue = 0;
|
||||||
GroupObject(1)
|
// minValue = 10000;
|
||||||
}
|
// }
|
||||||
;
|
//}
|
||||||
#define CURR groupObjects[0]
|
|
||||||
#define MAX groupObjects[1]
|
|
||||||
#define MIN groupObjects[2]
|
|
||||||
#define RESET groupObjects[3]
|
|
||||||
|
|
||||||
void measureTemp()
|
//void appLoop()
|
||||||
{
|
//{
|
||||||
long now = platfrom.millis();
|
// if (!bau.configured())
|
||||||
if ((now - lastsend) < 2000)
|
// return;
|
||||||
return;
|
//
|
||||||
|
// measureTemp();
|
||||||
lastsend = now;
|
//}
|
||||||
int r = rand();
|
|
||||||
currentValue = (r * 1.0) / (RAND_MAX * 1.0);
|
|
||||||
currentValue *= 100 * 100;
|
|
||||||
|
|
||||||
CURR.objectWrite(currentValue);
|
|
||||||
|
|
||||||
if (currentValue > maxValue)
|
|
||||||
{
|
|
||||||
maxValue = currentValue;
|
|
||||||
MAX.objectWrite(maxValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentValue < minValue)
|
|
||||||
{
|
|
||||||
minValue = currentValue;
|
|
||||||
MIN.objectWrite(minValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void resetCallback(GroupObject& go)
|
|
||||||
{
|
|
||||||
if (go.objectReadBool())
|
|
||||||
{
|
|
||||||
maxValue = 0;
|
|
||||||
minValue = 10000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void appLoop()
|
|
||||||
{
|
|
||||||
if (!bau.configured())
|
|
||||||
return;
|
|
||||||
|
|
||||||
measureTemp();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
srand((unsigned int)time(NULL));
|
srand((unsigned int)time(NULL));
|
||||||
bau.readMemory();
|
bau.readMemory();
|
||||||
|
|
||||||
GroupObjectTableObject& got(bau.groupObjectTable());
|
// GroupObjectTableObject& got(bau.groupObjectTable());
|
||||||
got.groupObjects(groupObjects, 4);
|
// got.groupObjects(groupObjects, 4);
|
||||||
|
|
||||||
DeviceObject& devObj(bau.deviceObject());
|
DeviceObject& devObj(bau.deviceObject());
|
||||||
devObj.manufacturerId(0xfa);
|
devObj.manufacturerId(0xfa);
|
||||||
|
|
||||||
RESET.updateHandler = resetCallback;
|
// RESET.updateHandler = resetCallback;
|
||||||
|
|
||||||
|
|
||||||
if (bau.parameters().loadState() == LS_LOADED)
|
|
||||||
{
|
|
||||||
printf("Timeout: %d\n", bau.parameters().getWord(0));
|
|
||||||
printf("Zykl. senden: %d\n", bau.parameters().getByte(2));
|
|
||||||
printf("Min/Max senden: %d\n", bau.parameters().getByte(3));
|
|
||||||
printf("Aenderung senden: %d\n", bau.parameters().getByte(4));
|
|
||||||
printf("Abgleich %d\n", bau.parameters().getByte(5));
|
|
||||||
}
|
|
||||||
bau.enabled(true);
|
bau.enabled(true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void* loop(void* x)
|
bool threadEnabled = false;
|
||||||
|
static void loop()
|
||||||
{
|
{
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
bau.loop();
|
bau.loop();
|
||||||
appLoop();
|
//appLoop();
|
||||||
platfrom.mdelay(100);
|
platform.mdelay(100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_exit(NULL);
|
static std::thread workerThread;
|
||||||
}
|
|
||||||
|
|
||||||
static pthread_t workerThread;
|
bool started = false;
|
||||||
|
static void Start()
|
||||||
static PyObject* Start(PyObject* self, PyObject* args)
|
|
||||||
{
|
{
|
||||||
if (!PyArg_ParseTuple(args, ""))
|
if (started)
|
||||||
return NULL;
|
return;
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
int res = pthread_create(&workerThread, NULL, loop, NULL);
|
workerThread = std::thread(loop);
|
||||||
if (res)
|
workerThread.detach();
|
||||||
{
|
|
||||||
printf("error %d\n", res);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_RETURN_NONE;
|
static bool ProgramMode(bool value)
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject* ProgramMode(PyObject* self, PyObject* args)
|
|
||||||
{
|
{
|
||||||
if (PyArg_ParseTuple(args, ""))
|
|
||||||
{
|
|
||||||
//no arguments
|
|
||||||
return Py_BuildValue("i", bau.deviceObject().progMode());
|
|
||||||
}
|
|
||||||
PyErr_Clear();
|
|
||||||
int value = 0;
|
|
||||||
if (!PyArg_ParseTuple(args, "i", &value))
|
|
||||||
return NULL;
|
|
||||||
bau.deviceObject().progMode(value);
|
bau.deviceObject().progMode(value);
|
||||||
return Py_BuildValue("i", bau.deviceObject().progMode());
|
return bau.deviceObject().progMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef knxMethods[] =
|
static bool ProgramMode()
|
||||||
{
|
{
|
||||||
{"Start", Start, METH_VARARGS, "Start knx handling thread." },
|
return bau.deviceObject().progMode();
|
||||||
{"ProgramMode", ProgramMode, METH_VARARGS, "Activate/deactivate programing mode." },
|
|
||||||
{ NULL, NULL, 0, NULL } /* End of list */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static struct PyModuleDef knxModule = {
|
|
||||||
PyModuleDef_HEAD_INIT,
|
|
||||||
"knx",
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
knxMethods,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
PyMODINIT_FUNC PyInit_knx(void)
|
|
||||||
{
|
|
||||||
PyObject* m = PyModule_Create(&knxModule);
|
|
||||||
return m;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void RegisterGroupObjects(std::vector<GroupObject>& gos)
|
||||||
|
{
|
||||||
|
GroupObjectTableObject& got(bau.groupObjectTable());
|
||||||
|
got.groupObjects(gos.data(), gos.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
PYBIND11_MAKE_OPAQUE(std::vector<GroupObject>);
|
||||||
|
|
||||||
|
PYBIND11_MODULE(knx, m) {
|
||||||
|
m.doc() = "wrapper for knx device lib"; // optional module docstring
|
||||||
|
|
||||||
|
py::bind_vector<std::vector<GroupObject>>(m, "GroupObjectList");
|
||||||
|
|
||||||
|
m.def("Start", &Start, "Start knx handling thread.");
|
||||||
|
m.def("ProgramMode", (bool (*)())&ProgramMode, "get programing mode active.");
|
||||||
|
m.def("ProgramMode", (bool(*)(bool))&ProgramMode, "Activate / deactivate programing mode.");
|
||||||
|
m.def("RegisterGroupObjects", &RegisterGroupObjects);
|
||||||
|
|
||||||
|
py::class_<GroupObject>(m, "GroupObject")
|
||||||
|
.def(py::init<uint8_t>())
|
||||||
|
.def("objectWrite", (void(GroupObject::*)(float))&GroupObject::objectWrite);
|
||||||
|
}
|
@ -3,6 +3,14 @@ import time
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
print("start")
|
print("start")
|
||||||
|
gos = knx.GroupObjectList()
|
||||||
|
gos.append(knx.GroupObject(2))
|
||||||
|
gos.append(knx.GroupObject(2))
|
||||||
|
gos.append(knx.GroupObject(2))
|
||||||
|
gos.append(knx.GroupObject(1))
|
||||||
|
curr = gos[0]
|
||||||
|
knx.RegisterGroupObjects(gos)
|
||||||
|
knx.Start()
|
||||||
while True:
|
while True:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
cmd = sys.stdin.read(1)
|
cmd = sys.stdin.read(1)
|
||||||
@ -14,4 +22,10 @@ while True:
|
|||||||
elif cmd == 'p':
|
elif cmd == 'p':
|
||||||
currentMode = knx.ProgramMode(not knx.ProgramMode())
|
currentMode = knx.ProgramMode(not knx.ProgramMode())
|
||||||
print("set programming mode to " + str(currentMode))
|
print("set programming mode to " + str(currentMode))
|
||||||
|
elif cmd == 'w':
|
||||||
|
cmd = sys.stdin.read(4)
|
||||||
|
print(cmd)
|
||||||
|
value = float(cmd)
|
||||||
|
curr.objectWrite(value)
|
||||||
|
print("wrote " + str(value) + " to curr")
|
||||||
print("end")
|
print("end")
|
1
knxPython/pybind11
Submodule
1
knxPython/pybind11
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 9a19306fbf30642ca331d0ec88e7da54a96860f9
|
@ -13,6 +13,17 @@ GroupObject::GroupObject(uint8_t size)
|
|||||||
updateHandler = 0;
|
updateHandler = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GroupObject::GroupObject(const GroupObject& other)
|
||||||
|
{
|
||||||
|
_data = new uint8_t[other._dataLength];
|
||||||
|
_commFlag = other._commFlag;
|
||||||
|
_table = other._table;
|
||||||
|
_dataLength = other._dataLength;
|
||||||
|
_asap = other._asap;
|
||||||
|
updateHandler = other.updateHandler;
|
||||||
|
memcpy(_data, other._data, _dataLength);
|
||||||
|
}
|
||||||
|
|
||||||
GroupObject::~GroupObject()
|
GroupObject::~GroupObject()
|
||||||
{
|
{
|
||||||
delete[] _data;
|
delete[] _data;
|
||||||
|
@ -24,6 +24,7 @@ class GroupObject
|
|||||||
friend class GroupObjectTableObject;
|
friend class GroupObjectTableObject;
|
||||||
public:
|
public:
|
||||||
GroupObject(uint8_t size);
|
GroupObject(uint8_t size);
|
||||||
|
GroupObject(const GroupObject& other);
|
||||||
virtual ~GroupObject();
|
virtual ~GroupObject();
|
||||||
// config flags from ETS
|
// config flags from ETS
|
||||||
bool responseUpdateEnable();
|
bool responseUpdateEnable();
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "knx/group_object_table_object.h"
|
#include "knx/group_object_table_object.h"
|
||||||
#include "knx/application_program_object.h"
|
#include "knx/application_program_object.h"
|
||||||
#include "knx/ip_parameter_object.h"
|
#include "knx/ip_parameter_object.h"
|
||||||
|
#include "knx/bits.h"
|
||||||
|
|
||||||
#define MAX_MEM 4096
|
#define MAX_MEM 4096
|
||||||
|
|
||||||
@ -129,8 +130,8 @@ void LinuxPlatform::setupMultiCast(uint32_t addr, uint16_t port)
|
|||||||
fatalError();
|
fatalError();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Broadcast auf dieser Maschine zulassen */
|
/* loopback */
|
||||||
loop = 1;
|
loop = 0;
|
||||||
if (setsockopt(_socketFd, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop)) < 0)
|
if (setsockopt(_socketFd, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop)) < 0)
|
||||||
{
|
{
|
||||||
perror("setsockopt:IP_MULTICAST_LOOP");
|
perror("setsockopt:IP_MULTICAST_LOOP");
|
||||||
@ -184,6 +185,7 @@ bool LinuxPlatform::sendBytes(uint8_t* buffer, uint16_t len)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} while (retVal == -1);
|
} while (retVal == -1);
|
||||||
|
// printHex("<-", buffer, len);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,6 +196,9 @@ int LinuxPlatform::readBytes(uint8_t * buffer, uint16_t maxLen)
|
|||||||
|
|
||||||
sin_len = sizeof(sin);
|
sin_len = sizeof(sin);
|
||||||
ssize_t len = recvfrom(_socketFd, buffer, maxLen, 0, (struct sockaddr *) &sin, &sin_len);
|
ssize_t len = recvfrom(_socketFd, buffer, maxLen, 0, (struct sockaddr *) &sin, &sin_len);
|
||||||
|
// if (len > 0)
|
||||||
|
// printHex("->", buffer, len);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,37 +11,37 @@ public:
|
|||||||
LinuxPlatform();
|
LinuxPlatform();
|
||||||
|
|
||||||
// ip stuff
|
// ip stuff
|
||||||
uint32_t currentIpAddress();
|
uint32_t currentIpAddress() override;
|
||||||
uint32_t currentSubnetMask();
|
uint32_t currentSubnetMask() override;
|
||||||
uint32_t currentDefaultGateway();
|
uint32_t currentDefaultGateway() override;
|
||||||
void macAddress(uint8_t* addr);
|
void macAddress(uint8_t* addr) override;
|
||||||
|
|
||||||
// basic stuff
|
// basic stuff
|
||||||
uint32_t millis();
|
uint32_t millis() override;
|
||||||
void mdelay(uint32_t millis);
|
void mdelay(uint32_t millis) override;
|
||||||
void restart();
|
void restart() override;
|
||||||
void fatalError();
|
void fatalError() override;
|
||||||
|
|
||||||
//multicast
|
//multicast
|
||||||
void setupMultiCast(uint32_t addr, uint16_t port);
|
void setupMultiCast(uint32_t addr, uint16_t port) override;
|
||||||
void closeMultiCast();
|
void closeMultiCast() override;
|
||||||
bool sendBytes(uint8_t* buffer, uint16_t len);
|
bool sendBytes(uint8_t* buffer, uint16_t len) override;
|
||||||
int readBytes(uint8_t* buffer, uint16_t maxLen);
|
int readBytes(uint8_t* buffer, uint16_t maxLen) override;
|
||||||
|
|
||||||
//uart
|
//uart
|
||||||
void setupUart();
|
void setupUart() override;
|
||||||
void closeUart();
|
void closeUart() override;
|
||||||
int uartAvailable();
|
int uartAvailable() override;
|
||||||
size_t writeUart(const uint8_t data);
|
size_t writeUart(const uint8_t data) override;
|
||||||
size_t writeUart(const uint8_t *buffer, size_t size);
|
size_t writeUart(const uint8_t *buffer, size_t size) override;
|
||||||
int readUart();
|
int readUart() override;
|
||||||
size_t readBytesUart(uint8_t *buffer, size_t length);
|
size_t readBytesUart(uint8_t *buffer, size_t length) override;
|
||||||
|
|
||||||
//memory
|
//memory
|
||||||
uint8_t* getEepromBuffer(uint16_t size);
|
uint8_t* getEepromBuffer(uint16_t size) override;
|
||||||
void commitToEeprom();
|
void commitToEeprom() override;
|
||||||
uint8_t* allocMemory(size_t size);
|
uint8_t* allocMemory(size_t size) override;
|
||||||
void freeMemory(uint8_t* ptr);
|
void freeMemory(uint8_t* ptr) override;
|
||||||
private:
|
private:
|
||||||
uint32_t _multicastAddr;
|
uint32_t _multicastAddr;
|
||||||
uint16_t _port;
|
uint16_t _port;
|
||||||
|
Loading…
Reference in New Issue
Block a user