[Nut-upsdev] fixing the cpsups driver

Arjen de Korte nut+devel at de-korte.org
Sat Dec 30 22:10:47 CET 2006

>> Good! Finally it's getting the attention that it badly needs.
> Yes..  I was disappointed on the way the driver worked when I bought the
> unit I have now.  It was a relatively inexpensive unit, and has a good
> capacity.


> ok, I will do that.  I will attach my current cpsups.c to this message..

I just committed this version to the SVN trunk. I only bumped up the
version to .06, since we were at .05 already.

I have the following remark:

> void upsdrv_shutdown(void)
> {
>     int ret;
>     char    buf[256];
> /*    Don't need ups_sync() here, initialization has been done a long
>  *    time ago!
>  *    ups_sync();
>  */

This is a common mistake for new developers, the above is not true. When
the -k flag is passed to the driver (to make it shutdown the UPS), it goes
straight from the upsdrv_initups to upsdrv_shutdown (see also 'main.c' in
the drivers directory). The driver has already been stopped when this
command is given. So you really should try to do a minimalistic detection
of the UPS, in order to find out the line status for instance. You may
also want to change the actual shutdown command to depend on which UPS was
detected (Z02 may not work for all supported UPS'es).

Best regards, Arjen

More information about the Nut-upsdev mailing list