LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

empty buffer and crashing vi

HI,
this vi take an X-ray image and display/save it. it runs ok with error if no hardware is attached to it and when the hardware is attched it runs with no error if not in the debugging mode(with highlight execution off). However it crashes(when the highlight execution -- the lightbulb is on) about a quarter of a seconds after "acquire image" when the hardware is attached to it. the image data are stored in "pProcessData" but when I check it I found that all the entries are empty. no images is taken. Is there anyway I can test where is the mistake? included in the attached zip is the vi, the manual and a sample c code demo provided by the company.
Can a computer learn how to program?
0 Kudos
Message 1 of 7
(2,984 Views)
Hi Kevin,

If the only thing that results in an error in your VI is to run it in Highlight Execution, then the issue is most likely caused by a timing/execution order change. Try to split the two Call Library Function Nodes in the fifth frame so they execute in separate frames. Now, there's no control whether "Acquire_GainImage" or "CreatePixelMap" excutes first, and this might cause an error.

Another thing; why haven't you connected the outputs of "Acquire_Image"? Currently you are only writing to "pProcessedData" from the "DefineDestBuffers" call. Make sure that wherever you want to access the image ("pProcessedData") you will have to wire a the "pProcessedData" indicator directly or to one of its Local Variables. It seems to me that you are mistaken the Local Variables to represent a reference to the image in memory, but they actually just create a copy of the value in the front panel object (in this case "pProcessedData").

I hope this helps.
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 2 of 7
(2,964 Views)
Thanks, I have found the crashing problem, it is becaues the correction data are somehow mismatching. some I make the correction data of size 0 array and the program doesn't crash any more.(it is ok to acquire image without correction)
Now the thing is the pProcessData, I have a demo C program provided by the company(the attached file, also include a libaray file which you need if you try to run the demo and a header file and my vi). The one named " pAcqBuffer" is equal to my "pProcessData". The thing to note is that:
1. this is how they call DefinedescBuffer:
pAcqBuffer = malloc(dwFrames*dwRows*dwColumns*sizeof(short));
if (!pAcqBuffer)
{
//error handling
goto Exit;
}

//route acquisition buffer to HSL
if ((nRet=Acquisition_DefineDestBuffers(hAcqDesc, pAcqBuffer, dwFrames, dwRows, dwColumns))!=HIS_ALL_OK)

and this is how they require image:
if ((nRet=Acquisition_Acquire_Image(hAcqDesc, dwFrames, 0,
HIS_SEQ_ONE_BUFFER, NULL, NULL, NULL))!=HIS_ALL_OK)
HIS_SEQ_ONE_BUFFER is just an int number(valued 1, in this case)

so Acquire_Image doesn't take the buffer as a parameter directly; however I when try to acquire image without defining buffer, the program crashes.
However, the image must be acquired because they have a printf statement:
sprintf(strBuffer, "acq buffer frame: %d, dest frame %d, row: %d, col: %d, value: %d\n",
dwActFrame, dwSecFrame,
dwRow, dwCol, pAcqBuffer[dwColumns*dwRow+dwCol]);

so, they print pAcqBuffer and get a value...
Guess my question is how would I aquire the image in labview. my vi runs but I can't get the image.
Can a computer learn how to program?
0 Kudos
Message 3 of 7
(2,951 Views)
Hi Kevin,

I'm not exactly sure what parameter holds the actual image data. Have you tried to connect indicators to the parameters from the DLL calls that might acquire the image (e.g. "Acquisition_Acquire_Image")? What data is output from the "pwOffsetData", "pdwGainData" and "pdwPixelData"? The only way that you can access an image acquired from these DLLs would be as a return-parameter from one of the function calls.

Let me know what you find, thanks.
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 4 of 7
(2,934 Views)
Sorry philip for not getting back to you on time. aparently "aquire image" doesn't take "pProcessData" as an input and "pwOffsetData", "pdwGainData" and "pdwPixelData" are just correction data which is not needed for now. "aquire image" get to know pProcessData" through "hAcqDesc" which is a structure handle. let me give you the reference book you will see from page 60 and on they talk about the dll functions. it looks like that I have defined a buffer "pProcessData" but did not do anything to it. but if I aquire image without defining buffer, the program complains, so the buffer must be "used" or referred to. I don't know why nothing has changed if "process data" had writen anything to the buffer.
Can a computer learn how to program?
0 Kudos
Message 5 of 7
(2,910 Views)
Hi, philip, I think I have found the problem: it is in my local variable "pProcessData", I make a local variable "pProcessData" and later extract data out of it. I think labview made a second copy of the array when I make that local variable and when "acquire image" writes the the buffer, it doesn't write to the local variable but to the really buffer prelocated by "defineDescBuffer". If I am to be correct, the question is how to access the real buffer that contains the real data, So far I have not got a clue how to do that.

kevin
Can a computer learn how to program?
0 Kudos
Message 6 of 7
(2,894 Views)
Hi Kevin,

LabVIEW cannot directly access a buffer allocated by the DLL without having it passed back from the DLL. It is not enough to know the address of the memory location, since LabVIEW doesn't have the access to the buffer allocated by the DLL. The only solutions seems to be to use a wrapper DLL written in e.g. VB or C that accesses this buffer and passes it back to LabVIEW.

Have Fun!
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 7 of 7
(2,888 Views)