Skip to content

Commit 6784c4f

Browse files
author
Filippo Mutta
committed
Testing request via USB.
1 parent 8a03d04 commit 6784c4f

File tree

4 files changed

+15
-34
lines changed

4 files changed

+15
-34
lines changed

cmake/depthaiDependencies.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ else()
176176
FetchContent_Declare(
177177
XLink
178178
GIT_REPOSITORY https://github.com/luxonis/XLink.git
179-
GIT_TAG 4126554f5854b8215ef5833af9ca85fd39816d0c
179+
GIT_TAG d46c049e30d2a56f7bbec2e25e7e2fa5c09ec6d0
180180
)
181181

182182
FetchContent_MakeAvailable(

include/depthai/xlink/XLinkStream.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,12 @@ class XLinkStream {
9292
void write(long fd);
9393
void write(long fd, span<const uint8_t> data);
9494
void write(const void* data, std::size_t size);
95-
void writeGate(span<const uint8_t> data);
9695
std::vector<std::uint8_t> read();
9796
std::vector<std::uint8_t> read(XLinkTimespec& timestampReceived);
9897
void read(std::vector<std::uint8_t>& data);
9998
void read(std::vector<std::uint8_t>& data, long& fd);
10099
void read(std::vector<std::uint8_t>& data, XLinkTimespec& timestampReceived);
101100
void read(std::vector<std::uint8_t>& data, long& fd, XLinkTimespec& timestampReceived);
102-
void readGate(std::vector<std::uint8_t>& data);
103101
// split write helper
104102
void writeSplit(const void* data, std::size_t size, std::size_t split);
105103
void writeSplit(const std::vector<uint8_t>& data, std::size_t split);

src/device/DeviceGate.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "device/DeviceGate.hpp"
22

33
#include <XLink/XLinkPublicDefines.h>
4+
#include <XLink/XLinkPlatform.h>
45

56
// std
67
#include <fstream>
@@ -56,10 +57,6 @@ DeviceGate::DeviceGate(const DeviceInfo& deviceInfo) : deviceInfo(deviceInfo) {
5657
pimpl->cli = std::make_unique<httplib::Client>(deviceInfo.name, DEFAULT_PORT);
5758
pimpl->cli->set_read_timeout(60); // 60 seconds timeout to allow for compressing the crash dumps without async
5859
// pimpl->cli->set_connection_timeout(2);
59-
60-
gateConnection = std::make_shared<XLinkConnection>(deviceInfo, X_LINK_GATE);
61-
gateStream = std::make_shared<XLinkStream>(gateConnection, "XLink Gate Stream", 32 * 1024 * 1024);
62-
spdlog::debug("Connected to gate stream");
6360

6461
}
6562

@@ -68,16 +65,6 @@ bool DeviceGate::isOkay() {
6865
return nlohmann::json::parse(res->body)["status"].get<bool>();
6966
}
7067

71-
struct request_t {
72-
uint16_t RequestNum;
73-
}__attribute__((packed));
74-
request_t request;
75-
request.RequestNum = 1;
76-
77-
span<const uint8_t> data;
78-
memcpy((char*)data.data(), &request, sizeof(request));
79-
gateStream->writeGate(data);
80-
8168
return false;
8269
}
8370

@@ -166,6 +153,19 @@ bool DeviceGate::createSession(bool exclusive) {
166153
}
167154

168155
bool DeviceGate::startSession() {
156+
struct request_t {
157+
uint16_t RequestNum;
158+
uint32_t RequestSize;
159+
}__attribute__((packed));
160+
request_t request;
161+
request.RequestNum = 1;
162+
request.RequestSize = 0;
163+
164+
XLinkPlatformGateWrite(&request, sizeof(request));
165+
XLinkPlatformGateRead(&request, sizeof(request));
166+
int requestNum = request.RequestNum;
167+
spdlog::warn("Request num: {}", requestNum);
168+
169169
std::string url = fmt::format("{}/{}/start", sessionsEndpoint, sessionId);
170170
if(auto res = pimpl->cli->Post(url.c_str())) {
171171
if(res->status != 200) {

src/xlink/XLinkStream.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,6 @@ void XLinkStream::write(long fd, span<const uint8_t> data) {
113113
}
114114
}
115115

116-
void XLinkStream::writeGate(span<const uint8_t> data) {
117-
auto status = XLinkGateWriteData(streamId, data.data(), static_cast<int>(data.size()));
118-
if(status != X_LINK_SUCCESS) {
119-
throw XLinkWriteError(status, streamName);
120-
}
121-
}
122-
123-
124116
void XLinkStream::read(std::vector<std::uint8_t>& data) {
125117
XLinkTimespec timestampReceived;
126118
read(data, timestampReceived);
@@ -166,15 +158,6 @@ std::vector<std::uint8_t> XLinkStream::read(XLinkTimespec& timestampReceived) {
166158
return data;
167159
}
168160

169-
void XLinkStream::readGate(std::vector<std::uint8_t>& data) {
170-
StreamPacketDesc packet;
171-
const auto status = XLinkReadMoveData(streamId, &packet);
172-
if(status != X_LINK_SUCCESS) {
173-
throw XLinkReadError(status, streamName);
174-
}
175-
data = std::vector<std::uint8_t>(packet.data, packet.data + packet.length);
176-
}
177-
178161
StreamPacketDesc XLinkStream::readMove() {
179162
StreamPacketDesc packet;
180163
const auto status = XLinkReadMoveData(streamId, &packet);

0 commit comments

Comments
 (0)