Alan, Thanks a lot for your reply. I would like to add a fix for this issue which will be a long term solution that others can also benefit from. Do you think that adding e.g. a kobject_uevent() signal to both composite_setup() and composite_disconnect() would be the right solution that can also go upstream? The main reason why I need cable detection is, that whenever the cable has been disconnected the data link is broken and I have to re-open the gadget serial device file, in order to re-establish the link. Maybe we can fix the gadget serial driver so that re-opening the device is not needed? In this way I may not even need the event signaling on cable detect/remove as I can simply wait for data to be available/transmitted again and I will know the link is back up. Best Regards, Thomas Søhus > -----Original Message----- > From: linux-usb-owner@xxxxxxxxxxxxxxx [mailto:linux-usb- > owner@xxxxxxxxxxxxxxx] On Behalf Of Alan Stern > Sent: 23. november 2009 22:45 > To: Thomas Søhus > Cc: linux-usb@xxxxxxxxxxxxxxx > Subject: Re: Gadget serial and cable detection (in user mode) > > On Mon, 23 Nov 2009, Thomas Søhus wrote: > > > Dear experts, > > > > I am currently working on a project using the Gadget serial driver, > and is > > having some issues coping with cable removal. I need to stop my data > > transmission (when the host disconnects) and restart it when the host > > connects again. I would expect that you can get some sort of event > from the > > Gadget driver when the host is connected/disconnected, but was not > able to > > find any info on that. > > > > What I would ultimately like to accomplish: > > 1. Receive events on cable insertion/removal (Host > connect/disconnect). > > In theory events could be generated for connect and disconnect. > However none of the device controller drivers or gadget drivers does > so. > > > 2. Receive events when the host is ready to receive data (the Port is > opened > > on the host PC). > > There is no way to find out when this happens. The host doesn't tell > the device when the port is opened or closed. > > > Is it possible to receive such events in user mode from the Gadget > stack or > > the USB sub-system? > > If not could you provide some advice on possible workaround to solve > my > > problem? > > You could modify the composite_disconnect() routine in composite.c to > provide some notification when a disconnection occurs. You could even > make a similar change to composite_setup() to create an event the first > time a control request is received following a disconnect -- that would > correspond to a connection. > > Alan Stern > > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 9.0.709 / Virus Database: 270.14.78/2521 - Release Date: > 11/23/09 08:52:00 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html