EmbeddedRelated.com
Forums
Memfault Beyond the Launch

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

Started by faiyaz June 14, 2008
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?

Please Describe.

Thanks in advance
Faiyaz


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
In article <Js6dnf1j6ruvxsfVnZ2dnUVZ_h7inZ2d@giganews.com>, "faiyaz" <faiyaz.pw@gmail.com> 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++.
> 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.
Is there any cross-platform library for USB communication?
In article <3524b070-47d8-4dd8-b537-34dfe05f7d9c@56g2000hsm.googlegroups.com>, =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= <toe@lavabit.com> wrote:
> >> 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. > > >Is there any cross-platform library for USB communication?
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.
Tom&#4294967295;s &#4294967295; h&#4294967295;ilidhe wrote:
>> 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. > > > Is there any cross-platform library for USB communication?
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
On Thu, 19 Jun 2008 07:50:41 -0700 (PDT), Tom&#4294967295;s &#4294967295; h&#4294967295;ilidhe
<toe@lavabit.com> wrote:

> >> 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. > > >Is there any cross-platform library for USB communication?
For low level access there is libusb. http://libusb.wiki.sourceforge.net/ and the windows port http://libusb-win32.sourceforge.net/ Regards Anton Erasmus
>In article <Js6dnf1j6ruvxsfVnZ2dnUVZ_h7inZ2d@giganews.com>, "faiyaz"
<faiyaz.pw@gmail.com> 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++. >
Mine is the Custom type device. Thanks Faiyaz
>Tom&#65533;s &#65533; h&#65533;ilidhe wrote: >>> 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. >> >> >> Is there any cross-platform library for USB communication? > >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 >
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
Hello all again,
                   Let me tell you in brief about this.
We are developing a USB device(having AT91SAM7) which has a control and
two Isochronous endpoints(1 for IN & 1 for OUT) and a bulk endpoint.  The
device is a custom type device.  It sends and receives packets on
Isochronous endpoints once enumerated.  Now we are using ATM6124.sys driver
provided by ATMEL for their Evaluation kit of AT91SAM7 and the Basic USB
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 custom
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 data
transfer with those?  & in which format & protocol data should be sent &
received?  

Anybody having experience pls help.


Thanks
Faiyaz

Memfault Beyond the Launch