LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

crash and 0xC0000005 error passing pointer to array

Solved!
Go to solution

Hello,

 

I'm interfacing a CCD detector (c7041 head cotrolled by c7557-01 usb controller) using a dll factory provided wich contains functions to control the detector. The dll installed succesfully, made a simple program to control simple functions (such as cooling, ADC resolution ...) ad it works fine.

Actually I'm trying to get datas from the CCD sensor using the "getProfile" function, wich ask as argument a pointer to an array of U16.

The dll reference is not so clear, but I found out that the function should "fill" the array with datas.

 

How can I pass by pointer the elements of a U16 array ?

 

Now when passing the array to the function, labview crashes.

 

Thanks

Eugenio

0 Kudos
Message 1 of 12
(3,359 Views)

The problem in detail is the following:

 

The function, according dll's manual, has the definition attached as definition.png .

 

I need to create an array of 1044 numbers wich can be filled by the function to store datas from CCD.

Then I need to access datas in array to save it in an external CSV file.

 

How can I do ?

 

At the moment tried to Initialize an array of 1044 integers, containing 0. Then pass the array to a Call Library Function Node, wich is configured in this way:

Library: LabVIEW

Function Name: MoveBlock

Calling Convention: C

return type: void

param 1: Array of signed 32 bit Integer, Format: Array Data Pointer

param 2: Numeric signed 32 bit Integer, Pass: Value

param 3: Numeric signed 32 bit Integer, Pass: Value

 

and wired all as seen in the second atached, named prova.vi

 

Thanks in advice

Download All
0 Kudos
Message 2 of 12
(3,342 Views)

What are we supposed to see in the "definition.png" attachment? It's a screenshot of the Device Manager, and doesn't show anything about the DLL. Also, you did not include the VI that actually calls your DLL.

 

My guess is there's no need to call MoveBlock to make this work, but without the documentation for the DLL function I can't be sure. Please attach the documentation for the DLL, and the VI that actually makes the call to the DLL.

 

(Also, as a helpful note, the phrase in English is "Thanks in advance." It would also be acceptable to write "Thanks for your advice.")

0 Kudos
Message 3 of 12
(3,332 Views)

The use of the MoveBlock() function in your VI definitely is BAD! That has to crash for sure! Most likely you won't need MoveBlock at all but need to setup the Call Library Node in the GetProfile VI that you did not include. Also show us the documentation to the C function too.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 12
(3,319 Views)

Sorry for my mistakes,

 

I've loaded the correct file with the C function definition.

I load GetProfile.vi too, as requested

 

Thanks in advance

 

Download All
0 Kudos
Message 5 of 12
(3,292 Views)
Solution
Accepted by topic author uge026

This is more likely what your function needs to be called like. No warranties, as the documentation is rather sparse, but it is a reasonable guess from the documentation you provided.

Rolf Kalbermatter
My Blog
Message 6 of 12
(3,261 Views)

Thanks it works fine ! U saved my bachelor degree thesis, I was screwing on this vi since 3 days !

0 Kudos
Message 7 of 12
(3,252 Views)

Hello,

 

I'm experiencing troubles again on this Vi  😞 😞 😞

 

Rolfk's Vi worked fine (returned 1), but after the  return value now it report "Error 1097" occurred at Call Library Function Node. Someone can help me ?

 

The first strange thing is that my Vi (vich is attached) worked just once ! (filling a csv with detector's value)

 

I'm very confused because the error report refers to function that work fine until GetProfile is called. I Tryed to delete the function that causes the error and it appears again on another function (other functions control just optional features of my CCD, as Gain, number of pixels ...).

The very strange thing is that everything works fine until the GetProfile function is called.

 

I post here my program (it's complicated, but the important part is signed with a big comment in the stacked sequence frame number four), the library and the reference

 

Really hope someone can help me 

Thanks in advace

 

Eugenio

0 Kudos
Message 8 of 12
(3,225 Views)

error 1097 means that something has written to memory it should not have done. This could be any of the functions you call through any Call Library Node. Typically this happens because you do not allocate a buffer for the function to write into.

 

When you look at the function I provided, there are really two possible reasons why they could cause this error:

 

1) The CCD array has more than the 1024 pixels that I assumed from your documentation. The documentation states something to that effect that this number will depend on the used CCD element.

2) The function is not filling in the data while the function executes but instead keeps the pointer in the background to be filled in asynchronously. The LabVIEW buffer passed into the function is only guaranteed to be valid during the function call itself. After the function returns control to LabVIEW, LabVIEW reserves the right to deallocate or reuse that buffer for anything it deems useful and when your function then attempts to write into that buffer asynchronously it may simply overwrite memory that is in the meantime used by LabVIEW for something else.

 

While these two reasons should not be ignored and thoroughly investigated, you should also account for the possibility that any other function you call may be called in the wrong way and cause such issues. The difficulty with this is that while a function may have been called in a way that it destroys memory, this does not always have to cause immediately an error or crash. Instead it can cause problems only later on when LabVIEW stumbles over the destroyed memory area by chance.

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 12
(3,213 Views)

Thank U for the answer,

 

1) Checked the datasheet of detector, it has 1024 active pixels, 1044 physical pixels. Changed the constant to 1050 and it works.

2) The function is working fine if in the program there are just initializations and getprofile function. I tryed to insert configuration functions in a frame of a stacked structure, preceding the getprofile function and after the initializations. It didn't work, all functions succedeed, but the generated csv (wich contains array's data) reports only zeros, so the array was initializated successfully, but not filled with datas from CCD.

 

I'll try to investigate other functions and write the simplest possible program. 

 

Thanks for help !

Eugenio

0 Kudos
Message 10 of 12
(3,194 Views)