简体   繁体   English

如何使用Winform C#应用程序通过USB电缆将数据传输到Hololens设备?

[英]How to use Winform C# app to transfer data to Hololens device with USB cable?

I am using Winform C# to make an application with Hololens device. 我正在使用Winform C#使用Hololens设备制作应用程序。

I hope I can check whether the Hololens device connected to the PC, so that I can tranfer data between Hololens and PC. 我希望我可以检查Hololens设备是否已连接到PC,以便可以在Hololens和PC之间传输数据。

I found one solution is that check whether I can access the Hololens internal storage, if can check, the Hololens has connected to the PC. 我发现一种解决方案是检查是否可以访问Hololens内部存储器,如果可以检查Hololens是否已连接到PC。

But I found I can't get the Hololens internal storage, even if I can see the internal storage in the explorer, but I can't get the driver(like C:\\ or D:\\ ), Hololens internal storage don't have a device number. 但是我发现即使可以在资源管理器中看到内部存储,也无法获得Hololens内部存储,但是却无法获得驱动程序(例如C:\\或D:\\),而Hololens内部存储却无法有设备号。

What should I do? 我该怎么办? Is there any better way to check whether Hololens has connected and transfer data between Hololens and PC except Network? 有什么更好的方法可以检查Hololens是否已连接并在网络之外的Hololens和PC之间传输数据?

Since there is smiliar project called ADB, is it necessary to develop something like ADB? 既然有一个名为ADB的附属项目,是否有必要开发类似ADB的项目? If so, how should I start? 如果是这样,我应该如何开始?

----------------------------Edit-------------------- - - - - - - - - - - - - - - 编辑 - - - - - - - - - -

I finally found the workable solution: 我终于找到了可行的解决方案:

First, in PC app, I use a library called libusbDotNet which allow you get full control to the USB device like Hololens to send a command to Hololens device 首先,在PC应用程序中,我使用一个名为libusbDotNet的库,该库可让您完全控制USB设备(例如Hololens),以向Hololens设备发送命令

Secondly, in Hololens platform, write a UWP application which can receive data from PC by usb cable, and send response data back to PC 其次,在Hololens平台上,编写一个UWP应用程序,该应用程序可以通过USB电缆从PC接收数据,并将响应数据发送回PC

From the discussion. 从讨论开始。 The actual problem is how to get an access to HoloLens filesystem from remote PC. 实际的问题是如何从远程PC访问HoloLens文件系统。

That could be solved by Windows Device Portal REST API . Windows Device Portal REST API可以解决该问题。

But I would recommend to use WindowsDevicePortalWrapper . 但是我建议使用WindowsDevicePortalWrapper You should connect to your device by USB or WiFi, and provide an access to it. 您应该通过USB或WiFi连接到设备,并提供对其的访问权限。

Simple code that reads content of one known folder. 读取一个已知文件夹内容的简单代码。

static void Main(string[] args1)
{

    string DeviceAddress = "http://127.0.0.1:10080/";

    DevicePortal Portal = new DevicePortal(new DefaultDevicePortalConnection(DeviceAddress, "user", "pass"));

    Portal.ConnectAsync().Wait(); 

    var folders = Portal.GetKnownFoldersAsync().Result.Folders;
    var rootDirOfFirstFolder = Portal.GetFolderContentsAsync(folders[0], null).Result.Contents;

    Console.WriteLine($"First known folder is {folders[0]}. It contains:");
    foreach(var file in rootDirOfFirstFolder)
    {
        Console.WriteLine($"\t{file.Name}");
    }


    Console.WriteLine("Press ANY key to continue.....");
    Console.ReadKey();

}

The similar staff is for reading/writing files on a device. 类似的人员用于在设备上读取/写入文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM