Skip to content

Commit 49cea8a

Browse files
committed
Bump for the submodule
1 parent d2abf73 commit 49cea8a

3 files changed

Lines changed: 108 additions & 1 deletion

File tree

src/XLinkBindings.cpp

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#include "XLinkBindings.hpp"
2+
3+
#include "depthai/xlink/XLinkConnection.hpp"
4+
#include "depthai/xlink/XLinkStream.hpp"
5+
6+
#include <cmath>
7+
#include <cstring>
8+
9+
void XLinkBindings::bind(pybind11::module &m, void *pCallstack)
10+
{
11+
12+
using namespace dai;
13+
14+
// Type definitions
15+
py::class_<DeviceInfo> deviceInfo(m, "DeviceInfo", DOC(dai, DeviceInfo));
16+
py::class_<deviceDesc_t> deviceDesc(m, "DeviceDesc");
17+
py::enum_<XLinkDeviceState_t> xLinkDeviceState(m, "XLinkDeviceState");
18+
py::enum_<XLinkProtocol_t> xLinkProtocol(m, "XLinkProtocol");
19+
py::enum_<XLinkPlatform_t> xLinkPlatform(m, "XLinkPlatform");
20+
py::class_<XLinkConnection, std::shared_ptr<XLinkConnection> > xLinkConnection(m, "XLinkConnection", DOC(dai, XLinkConnection));
21+
py::class_<XLinkError> xLinkError(m, "XLinkError", DOC(dai, XLinkError));
22+
py::class_<XLinkReadError, XLinkError> xLinkReadError(m, "XLinkReadError", DOC(dai, XLinkReadError));
23+
py::class_<XLinkWriteError, XLinkError> xLinkWriteError(m, "XLinkWriteError", DOC(dai, XLinkWriteError));
24+
25+
///////////////////////////////////////////////////////////////////////
26+
///////////////////////////////////////////////////////////////////////
27+
///////////////////////////////////////////////////////////////////////
28+
// Call the rest of the type defines, then perform the actual bindings
29+
Callstack *callstack = (Callstack *)pCallstack;
30+
auto cb = callstack->top();
31+
callstack->pop();
32+
cb(m, pCallstack);
33+
///////////////////////////////////////////////////////////////////////
34+
///////////////////////////////////////////////////////////////////////
35+
///////////////////////////////////////////////////////////////////////
36+
37+
// Bindings
38+
deviceInfo
39+
.def(py::init<>())
40+
.def_readwrite("desc", &DeviceInfo::desc)
41+
.def_readwrite("state", &DeviceInfo::state)
42+
.def("getMxId", &DeviceInfo::getMxId);
43+
44+
deviceDesc
45+
.def(py::init<>())
46+
.def_readwrite("protocol", &deviceDesc_t::protocol)
47+
.def_readwrite("platform", &deviceDesc_t::platform)
48+
.def_property(
49+
"name",
50+
[](deviceDesc_t &o)
51+
{ return std::string(o.name); },
52+
[](deviceDesc_t &o, std::string n)
53+
{ std::strncpy(o.name, n.c_str(), std::min(XLINK_MAX_NAME_SIZE, (int)n.size())); });
54+
55+
xLinkDeviceState
56+
.value("X_LINK_ANY_STATE", X_LINK_ANY_STATE)
57+
.value("X_LINK_BOOTED", X_LINK_BOOTED)
58+
.value("X_LINK_UNBOOTED", X_LINK_UNBOOTED)
59+
.value("X_LINK_BOOTLOADER", X_LINK_BOOTLOADER)
60+
.export_values();
61+
;
62+
63+
xLinkProtocol
64+
.value("X_LINK_USB_VSC", X_LINK_USB_VSC)
65+
.value("X_LINK_USB_CDC", X_LINK_USB_CDC)
66+
.value("X_LINK_PCIE", X_LINK_PCIE)
67+
.value("X_LINK_TCP_IP", X_LINK_TCP_IP)
68+
.value("X_LINK_IPC", X_LINK_IPC)
69+
.value("X_LINK_NMB_OF_PROTOCOLS", X_LINK_NMB_OF_PROTOCOLS)
70+
.value("X_LINK_ANY_PROTOCOL", X_LINK_ANY_PROTOCOL)
71+
.export_values();
72+
73+
xLinkPlatform
74+
.value("X_LINK_ANY_PLATFORM", X_LINK_ANY_PLATFORM)
75+
.value("X_LINK_MYRIAD_2", X_LINK_MYRIAD_2)
76+
.value("X_LINK_MYRIAD_X", X_LINK_MYRIAD_X)
77+
.export_values();
78+
79+
xLinkConnection
80+
.def(py::init<const DeviceInfo &, std::vector<std::uint8_t> >())
81+
.def(py::init<const DeviceInfo &, std::string>())
82+
.def(py::init<const DeviceInfo &>())
83+
.def_static("getAllConnectedDevices", &XLinkConnection::getAllConnectedDevices, py::arg("state") = X_LINK_ANY_STATE)
84+
.def_static("getFirstDevice", &XLinkConnection::getFirstDevice, py::arg("state") = X_LINK_ANY_STATE)
85+
.def_static("getDeviceByMxId", &XLinkConnection::getDeviceByMxId, py::arg("mxId"), py::arg("state") = X_LINK_ANY_STATE);
86+
87+
xLinkError
88+
.def(py::init<XLinkError_t, const std::string &, const std::string &>())
89+
.def_readonly("status", &XLinkError::status)
90+
.def_readonly("streamName", &XLinkError::streamName)
91+
.def("what", &XLinkError::what);
92+
93+
xLinkReadError
94+
.def(py::init<XLinkError_t, const std::string &>());
95+
96+
xLinkWriteError
97+
.def(py::init<XLinkError_t, const std::string &>());
98+
}

src/XLinkBindings.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
// pybind
4+
#include "pybind11_common.hpp"
5+
6+
struct XLinkBindings
7+
{
8+
static void bind(pybind11::module &m, void *pCallstack);
9+
};

0 commit comments

Comments
 (0)