[Nut-upsdev] Problem with bestfcom and old Ferrups

Chris Adams cmadams at hiwaay.net
Wed Feb 6 19:44:58 UTC 2008


Once upon a time, Chris Adams <cmadams at hiwaay.net> said:
> I have an old (1997) Best Ferrups (model FE18KVA) that I am trying to
> monitor for the first time, but all the Best drivers fail to communicate
> with it.

Okay, I think I have bestfcom working with my old UPS.  Here's a patch
verses 2.2.1 that fixes three issues I saw with my UPS:

- the "time" command sends a prompt, so always send an empty command
  after "time" (on versions that prompt, hitting return doesn't change
  the time, and on UPSes that don't, this just sends an empty command)

- the spacing in the "id" command is different, so match a second string
  for Ferrups

- the sscanf calls have various combinations of space and tab before the
  matched valud, which is unneeded; scanf will skip any amount of white
  space in the input when the format has a space

With this, bestfcom starts and reports valid values.  I have not tried
cutting the power yet (just to be safe I will need to do that outside
normal business hours).
-- 
Chris Adams <cmadams at hiwaay.net>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.


diff -urN nut-2.2.1-dist/drivers/bestfcom.c nut-2.2.1/drivers/bestfcom.c
--- nut-2.2.1-dist/drivers/bestfcom.c	2007-12-17 09:13:09.000000000 -0600
+++ nut-2.2.1/drivers/bestfcom.c	2008-02-06 13:39:50.000000000 -0600
@@ -423,6 +423,9 @@
 	} else {
 		fatalx(EXIT_FAILURE, "Error connecting to UPS.");
 	}
+	/* old Ferrups prompt for new time so send a blank line */
+	execute("\r", buf, sizeof(buf));
+	ser_get_line(upsfd, buf, sizeof(buf), '>', "\012", 3, 0);
 }
 
 /* power down the attached load immediately */
@@ -570,7 +573,8 @@
 			fc.watts = 3000;
 		}
 	} else
-	if (strstr(rstring, "Model:	   FE")){
+	if (strstr(rstring, "Model:	   FE")
+	    || strstr(rstring, "Model:    FE")){
 		fc.model = FExxxx;
 		fc.type = FERRUPS;
 		snprintf(fc.name, sizeof(fc.name), "%s", "Ferrups");
@@ -591,15 +595,15 @@
 	  case FDxxxx:
 		/* determine shutdown battery voltage */
 		if (execute("d 27\r", tmp, sizeof(tmp)) > 0) {
-			sscanf(tmp, "27 LowBatt	 %f", &fc.emptyvolts);
+			sscanf(tmp, "27 LowBatt %f", &fc.emptyvolts);
 		}
 		/* determine near low battery voltage */
 		if (execute("d 30\r", tmp, sizeof(tmp)) > 0) {
-			sscanf(tmp, "30 NLBatt	%f", &fc.lowvolts);
+			sscanf(tmp, "30 NLBatt %f", &fc.lowvolts);
 		}
 		/* determine fully charged battery voltage */
 		if (execute("d 28\r", tmp, sizeof(tmp)) > 0) {
-			sscanf(tmp, "28 Hi Batt	 %f", &fc.fullvolts);
+			sscanf(tmp, "28 Hi Batt %f", &fc.fullvolts);
 		}
 		fc.fullvolts = 13.70;
 		/* determine "ideal" voltage by a guess */
@@ -607,19 +611,19 @@
 		break;
 	  case FExxxx:
 		if (execute("d 45\r", tmp, sizeof(tmp)) > 0) {
-			sscanf(tmp, "45 RatedVA	 %d", &fc.va);			/* 4300  */
+			sscanf(tmp, "45 RatedVA %d", &fc.va);			/* 4300  */
 		}
 		if (execute("d 46\r", tmp, sizeof(tmp)) > 0) {
-			sscanf(tmp, "46 RatedW	%d", &fc.watts);		/* 3000  */
+			sscanf(tmp, "46 RatedW %d", &fc.watts);		/* 3000  */
 		}
 		if (execute("d 65\r", tmp, sizeof(tmp)) > 0) {
-			sscanf(tmp, "65 LoBatV	%f", &fc.emptyvolts);	/* 41.00 */
+			sscanf(tmp, "65 LoBatV %f", &fc.emptyvolts);	/* 41.00 */
 		}
 		if (execute("d 66\r", tmp, sizeof(tmp)) > 0) {
-			sscanf(tmp, "66 NLBatV	%f", &fc.lowvolts);		/* 44.00 */
+			sscanf(tmp, "66 NLBatV %f", &fc.lowvolts);		/* 44.00 */
 		}
 		if (execute("d 67\r", tmp, sizeof(tmp)) > 0) {
-			sscanf(tmp, "67 HiBatV	%f", &fc.fullvolts);	/* 59.60 */
+			sscanf(tmp, "67 HiBatV %f", &fc.fullvolts);	/* 59.60 */
 		}
 		fc.idealbvolts = ((fc.fullvolts - fc.emptyvolts) * 0.7) + fc.emptyvolts;
 		if (fc.va < 1.0) {
@@ -741,6 +745,7 @@
 
 	execute("fc\r", rstring, sizeof(rstring));
 	if (strlen(rstring) < 80 ) {
+		ser_get_line(upsfd, rstring, sizeof(rstring), '>', "\012", 3, 0);
 		upsdrv_init_nofc();
 	} else {
 		upsdrv_init_fc(rstring);



More information about the Nut-upsdev mailing list