Skip to content

Commit c2230ff

Browse files
committed
Add M8 Fsync role switching
Signed-off-by: stas.bucik <[email protected]>
1 parent 2ef3bde commit c2230ff

File tree

5 files changed

+87
-0
lines changed

5 files changed

+87
-0
lines changed

bindings/python/src/DeviceBindings.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,23 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack) {
837837
},
838838
py::arg("enable"),
839839
DOC(dai, DeviceBase, setTimesync, 2))
840+
.def(
841+
"setM8FsyncRole",
842+
[](DeviceBase& d, M8FsyncRole role) {
843+
py::gil_scoped_release release;
844+
return d.setM8FsyncRole(role);
845+
},
846+
py::arg("role"),
847+
DOC(dai, DeviceBase, setM8FsyncRole)
848+
)
849+
.def(
850+
"getM8FsyncRole",
851+
[](DeviceBase& d) {
852+
py::gil_scoped_release release;
853+
return d.getM8FsyncRole();
854+
},
855+
DOC(dai, DeviceBase, getM8FsyncRole)
856+
)
840857
.def(
841858
"getDeviceName",
842859
[](DeviceBase& d) {

bindings/python/src/pipeline/CommonBindings.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
// depthai/
77
#include "depthai/common/CameraBoardSocket.hpp"
8+
#include "depthai/common/M8FsyncRoles.hpp"
89
#include "depthai/common/CameraFeatures.hpp"
910
#include "depthai/common/CameraImageOrientation.hpp"
1011
#include "depthai/common/CameraSensorType.hpp"
@@ -50,6 +51,7 @@ void CommonBindings::bind(pybind11::module& m, void* pCallstack) {
5051
py::class_<Quaterniond> quaterniond(m, "Quaterniond", DOC(dai, Quaterniond));
5152
py::class_<Size2f> size2f(m, "Size2f", DOC(dai, Size2f));
5253
py::enum_<CameraBoardSocket> cameraBoardSocket(m, "CameraBoardSocket", DOC(dai, CameraBoardSocket));
54+
py::enum_<M8FsyncRole> m8FsyncRole(m, "M8FsyncRole", DOC(dai, M8FsyncRole));
5355
py::enum_<ConnectionInterface> connectionInterface(m, "connectionInterface", DOC(dai, ConnectionInterface));
5456
py::enum_<CameraSensorType> cameraSensorType(m, "CameraSensorType", DOC(dai, CameraSensorType));
5557
py::enum_<CameraImageOrientation> cameraImageOrientation(m, "CameraImageOrientation", DOC(dai, CameraImageOrientation));
@@ -221,6 +223,12 @@ void CommonBindings::bind(pybind11::module& m, void* pCallstack) {
221223
});
222224
HEDLEY_DIAGNOSTIC_POP
223225

226+
// M8FsyncRole enum bindings
227+
m8FsyncRole.value("AUTO_DETECT", M8FsyncRole::AUTO_DETECT)
228+
.value("MASTER_WITHOUT_OUTPUT", M8FsyncRole::MASTER_WITHOUT_OUTPUT)
229+
.value("MASTER_WITH_OUTPUT", M8FsyncRole::MASTER_WITH_OUTPUT)
230+
.value("SLAVE", M8FsyncRole::SLAVE);
231+
224232
// CameraSensorType enum bindings
225233
cameraSensorType.value("COLOR", CameraSensorType::COLOR)
226234
.value("MONO", CameraSensorType::MONO)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#pragma once
2+
#include <cstdint>
3+
#include <iostream>
4+
#include <string>
5+
6+
namespace dai {
7+
/**
8+
* Which Fsymc role the device will have.
9+
*
10+
* AUTO_DETECT denotes that the decision will be made by device.
11+
* It will choose between MASTER_WITH_OUTPUT and SLAVE.
12+
*/
13+
enum class M8FsyncRole : int32_t {
14+
AUTO_DETECT = -1,
15+
MASTER_WITHOUT_OUTPUT,
16+
MASTER_WITH_OUTPUT,
17+
SLAVE,
18+
};
19+
20+
inline std::string toString(M8FsyncRole role) {
21+
switch(role) {
22+
case M8FsyncRole::AUTO_DETECT:
23+
return "AUTO DETECT";
24+
case M8FsyncRole::MASTER_WITHOUT_OUTPUT:
25+
return "MASTER, NO OUTPUT";
26+
case M8FsyncRole::MASTER_WITH_OUTPUT:
27+
return "MASTER, WITH OUTPUT";
28+
case M8FsyncRole::SLAVE:
29+
return "SLAVE";
30+
default:
31+
return "UNKNOWN";
32+
}
33+
}
34+
35+
} // namespace dai
36+
37+
// Global namespace
38+
inline std::ostream& operator<<(std::ostream& out, const dai::M8FsyncRole& socket) {
39+
return out << dai::toString(socket);
40+
}

include/depthai/device/DeviceBase.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// project
1818
#include "depthai/common/CameraBoardSocket.hpp"
1919
#include "depthai/common/CameraFeatures.hpp"
20+
#include "depthai/common/M8FsyncRoles.hpp"
2021
#include "depthai/common/UsbSpeed.hpp"
2122
#include "depthai/device/CalibrationHandler.hpp"
2223
#include "depthai/device/DeviceGate.hpp"
@@ -797,6 +798,19 @@ class DeviceBase {
797798
*/
798799
void setMaxReconnectionAttempts(int maxAttempts, std::function<void(ReconnectionStatus)> callBack = nullptr);
799800

801+
/**
802+
* Sets M8 Fsync role for the device
803+
* @param role M8 Fsync role to be set, AUTO_DETECT by default
804+
* @returns Tuple of bool and string. Bool specifies if role was set without failures. String is the error message describing the failure reason.
805+
*/
806+
std::tuple<bool, std::string> setM8FsyncRole(M8FsyncRole role = M8FsyncRole::AUTO_DETECT);
807+
808+
/**
809+
* Gets M8 Fsync role for the device
810+
* @returns Gets M8 Fsync role
811+
*/
812+
M8FsyncRole getM8FsyncRole();
813+
800814
protected:
801815
std::shared_ptr<XLinkConnection> connection;
802816

src/device/DeviceBase.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,14 @@ void DeviceBase::crashDevice() {
11901190
}
11911191
}
11921192

1193+
std::tuple<bool, std::string> DeviceBase::setM8FsyncRole(M8FsyncRole role) {
1194+
return pimpl->rpcClient->call("setM8FsyncRole", role);
1195+
}
1196+
1197+
M8FsyncRole DeviceBase::getM8FsyncRole() {
1198+
return pimpl->rpcClient->call("getM8FsyncRole");
1199+
}
1200+
11931201
dai::Version DeviceBase::getIMUFirmwareVersion() {
11941202
isClosed();
11951203
std::string versionStr = pimpl->rpcClient->call("getIMUFirmwareVersion").as<std::string>();

0 commit comments

Comments
 (0)