06-21-2012 02:38 AM
hi, ALL
I want to use some instrument driver(DLL) to create a sequence.and step type base on C++,When initialized instrument with hp34970a_init("GPIB0::5::INSTR", False, True, Locals.SW) ,the prototype is
ViStatus _VI_FUNC hp34970a_init(
ViRsrc resourceName,
ViBoolean IDQuery,
ViBoolean resetDevice,
ViPSession instrumentHandle)
it works fine,So i want to more operations for intrument,Such as :write,read....
the arg4 (Locals.SW)is defined as "pointer/handle" -->"by reference &" in the module pane.And Locals.SW is defined as a object reference in Variable pane.After the initialized function is executed,The Locals.SW will be evaluated "Pointer: 0x1fa4f908".So in the next step,I want to use this instrument handle to execute other functions(invoke some functions in the DLL).Example:hp34970a_reset(Locals.SW),the prototype is
ViStatus _VI_FUNC hp34970a_reset(
ViSession instrumentHandle)
it seems not to work.
How to fix it? Thanks a lot.
BR
Johnny
06-21-2012 02:43 AM
the version of TS is 2010.
06-21-2012 10:00 AM
What does the prototype in the step module call for the reset function have specified for the instrumentHandle? It should be pointer/handle passed by value.
What do you mean by it not working, are you getting a crash or an error?
Hope this helps,
-Doug
06-21-2012 02:16 PM
Hi Johnny,
I think you want to use a numeric for the instrumentHandle parameter, not an object reference. The init will set the value of the numeric as a reference number for the current instrument session, which you then pass to the other functions instrumentHandle parameter.
Hope this helps.
-Jack
06-25-2012 01:28 AM
Hi,
Appreciate your reply.
Doug,
hp34970a_reset(Locals.SW),the prototype is
ViStatus _VI_FUNC hp34970a_reset(
ViSession instrumentHandle).
The instrumentHandle is defined pointer/handle passed by reference previously.So i change to "passed by value" instead of it as you said.The instrument can be reset.
It is done.
Jack,
If i changed the Local.SW to numeric instead of object reference.And in
ViStatus _VI_FUNC hp34970a_init(
ViRsrc resourceName,
ViBoolean IDQuery,
ViBoolean resetDevice,
ViPSession instrumentHandle)
instrumentHandle is passed by reference and in
ViStatus _VI_FUNC hp34970a_reset(
ViSession instrumentHandle). the instrumentHandle is passed by value.The sequence works fine too.
Thank you very much!
one more question,Both of methods can meet the applicaiotn.Which one is reasonable?
BR
Johnny
06-25-2012 08:36 AM
Hi Johnny,
I believe that using a numeric as your instrumentHandle would mean that you don't have to edit the prototype of the functions you're using in TestStand (which is what I assume you did to get the 'pass by value' to work).
If you look for the intrinsic type of ViResource, it is derived from an unsigned 32 bit integer in visatype.h, so I'd recommend setting you instrument handle using the numeric approach.
Hope this answers your question.
-Jack