[Nut-upsdev] [nut-commits] svn commit r1074 - in trunk: .

Peter Selinger selinger at mathstat.dal.ca
Mon Sep 3 22:04:19 UTC 2007


Arjen de Korte wrote:
> 
> > Even in this case, I would *still* use MODE_OPEN, because even the
> > exact matcher is not 100% sure to open the exact same device. Many
> > vendors don't include a serial number, for example.
> 
> If two UPS'es are attached that can't be distinguished from one another by
> neither the 'exact' matcher nor the 'regex' matcher, the behaviour will be
> unpredictable from the start. What should we do if *both* loose their
> connection, because the hub they are connected to was replugged?

This is not a question of predictability, but of soundness (i.e., no
segmentation faults). Two devices that cannot be distinguished by
either the exact or regex matchers might still be very different
devices. MODE_REOPEN does not re-read the report descriptor. If the
driver later tries to set a variable, who knows where it might be
written. 

> I propose to add a new option to "ups.conf" that would tell how we should
> deal with reconnects:
> 
> reconnect = [ retry, reload, restart ]
> 
> [retry]
> Match the device with the 'exact->regex->subdriver' matchers as we do now
> (should be the default). All variables will be read again from the UPS, to
> make sure we have fresh data.
> 
> [reload]
> Match the device through the 'regex->subdriver' matcher and after reading
> the report descriptor and vendor specific formatting applied, run the
> 'exact' matcher. If this matches, refresh all variables / commands from
> the UPS. The difference with the retry mechanism is that the subdriver
> specific formatting is applied *before* creating/using the 'exact'
> matcher, which might be useful for devices that don't report the serial
> number in the usb_device structure or where we want to include other
> parameters from the HID tree in the matching mechanism. If this creates a
> unique device identification, there is no reason to assume this is a
> different device.
> 
> [restart]
> Same as reload, but don't run the 'exact' matcher after reading the report
> descriptor. Since this may mean we're connecting to a completely different
> device we brutally DELCMD/DELINFO everything we have and act as restarting
> the driver (including creating a new 'exact' matcher). Not for the faint
> of heart.
> 
> In most cases, I think either 'retry' or 'reload' should be fine. The
> 'restart' mode is only needed in case you really have no clue what you're
> connecting to and just hope for the best that this is the UPS that is
> powering your all important application. ;-)

The 'restart' mode has one additional use: if you have only one UPS,
so you *know* it's the correct one; but for some reason it changes its
serial number or product name on reconnection. There has been at least
one report of a device that did this (it changed the strings to empty
strings on reconnection, for no apparent reason).

-- Peter



More information about the Nut-upsdev mailing list