06-26-2008 02:36 PM
Hi Rolf
this still isn't working, and after discussing it with my client, it turns out that one of the two arrays isn't fixed length. The cluster contains:
U16, U16, U32, U32, U16, U16, U16[3], U16, U16, U16[1]
he explained that even though it isn't defined as a pointer, the second array is open-ended and only points to the first element
This complicates this, you mentioned
"in the second case you have to treat it as an uInt32 (uInt64 on the upcoming LabVIEW for Windows x64 platform) and do some other magic if you need to retrieve the values."
is this documented somewhere (like a white paper?) or could you possibly eleaborate??
sorry, I really appreciate your help on this,
thanx
lmd2
06-26-2008 03:38 PM
@lmd2 wrote:
Hi Rolf
this still isn't working, and after discussing it with my client, it turns out that one of the two arrays isn't fixed length. The cluster contains:
U16, U16, U32, U32, U16, U16, U16[3], U16, U16, U16[1]
he explained that even though it isn't defined as a pointer, the second array is open-ended and only points to the first element
This complicates this, you mentioned
"in the second case you have to treat it as an uInt32 (uInt64 on the upcoming LabVIEW for Windows x64 platform) and do some other magic if you need to retrieve the values."
is this documented somewhere (like a white paper?) or could you possibly eleaborate??
sorry, I really appreciate your help on this,
thanx
lmd2
06-27-2008 10:28 AM - edited 06-27-2008 10:35 AM
Hi Rolf
found this thread (looks good):
http://forums.ni.com/ni/board/message?board.id=170&message.id=281715&query.id=89055#M281715
but the example is in 7.1 and I can't find the MoveBlock function in 7.0
does it exist back then? is it called something else?
I guess I need to know what DLL contains this function, thanx
06-29-2008 01:16 PM
It's not exported by a DLL but by LabVIEW.exe and as far back as LabVIEW 2.5 although as a normal Call Library Node interfaceable export only since around 5.0. Before that it was for use in external CIN code only.
@lmd2 wrote:
Hi Rolf
found this thread (looks good):
http://forums.ni.com/ni/board/message?board.id=170&message.id=281715&query.id=89055#M281715
but the example is in 7.1 and I can't find the MoveBlock function in 7.0
does it exist back then? is it called something else?
I guess I need to know what DLL contains this function, thanx
Message Edited by lmd2 on 06-27-2008 10:35 AM
07-01-2008 12:53 PM
07-02-2008 02:03 AM
Asuming that you have configured the parameter to be correctly an array data pointer the only other thing I can think of is that you need to fill in some data beforehand too, as the function is looking at the structure to figure out what it needs to do or simply as a safety check to make sure there is an initialized buffer and not just some garbage.
@lmd2 wrote:
Okay, I think I understand the pointer to a pointer, and MoveBlock, but I am not there yet; the original DLL function call is still returning a bad buffer error.
To allocate space I am initializing an array of U8.
From the C code:
S32BIT dwPktPoolSize = 0x20000;
pPkt = (MTI_CH10_DATA_PKT*) malloc(dwPktPoolSize);
where MTI_CH10_DATA_PKT is the STRUCT
I size my array of U8 to 131078 elements (HEX 20000) and used a cluster to type cast, only I can't type cast cause the CLFN errors out - invalid buffer; am I sizing the array wrong? would that cause the error? I don't see anything else that would return invalid buffer unless the function doesn't recognize the array of U8?
Here is a screen shot of the code:
07-02-2008 03:30 AM - edited 07-02-2008 03:33 AM
07-02-2008 03:47 AM
Several ways are possible but the Typecast one is a good one if you only need to initialize the first struct element in that buffer. Just don't forget that Typecast will standardize your data to Big Endian when turning your cluster into an byte stream so when interfacing with shared libraries on x86 platforms you should first wire the cluster through Swap Words and Swap Bytes before wiring it to Typecast.
@lmd2 wrote:
If I was allocating space by wiring a copy of the STRUCT (cluster) to the node, then I could understand populating the cluster but if I am allocating space with an empty byte array how would I initialize the byte array in any meaningful way?
maybe typecast a struct into a byte array, and then resize the array to 131078 bytes?
Message Edited by lmd2 on 07-02-2008 03:33 AM
07-02-2008 06:08 AM
07-02-2008 03:04 PM