06-25-2008 03:43 AM
The created wrapper works for the most part, however, some types remain unconverted, since the declaration is obviously missing in the driver dll. The wrapper correctly states the types however in the first lines of the c-sharp code file:
// TODO: Function Panel type with id: 1016 and name: "nicomplexnumber" could not be resolved; Type will be treated as System.Int32.
// TODO: Function Panel type with id: 1013 and name: "nirfsa_wfminfo" could not be resolved; Type will be treated as System.Int32.
// TODO: Function Panel type with id: 1014 and name: "nirfsa_spectruminfo" could not be resolved; Type will be treated as System.Int32.
// TODO: Function Panel type with id: 1015 and name: "viint64" could not be resolved; Type will be treated as System.Int32.
// TODO: Function Panel type with id: 1018 and name: "smtspectruminfo" could not be resolved; Type will be treated as System.Int32.
I want to make an IQ Acquisition and therefor i need the "nicomplexnumber" but as seen above the type remain unconverted.
So i rebuilt the structure in C#
[StructLayout(LayoutKind.Sequential)]
public struct NIComplexNumber_struct
{
double real;
double imaginary;
}
But it doesn't works. The message is that he can not read/write to corrupted memory. I understand what the problem is. The complex numbers are addicted by the number of samples.So it must be an array which is flexible.
Does anybody know how to solve the problem??06-26-2008 03:36 AM
I checked the header of the LabWindows/CVI driver(which is the basis fore the wrapper), and the struct is defined like this:
typedef struct NIComplexNumber_struct {
ViReal64 real;
ViReal64 imaginary;
} NIComplexNumber;
As ViReal64 is a double in C#, this should fit to your declaration.
In an CVI I/Q example, it is used like this:
NIComplexNumber* dataPtr = NULL;
dataPtr = malloc (sizeof (ViReal64) * 2 * samplesPerBlock); //dynamically set the arrysize
niRFSA_FetchIQSingleRecordComplexF64 (
session, /* session */
"0", /* channel list */
0, /* record number */
samplesPerBlock,
10.0, /* timeout */
dataPtr,
&wfmInfo));
I hope this helps!
06-26-2008 05:35 AM - edited 06-26-2008 05:36 AM
06-26-2008 10:14 AM
06-26-2008 11:48 AM
06-26-2008 12:02 PM - edited 06-26-2008 12:03 PM
06-27-2008 06:06 AM - edited 06-27-2008 06:07 AM
10-06-2008 06:52 PM
10-07-2008 01:44 AM - edited 10-07-2008 01:48 AM
I downloaded the Measurement Studio 8.5 for Visual Studio 2005 Evaluation Kit. After installing you have the opportunity in Visual Studio to create a .NET Wrapper for National Instrument Drivers. Have a look at the 2 links below:
http://digital.ni.com/public.nsf/allkb/27177DA13C6ED0AE86257362006A68B0
http://digital.ni.com/public.nsf/websearch/52D289F65941474A86256E8A0057D72E?OpenDocument
But i can say that this tool isn't working so well. Some of the functions and methods could not be "wrapped" into C#, so you have to manipulate the wrapper a little bit.
The parts which could not be "wrapped" you can see first Post. I have manipulated the "wrapped" (Post 7) file so that it now works fine.
11-23-2008 10:56 PM
Hi,
National Instruments provides .NET wrappers, both in C# and VB, for most of the Modular Instruments drivers in the KB 3939UN5B on ni.com. Currently it includes.NET wrappers generated against the 2.1 version of the NI-RFSA driver. The zip file containing the niRFSA wrapper also contains a couple of simple C# and VB examples that show how to use them.
If the driver version that you are using is lower than the one that the wrappers are generated, you can still utilize these wrappers as long as you make sure that you do not call into the entry points that are not present in the version of the driver that you are using but are present in the wrapper.
Feel free to use the Product Suggestion Center, if you do not find wrapper for a particular driver or if the one generated by the .NET Instrument Driver Wizard of Measurement Studio does not work as expected.