Re: developing Application software for a host to communicate with a USB device



In article <Js6dnf1j6ruvxsfVnZ2dnUVZ_h7inZ2d@xxxxxxxxxxxx>, "faiyaz" <faiyaz.pw@xxxxxxxxx> wrote:
Dear members,
I am developing an Application software in VC++ for a host
CPU to communicate with a device on USB. I have seen use of Createfile,
Writefile, & Readfile functions to communicate with the USB peripheral.
My
question is How do we send IN or OUT token packets or SOF packets through
software? OR Is it automatically done when we use Readfile or Writefile
functions and do we just need to take care about the data only?

If we need to send the token packets by the software then how is it done?

Also how to access different endpoints of device by the host?

This all depends on what kind of USB device you're using. There are many
possibilities:

1. Mass storage device
2. Standard HID device (mouse, keyboard, joystick)
3. Custom HID device
4. Audio device
5. Virtual serial port
6. Custom device type
7. Many other types like printers, scanners, cameras, etc.

For #1 it's as easy as writing to a file on disk. For #2 you can use the
regular Windows messages generated by those devices. For #3 you can use
ReadFile and WriteFile but you can only send complete reports, not
individual packets. The first byte has to be the report ID and the size of the
write has to equal the size of the largest report your device supports. For
#4, use waveOutWrite and waveInProc. For #5 use it as you would any other
serial port with CreateFile and WriteFile. For #6, see the documentation that
comes with the driver. For printers, create a device context and use GDI calls
on it.

Every device is different and without knowing what type of USB device you're
using it's pretty much impossible to tell how do access it in VC++.
.



Relevant Pages