On Fri, 27 Oct 2006, Hughes, James wrote: > Hi Alan, > > Thanks for the replies.
> > > There are obviously issues with timing - for example, how is the > > > situation where the app is writing something to the backing > > file when > > > the host is connected handled? > > > > Correct. Basically there is no way to manage such cases. > > The only safe approach is to avoid writing to the backing > > file whenever the USB cable is plugged into a host, or is > > about to be plugged into a host (which means your user > > program would need to be able to see a short distance into > > the future!). > > > > > I am assuming all these issue are handled somehow, as many devices > > > appear to be able to do this (I could be wrong > > > - is there a better way?) > > > > What you mean isn't entirely clear -- but I suspect you _are_ wrong. > > I was thinking of the case of digital cameras which when connected over > USB appear to know when they are plugged in, and stop the camera taking > pictures (presumably to prevent access to the store) by going in to > transfer mode Okay, yes. I don't know exactly how digital cameras decide they are connected, but checking for power on the USB lines would be a good way to do it. The firmware inside a camera is much more tightly integrated than the programs running on a Linux system, as a general rule. Hence it can react more quickly and more definitively to changes of state. An interesting experiment would be to see what happens if you plug in the camera's USB cable while taking a picture! > > If you really need to _share_ the backing file between the > > host and the user program, your best bet is not to use USB > > Mass Storage at all but instead use a genuine file-sharing > > protocol. For instance, you might set up a network > > connection between the gadget and the host and use Samba or NFS. > > > > Alan Stern > > > > Could this be done over the USB Ethernet gadget? Is that the usual way > for this to be done? You know, I'm not sure. I've never tried using g_ether. > The reason I am looking is that our 'device' sits on production lines, > and occasionally, people with a laptop may turn up and wish to move data > on and off it via USB (easier then ethernet - plug and go - and in fact > the ethernet port may be used for other things). The file storage gadget > seems to be a option to do this, but I get the impression it may not be > suitable given the above. Is there a more appropriate way of using USB > to accomplish what we are trying to do? That's a good question. Depending on your situation, you might want to set up g_file_storage so that it pretends to have removable media. Every so often your user program could "remove the media" (this can be done using sysfs), update the contents of the backing file, and then "insert the media". If somebody had attached a laptop and was reading the data at the time, then the "remove the media" step would fail and your program would know not to update the contents at that moment. This doesn't allow for dynamic updates while somebody is attached; I don't think there's any good way to accomplish that using the USB mass storage protocol. Another standard protocol which might be useful is PTP (picture transfer protocol or something like that). I haven't used it; it's the sort of thing scanners (and some digital cameras) employ for transferring images. But nobody has written a USB gadget driver implementing that protocol. Alan Stern ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel