LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 1097 when calling void **

Solved!
Go to solution

I am trying to setup an x-ray camera that I bought from Sens-Tech. The camera comes with an API called xapi. I have been able to use the camera in c and c++ successfully. I now want to implement the same code in labview.

 

Most of the vi that I have built are working fine. The only one that is giving me a problem is the image capture vi.

 

int xapi_getblock(struct context* ctx, void ** pData, int nTimeout)

 

All the vi use "struct context *" The only variable that can be at fault is the "void **" declaired pData. The functions are hidden in the dll and only the prototypes are available in the h-file. Also, pData's structure is hidden but it returns a hex number char array.

 

Has anyone successfully worked with "void **" in LabView?

0 Kudos
Message 1 of 35
(4,860 Views)

You can work with a void ** type in LabVIEW, but it will require some unusual tricks.  You will need to provide more information about how pData is used.  Are you as the user expected to allocate space for that data, or does the library allocate it and return a pointer to it?  What documentation do you have for this function?

 

As you may know, void ** is a pointer to a pointer to a block of memory of undefined type.  You can use DSNewPtr to allocate memory and MoveBlock to get data out of a pointer and into LabVIEW, but you need to explain what you're doing with it before I can provide any specific advice.  Both of those functions are accessible through the Call Library Function Node by setting the library name to "LabVIEW".

0 Kudos
Message 2 of 35
(4,841 Views)

Hi Nathand. Thank you for the speedy response.

 

This API hides all the functionalities from the programmer, eg. the context structure is declared in a function {int xapi_allocx(struct xapi_context ** ctx)}. I declared this as an unsigned pointer sized integer passed to the allocx vi as a pointer and to all other vi as a value. I have no access or any ideas on how this structer looks. In c/c++ the library handles the memory allocation and returns a pointer to the data. 

 

I was previously able to use an unsigned 32-bit integer passed as a pointer to get the pointer address but that was about two weeks ago and the same process doesn't seem to work. It now yields an Error 1097.

 

What I will do with the data is convert it from a 10/20 digit string to a Hex number. 

0 Kudos
Message 3 of 35
(4,829 Views)

Khonzi wrote:

This API hides all the functionalities from the programmer, eg. the context structure is declared in a function {int xapi_allocx(struct xapi_context ** ctx)}. I declared this as an unsigned pointer sized integer passed to the allocx vi as a pointer and to all other vi as a value. I have no access or any ideas on how this structer looks. In c/c++ the library handles the memory allocation and returns a pointer to the data.


Why would you pass it one way to the allocx function, and differently to all the other functions, when all the functions declare it as the same parameter type?  An unsigned pointer-sized integer passed by pointer seems correct to me for a void ** type for which the library allocates memory.  Passing that same parameter by value means you're essentially passing a void * instead of a void ** which will not work when the library tries to dereference the pointer.


Khonzi wrote:

I was previously able to use an unsigned 32-bit integer passed as a pointer to get the pointer address but that was about two weeks ago and the same process doesn't seem to work. It now yields an Error 1097.


If changing it to pass that parameter the same way does not solve the problem, can you upload your code to show how what you're doing?


@Khonzi wrote:
What I will do with the data is convert it from a 10/20 digit string to a Hex number. 

I have no idea what you mean by this, but it sounds unnecessary.

0 Kudos
Message 4 of 35
(4,810 Views)

Please take a look at the c example. This explains the whole process of acquiring images. I am porting the whole code to LabView

0 Kudos
Message 5 of 35
(4,782 Views)

Can you also upload your LabVIEW VI(s) too?  If there are several, zip them into a single archive and upload that.

0 Kudos
Message 6 of 35
(4,774 Views)

I have attached the full API and vi. I am not working from my laptop so I hope it is fine. 

 

But just in case. I used the import> .dll in labview. Imported all the functions from the dll and header files into labview. the context_struct was set to unsigned pointer sized number and all functions worked pretty well except the getblock function. This function once worked with void** set to unsigned32 and passed by reference. 

 

This is all I could do. I am currently out of the office. Apon my return, I plan to run the dll in Matlab. If I get this working, I will make a new dll from matlab that passes the data in an easier format.

Download All
0 Kudos
Message 7 of 35
(4,762 Views)

Sorry, I haven't installed LabVIEW 2012 yet... would you mind saving it for 2011 and attaching it again?

0 Kudos
Message 8 of 35
(4,750 Views)

Please find the VIs and dlls attached. The code follows the same process as the c file attached before. 

0 Kudos
Message 9 of 35
(4,744 Views)

Not sure what you did to save for previous version, but all the VIs I'd actually need to look at - the three that are called by Tester.vi, at least - are still in LabVIEW 2012 and I can't open them.  Tester.vi itself opens, but allocx, configurefromfile, and configure do not.

0 Kudos
Message 10 of 35
(4,739 Views)