Vladislav Bogdanov
2006-Jan-27 13:31 UTC
[Nut-upsdev] [PATCH] fentonups patch to make it work with some powercom ups's
Hi list here is the patch to make fentonups recognize some PowerCOM's UPS's, and to setup terminal lines for them (at least for SMK-1500a) as powercom's original upsmon do. fentonups -x powercom works correctly with SMK-1500a (it screamed ''Communications with UPS lost - check cabling' or 'Short read during UPS id sequence' without this patch). Sorry for sending as attachement, I'm not sure about right patch formatting in the inline post. I'm not in list, so please send me copy if/when replying. -- Vladislav Bogdanov -------------- next part -------------- --- nut-2.0.2/drivers/fentonups.c.orig 2005-05-26 15:22:27.000000000 +0300 +++ nut-2.0.2/drivers/fentonups.c 2006-01-27 14:20:07.000000000 +0200 @@ -18,6 +18,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/termios.h> #include "main.h" #include "serial.h" @@ -176,11 +179,27 @@ static char *get_id(void) return NULL; } +static void set_powercom_lines (void) +{ +// straced from powercom's upsmon +//ioctl(4, TIOCMSET, [TIOCM_DTR|0x4000]) = 0 + + int dtr_bit = TIOCM_DTR|0x4000; + ioctl(upsfd, TIOCMSET, &dtr_bit); +} + void upsdrv_initinfo(void) { int modelnum, i, ret; char temp[256], model[32], *raw; + if (testvar("powercom")) { + set_powercom_lines(); +// straced from powercom's upsmon (reset?) + ret = ser_send(upsfd, "%c%c%c%c%c\r", 1, 2, 2, 3, 5); + ret = ser_get_line(upsfd, temp, sizeof(temp), ENDCHAR, "", + SER_WAIT_SEC, SER_WAIT_USEC); + } raw = get_id(); if (!raw) @@ -426,6 +445,7 @@ void upsdrv_help(void) void upsdrv_makevartable(void) { addvar(VAR_VALUE, "lowbattvolt", "Set low battery level, in volts"); + addvar(VAR_FLAG, "powercom", "Set signal lines for PowerCOM UPS (method straced from PowerCOM's upsmon)"); } void upsdrv_banner(void) --- nut-2.0.2/drivers/fentonups.h.orig 2005-05-04 12:36:36.000000000 +0300 +++ nut-2.0.2/drivers/fentonups.h 2006-01-27 14:13:09.000000000 +0200 @@ -63,6 +63,10 @@ struct { { "ULT-1000", "PowerCom ULT-1000", 1.91, 0.42, 1.91, 0.42, 165, 200, 240, 275, 1 }, + { "SXL-1500A", "PowerCom SXL-1500A", 1.91, 0.42, 1.91, 0.42, 165, 200, 240, 275, 1 }, + { "SMK-1500A", "PowerCom SMK-1500A", 1.91, 0.42, 1.91, 0.42, 165, 200, 240, 275, 1 }, + { "SMK-800A", "PowerCom SMK-800A", 1.91, 0.42, 1.91, 0.42, 165, 200, 240, 275, 1 }, + { "Alpha500iC", "Alpha 500 iC", 10.7, 1.4, 13.0, 0.8, 172, 196, 252, 288, 0 }, { NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0 }