03-02-2015 04:12 PM - edited 03-02-2015 04:30 PM
I am trying to import a FTDI dll function that has a device info structure and when run it causes an access violation. Does anyone know how to debug/resolve this? Attached is the dll, VI and document. This is the structure that is returned: typedef struct _ft_device_list_info_node {
ULONG Flags;
ULONG Type;
ULONG ID;
DWORD LocId;
char SerialNumber[16];
char Description[64];
FT_HANDLE ftHandle;
} FT_DEVICE_LIST_INFO_NODE;
Solved! Go to Solution.
03-02-2015 04:39 PM
Start with this thread http://forums.ni.com/t5/LabVIEW/Using-Call-Library-Function-Node-To-Return-C-Structure/td-p/2990127. Sorry it gets a bit muddled at the end, my fault. If you can't find an answer to your question there, follow up with a more detailed description of your problem.
03-02-2015 05:48 PM
Hi Nathand,
That was very helpful. I set it to call the function in the SPI dll and no crashes and most of the channel info is correct when compared to FTDIs command line application. The only problem left is that the two strings are not quite correct and have odd characters. Any ideas on this problem? VI added has strange strings saved as default value.
03-02-2015 06:30 PM
Can you save back to LabVIEW 2012? I don't have anything newer on this computer.
If the weird characters are at the end of the string, then you need to cut the string at the first null character (the first byte that has a value of 0), which I think you can do with search/split string. For the string to match, set the format to show \ codes, and put \00.
03-02-2015 06:44 PM
Attached is 12.0 version.
03-02-2015 06:50 PM
Yup, you need to trim after the first null. In case you're not familiar with C, in C a string ends with a byte containing a value of 0 (the string pointer may point at more space than that, but string functions stop processing at a null). LabVIEW stores string length as part of the data, so the value of the bytes in the string can be anything. That's what you're seeing here. If you right-click the string indicators and choose '\' codes display, you'll see a value of \00 before the "weird" characters start (they're just whatever bytes happen to be in memory at that location).
03-02-2015 07:18 PM
I tried trimming but still not correct it should be as follows: Number of available SPI channels = 1
Information on channel number 0:
Flags=0x2
Type=0x8
ID=0x4036014
LocId=0x0
SerialNumber=FTXXG2O6
Description=UM232H
ftHandle=0x0
03-02-2015 07:29 PM - edited 03-02-2015 07:33 PM
OK, sorry, I should have looked more closely. Two things. First, get the data types right. A DWORD is not a double-precision floating point value. No idea why they would define some values as ULONG and one as DWORD, but they're both 32-bit unsigned integers. Second, in the CLFN configuration, for the ChannelInfo parameter, change the Data Format option to "Array Data Pointer." I think that will do it.
EDIT: actually, changing the Data Format won't make any difference, since you're not passing any strings or arrays.
05-14-2019 01:20 AM
Dear
I have just finished a LabVIEW API for the MCP2210 USB to SPI bridge.
You can connect up to 9 SPI devices to it.
Check it out: https://www.digiinst.de/p/labview-r-api-for-the-microchip-r-mcp2210-c-usb-r-to-spi-r-bridge
Best regards
Martin