Test and Measurement Forum

Pico driver handle value

Post general discussions on using our drivers to write your own software here

Pico driver handle value

Postby BSI » Tue Apr 10, 2012 4:57 pm

I have been using Pico 4224 and more recently 4227 for a few years, and I am programming with LabVIEW.
I work with one scope at a time, and I had notice that the handle returned by the dll function call that opens a connection to the scope was typically always 0 or sometimes 1.

Based on this, in my code, I would run a loop on handles = 0 to 5 (just to be safe) and run a Close function call, to insure no handle was left open by mistake.

Now on the latest 4227 I got, I noticed a handle value of 16394. Are you aware of any changes made in the firmware or dll driver? Is there some rule behind the handle number generation :?: ? Thx.

Laurent
BSI
Newbie
 
Posts: 0
Joined: Wed May 12, 2010 3:15 pm
Location: Canada

Re: Pico driver handle value

Postby TinWhisker » Fri Apr 13, 2012 11:42 am

I do not know the full reason/answer, but I haven't seen a linear or pattern based handle allocation. (It's pretty random in other words)

The handle is allocated when the driver finds a device, so I would grab it then and place it in an array.
Then loop on that array later when closing them.
TinWhisker
Newbie
 
Posts: 0
Joined: Fri Dec 16, 2011 10:48 am

Re: Pico driver handle value

Postby BSI » Tue Apr 17, 2012 3:37 pm

I had situations where an error would occur and the handle would remain "active", and it would become impossible to re-open a connection unless the scope USB cable is unplugged/replugged. This is not possible in some situation, and the most successful approach I used was to preempt the issue by first closing handles 0 to 5, just to be sure.

Is Pico aware of at least what is the expected range of handles produced by the driver?

L.
BSI
Newbie
 
Posts: 0
Joined: Wed May 12, 2010 3:15 pm
Location: Canada

Re: Pico driver handle value

Postby TinWhisker » Thu Apr 19, 2012 9:13 am

Maybe I misunderstand the issue?

From what your saying, is either:
Whatever handle is given, closing 0 to 5 clears connection issues?
or
If a scope stops responding, you try to re-open using the given handle, rather than closing it first?

I'm assuming the latter, by which closing the driver handle first is the correct action if the connection has failed.
There's no need to close them all - just the failed connection.

You had a handle of '16394' - trying connections, I've had greater and lesser, not necessarily in any real order.

As an aside:

It's best to write your code to handle 'handles' dynamically. Not only from a tidy-code/readabillity point or expandability point, but to handle such issues as above with minimal effort.

My code typically consists of:

- Create Handle Array (to remember all handles)
- OpenCode (When connecting to a scope, a handle is generated/returned and I add it to my array - this is always needed to actually talk to the scope, so if your talking to many scopes, you have many handles)
- TalkCode (again, I have a list of handles, so I tell the driver to get or set info with handle, of which a particular scope that the driver assigned a handle will respond. Here, If a scope fails because I've told it something silly, I'll close that handle and re-open. The new handle gets added to my array in the OpenCode, in which TalkCode just uses what that array lists.)
- CloseCode (I can close any scope in any order, using my handle array)

The handles assigned are moot point, so far as it could give you any number, be it 1 or 10000, it's just it's 'ticket' for this session, issued by the driver. Tomorrow, the 'tickets' (handles) could be issued in a different order.

Also:
If you wanted to be clever, your code could differentiate the scopes by requesting their serial numbers, then with a look-up, tie the handle to the serial, then request data in the physical order you have assembled your experiment.
This way, no matter what order they are initialized and whatever handle they are given, you know who is who.
TinWhisker
Newbie
 
Posts: 0
Joined: Fri Dec 16, 2011 10:48 am

Re: Pico driver handle value

Postby Martyn » Mon Apr 23, 2012 10:30 am

I would have expected 16384 and above starting at Hex 4000, which is the range that applies to all recent PicoScopes and drivers.

So is 16394 a typo ?
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2351
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Pico driver handle value

Postby BSI » Fri Apr 27, 2012 9:02 pm

Hi Martyn,
Yes ! 16384 . It was a typo.
So if I read you correctly. Handles are now starting at 16384 (Hex4000) ?

Thx
Laurent
BSI
Newbie
 
Posts: 0
Joined: Wed May 12, 2010 3:15 pm
Location: Canada

Re: Pico driver handle value

Postby TinWhisker » Mon Apr 30, 2012 8:28 am

Just made sure my PS & drivers are up-to-date and can confirm Martyn is correct.
TinWhisker
Newbie
 
Posts: 0
Joined: Fri Dec 16, 2011 10:48 am


Return to General Software Discussions

Who is online

Users browsing this forum: No registered users and 0 guests