RF Measurement Devices

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing RFSG Handle from C++ to LabVIEW

Hi all,

 

I am developping an application where I have mixed C++ and LabVIEW code, using RFSG (Signal Generator is NI-PXIe-5672).

Running under WIndows XP 32-bit.

Visual C++ 2008.

LabVIEW 8.6.1.

 

At first, only the LabVIEW code was using the RFSG driver.

But now, I would like the C++ code to access the RFSG driver too.

 

The C++ code has do the call "niRFSG_InitWithOptions", so it gets a ViSession.

Then, the LabVIEW code calls the C++ code (DLL) to get a handle to the RFSG.

 

My C++ code works correctly, because I'm able to create a signal with it.

But as soon as I try to use the handle in LabVIEW, I always get an error saying "Invalid Handle".

 

To pass the Handle from C++ to LabVIEW, I do the fallowing:

1- I call niRFSG_InitWithOptions like this:

niRFSG_InitWithOptions(RFUC_name_ptr, VI_TRUE, VI_TRUE, rfuc_options.c_str(), &m_rfsg_session)
 where rfuc_options is "RangeCheck=1,Cache=1,DriverSetup=AWG:AWG"

2- Then, I do some basic config of the RFSG (set central freq, IQ rate, etc)

3- Then, when LabVIEW requests the RFSG Handle, the C++ DLL calls

niRFSG_GetAttributeViString(m_rfsg_session, 0, NIRFSG_ATTR_IO_RESOURCE_DESCRIPTOR, handle_max_length, rfsg_handle)

 and it returns the rfsg_handle as a char * to LabVIEW.

 

Before returning to LabVIEW, I can see that the rfsg_handle is equal to the "RFUC_name_ptr" name I have given to niRFSG_InitWithOptions, so I know that the attribute "NIRFSG_ATTR_IO_RESOURCE_DESCRIPTOR" is fine.

But it doesn't seem to be the right thing to do, since the LabVIEW code always gets an "invalid hanle" error.

 

If anyone has been successful doing this, I'd like to know how!

 

Best regards,

Serge

serge.malo@skydelsolutions.com
0 Kudos
Message 1 of 3
(6,572 Views)

Kudos!

 

A friend here found the answer for me.

Yes, it is possible to transform a ViSession created in C++ into a RFSG handle in LabVIEW.

The trick lies in the LabVIEW VI "niRFSG Initialize.vi".

You have to use the "IVI New Session" VI.

In C++, you have to return both the Ressource Name as a CStr and the ViSession as a unsigned int (U32), and then use them as inputs to the "IVI New Session" VI

Very important also to wire the type of Session you want to create.

serge.malo@skydelsolutions.com
Message 2 of 3
(6,544 Views)

Here you go...

 

Thanks for pointing out..

 

Regards

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 3 of 3
(5,648 Views)