07-02-2008 03:08 PM
07-02-2008 11:57 PM - edited 07-02-2008 11:58 PM
@lmd2 wrote:
No good, the function still returns the same error: Invalid Buffer
I am attaching the diagram, don't see how the buffer could be better initialized
07-03-2008 03:46 AM - edited 07-03-2008 03:47 AM
07-03-2008 03:57 AM
malloc() is indeed NOT guaranteed to initialize the memory at all. Fro that you would need calloc. But you have not shown much of your code oder than how you allocate your buffer. Not event the function call. After all there might be some assignments to structure elements between the malloc and the function call or what about other function parameters that might be considered invalid and cause this error code?
@lmd2 wrote:
Well in the C code, malloc seems to point/reference the STRUCT definition (from the header file) which is un-initialized; but I will confirm with the client if the malloc requires an initialized STRUCT. (but due to the holiday weekend here in the states I probably won't get a reply until Monday)
Thanks for sticking with this,
lmd2
Message Edited by lmd2 on 07-03-2008 03:47 AM
07-03-2008 05:01 AM
07-03-2008 05:09 AM
07-03-2008 08:07 AM
The buffer itself seems not to be initialized prior to calling. So I would concentrate on other possible problems and that would be that invalid parameters for the Init and Start function might cause the Get Packet function to return this error.
@lmd2 wrote:
here is the same sample app in LabVIEW (not an elegant architecture, but the client wants a literal translation from C to LabVIEW)The sample crashes at this function, and returns INVALID BUFFER
if you actually wish to run it I can post the distribution for the DLL as well
07-03-2008 08:20 AM
07-08-2008 07:07 AM
from the client:
"Larry,
This is a driver level failure that is being passed up to the library. The driver portion of the aceGetCh10DataPkt does a check on the buffer it is trying to copy into with the following code:
_try
{
ProbeForWrite(pCh10Pkt, sizeof(MTI_CH10_DATA_PKT) + (pdc -> MtiDataPoolBufferSize[Channel] -
MTI_POOL_OVERHEAD_SIZE), sizeof(CHAR));
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
return MTI_ERR_INVALID_BUFFER;
}
The only way to fail this code block is for the size of the buffer being too small or NULL. There is no other way to get this error code. Maybe it's a bytes -> words problem? The aceMTIConfigure function used kb for all buffer sizes.
-Eric"
and my response:
National Instruments also felt that it was something to do with the config of the buffers, but I don't know if it is a byte / word issue.
in aceMTiConfiguration I am setting the device buffer to 524288 (512kB).
In the C sample, the malloc is done prior to calling aceMTIConfigure. In LabVIEW the memory space for aceGetCh10DataPkt is allocated on the fly when the function is called, I think this maybe the issue
let me run this past NI and see what they can come up with,
thanx for the insights
07-08-2008 08:41 AM
I tried to create the instance of the bit stream prior to calling the MTiConfiguration function, and then using that bitstream to feed the input terminal of the GetCh10DataPkt function -
same error
guess the problem is that at the driver level, the hardware isn't aware that LabVIEW has allocated this space. Anyone know a work-around for this?