how to connect scope on USB from UWP app

Post your .Net discussions here
Post Reply
Berol
Newbie
Posts: 0
Joined: Mon Dec 30, 2019 1:24 pm

how to connect scope on USB from UWP app

Post by Berol » Mon Dec 30, 2019 2:18 pm

Hello to everyone, I'm a new member of the forum ; thanks to all for the support!

I am writing my own code in C# with Visual Studio 2019 for connecting and streaming data from a PS4262 scope, on WINDOWS 10 system. Starting by the ConsoleExample.sln code, I have been able to connect to the scope and streaming; then I moved it into a WPF C# application for having a better UI and everithing works well too.
I now need to use the Win2D graphic library for efficiently display huge amount of data on the screen; unforntunately the Win2D library works only on UWP apps. That is why I had to move from WPF C#.NET code to a UWP code. The problem I have once i wrote the UWP app, is that now it seems that the scope does not connect anymore (handler returns -1) .
I have seen that UWP need to activate USB device before using them , I already tried some possible solutions I found but without success. I am not much expert in SW
Any suggestion will be appreciated. thank you!

Gerry
PICO STAFF
PICO STAFF
Posts: 557
Joined: Mon Aug 11, 2014 11:14 am

Re: how to connect scope on USB from UWP app

Post by Gerry » Thu Jan 02, 2020 10:51 am

Hi Berol,

To get the code to work you need to be fully aware of the startup process that you need to follow in order to successfully get control of the PicoScope. The startup code needs to first of all find your connected device on the USB bus, and then get its handle by opening it. If your implementation of code when using UWP is not performing this transparently enough (i.e. if it is interfering in some way instead of just passing the commands straight through) then you may have to find a way to bypass it (e.g. by using your own wrapper code).

You say that, when using UWP, the code has to activate it before using it, then you need to find out why, and exactly what that entails (as this could be be what is corrupting the startup process). You also need to find out if under UWP the bus is being placed into a specific mode or state that is preventing the PicoScope driver from correctly opening the unit (a preventative state could even be where the timing has become a problem for correct execution of a driver command). Finally if the device is being activated first when using UWP, then it could be that the handle has been taken and it is not being returned.

Regards,

Gerry
Gerry
Technical Specialist

Berol
Newbie
Posts: 0
Joined: Mon Dec 30, 2019 1:24 pm

Re: how to connect scope on USB from UWP app

Post by Berol » Sat Jan 04, 2020 4:06 pm

Hi Gerry,
thanks for your feedback.

After some search I understood that UWP apps work as a sandbox so that it is necessary to enable some functionalities in the app.manifest of the project to work with USB.
I think to have managed the above needs with the following code in xaml manifest:
"
Capabilities
Capability Name="internetClient"
DeviceCapability Name="usb"
Device Id="vidpid:0ce9 1009"
Function Type="classId:ff * *"
Function Type="name:vendorSpecific"
/Device>
/DeviceCapability
"

Unfortunately I also found something that might explain why the above modifications of the manifest file might be not enough:

https://docs.microsoft.com/en-us/windows-hardware/drivers/devapps/hardware-support-app--hsa--steps-for-driver-developers

In my understaning of this link (but I'm not sure of that) if I want to use a device driver (i.e. the ps4000.dll calling the OpenUnit function) inside a UWP app it is necessary that the manufacturer of the driver (Pico Technolocy) does two things :
- asks Microsoft to recognize and enable the driver also for the UWP
- asks the dirver to be allowed for all UWP application that want to use it ("AllowAny").

so my questions are:

- if you agree that requiring a Microsoft aknowledge for your driver is necessary , does Pico Technology plan to do it for all of its drivers so that to extend the capability of writing own SW also for the Universal app?
- otherwise , if you know that the above aknowledge is actually not necessary, do you have a UWP example in which the driver is working well when called by a UWP app?

thank you very much for your support !

regards
Berol

Gerry
PICO STAFF
PICO STAFF
Posts: 557
Joined: Mon Aug 11, 2014 11:14 am

Re: how to connect scope on USB from UWP app

Post by Gerry » Thu Jan 16, 2020 1:30 pm

Hi Berol,

So are you saying that UWP acts as a virtual machine (and is it running some form of windows if you need Microsoft authentication)? In windows authentication is normally taken care of by driver signing, so if it is a version of Windows, then you would need to get it authenticated (as far as I'm aware we wouldn't have a UWB example).

Regards,

Gerry
Gerry
Technical Specialist

Post Reply