[Nut-upsdev] telling apart USB devices

Peter Selinger selinger at mathstat.dal.ca
Tue Nov 8 04:04:46 UTC 2005


Arnaud Quette wrote:
> 
> ... 
> 
> 1) the above problem is due to the state sockets and driver pidfile naming.
> These are currently build using "drv-name"-"port" (adding ".pid" for the
> pidfile).
> This is, as you stated, not enough now with the newhidups case and its
> "auto" port probing!
> I've thinked about that when starting newhidups, and come to the conclusion
> that using the ups definition name (ie belkinusb and mgeusb) would be
> sufficient. A good way to ensure a unique filename. A special case is when
> the driver is launched manually (ie just with a port, no -a and not with
> upsdrvctl). In that case, we'll use the current behavior.
> I'm preparing that for the cvs Dev. Watch the commit list this evening...

Hi Arnaud,

I have just tested your CVS commits regarding the socket naming
conventions, and I have found that this almost works, but there are
some bugs. I am presenting four scenarios (1)-(4) below, of which
three are working correctly but (2) is not.

Here is the relevant part of my ups.conf:

[belkinusb]
        driver = newhidups
        port = auto
        desc = "Belkin UPS, USB interface"
        vendorid=050d

[mgeusb]
        driver = newhidups
        port = auto
        desc = "MGE UPS, USB interface"
        vendor = "MGE.*"

(1) If I start the driver with:
./drivers/newhidups -u root -DD -a mgeusb

then /var/state/ups shows the following socket:
srw-rw----  1 root root 0 Nov  7 23:53 mgeusb

Upsd can connect to this correctly, and when I stop the driver (with
CTRL-C), the socket disappears.

(2) If I start the driver with:
upsdrvctl start mgeusb

then /var/state/ups shows the following socket and PID file:
srw-rw----  1 root root 0 Nov  7 23:53 newhidups-auto
-rw-r--r--  1 root root 6 Nov  7 23:53 newhidups-auto.pid

Upsd *cannot* connect to the driver, and claims the driver is not
connected.

Also, if I try to stop the driver with:
upsdrvctl stop mgeusb

then I get this error message:

Network UPS Tools - UPS driver controller 2.1.0
Stopping UPS: mgeusb
Can't open /var/state/ups/newhidups-mgeusb.pid: No such file or directory

Note that this is bizarre, as neither the name of the PID file nor the
name of the socket is the correct one.

Also, if I try to stop the driver with:
upsdrvctl stop

then I get 
Network UPS Tools - UPS driver controller 2.1.0
Stopping UPS: belkinusb
Can't open /var/state/ups/newhidups-belkinusb.pid: No such file or directory
Stopping UPS: mgeusb
Can't open /var/state/ups/newhidups-mgeusb.pid: No such file or directory

So it seems that the new naming scheme is not yet working properly
with upsdrvctl.

(3) If I start the driver with
./drivers/newhidups -u root -DD gaga

then /var/state/ups shows the following socket:
srw-rw----  1 root root 0 Nov  7 23:58 newhidups-gaga

(and the socket disappears when I stop the driver). In this case, upsd
cannot connect to the driver, but this seems to be the intended
behavior.

(4) There is no particular problem running two drivers in parallel, as
long as I start both of them manually using method (1) above. Upsd
correctly distinguishes the two drivers.

-- Peter




More information about the Nut-upsdev mailing list