• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

USB Communication Software Algoritm

Status
Not open for further replies.

iso9001

New Member
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 ?
 

checkmate

New Member
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.
 

iso9001

New Member
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

New Member
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.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
iso9001 said:
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.
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top