[Nut-upsuser] N-Power MEV-3000LT compatibility report and problem

Александр Безруков phmagic at mail.ru
Tue Aug 13 05:25:13 UTC 2013


 Hello,

below is a patch which makes blazer_ser to speak a special flavor of the protocol which
in the driver code is called 'Best'. I tested this patch thoroughly on my device (N-Power
MEV-3000LT).

Regards,
Alexander.

>cat /usr/local/portage/sys-power/nut/files/nut-2.6.5-ACK.patch

--- a/drivers/blazer.c	2013-08-13 06:46:18.227007117 +0400
+++ b/drivers/blazer.c	2013-08-13 06:49:36.315620485 +0400
@@ -405,7 +405,7 @@
 	};
 
 	char	buf[SMALLBUF] = "";
-	int	i;
+	int	i,ret;
 
 	for (i = 0; instcmd[i].cmd; i++) {
 
@@ -417,8 +417,11 @@
 
 		/*
 		 * If a command is invalid, it will be echoed back
+		 * As an exception, Best UPS units will report "ACK" in case of success!
+		 * Also this command may fail with "NAK" in case shutdown is not is progress
 		 */
-		if (blazer_command(buf, buf, sizeof(buf)) > 0) {
+		if ((ret=blazer_command(buf, buf, sizeof(buf)))<0
+		 || ret>0 && strncmp(buf,"ACK",sizeof "ACK"-1) && strncmp(buf,"NAK",sizeof "NAK"-1)) {
 			upslogx(LOG_ERR, "instcmd: command [%s] failed", cmdname);
 			return STAT_INSTCMD_FAILED;
 		}
@@ -463,11 +466,9 @@
 	 * If a command is invalid, it will be echoed back.
 	 * As an exception, Best UPS units will report "ACK" in case of success!
 	 */
-	if (blazer_command(buf, buf, sizeof(buf)) > 0) {
-		if (strncmp(buf, "ACK", 3)) {
-			upslogx(LOG_ERR, "instcmd: command [%s] failed", cmdname);
-			return STAT_INSTCMD_FAILED;
-		}
+	if ((ret=blazer_command(buf, buf, sizeof(buf)))<0 || ret>0 && strncmp(buf, "ACK", sizeof "ACK"-1)) {
+		upslogx(LOG_ERR, "instcmd: command [%s] failed", cmdname);
+		return STAT_INSTCMD_FAILED;
 	}
 
 	upslogx(LOG_INFO, "instcmd: command [%s] handled", cmdname);


More information about the Nut-upsuser mailing list