09-16-2014 03:42 PM
You need to initialize the BufferToWrite array to the correct length prior to passing it to the function. You can do this by inserting a "Reshape Array" function, or using "Initialize Array" instead of the array control, or by setting the minimum size in the Call Library Function Node configuration. Also, if you care about the data written into the buffer, then you should wire the output side of the buffer to an indicator.
09-16-2014 04:08 PM
NathanD,
Thanks for the quick reply.
I updated my VI to the following. I used the ArraySubset function to determine how many bytes to write. I've attached the updated VI.
How does it look?
Thanks so much!
09-16-2014 04:34 PM - edited 09-16-2014 04:38 PM
Sorry, again, can't open your VI - wrong version of LabVIEW. However, your description of what you did sounds wrong. I suggested three ways you could pass an allocated buffer to the DLL, and none of them involve Array Subset. You need to check the DLL documentation to see how large the buffer should be, and you MUST pass an array containing at least that number of bytes, otherwise the DLL calls may write into memory that isn't part of the buffer which will likely corrupt data or cause a crash. You have NO CONTROL over how many bytes the DLL writes to the buffer. The DLL doesn't know the size of the array it receives. It receives only a pointer to the start of that buffer, and it assumes that the buffer is large enough, so your LabVIEW code needs to make sure that the buffer is, in fact, large enough.
EDIT: sorry, should have looked more closely at the function. I assume the sizeToTransfer parameter does tell the DLL how large the buffer is. If that's the case, then you need to make sure the buffer matches that size. Also you should know if the sizeToTransfer is in bytes, or some other units (for example a number of 32-bit values) - if it's a different unit than the elements of the buffer, then you'll need to do some math to get everything to match.
09-16-2014 05:09 PM
Nathand,
Thanks for the info. I have updated my VI and resaved as LabVIEW 2012. I have attached it here.
Can you take a quick look at it?
Thanks so much!
09-16-2014 05:23 PM
That looks fine. Personally I'd replace the "BufferToWrite" control with a constant, since the value is irrelevant.
My apologies if my last message came out sounding hasty and aggressive, was trying to write something quickly and didn't edit as I usually would.
09-16-2014 08:16 PM
NathanD,
I'm a bit confused when you say you would personally change the "BufferToWrite" to a constant since its value is irrelevant. I am assuming that Buffer is the Bytes I want to write to the slave address. In this case, the slave address registers are 2 bytes long so I chose the "SizeToTranfer" = 2 bytes and the "BufferToWrite" array = The 2 bytes I want to write to the slave address register. Am I interpretting this wrong?
Thanks!
09-16-2014 09:52 PM
I'm sorry for the confusing response. Let me try that again, now that I'm not trying to do other work and post to the forum at the same time.
I misread what your function is doing; I thought you were reading from the device, not writing to it. In that case you don't need the indicator for the buffer (it's being used as an input, not an output). Leave the BufferToWrite control alone, as you suggested. You could instead get rid of the SizeToTransfer control, and wire the size of the BufferToWrite array to that input.
02-08-2016 07:42 AM
Hi,
and sorry for reactivation this thread. I also use the libMPSSE.dll and i have a problem with the readDevice-function. I connect a simple EEPROM to a FTDI device and i am not able to read more than 1 byte of the received array. The write function works perfect. The first byte i receive is correct, but all other bytes are zero. I try to resolve the array with the MoveBlock-function, without any success. The dll-methode described in the documention is: FT_STATUS I2C_DeviceRead(FT_HANDLE handle, uint32 deviceAddress, uint32 sizeToTransfer, uint8 *buffer, uint32 *sizeTransferred, uint32 options).
I think the main problem is the correct dereferencing of the parameter *buffer. Do u have any solution?
thx and greetings
Stefan
02-08-2016 09:07 AM
Stefan,
The buffer should be initialized as an array with the number of dimensions = to the Size To transfer. Please see my screen shot. Hope this helps.
02-08-2016 09:57 AM
Thanks for your answer. I allready tested everything. Also your example and many other in this forum. Luckily i found out, when i use a older version of libMPSSE.dll everything work fine. Thanks for the support.
Stefan