-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop sever usb #70
Open
TheMutta
wants to merge
13
commits into
develop_server
Choose a base branch
from
develop_sever_usb
base: develop_server
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7134348
Added X_LINK_USB_EP define.
TheMutta 7cce347
Added reading and writing functions in PlatformData.c
TheMutta d0197a9
USB EP Protocol.
TheMutta 7f2f6fe
Added examples for USB EP.
TheMutta efb454d
Added initialization, connecting and closing for USB EP.
TheMutta 93d3f20
Added XLinkProtocolToStr for X_LINK_USB_EP
TheMutta 659c8e3
Added missing header
TheMutta d2a709b
Fixed issue of missing headers and the impossibility of using EPs on …
TheMutta 4427ade
Added checks for Win32 in all usb EP functions.
TheMutta 558d1c1
Semi-successful client/server with usb-ep
TheMutta 6165959
Working implementation with USB_EP as server and USB_VSC as client.
TheMutta a6f2d39
Using now fdKeys and getting Read and Write paths from the user in US…
TheMutta d4fffc3
Adapted examples to USB_EP.
TheMutta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include <cstdio> | ||
#include <string> | ||
#include <vector> | ||
#include <array> | ||
#include <thread> | ||
#include <stdexcept> | ||
#include <iostream> | ||
#include <cassert> | ||
#include <chrono> | ||
#include <thread> | ||
#include <algorithm> | ||
#include <cstring> | ||
#include <atomic> | ||
|
||
#include "XLink/XLink.h" | ||
#include "XLink/XLinkPublicDefines.h" | ||
#include "XLink/XLinkLog.h" | ||
|
||
// Common constants | ||
const uint8_t DUMMY_DATA[1024*128] = {}; | ||
XLinkGlobalHandler_t xlinkGlobalHandler = {}; | ||
|
||
// Client | ||
int main(int argc, char** argv) { | ||
if (argc != 2) { | ||
printf("Usage: xlink_usb_client [name of device]\n"); | ||
exit(1); | ||
} | ||
|
||
XLinkGlobalHandler_t gHandler; | ||
XLinkInitialize(&gHandler); | ||
|
||
mvLogDefaultLevelSet(MVLOG_ERROR); | ||
|
||
deviceDesc_t deviceDesc; | ||
strcpy(deviceDesc.name, argv[1]); | ||
deviceDesc.protocol = X_LINK_USB_VSC; | ||
// deviceDesc.protocol = X_LINK_USB_EP; | ||
|
||
printf("Device name: %s\n", deviceDesc.name); | ||
|
||
XLinkHandler_t handler; | ||
handler.devicePath = deviceDesc.name; | ||
handler.protocol = deviceDesc.protocol; | ||
auto connRet = XLinkConnect(&handler); | ||
printf("Connection returned: %s\n", XLinkErrorToStr(connRet)); | ||
|
||
if(connRet != X_LINK_SUCCESS) { | ||
return -1; | ||
} | ||
|
||
auto s = XLinkOpenStream(handler.linkId, "test_0", sizeof(DUMMY_DATA)); | ||
if(s == INVALID_STREAM_ID){ | ||
printf("Open stream failed...\n"); | ||
} else { | ||
printf("Open stream OK - id: 0x%08X\n", s); | ||
} | ||
|
||
streamPacketDesc_t p; | ||
auto r = XLinkReadMoveData(s, &p); | ||
if (r == X_LINK_SUCCESS) { | ||
printf("Read successful: 0x%08X\n", r); | ||
} else { | ||
printf("Read failed...\n"); | ||
} | ||
XLinkDeallocateMoveData(p.data, p.length); | ||
|
||
auto w = XLinkWriteData(s, (uint8_t*) &s, sizeof(s)); | ||
if (w == X_LINK_SUCCESS) { | ||
printf("Write successful: 0x%08X\n", w); | ||
} else { | ||
printf("Write failed...\n"); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include <cstdio> | ||
#include <string> | ||
#include <vector> | ||
#include <array> | ||
#include <thread> | ||
#include <stdexcept> | ||
#include <iostream> | ||
#include <cassert> | ||
#include <chrono> | ||
#include <thread> | ||
#include <algorithm> | ||
#include <cstring> | ||
#include <atomic> | ||
|
||
#include "XLink/XLink.h" | ||
#include "XLink/XLinkPublicDefines.h" | ||
#include "XLink/XLinkLog.h" | ||
|
||
// Common constants | ||
const uint8_t DUMMY_DATA[1024*128] = {}; | ||
XLinkGlobalHandler_t xlinkGlobalHandler = {}; | ||
|
||
// Server | ||
int main(int argc, const char** argv){ | ||
xlinkGlobalHandler.protocol = X_LINK_USB_EP; | ||
|
||
// Initialize and suppress XLink logs | ||
mvLogDefaultLevelSet(MVLOG_ERROR); | ||
auto status = XLinkInitialize(&xlinkGlobalHandler); | ||
if(X_LINK_SUCCESS != status) { | ||
throw std::runtime_error("Couldn't initialize XLink"); | ||
} | ||
|
||
XLinkHandler_t handler; | ||
// Write is ep1, read is ep2 | ||
handler.devicePath = "/dev/usb-ffs/depthai_device/ep1"; | ||
handler.devicePath2 = "/dev/usb-ffs/depthai_device/ep2"; | ||
handler.protocol = X_LINK_USB_EP; | ||
auto serverRet = XLinkServer(&handler, "eps", X_LINK_BOOTED, X_LINK_MYRIAD_X); | ||
printf("Connection returned: %s\n", XLinkErrorToStr(serverRet)); | ||
|
||
// loop through streams | ||
auto s = XLinkOpenStream(0, "test_0", sizeof(DUMMY_DATA)); | ||
if(s == INVALID_STREAM_ID){ | ||
printf("Open stream failed...\n"); | ||
} else { | ||
printf("Open stream OK - id: 0x%08X\n", s); | ||
} | ||
|
||
auto w = XLinkWriteData(s, (uint8_t*) &s, sizeof(s)); | ||
if (w == X_LINK_SUCCESS) { | ||
printf("Write successful: 0x%08X\n", w); | ||
} else { | ||
printf("Write failed...\n"); | ||
} | ||
|
||
// Wait to make sure we caugth up to all requests | ||
std::this_thread::sleep_for(std::chrono::seconds(2)); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required?