09-11-2014 05:33 PM
I'm currently on LabVIEW 2012, but if you can save back a version I'd be happy to look at it.
See the help: a cluster is always passed by pointer, and the Data Format settings has no effect for a cluster. Make sure you have chosen the correct calling convention. Also note (perhaps you've already done this, can't see your VI) that you must replace the embedded arrays with clusters containing the correct number of elements; you cannot replace a fixed-size array with a LabVIEW array.
09-11-2014 05:49 PM
Thanks Nathan.
I have resaved this VI for LabVIEW 2012. If you still have issues viewing it let me know and I will send out screenshots.
Thanks again.
09-11-2014 06:24 PM
Again, you must replace fixed-sized arrays with CLUSTERS containing the same number of elements. A string won't work. Also, the correct calling convention for this DLL is almost definitely "C" and not "WINAPI". See modified VI attached.
09-12-2014 09:28 AM
Thanks Nathan. That did the job
Where in the LabVIEW help section for the Call Library Function Node does it explain that you must replace fixed-sized array with CLUSTERS? I think in the regular LabVIEW help this information is missing.
09-12-2014 11:13 AM
It's not in the help for Call Library Function Node, but it is in many of the forum posts on this topic (as well as in my earlier post in this thread). The relevant help information is "How LabVIEW Stores Data in Memory" combined with an understanding of how a C program stores structs. The help for Call Library Function assumes some understanding of C, as it would be impractical for the help to provide a sufficiently detailed lesson in C to cover every possible complicated structure that might be passed to a DLL. I haven't tried it recently but apparently the DLL import tool has gotten better at automatically generating LabVIEW equivalents for some complex structs, so you could try that too and see if it works.
09-15-2014 04:33 PM
Nathan,
Thanks for your help.
I have one more example CLFN VI that I am having trouble with. This dll function reads the specified number of bytes from an addressed I2C slave device:
FT_STATUS I2C_DeviceRead (FT_HANDLE handle, uint32 deviceAddress, uint32 sizeToTransfer, uint8 *buffer, uint32 *sizeTransferred, uint32 options)
Parameters:
In = handle (Handle of channel)
In = deviceAddress (7 bit address of the I2C slave)
In = sizeToTranfer (Number of bytes to be read)
Out = buffer (Pointer to the buffer where data is to be read)
Out = sizeTransferred (Pointer to variable containing the number of bytes read)
In = options
I keep on getting an error from the dll saying the slave device is not found found.
I have attached my VI. Can you please take a look at it? I would really appreciate it.
Thanks so much for your help!
09-15-2014 04:42 PM - edited 09-15-2014 04:43 PM
You took the description of the function way to literally. Eventhough it says "pointer to the buffer" the function really needs an entire buffer preallocated by the caller to write into.
09-15-2014 04:55 PM
rolfk,
Thanks for your help. That makes sense. Is there a reason you connected the Options parameter also into the Initial Array dimension size? Shouldn't it be the sizeTransferred parameter connected to the dimension size input?
09-15-2014 05:18 PM - edited 09-15-2014 05:22 PM
Oops, a typo! or how do you call this in LabVIEW speak?
But no it shouldn't be "size transfered" but "Size To Transfer"!
And you should arrange the parameters in the correct order!!!!
FT_STATUS I2C_DeviceRead (FT_HANDLE handle, uint32 deviceAddress, uint32 sizeToTransfer, uint8 *buffer, uint32 *sizeTransferred, uint32 options)
options is the last parameter in the parameter list
09-16-2014 03:16 PM
Rolfk,
I want to use the FT_I2C_DeviceWrite function in the dll library as well using the CLFN function in LabVIEW. The dll function is as follows:
FT_STATUS I2C_DeviceWrite (FT_HANDLE handle, uint32 deviceAddress, uint32 sizeToTransfer, uint8 *buffer, uint32 *sizeTransferred, uint32 options)
In (handle) = Handle of channel
In (deviceAddress) = Device Address
In (sizeToTransfer) = Number of bytes to be written
Out (buffer) = Pointer to buffer from where data is to be written
Out (sizeTransferred) = Pointer to variable containing the number of bytes written
In (tranferOptions) = Data tranfer options
I'm pretty sure I know how to do this based on the FT_I2C_ReadDevice function. I have attached the VI to this post.
Could you take a look at it and make sure I set up everything right?
Thanks so much for your help!