EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

New to USB, Is this possible?

Started by Sivart June 12, 2009
Hi everyone, 

So I'm working on a new project where I want a web browser to a certain
site to open whenever my USB device is plugged in and send some data. I
plan on using a Cypress Encore chip and am looking over all the app notes
and sample code but most of it just directly sends data like a mouse or
keyboard. Is there a good resource on sending commands to a PC/Mac? Please
let me know if you have any ideas on how to implement this system or if
you've encountered something similar.

Thank you in advance,

Travis Cochran


On Jun 12, 1:19=A0pm, "Sivart" <travis.coch...@gmail.com> wrote:
> So I'm working on a new project where I want a web browser to a certain > site to open whenever my USB device is plugged in and send some data. I
You can't really do it without writing a custom app on the PC. You CAN however make your device look like a storage device, and put an autorun file on it that will cause Windows to open a browser and load your site - you can embed active content in it that will send whatever it is you're trying to send. But on any properly configured machine this will not work.
On Jun 12, 1:19=A0pm, "Sivart" <travis.coch...@gmail.com> wrote:

> So I'm working on a new project where I want a web browser to a certain > site to open whenever my USB device is plugged in and send some data.
Two ideas: 1) Using an operating system like windows insecure enough to automatically execute code off of untrusted media, you can have your device emulate a USB mass storage (ie "thumb drive") and have an autorun.inf on it. This would read data from an emulated file on the device and upload it to the web site. This is a common method for viruses to propagate, so it may be closed off at some point. 2) Write a USB driver for your device for various host systems. Have the driver automatically read the data and upload it when the operating system's USB stack tells your driver that it has a newly connected device to deal with. This is safer, but the user will have to install a driver for your device (and you have to provide a version of the driver appropriate to their operating system)
> Is there a good resource on sending commands to a PC/Mac?
It's best to do this from software executing on the PC/Mac, triggered by the presence of the USB device.
cs_posting@hotmail.com wrote:
> On Jun 12, 1:19&nbsp;pm, "Sivart" <travis.coch...@gmail.com> wrote: >> So I'm working on a new project where I want a web browser to a certain >> site to open whenever my USB device is plugged in and send some data.
> 2) Write a USB driver for your device for various host systems. Have > the driver automatically read the data and upload it when the > operating system's USB stack tells your driver that it has a newly > connected device to deal with.
On a Linux system with a kernel 2.6 or later, or on a BSD system, it ought to be possible to write udev rules to trigger your choice of actions when a USB device is found. Mel.
On Jun 13, 11:06 am, Mel <mwil...@the-wire.com> wrote:

> On a Linux system with a kernel 2.6 or later, or on a BSD system, it ought > to be possible to write udev rules to trigger your choice of actions when a > USB device is found.
Good point. Of course you could argue that this constitutes writing a driver - just in a particular high-level language.
>On Jun 13, 11:06 am, Mel <mwil...@the-wire.com> wrote: > >> On a Linux system with a kernel 2.6 or later, or on a BSD system, it
ought
>> to be possible to write udev rules to trigger your choice of actions
when a
>> USB device is found. > >Good point. Of course you could argue that this constitutes writing a >driver - just in a particular high-level language. > >
Thank you for all of your ideas. I think right now my best bet is to have my device recognized as a storage device and have either a autorun file or a driver install file on it since I won't have access to all of the computers this will be used on before hand. This shouldn't be too hard to accomplish with a Cypress USB MCU. Thanks again for all your help. -Travis
Sivart wrote:
>> On Jun 13, 11:06 am, Mel <mwil...@the-wire.com> wrote: >> >>> On a Linux system with a kernel 2.6 or later, or on a BSD system, it > ought >>> to be possible to write udev rules to trigger your choice of actions > when a >>> USB device is found. >> Good point. Of course you could argue that this constitutes writing a >> driver - just in a particular high-level language. >> >> > > > Thank you for all of your ideas. I think right now my best bet is to have > my device recognized as a storage device and have either a autorun file or > a driver install file on it since I won't have access to all of the
Is this a "catch 22" ? If the driver is on the device, and you need to load the driver *before* the device can be used, how will the driver ever get loaded ? Did that make sense ?? Also, can a single USB device enumerate as two devices ?? Say, a hard drive and a serial port ? Or any two devices ? How does the enumeration process work aon the device side, can the same device hardware respond twice ? Thanks don
> computers this will be used on before hand. This shouldn't be too hard to > accomplish with a Cypress USB MCU. > > Thanks again for all your help. > > -Travis
On Jun 15, 11:23=A0am, don <don> wrote:
> Sivart wrote:
> > Thank you for all of your ideas. I think right now my best bet is to ha=
ve
> > my device recognized as a storage device and have either a autorun file=
or
> > a driver install file on it since I won't have access to all of the > > Is this a "catch 22" ? > > If the driver is on the device, > and you need to load the driver *before* the device can be used, > how will the driver ever get loaded ?
No, because the operating system typically implements the mass-storage device driver. It's not clear if his custom "driver" will be a new driver to put the device in some other mode that is not mass-storage, or just something that extends the functionality of a device still treated as mass- storage by the operating system's USB implementation. I'd recommend the later.

The 2024 Embedded Online Conference