"LJ Malone" <ljma...@yahoo.com> wrote in message
news:eefa4...@webx.raydaftYaTP...
does your implementaion work on several plattforms (linux, win, mac)?
Can you handle several FTDI's even without EEPROM product
information. If yes, i might be interested in you solution.
Thanks for your feedback. Best,
-Sam
Jarrett,
Did you make an implementation which uses
ftd2xx.h / ftd2xx.lib to talk to an ftdi chip?
I惴 trying to do it, but it愀 not working.
Can you help me?
Thanks
Kleinmayer
long FT_Open(
int deviceNumber,
unsigned long int *pHandle
);
long FT_Close(
unsigned long ftHandle
);
long FT_Read(
unsigned long ftHandle,
unsigned long * lpBuffer,
unsigned long nBufferSize,
unsigned long * lpBytesReturned
);
long FT_Write(
unsigned long ftHandle,
ussigned long * lpBuffer,
unsigned long nBufferSize,
unsigned long * lpBytesWritten
);
etc.
Notice that I don't call ftHandle a void * - Matlab tends to crash
when I do that. So, I treat it as a 32 bit number I have to cart
around.
With a good version of the .h file, the matlab syntax is:
loadlibrary('FTD2XX.dll','myFTD2XXheader.h')
usbMem = uint32(0);
handlePtr = libpointer('uint32Ptr',usbMem);
deviceNum = 0;
retval = calllib('FTD2XX', 'FT_Open', deviceNum, handlePtr);
handle = get(handlePtr,'Value');
The handle is then the first pass parameter to all the functions.
You have to FT_Close when you are done. If you are reading short
messages (one or two words) back, don't forget to use
FT_SetLatencyTimer to 1 ms, so the FTDI will flush out the partial
buffer.
This was done on windows.
Doug Olney
Thank愀 Doug...
But, only one question: isn愒 your .h file the .h from FTDI chip? Is
it a new .h file whit only the functions that you want to use?
Thank愀
Kleinmayer
There are two issues with the FTDI provided .h file. One is that
they don't use fundamental types in their declarations: they use
types like uchar8 that matlab doesn't always know what to do with.
Somehow you have to get the right typecasts for all those types. I
only use about 7 functions, so I just typed it.
Second is the use of the void * for ftHandle. For whatever reason,
matlab crashes immediatly as soon as you try to get( ,'Value') of the
pointer. It is easier to lie and call it a unsigned long.
Doug
I惴 open my usb device sucessfuly, but when I try to write data in
the buffer it crashes.
How can you make ir??
Thank愀 agains...
Kleinmater
I have questioned about using FTDI Chip with Matlab in the Matlab
Newsgroup and you helped me. But now I have a problem and I want your
help.
Do you use the function FT_OpenEx in your application? I´m trying to
use this function and Matlab chashes.
Thank´s for your help,
Kleinmayer
"Doug Olney" <olney...@keithley.com> wrote in message <eefa...@webx.raydaftYaTP>...
> > I?m trying to do it, but it?s not working.
typedef unsigned long int ULONG;
typedef unsigned char UCHAR;
typedef unsigned short USHORT;
typedef unsigned long * LPDWORD;
typedef ULONG FT_STATUS;
typedef ULONG FT_HANDLE;
I want to report the fact that for my application (sending a block of simulated data to the dsPIC, then retrieving the resulting processed block. Using CTS/RTS hardware flow control) the communication between PC and dsPIC is stable using the d2xx DLL at 921600 bauds. Just to mention occasionnaly one or 2 errors every 50 mega bytes of transferred data. On the contrary I experienced instabilities using the Virtual Com Port (VCP) with sometimes obligation to abort Matlab and restart the computer (to reinitialize the com port which 'hangs'). Using VCP involves using java methods used for graphics display and for serial link amongst other. If you move a graphics window during serial communication you can eventually crash the application.
In conclusion my advise is to use D2xx DLL instead of VCP to get a stable application.
Francois
"Doug Olney" <olney...@keithley.com> wrote in message <eefa...@webx.raydaftYaTP>...
> > I´m trying to do it, but it´s not working.
I'm trying to do the same thing it would be great if you could send me a copy of the entire header file.
"Doug Olney" <olney...@keithley.com> wrote in message <eefa...@webx.raydaftYaTP>...
I tried to use what you gave in your last post but Matlab crashes on the
retval = calllib('ftd2xx', 'FT_Open', deviceNum, handlePtr);
line.
"Rebecca " <el0...@leeds.ac.uk> wrote in message <hnqg33$71t$1...@fred.mathworks.com>...
Thought I would post successful Matlab code for any others working on this:
Device UM245R . Uses the modified .h file as suggested above to deal with datatypes.
code writes 0xff to bits :
[a b]=loadlibrary('ftd2xx.dll','myftd2xx.h');
usbMem = uint32(0);
handlePtr = libpointer('uint32Ptr',usbMem);
deviceNum = 0;
retval = calllib('ftd2xx', 'FT_Open', deviceNum, handlePtr);
handle = get(handlePtr,'Value');
calllib('ftd2xx', 'FT_SetBitMode',handle,uint8(255),uint8(1));
calllib('ftd2xx', 'FT_SetBaudRate',handle,38400);
buffsize = uint32(1);
on = uint8(255); onPtr = libpointer('uint8Ptr',on);
bytes = uint32(0); bytePtr = libpointer('uint32Ptr',bytes);
calllib('ftd2xx','FT_Write',handle,onPtr,buffsize,bytePtr);
Also, should ad:
calllib('ftd2xx','FT_Close',handle);
unloadlibrary('ftd2xx');
Another note for creating .exe......
http://www.mathworks.com/support/solutions/en/data/1-1AJI4/index.html?product=CO