Mike Ashe Posted August 1, 2006 Report Share Posted August 1, 2006 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... Quote Link to comment
Mike Ashe Posted August 2, 2006 Author Report Share Posted August 2, 2006 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. Quote Link to comment
Grampa_of_Oliva_n_Eden Posted August 3, 2006 Report Share Posted August 3, 2006 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. Thanks for sharing Mike! Ben Quote Link to comment
Mike Ashe Posted August 3, 2006 Author Report Share Posted August 3, 2006 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. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.