mirror of
https://github.com/thelsing/knx.git
synced 2025-04-19 01:15:27 +02:00
add Prepare and Destroy
This commit is contained in:
parent
b405bff672
commit
a585bf2bb7
@ -6,6 +6,37 @@ project(knx)
|
|||||||
|
|
||||||
add_subdirectory(pybind11)
|
add_subdirectory(pybind11)
|
||||||
|
|
||||||
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)
|
pybind11_add_module(knx
|
||||||
|
knxmodule.cpp
|
||||||
|
../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/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/table_object.cpp
|
||||||
|
../src/knx/tpdu.cpp
|
||||||
|
../src/knx/tpuart_data_link_layer.cpp
|
||||||
|
../src/knx/transport_layer.cpp
|
||||||
|
../src/knx/platform.cpp
|
||||||
|
../src/linux_platform.cpp
|
||||||
|
../src/knx_facade.cpp
|
||||||
|
../src/knx/dptconvert.cpp
|
||||||
|
../src/knx/knx_value.cpp
|
||||||
|
../src/knx/dpt.cpp)
|
||||||
include_directories(../src pybind11/include)
|
include_directories(../src pybind11/include)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
"ctestCommandArgs": "",
|
"ctestCommandArgs": "",
|
||||||
"inheritEnvironments": [ "linux_x64" ],
|
"inheritEnvironments": [ "linux_x64" ],
|
||||||
"wslPath": "${defaultWSLPath}",
|
"wslPath": "${defaultWSLPath}",
|
||||||
"addressSanitizerEnabled": true,
|
"addressSanitizerEnabled": false,
|
||||||
"addressSanitizerRuntimeFlags": "detect_leaks=0",
|
"addressSanitizerRuntimeFlags": "detect_leaks=0",
|
||||||
"variables": []
|
"variables": []
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
#include <pybind11/stl_bind.h>
|
#include <pybind11/stl_bind.h>
|
||||||
#include <pybind11/functional.h>
|
#include <pybind11/functional.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
|
||||||
namespace py = pybind11;
|
namespace py = pybind11;
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ namespace py = pybind11;
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "linux_platform.h"
|
#include "linux_platform.h"
|
||||||
#include "knx/bau57B0.h"
|
#include "knx/bau57B0.h"
|
||||||
@ -31,10 +33,22 @@ static void loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static std::thread workerThread;
|
static std::thread workerThread;
|
||||||
|
static std::vector<const char*> argv;
|
||||||
|
|
||||||
static void Prepare(int argc, char** argv)
|
struct StdStringCStrFunctor
|
||||||
{
|
{
|
||||||
platform = new LinuxPlatform(argc, argv);
|
const char* operator() (const std::string& str) { return str.c_str(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void Prepare(std::vector<std::string> args)
|
||||||
|
{
|
||||||
|
//for(int i = 0; i < args.size(); i++)
|
||||||
|
// printf("%s\n", args[i].c_str());
|
||||||
|
|
||||||
|
argv = std::vector<const char*>(args.size());
|
||||||
|
std::transform(args.begin(), args.end(), argv.begin(), StdStringCStrFunctor());
|
||||||
|
|
||||||
|
platform = new LinuxPlatform(argv.size(), const_cast<char**>(argv.data()));
|
||||||
bau = new Bau57B0(*platform);
|
bau = new Bau57B0(*platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +123,9 @@ PYBIND11_MODULE(knx, m)
|
|||||||
py::bind_vector<std::vector<GroupObject>>(m, "GroupObjectList");
|
py::bind_vector<std::vector<GroupObject>>(m, "GroupObjectList");
|
||||||
|
|
||||||
m.def("Start", &Start, "Start knx handling thread.");
|
m.def("Start", &Start, "Start knx handling thread.");
|
||||||
m.def("Stop", &Start, "Stop knx handling thread.");
|
m.def("Stop", &Stop, "Stop knx handling thread.");
|
||||||
|
m.def("Prepare", &Prepare, "Allocated needed objects.");
|
||||||
|
m.def("Destroy", &Destroy, "Free object allocated by Prepare.");
|
||||||
m.def("ProgramMode", (bool(*)())&ProgramMode, "get programing mode active.");
|
m.def("ProgramMode", (bool(*)())&ProgramMode, "get programing mode active.");
|
||||||
m.def("ProgramMode", (bool(*)(bool))&ProgramMode, "Activate / deactivate programing mode.");
|
m.def("ProgramMode", (bool(*)(bool))&ProgramMode, "Activate / deactivate programing mode.");
|
||||||
m.def("Configured", (bool(*)())&Configured, "get configured status.");
|
m.def("Configured", (bool(*)())&Configured, "get configured status.");
|
||||||
|
Loading…
Reference in New Issue
Block a user