Skip to content

Commit d314c35

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

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
@@ -830,6 +830,23 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack) {
830830
},
831831
py::arg("enable"),
832832
DOC(dai, DeviceBase, setTimesync, 2))
833+
.def(
834+
"setM8FsyncRole",
835+
[](DeviceBase& d, M8FsyncRole role) {
836+
py::gil_scoped_release release;
837+
return d.setM8FsyncRole(role);
838+
},
839+
py::arg("role"),
840+
DOC(dai, DeviceBase, setM8FsyncRole)
841+
)
842+
.def(
843+
"getM8FsyncRole",
844+
[](DeviceBase& d) {
845+
py::gil_scoped_release release;
846+
return d.getM8FsyncRole();
847+
},
848+
DOC(dai, DeviceBase, getM8FsyncRole)
849+
)
833850
.def(
834851
"getDeviceName",
835852
[](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"
@@ -790,6 +791,19 @@ class DeviceBase {
790791
*/
791792
void setMaxReconnectionAttempts(int maxAttempts, std::function<void(ReconnectionStatus)> callBack = nullptr);
792793

794+
/**
795+
* Sets M8 Fsync role for the device
796+
* @param role M8 Fsync role to be set, AUTO_DETECT by default
797+
* @returns Tuple of bool and string. Bool specifies if role was set without failures. String is the error message describing the failure reason.
798+
*/
799+
std::tuple<bool, std::string> setM8FsyncRole(M8FsyncRole role = M8FsyncRole::AUTO_DETECT);
800+
801+
/**
802+
* Gets M8 Fsync role for the device
803+
* @returns Gets M8 Fsync role
804+
*/
805+
M8FsyncRole getM8FsyncRole();
806+
793807
protected:
794808
std::shared_ptr<XLinkConnection> connection;
795809

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)