简体   繁体   中英

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.

I hope I can check whether the Hololens device connected to the PC, so that I can tranfer data between Hololens and 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.

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.

What should I do? Is there any better way to check whether Hololens has connected and transfer data between Hololens and PC except Network?

Since there is smiliar project called ADB, is it necessary to develop something like 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

Secondly, in Hololens platform, write a UWP application which can receive data from PC by usb cable, and send response data back to PC

From the discussion. The actual problem is how to get an access to HoloLens filesystem from remote PC.

That could be solved by Windows Device Portal REST API .

But I would recommend to use WindowsDevicePortalWrapper . You should connect to your device by USB or WiFi, and provide an access to it.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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