[Nut-upsdev] Driver bestfcom - Timing problem with Fortress LI1420

Heiko Kegel h.kegel at cityweb.de
Sun Dec 2 02:27:24 UTC 2007


Hi,
my UPS is a Best Fortress LI1420 with the monitoring master running fedora 7.
I have to replace the manufacturer's software "Checkups II" because it's not 
working with releases after fc4.

My choice is the nut package.
But it isn't just installing rpm's and configure the parameter files.

 
The first hurdle to take was realising the UPS doesn't send a prompt.
Function sync_serial() sends only <cr>, no command, and the UPS answers with a 
new line. Without prompt enabled bestfcom will loop forever. Called via 
upsdrvctl it will time out.
So debugging the source helped.
Setting the Fortress parameter 75 (prompt) to 1 solved this.

Next the driver doesn't work. Error message is:

[nut at ls1 ~]# bestfcom -D -D -D -a LI1420
Network UPS Tools - Best Ferrups/Fortress 0.11 (2.0.5)
debug level is '3'
UPS Time: Sunday, December 02, 2007 - 02:41:19
fc response: 80                                                      
120202411901000000010000022002200000001100024200000533500000230000000000E0010663
Bad response from formatconfig command in upsdrv_init_fc()

The line returned is not from command "fc" but from command "f" called just 
before. 
When stepping the source under gdb everything works fine.
Inserting some sleep(1) commands helps.

############################################################
 begin diff
############################################################
--- bestfcom.c  2006-11-08 03:08:45.000000000 +0100
+++ nut-2.0.5/drivers/bestfcom.c        2007-12-02 01:21:51.000000000 +0100
@@ -181,7 +181,8 @@
 static int execute(const char *cmd, char *result, int resultsize)
 {
        int ret;
-       char ch, buf[256];
+       unsigned char ch;
+       char buf[256];
 
        /* Check for the Inverter status alarm if pending :
         * "\r\n{Inverter:     On}\r\n=>"
@@ -190,10 +191,12 @@
                POLL_ALERT, alert_handler, 0, 20);
 
        ser_send(upsfd, cmd);
+       sleep(UPSDELAY);
 
        /* delete command echo up to \012 but no further */
        for (ch = '\0'; ch != '\012'; ser_get_char(upsfd, &ch, 0, 10));
 
+       sleep(UPSDELAY);
        /* get command response */
        ret = ser_get_line(upsfd, result, resultsize, '\015', "\012", 3, 0);
 
@@ -741,7 +744,9 @@
                exit(EXIT_FAILURE);
        }
 
+       sleep(UPSDELAY);
        execute("fc\r", rstring, sizeof(rstring));
+       sleep(UPSDELAY);
        if (strlen(rstring) < 80 ) {
                upsdrv_init_nofc();
        } else {

############################################################
 end diff
############################################################
 
Am I the only one facing this? Or is my UPS (manufactured 1998) the last of 
it's kind?

I hope this helps other Fortress users.

H.Kegel


More information about the Nut-upsdev mailing list