LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FTDI SPI dll

Solved!
Go to solution

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;

Download All
0 Kudos
Message 1 of 9
(4,049 Views)

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.

0 Kudos
Message 2 of 9
(4,040 Views)

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.

 

 

 

0 Kudos
Message 3 of 9
(4,025 Views)

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.

0 Kudos
Message 4 of 9
(4,018 Views)

Attached is 12.0 version.

0 Kudos
Message 5 of 9
(4,012 Views)

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).

0 Kudos
Message 6 of 9
(4,005 Views)

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

0 Kudos
Message 7 of 9
(3,999 Views)
Solution
Accepted by topic author LabTech

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.

Message 8 of 9
(3,995 Views)

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

0 Kudos
Message 9 of 9
(2,591 Views)