I've messed with this before trying to troubleshoot USB cams.

It's highly dependent on the USB hardware.  Not all USB devices implement "low 
power" mode.

Your best shot is to get a good USB 4 port hub - not a crappy one - a good one 
and the good ones
Implement power control and can cut power to a USB device if you command them 
to.

I went through several different USB hubs experimenting with this and 
ultimately gave it up as a waste of time.

Depending on the hardware there can be side effects.  Such as the entire USB 
bus freezing up and it won't even
Come back with a warm boot of the computer.

USB put the BS in peripheral interconnections.

Ted

-----Original Message-----
From: PLUG <plug-boun...@lists.pdxlinux.org> On Behalf Of Vince Winter
Sent: Monday, January 22, 2024 1:58 PM
To: Portland Linux/Unix Group <plug@lists.pdxlinux.org>
Subject: [PLUG] How to script USB device detection

I will need to test but this may work.

On Mon, Jan 22, 2024, 12:50 PM Tomas Kuchta <tomas.kuchta.li...@gmail.com>
wrote:

> Correction: recent kernels > 2.6 do not have ..../power/level --> use 
> .../power/control
>
> Or something like:
> echo 1.4 /sys/bus/usb/drivers/usb/unbind
>
> -T
>
> On Mon, Jan 22, 2024, 15:42 Tomas Kuchta 
> <tomas.kuchta.li...@gmail.com>
> wrote:
>
> > While not answering your question - this may solve your problem...
> >
> > You can cut power to usb device by something like this:
> >
> > echo suspend > /sys/bus/usb/devices/usb1/power/level
> >
> > That way, you could just make sure that nothing draws power 
> > regardless of plugged in or not. It could save you from unplugging 
> > stuff manually based on some message.
> >
> > Hope it helps,
> > Tomas
> >
> > On Mon, Jan 22, 2024, 15:12 Vince Winter 
> > <thine.technoc...@gmail.com>
> > wrote:
> >
> >> We are running power testing and we need to make sure their isn't 
> >> USB device plugged in it adds to the total system power by having 
> >> the USB
> port
> >> activate.
> >>
> >> I am trying to do a automated is USB plugged.
> >>
> >> We are using multiple generations of systems that are regularly 
> >> reinstalled.
> >>
> >>
> >> On Mon, Jan 22, 2024, 9:42 AM Russell Senior 
> >> <russ...@personaltelco.net
> >
> >> wrote:
> >>
> >> > I don't quite understand. You are looking for a specific device? 
> >> > How
> do
> >> you
> >> > identify the device?
> >> >
> >> > On Mon, Jan 22, 2024 at 9:35 AM Vince Winter <
> >> thine.technoc...@gmail.com>
> >> > wrote:
> >> >
> >> > > I need if USB device is plugged to not to continue the rest of 
> >> > > the
> >> script
> >> > > across multiple devices. I can't change every device and I am 
> >> > > trying
> >> to
> >> > > eliminate humans looking at which devices are plugged in.
> >> > >
> >> > > I do conceded that many laptop cameras are USB and Bluetooth
> generally
> >> > runs
> >> > > on the USB bus.
> >> > >
> >> > > I have yet to find a good answer to this myself.
> >> > >
> >> > > On Fri, Jan 19, 2024, 3:54 PM Russell Senior <
> >> russ...@personaltelco.net>
> >> > > wrote:
> >> > >
> >> > > > Two things I will mention: lsusb and udev rules.
> >> > > >
> >> > > > I have a set of udev rules that match ttyusb devices by path 
> >> > > > (they
> >> > don't
> >> > > > implement serial numbers, which would be better) and give 
> >> > > > them a consistently named symlink. I use /dev/ttyRn, where n 
> >> > > > is a whole
> >> > number.
> >> > > > That means no matter what order they are enumerated in, I can 
> >> > > > find
> >> the
> >> > > > device.
> >> > > >
> >> > > > I don't know if that helps with your problem or not, but I 
> >> > > > have
> >> found
> >> > > them
> >> > > > to be useful in adjacent problems.
> >> > > >
> >> > > > --
> >> > > > Russell
> >> > > >
> >> > > > On Fri, Jan 19, 2024, 15:17 Vince Winter <
> >> thine.technoc...@gmail.com>
> >> > > > wrote:
> >> > > >
> >> > > > > Hello,
> >> > > > >
> >> > > > > I am trying to write a bash script to detect if USB device 
> >> > > > > is
> >> plugged
> >> > > > into
> >> > > > > a device and post a message with a device name that is 
> >> > > > > plugged
> to
> >> > > stdout.
> >> > > > >
> >> > > > > Complications are USB webcams, USB controllers, and this is
> going
> >> to
> >> > be
> >> > > > > used on large number of systems, so I can't customize to 
> >> > > > > each
> >> system.
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> >
>

Reply via email to