Pelles C forum

C language => Windows questions => Topic started by: JohnArnoldBrown on April 26, 2012, 10:05:03 AM

Title: FTDI D2XX drivers
Post by: JohnArnoldBrown on April 26, 2012, 10:05:03 AM
Hi,

Does anyone know whether Pelles C will work with the FTDI D2xx USB bridge drivers?

John
Title: Re: FTDI D2XX drivers
Post by: CommonTater on April 26, 2012, 10:09:48 AM
Hi John and welcome to the forums...

In what context do you mean "will work"...

As in writing a program that uses them... If they're installed in Windows Pelles C can open the device as a file.

If you mean writing or compiling them... in both cases so long as the source is C (not C++)... Yes, it should be able to.

Is there a specific problem you're having?
Title: Re: FTDI D2XX drivers
Post by: JohnArnoldBrown on April 26, 2012, 10:13:57 AM
Thanks, I meant the first thing, using the installed drivers.
I'm an embedded C/micro person, so not too familiar with the whole Windows/DLL thing, so I thought I'd ask the question before wasting a lot of time.

Kind regards,

John Brown
Title: Re: FTDI D2XX drivers
Post by: Bitbeisser on April 26, 2012, 07:45:19 PM
Thanks, I meant the first thing, using the installed drivers.
I'm an embedded C/micro person, so not too familiar with the whole Windows/DLL thing, so I thought I'd ask the question before wasting a lot of time.
Still not quite clear what you intend to do? Pelle's C is a Windows based and targeted compiler/environment, so it might not be suitable for embedded work...

Ralf
Title: Re: FTDI D2XX drivers
Post by: CommonTater on April 26, 2012, 07:56:29 PM
Thanks, I meant the first thing, using the installed drivers.
I'm an embedded C/micro person, so not too familiar with the whole Windows/DLL thing, so I thought I'd ask the question before wasting a lot of time.

Kind regards,

John Brown


I trust you've already downloaded the programming guide from THIS PAGE (http://www.ftdichip.com/Drivers/D2XX.htm) I just did a very quick scan of the examples and they seem close enough to plain C so there shouldn't be any big problems using the supplied driver DLLs to access the chip.
 
 
Title: Re: FTDI D2XX drivers
Post by: JohnArnoldBrown on April 27, 2012, 01:11:07 PM
Thanks, I meant the first thing, using the installed drivers.
I'm an embedded C/micro person, so not too familiar with the whole Windows/DLL thing, so I thought I'd ask the question before wasting a lot of time.
Still not quite clear what you intend to do? Pelle's C is a Windows based and targeted compiler/environment, so it might not be suitable for embedded work...

Ralf
I was merely explaining my ignorance of Windows/dlls etc.
I didn't mean that I wanted to use Pelles C for the embedded end of things, but I often need to communicate with the embedded stuff from a PC.

John
Title: Re: FTDI D2XX drivers
Post by: Bitbeisser on April 27, 2012, 03:25:24 PM
I didn't mean that I wanted to use Pelles C for the embedded end of things, but I often need to communicate with the embedded stuff from a PC.
Ok, I just misunderstood your initial post then a bit...  ;)

Ralf
Title: Re: FTDI D2XX drivers
Post by: JohnArnoldBrown on April 27, 2012, 03:58:00 PM
Well, just including the FTD2xx.h file in your hello world example brings up hundreds of errors!
I'm way out of my depth here.
BTW, does Pelles C understand C99 data tpes, such as uint32_t ?

John

Title: Re: FTDI D2XX drivers
Post by: TimoVJL on April 27, 2012, 04:32:26 PM
Remember to use pocc.exe commanline option -Ze Enable Microsoft extension.

Quote
BTW, does Pelles C understand C99 data tpes, such as uint32_t ?
Code: [Select]
#include <stdint.h>
Title: Re: FTDI D2XX drivers
Post by: JohnArnoldBrown on April 27, 2012, 04:35:05 PM
Remember to use pocc.exe commanline option -Ze Enable Microsoft extension.

Quote
BTW, does Pelles C understand C99 data tpes, such as uint32_t ?
Code: [Select]
#include <stdint.h>

Done that.

Sorry, I've done the -Ze option, I will try the stdint.h

John

Title: Re: FTDI D2XX drivers
Post by: TimoVJL on April 27, 2012, 04:54:19 PM
Sorry , forgot add these too:
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "FTD2XX.h"
#pragma comment(lib, "FTD2XX.lib")
Example
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include "FTD2XX.h"

#pragma comment(lib, "FTD2XX")

int main(int argc, char **argv)
{
FT_STATUS ftStatus;
DWORD numDevs;

ftStatus = FT_ListDevices((void*)&numDevs, NULL, FT_LIST_NUMBER_ONLY);
if(ftStatus == 0)
{
DWORD uDevNo;
char Buffer[64]; // more than enough room!
for(uDevNo=0; uDevNo<numDevs; uDevNo++)
{
ftStatus = FT_ListDevices((PVOID)uDevNo,Buffer,FT_LIST_BY_INDEX|FT_OPEN_BY_SERIAL_NUMBER);
if (ftStatus == FT_OK) printf("%u %s\n", uDevNo, Buffer);
printf("%u %s\n", uDevNo, "Error");
}
}
return 0;
}
Title: Re: FTDI D2XX drivers
Post by: CommonTater on April 27, 2012, 05:51:58 PM
Well, just including the FTD2xx.h file in your hello world example brings up hundreds of errors!
I'm way out of my depth here.
BTW, does Pelles C understand C99 data tpes, such as uint32_t ?

John

Hi John... I see the excrement has found the rotating impeller :D  ....

One tip the others haven't given you yet is when you have questions about Pelles C... the F1 button on your keyboard is your very best friend.  Pelle has written an excellent help file for both the IDE and C-11 (the new standard) and it's all tucked away very nicely under the standard Windows "help" button...  Place your cursor on any highlighted keyword and press F1 for full information about it's pupose and use.  Click on any "whitespace"  then F1 for general help on the editor or panel you've clicked on.  You're gonna love it... ;)

And by the way... Pelle even has a good sense of humour... wait till you see the last message in a very long cascade of messages... "More than 100 errors, please improve yourself"... I nearly peed myself laughing the first time I saw it!
 
Title: Re: FTDI D2XX drivers
Post by: JohnArnoldBrown on April 27, 2012, 06:57:02 PM
Thanks to everyone for their patience and help. I won't have time to look at this now for a day or so, but I'll try to digest it all when I do.

John
Title: Re: FTDI D2XX drivers
Post by: JohnArnoldBrown on April 28, 2012, 02:54:50 PM
That's all looking good now. Gives me something to start from, which I always find is the biggest hurdle.

On a separate matter, how do I circumvent the "Do you want to allow the following program from an unknown publisher to make changes to this computer" dialog box that always pops up when I start the Pelles C IDE?

John
Title: Re: FTDI D2XX drivers
Post by: Bitbeisser on April 28, 2012, 06:22:22 PM
On a separate matter, how do I circumvent the "Do you want to allow the following program from an unknown publisher to make changes to this computer" dialog box that always pops up when I start the Pelles C IDE?
Welcome to the wonderful world of Windows 7 (seriously hope you're not running Vista). The UAC doesn't have an option to do something like a "whitelist" for certain programs not to come up with that ****.
You could try to create your own manifest for POIDE.EXE, but you still might get that crap every time you start your own testing application. A general description, though from the Vista days can be found at http://brethorsting.com/blog/2007/02/meet_uac_-_creating_a_uac_manifest/

Otherwise, try TweakUAC at http://www.tweak-uac.com/what-is-tweak-uac/

Ralf
Title: Re: FTDI D2XX drivers
Post by: CommonTater on April 29, 2012, 01:32:15 AM
That's all looking good now. Gives me something to start from, which I always find is the biggest hurdle.

On a separate matter, how do I circumvent the "Do you want to allow the following program from an unknown publisher to make changes to this computer" dialog box that always pops up when I start the Pelles C IDE?

John


You must be on Vista or 7 ...

On Win7 ... Control Panel -> Action Center -> Change UAC settings -> "Never warn".
On Vista ... get used to it.
Title: Re: FTDI D2XX drivers
Post by: jboyes on August 01, 2012, 12:24:10 PM
I am not a Pelles C expert by any means but I do use the IDE and enjoy writing Windows programs. I also write code for PICs and have successfully communicated between PC and PIC without having to call any special drivers from within my code.

I use the CreateFile function and specify "COMx" as the 'file' to open.

Just in case it is of any use to you, I have attached a code snippet of the section I use to identify which ports are available. (I only test up to 9 because higher numbered ports are a bit fiddly and I do not have very many on my PC).

Code: [Select]
:
case WM_INITDIALOG:
:
for (int i = 1; i < 10; i++) {
sprintf(myPort, "COM%d", i);
hCom = CreateFile(myPort, GENERIC_READ | GENERIC_WRITE,
0, // exculsive access to this 'file'
NULL, // Security Descriptor - cannot be passed to child
OPEN_EXISTING, // Required for COM ports
FILE_ATTRIBUTE_NORMAL, NULL);
if ((hCom != INVALID_HANDLE_VALUE) && (GetLastError() != ERROR_FILE_NOT_FOUND)){
SendMessage(hPorts, LB_INSERTSTRING, -1, (LPARAM)myPort); // append to listbox
}
CloseHandle(hCom);
}

My Listbox gets filled with the names of all COM ports that are available. I then open up the one I want and use ReadFile and WriteFile to communicate. Of course the driver for the USB-to-TTL converter has to have been loaded outside of my program but this only has to be done once.

I hope this is relevant and of some use.

John.