Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > General Electronics Chat


General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion?

Reply
 
LinkBack Thread Tools Display Modes
Old 13th January 2005, 05:32 PM   (permalink)
Default USB Communication Software Algoritm

Hi,

I'm about to be working with a USB Uart/fifo chip from ftdichip.com, its thier FT245BM model. I'm writing my own software and they have a driver that creates a com port for the usb and allows easy access, but for what I'm doing I would MUCH rather access the device directly (which they also have a driver for)

However, I've never programmed for hardware i/o before. I'm a little curious as to how the algoritm goes (English description of what I'll need to do in the code). I'll be mostly sending a few bytes at a time (no file tranfers)... Sometimes writing to device, mostly reading from.

I see some code in thier driver regarding the read function:
Code:
FT_STATUS WINAPI FT_Read(
    FT_HANDLE ftHandle,
    LPVOID lpBuffer,
    DWORD nBufferSize,
    LPDWORD lpBytesReturned
    );
Can someone kind of explin the process of pulling info from and writing to usb devices ?
iso9001 is offline  
Old 13th January 2005, 05:56 PM   (permalink)
Default

These are all functions written by FTDI. They are not standard API. They do have documentation for their DLL here.
Their DLL is essentially only wrapper functions to access their driver.
checkmate is offline  
Old 13th January 2005, 06:35 PM   (permalink)
Default

I guess I'm curious as to how the whole read and write goes with buffers and whatnot.

I see the read function has:

ftHandle: pointer to the communication handle of the device to read.
lpBuffer: pointer to the buffer that receives the data from the device.
DwBytesToRead: Number of bytes to be read from the device.
lpdwBytesReturned: Pointer to a variable of type DWORD which receives the number of bytes read from the device.

ftHandle... thats the device id (?)
lpBuffer... uh, the pointer to where data is stored
DwBytesToRead... number of data bytes I suppose
lpdwBytesReturned... dunno, isnt it the same as DwBytesToRead ?

Also say I call the read()and get the data from it... when I read again, how do i know that data is new or is the same data I just read ? When does this buffer get cleared ? I read throught the manual, but 11 pages isnt exactly in depth...
[/b]
iso9001 is offline  
Old 14th January 2005, 02:34 AM   (permalink)
Default

Ah, nevermind.... I see, there is a purge buffer function too.

Ok... well I think I can manage that. But if I go with the virtual port emulator then I can still use rs232 programs to talk with my interface...

Can someone explain to me how to talk to ports using C++ or Java (windows api maybe) ?

General alorithm is fine.
iso9001 is offline  
Old 14th January 2005, 06:58 AM   (permalink)
Default

Quote:
Originally Posted by iso9001
Ah, nevermind.... I see, there is a purge buffer function too.

Ok... well I think I can manage that. But if I go with the virtual port emulator then I can still use rs232 programs to talk with my interface...

Can someone explain to me how to talk to ports using C++ or Java (windows api maybe) ?

General alorithm is fine.
Just do a google search, you'll find loads of info about it.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 14th January 2005, 07:38 PM   (permalink)
Default

Take a look at Silicon Labs USB controller www.silabs.com . It's a super fast 8051 + USB. They provide an API for both the host side and the Device side - No RS232 required.
bmcculla is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 03:38 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker