Jump to content

Convert VISA Class from GPIB-Instr to Instr (LV 8.0.1)


Mike Ashe

Recommended Posts

Hi All,

I am working on porting a bunch of GPIB code from one project to a "sister" project. Unfortunately, the two projects somehow decided to use different VISA classes for the VISA Session name controls.

Group A uses VISA class: GPIB-Instr

Group B uses VISA class: Instr

I am porting code from Group A's project to Group B. Naturally, you cannot wire VISA Sessions of different classes together.

I tried to use the typecasts "To More Specific" "To More Generic" from the Application Control palette, but that did not work, you get broken wires. I also tried using the Type Cast from the Data Manipulation palette. That appears to work, in that you can run the VI, but when you get to the Type Cast node, more often than not I get "error: memory.cpp Line 352" followed by "you're toast!!" :laugh: and LabVIEW dies. :headbang:

Well, it doesn't actually say "you're toast", but it might as well, cause LabVIEW really does die.

At this point I'm mulling over a couple of options:

1. Humble Myself and ask for help here, to see if one of my fellow GWizards knows of a typecast method that I have missed, or has a VI that takes a GPIB-Instr in one end and through myriads of property nodes parses out the properties and stuffs them adequately into an output session of type Instr.

2. Manually change all the VISA Sessions in the ported code from one class to another (ugh, not very elegant, and very time-consuming, there's a fair amount of VI's & controls)

3. Try to whip up a VI Scripting gadget that will do the change automagically. I'd also be happy to use someone else's magic (and heap praise and thanks upon them) if they already have coded something like this.

Well, thanks for listening, I'm off to the VI Scripting forums to check what's in goodie bag...

Link to comment

Okay, problem solved, or I should say problem worked around. It turns out that you cannot wire VISA Resource Name controls of different classes together, but you can wire from the property:values from one to another. You can also coerce from a VISA Session to a string and then from that string to a VISA Session of another class.

Go figure ...

Anyway, attached is two VIs that take a VISA Instr class in and give a VISA GPIB Instr class out. But if you try to wire directly from Session to Session they break.

Download File:post-45-1154550195.vi This uses property nodes

Download File:post-45-1154550232.vi This uses string coercion

This seems to work fine, so far, if anyone knows of a reason why not to do, this, ie, gotchas lurking, please enlighten us.

Link to comment
Okay, problem solved, or I should say problem worked around. It turns out that you cannot wire VISA Resource Name controls of different classes together, but you can wire from the property:values from one to another. You can also coerce from a VISA Session to a string and then from that string to a VISA Session of another class.

Go figure ...

Anyway, attached is two VIs that take a VISA Instr class in and give a VISA GPIB Instr class out. But if you try to wire directly from Session to Session they break.

Download File:post-45-1154550195.vi This uses property nodes

Download File:post-45-1154550232.vi This uses string coercion

This seems to work fine, so far, if anyone knows of a reason why not to do, this, ie, gotchas lurking, please enlighten us.

Why do I like these crash bugs so much?

;)

Another approach type casts as a string and then to the target class.

This did NOT crash my machine and appeared to convert com3 and LPT1 OK.

post-29-1154561474.jpg?width=400

Thanks for sharing Mike!

Ben

Link to comment
Another approach type casts as a string and then to the target class.

Hmm ... your attachment doesn't appear to show up. I did try your cast -> string -> cast -> target and that seems to work fine as well. Funny that NI has not provided a conversion to more|less specific VISA type.

Wasn't the promise of VISA that if we all used it we would have a single type & interface. Well, time to put this into the next request list to NI.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.