Program Hangs in ps6000CloseUnit

Post any questions you may have about our current range of oscilloscopes
cpede
Newbie
Posts: 0
Joined: Fri Dec 23, 2016 7:46 am

Program Hangs in ps6000CloseUnit

Post by cpede » Fri Dec 23, 2016 11:11 am

I'm trying to make a small program in C++ using the SDK for the PicoScope 6402C.

I'm calling the SDK from a DLL, and uses only the functions ps6000OpenUnit, ps6000GetUnitInfo, and ps6000CloseUnit.

In the constructor I call ps6000OpenUnit and ps6000GetUnitInfo, and in the destructor I call ps6000CloseUnit.

My problem is that the code hangs in the ps6000CloseUnit call. This call simply never returns?

While hanging I can see that 6 threads are alive in the SDK:

Code: Select all

Not Flagged		17708	0	Worker Thread	ps6000.dll thread	ps6000.dll!0b55fd59	Normal
Not Flagged		26188	0	Worker Thread	ps6000.dll thread	ps6000.dll!0b55b508	Normal
Not Flagged		25952	0	Worker Thread	ps6000.dll thread	ps6000.dll!0b55fd59	Normal
Not Flagged		30848	0	Worker Thread	ps6000.dll thread	ps6000.dll!0b55b508	Normal
Not Flagged		28256	0	Worker Thread	ps6000.dll thread	ps6000.dll!0b53e461	Normal
Not Flagged		24144	0	Worker Thread	ps6000.dll thread	ps6000.dll!0b57a356	Normal
And 2 DLL are still loaded:

Code: Select all

ps6000.dll	C:\Program Files (x86)\Pico Technology\SDK\lib\ps6000.dll	N/A	N/A	Binary was not built with debug information.		73	1.04.4.45	06-07-2015 09:46	0B530000-0B869000	[23576] myapp.exe		
picoipp.dll	C:\Program Files (x86)\Pico Technology\SDK\lib\picoipp.dll	N/A	N/A	Binary was not built with debug information.		75	1.01.2.52	25-03-2015 10:06	0B870000-0C63E000	[23576] myapp.exe
Any idea what is going on?

Calling ps6000CloseUnit does not seem to terminate its internal threads and unload the PicoScope DLLs correctly?

-cpede

Martyn
Site Admin
Site Admin
Posts: 3371
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Program Hangs in ps6000CloseUnit

Post by Martyn » Wed Dec 28, 2016 1:53 pm

Can you post your code, and give details of your development environment, hopefully we can help resolve your issues.
Martyn
Technical Support Manager

cpede
Newbie
Posts: 0
Joined: Fri Dec 23, 2016 7:46 am

Re: Program Hangs in ps6000CloseUnit

Post by cpede » Mon Jan 02, 2017 8:37 am

OK, I made a small sample.

In VS2015 I made a small dialog based EXE project and a DLL project in one solution. The EXE have two functions to load and unload the DLL using ::LoadLibrary and ::FreeLibrary, that's it.

In the DLL I have references to the ps6000.lib (in stdafx.cpp) and an include to ps6000API.h (in PicoTextDLL.cpp). When running the driver version is tells me: 1.4.4.45, which I believe is the latest.

When running the program I press the button LoadDLL.

Here I see the same problem directly, the call to ps6000EnumerateUnits hangs in InitInstance. In my original program I do not call this in InitInstance, but I call ps6000CloseUnit in ExitInstance which shows the same behavior.

So, you driver do not like to be called in either InitInstance or ExitInstance of a DLL?

Please fix this.

-cpede
Attachments
PicoTest.zip
VS2015 Solution which shows the problem
(140.74 KiB) Downloaded 181 times

cpede
Newbie
Posts: 0
Joined: Fri Dec 23, 2016 7:46 am

Re: Program Hangs in ps6000CloseUnit

Post by cpede » Mon Jan 09, 2017 7:38 am

Any progress after looking at my sample project?
I can also offer you to run a TeamViewer session if that helps?

-cpede

Martyn
Site Admin
Site Admin
Posts: 3371
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Program Hangs in ps6000CloseUnit

Post by Martyn » Mon Jan 16, 2017 9:09 am

Sorry for the delay, it has been very busy, and we have been short on staff.
My problem is that the code hangs in the ps6000CloseUnit call
Can you confirm if you have successfully called ps6000OpenUnit at any stage in your testing ?
Martyn
Technical Support Manager

cpede
Newbie
Posts: 0
Joined: Fri Dec 23, 2016 7:46 am

Re: Program Hangs in ps6000CloseUnit

Post by cpede » Mon Jan 16, 2017 9:22 am

Yes, the ps6000OpenUnit has been called successfully.

The problem is not as much your function calls. Both ps6000OpenUnit and ps6000CloseUnit as well as other function calls can be successfully called as long as it is not called from the DLL's InitInstance or ExitInstance methods.

It is very easily verified running my small sample.

-cpede

Martyn
Site Admin
Site Admin
Posts: 3371
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Program Hangs in ps6000CloseUnit

Post by Martyn » Tue Jan 17, 2017 7:32 am

That is what I was seeing, just needed to check, I will need to debug this from the driver and/or speak with the development team.
Martyn
Technical Support Manager

cpede
Newbie
Posts: 0
Joined: Fri Dec 23, 2016 7:46 am

Re: Program Hangs in ps6000CloseUnit

Post by cpede » Fri Jan 27, 2017 1:07 pm

Any news.

It should be easy to reproduce with my small sample.

-cpede

Martyn
Site Admin
Site Admin
Posts: 3371
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Program Hangs in ps6000CloseUnit

Post by Martyn » Mon Jan 30, 2017 1:28 pm

I have used your example, and have seen it go missing in the ps6000EnumerateUnits call.

As the ps600GetUnitInfo call works, it would appear the issue is due to the ps6000.dll calling the lower level USB kernel drivers when using the other functions.

I will need to discuss this with the development team, so it may take a little while, they are currently very busy.

Is there a particular reason you need to use InitInstance and ExitInstance for your application ?
Martyn
Technical Support Manager

cpede
Newbie
Posts: 0
Joined: Fri Dec 23, 2016 7:46 am

Re: Program Hangs in ps6000CloseUnit

Post by cpede » Mon Jan 30, 2017 2:07 pm

I have no problems with the ps6000EnumerateUnits.

The reason for using the InitInstance and ExitInstrance is that I uses the PicoScope driver in a DLL which is manually loaded using LoadLibrary and FreeLibrary.

And by the way, it has already taken more than one month for you to answer that you will look at it.

-cpede

Martyn
Site Admin
Site Admin
Posts: 3371
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Program Hangs in ps6000CloseUnit

Post by Martyn » Tue Jan 31, 2017 8:23 am

I did look at your code earlier this month, and could see there was an issue when calling into our dll.

I have been investigating this, in particular looking at the processes involved when calling an extension DLL from a regular DLL, and have spoken with the development team. This method of calling our dll is not something they have used, so they have no immediate answers, and is new territory for me.

On opening a unit our drivers load firmware into the device, which then restarts and re-enumerates as a fully working device on the USB bus. You can see this process if you have device manager open when you start PicoScope 6, or call OpenUnit from an application. I am not seeing this happen when your dll calls OpenUnit from the InitInstance method, so maybe there is a step missing.
Martyn
Technical Support Manager

cpede
Newbie
Posts: 0
Joined: Fri Dec 23, 2016 7:46 am

Re: Program Hangs in ps6000CloseUnit

Post by cpede » Fri Feb 17, 2017 7:15 am

How are things progressing on this issue?

-cpede

Martyn
Site Admin
Site Admin
Posts: 3371
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Program Hangs in ps6000CloseUnit

Post by Martyn » Tue Feb 21, 2017 2:47 pm

I am awaiting input from the development team. Unfortunately with a new release coming through I haven't had the opportunity to debug this with them.
Martyn
Technical Support Manager

cpede
Newbie
Posts: 0
Joined: Fri Dec 23, 2016 7:46 am

Re: Program Hangs in ps6000CloseUnit

Post by cpede » Mon Jul 31, 2017 9:48 am

Hi please talk to the development.

Since both you and I can easily reproduce the problem, - it should be possible to fix it.

Maybe this topic should be moved to the C/C++ Forum?

-cpede

Martyn
Site Admin
Site Admin
Posts: 3371
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Program Hangs in ps6000CloseUnit

Post by Martyn » Wed Aug 16, 2017 6:54 am

I will follow this up with the development team to see if there has been any progress. There are new drivers available in the recently released SDK download so I will test with these as well.
Martyn
Technical Support Manager

Post Reply