Need some starting help with a .dll from FTDI USB Chip

Hi i would like to use my serial converter directly over the FTD2XX.dll
from FTDI CHIP

Ok what i got figured out so far is to load the dll, i hope so
here i my code

  
  
    LoadME =  LoadLibrary("FTD2XX.dll");  
    cout<< LoadME<<"\n\n";  
  
    // Get function pointer  
  
    typedef void (*testfunc)(DWORD,DWORD,DWORD);  
    testfunc FT_ListDevices;  
    FT_ListDevices = (testfunc)GetProcAddress(LoadME,"FT_ListDevices");  
  

the cout gives me pointer to the dll.

so i want to call now the function form the data sheet FT_ListDevices
how do i do that and do i have the typedef right ??

can some one give me a example of how its done right ??

http://ftdichip.com/Documents/ProgramGuides/D2XXPG34.pdf

Best regards Oliver

You still working on this? I was just doing this recently myself, and have made it a little bit further, still having a few issues though. First some questions though, what is the LoadLibrary function you are calling. What operating system are you using? I think that’s going to make a difference here, as those are the issues I had. I’m using mine on OSX. I’ve been able to use all the commands in the datasheet just fine, but I’m having some problems getting the initial communication going due to the kext files. Let me know if you still need help with this.

the typedef looks good… to execute the function you’d just go

  
FT_ListDevices( .., .., .. );  

[/code]

year i still try to figure it out.
Do you have some code sample how you did it ??
I run on windows, but any code should help : )

like i said: just write FT_ListDevices( … ) and it should work.

Before you try FT_ListDevices(), your really need to make sure you have the DLL installed properly. To do this, follow the directions in the installation guide for windows on the website.

What are you using to code in ? Visual Studio? Are you including the .dll file correctly?

If so, a call to FT_ListDevices should look like this:

  
  
FT_STATUS ftStatus;  
DWORD numDevs;  
  
ftStatus = FT_ListDevices(&numDevs,NULL,FT_LIST_NUMBER_ONLY);  
if (ftStatus == FT_OK) {  
// FT_ListDevices OK, number of devices connected is in numDevs  
}  
else {  
// FT_ListDevices failed  
}  
  

You can find this information, and more at the website for the D2XX driver:

http://www.ftdichip.com/Drivers/D2XX.htm

At a minimum, you should be able to execute this function correctly, getting FT_Open to work may not be as easy, but you should be able to call FT_ListDevices() regardless of your usb port status. See if that works, then check back in. :wink:

So i use Codeblocks, on windows, and
i get with this test code now
a error on compiling.

  
  
  
void testApp::setup(){  
    HINSTANCE LoadME ;  
    LoadME =  LoadLibrary("FTD2XX.dll");  
    cout<< LoadME<<"\n\n";  
  
    // Get function pointer  
  
    typedef void (*testfunc)(DWORD,DWORD,DWORD);  
    testfunc FT_ListDevices;  
    FT_ListDevices = (testfunc)GetProcAddress(LoadME,"FT_ListDevices");  
  
    DWORD ftStatus;  
    DWORD numDevs;  
    ftStatus = FT_ListDevices(&numDevs,NULL,0x80000000);  
  
}  
  
  

The error i get is :

  
  
D:\ofx\apps\My files\emptyExample\src\testApp.cpp||In member function `virtual void testApp::setup()':|  
D:\ofx\apps\My files\emptyExample\src\testApp.cpp|18|error: invalid conversion from `DWORD*' to `DWORD'|  
D:\ofx\apps\My files\emptyExample\src\testApp.cpp|18|warning: converting to non-pointer type `DWORD' from NULL|  
D:\ofx\apps\My files\emptyExample\src\testApp.cpp|18|error: void value not ignored as it ought to be|  
||=== Build finished: 2 errors, 1 warnings ===|  
  

When i dont call the funtion the cout gives me a pointer, so it seems it finds the dll on my system. Since i have used it in several VBExpress projects.

But getting it running in C++ is a diffrent league.
I saw some where a .h file from FTDI do i need that ??

while we’re on this topic, I would like to ask what header files are needed to use the LoadLibrary function?

I’ve tried including windows.h but to no avail.