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

Dear members, I am developing an Application software in VC++ for a hos CPU to communicate with a device on USB. I have seen use of Createfile Writefile, & Readfile functions to communicate with the USB peripheral. M question is How do we send IN or OUT token packets or SOF packets throug software? OR Is it automatically done when we use Readfile or Writefil 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

Please Describe.

Thanks in advance Faiyaz

Reply to
faiyaz
Loading thread data ...

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?

Please Describe.

Thanks in advance Faiyaz

Reply to
faiyaz

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++.

Reply to
Tom

Is there any cross-platform library for USB communication?

Reply to
Tomás Ó hÉilidhe

I haven't seen any. It may be possible to write one for a small subset of devices but it probably wouldn't be compatible with devices like the latest USB all-in-one printer-copier-scanner-fax with LCD screen and SD card reader or with a device like a USB doughnut maker.

Reply to
Tom

In general, USB devices are intended to be accessed using the same operating system features as non-usb devices of the same type.

For example:

- Mass storage devices are accessed just like any other "disk drive" using file i/o.

- Serial port devices are intended to be used just like any COM or /dev/tty type device.

- HID devices are used by the system to support mouse, keyboard and similar types of human input devices.

The need to access lower level USB explicit functions is usually reserved for those writing device drivers for custom devices.

Linux has support for user-space access to certain parts of the USB sub-system (libusb).

However, most USB class/interface/device drivers execute within the operating system kernel.

--
Michael N. Moran           (h) 770 516 7918
5009 Old Field Ct.         (c) 678 521 5460
Kennesaw, GA, USA 30144    http://mnmoran.org

"So often times it happens, that we live our lives in chains
  and we never even know we have the key."
"Already Gone" by Jack Tempchin (recorded by The Eagles)

The Beatles were wrong: 1 & 1 & 1 is 1
Reply to
Michael N. Moran

For low level access there is libusb.

formatting link
and the windows port
formatting link

Regards Anton Erasmus

Reply to
Anton Erasmus

host

Createfile,

through

Writefile

done?

of the

For

that

calls

you're

Mine is the Custom type device.

Thanks Faiyaz

Reply to
faiyaz

many

Mine is a Custom type device Then i think i need to look into the device driver documentation.

Thanks all for your valuable advice Faiyaz

Reply to
faiyaz

Hello all again, Let me tell you in brief about this. We are developing a USB device(having AT91SAM7) which has a control an two Isochronous endpoints(1 for IN & 1 for OUT) and a bulk endpoint. Th device is a custom type device. It sends and receives packets o Isochronous endpoints once enumerated. Now we are using ATM6124.sys drive provided by ATMEL for their Evaluation kit of AT91SAM7 and the Basic US

6124 application exe provided by ATMEL again. That uses createfile writefile & readfile for data transfer.

First i dont know whether we can use that ATM6124 driver for our custo application or not? Do we need to develop our own device driver?

Secondly i dont know how to access isochronous endpoint and how to do dat transfer with those? & in which format & protocol data should be sent received?

Anybody having experience pls help.

Thanks Faiyaz

Reply to
faiyaz

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.