LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 1097 when passing array from C++ DLL to LabView

Ahhh, now this starts to make some more sense. It seems indeed a LabVIEW message, and most likely has to do with the fact that LabVIEW uses resource files for localized strings. Could it be you have installed a LabVIEW version with a different language than English? Do you have a lvstrings.rsc file in <labVIEW>/resource? Maybe it got damaged. Although the strange string is at the location where the VI hierearchy should be, so somehow LabVIEW is not able to retrieve the call chain. I can't really help more, but it seems something in LabVIEW got corrupted. Maybe a repair or reinstallation is at its place.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 21 of 55
(3,454 Views)

"DO NOT USE STR# 0 !!! [Thanks, from Akash B and Stephen M]"

I also got this strange error if a vi tried to get the callchain from an inlined vi! 🙂

0 Kudos
Message 22 of 55
(3,388 Views)

This would be a bug, but a quite obscure one. The Call Chain function wasn't updated to adapt to the reduced VI call chain when code is compiled with inlined VIs. But I have a feeling that a possible fix to this might be not to fix the Call Chain function to do that (which might be quite complicated), but instead generate a compilation error when a Call Chain function is inside a VI that is set to be inlined.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 23 of 55
(3,383 Views)

I am bringing this thread back up from the dead because I am facing very similar issues. I am working with a Basler camera, with the Pylon API (http://www.baslerweb.com/pylon) version 3.0 on a 64 bit machine. I am using the C version of the code. Most of the code below are from the Pylonc.h file (attached) in the Pylon API.

 

I am trying to call this function in labview:

 

HRESULT PylonCreateDeviceByIndex( size_t index, RETVAL_PAR PYLON_DEVICE_HANDLE *phDev);

 

HRESULT is basically a long, size_t is a uint32. I have no idea what this RETVAL_PAR is. I just see "#    define RETVAL_PAR" earlier in the .h file. I have spent hours trying to figure out what the type PYLON_DEVICE_HANDLE is. It is defined in quite an obscure way:

 

GENAPIC_DECLARE_HANDLE( PYLON_DEVICE_HANDLE ); 

 

# define GENAPIC_DECLARE_HANDLE(name) \
struct name##_; typedef struct name##_ *name

 

I'm viewing the source code from Visual studio, so I tried to right click -> go to definition for "name" and it led me to a definition for NetBios 3.0 (Nb30.h)

 

typedef struct _NAME_BUFFER {
UCHAR name[NCBNAMSZ];     //NCBNAMSZ=16
UCHAR name_num;
UCHAR name_flags;
} NAME_BUFFER, *PNAME_BUFFER;

 

I tried to implement that 18-element struct in labview to input it, but I keep getting problems. I tried using clusters, played around with the data type. I am attaching a simple vi with exactly what I have in my larger vi. This will never run as is. The first two functions called are happy, but they require a serial port to be running. This is running in conjunction with some FPGA vi that instantiates a serial port (before these function calls), which is why I haven't included the large vi. Let me know if I should include the large vi (or the whole project). Please let me know if you have suggestions.

 

Thank you

 

Download All
0 Kudos
Message 24 of 55
(3,235 Views)

@elsayed3 wrote:

I am bringing this thread back up from the dead because I am facing very similar issues. I am working with a Basler camera, with the Pylon API (http://www.baslerweb.com/pylon) version 3.0 on a 64 bit machine. I am using the C version of the code. Most of the code below are from the Pylonc.h file (attached) in the Pylon API.

 

I am trying to call this function in labview:

 

HRESULT PylonCreateDeviceByIndex( size_t index, RETVAL_PAR PYLON_DEVICE_HANDLE *phDev);

 

HRESULT is basically a long, size_t is a uint32. I have no idea what this RETVAL_PAR is. I just see "#    define RETVAL_PAR" earlier in the .h file. I have spent hours trying to figure out what the type PYLON_DEVICE_HANDLE is. It is defined in quite an obscure way:

 

GENAPIC_DECLARE_HANDLE( PYLON_DEVICE_HANDLE ); 

 

# define GENAPIC_DECLARE_HANDLE(name) \
struct name##_; typedef struct name##_ *name

 

I'm viewing the source code from Visual studio, so I tried to right click -> go to definition for "name" and it led me to a definition for NetBios 3.0 (Nb30.h)

 

typedef struct _NAME_BUFFER {
UCHAR name[NCBNAMSZ];     //NCBNAMSZ=16
UCHAR name_num;
UCHAR name_flags;
} NAME_BUFFER, *PNAME_BUFFER;

 

I tried to implement that 18-element struct in labview to input it, but I keep getting problems. I tried using clusters, played around with the data type. I am attaching a simple vi with exactly what I have in my larger vi. This will never run as is. The first two functions called are happy, but they require a serial port to be running. This is running in conjunction with some FPGA vi that instantiates a serial port (before these function calls), which is why I haven't included the large vi. Let me know if I should include the large vi (or the whole project). Please let me know if you have suggestions.

 

Thank you

 


You say you try to do this on 64 Bit Windows and I assume you use 64 Bit LabVIEW too. How did you determine that size_t is an uint32? In my Visual C environment this is in fact an usigned int for 32 Bit Windows with an extra warning when used in situations where it is assigned to a 32 Bit variable and an unsigned __int64 for 64 Bit Windows.

 

When you look at the declaration of the HANDLE macro you see that it is defined as a pointer to an opaque structure. Opaque means here unknown which is valid for a C compiler, as long as you don't try to dereference the pointer. Your function declares a pointer (reference) to this handle since it is an output variable that receives this handle.

 

So the absolute correct way to configure this function would be to use pointer sized unsigned integer (pass as: value) for index and a pointer sized unsigned integer (pass as: pointer to value) for your *phDev parameter. Most other APIs will likely require a hDev parameter (without the reference operator * in front) and there you will configure the parameter to be a pointer sized unsigned integer (pass as: value).

 

The NetBIOS structure has nothing to do with this, your Visual Studio dependency parser got a bit confused here, but that is not the same parser used for the C compiler, so it won't be a problem for the code generation.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 25 of 55
(3,231 Views)

Hi Rolf,

 

Thanks for the quick reply. about whether size_t is 34 or 64 bit, its somewhat confusing... I am using Labview 2010 32 bit edition on 64-bit windows 7. As I mentioned, there is some FPGA programming going on too, and the FPGA module only works in 32 bit. However, I specifically downloaded the 64 bit version of Pylon... when I tried installing the 32 bit version the installer complained and exited. In any case, it is declared as "typedef unsigned int size_t" unless I am misunderstanding something. I just hovered over it and visual studio told me that. Not really sure where it got that from. Right click -> go to definition doesn't work.

 

I am more comfortable with the C++ version of this api than C. I have already made some nice wrappers for them (the C++ one), then I found I couldn't really use them because they had classes and stuff. But your suggestion of passing numbers as pointers seems promising, and if it works I see no problem of it working with the C++ version. I had played with this idea once but I think I wasn't passing them correctly.

 

I'll try this later and I will let you know how it goes.

 

Thanks

0 Kudos
Message 26 of 55
(3,243 Views)

You can't use a 64 Bit DLL from within a 32 Bit application! Either you get the 32 Bit Pylon API installed on your 64 Bit machine or you have a problem here. As far as the size of size_t is concerned in 32 bit LabVIEW and with 32 Bit DLL it is an unsigned 32 Bit integer.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 27 of 55
(3,229 Views)

Unless of course the 64 Pylon Version contains 32 Bit user space DLLs to access the driver. That should be ok although I would expect the installer for this to be able to cope with installations for both 32 Bit and 64 Bit Windows. It's really confusing to have two installers here.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 28 of 55
(3,228 Views)

Hi,

 

I am also getting the same error I actually started the other thread here but even if someone can tell me how to set parameters for this function 

 

void function(int imax, unsigned char * data, double * yout, int OSR, int order);

 

I am not getting any error but not recieving any value.

Naqqash
0 Kudos
Message 29 of 55
(3,100 Views)

Hi Naqqash, 

 

It seems your question was answered on your original post here

 

 

Maggie
National Instruments
Applications Engineer
ni.com/support
0 Kudos
Message 30 of 55
(3,077 Views)