Package: nut Version: 2.0.1-2.1 Severity: normal
I noticed that the "etapro" driver (written by me some time ago, for the "ETA mini+UPS PRO" manufactured by http://www.eta.com.pl/) stopped working after the nut 1.4 -> 2.0 upgrade. The problem appears to be caused by the upsrecv -> ser_get_line conversion. This UPS type returns multi-line responses, which were read by multiple upsrecv calls. Now, ser_get_line discards data after the newline, so only the first line is parsed correctly. This causes the driver to log a lot of "bad response" errors, and always return "Data stale" for this UPS. See below for a fix - I'm testing it right now, seems to work... Thanks, Marek diff -ur orig/nut-2.0.1/drivers/etapro.c nut-2.0.1/drivers/etapro.c --- orig/nut-2.0.1/drivers/etapro.c 2004-01-09 21:35:14.000000000 +0100 +++ nut-2.0.1/drivers/etapro.c 2005-04-21 21:33:19.000000000 +0200 @@ -61,11 +61,19 @@ { char tmp[256]; char *cp; - int ret; - unsigned int val; + unsigned int n, val; - ret = ser_get_line(upsfd, tmp, sizeof(tmp), '\n', "", 3, 0); - if (ret < 0) { + /* Read until a newline is found or there is no room in the buffer. + Unlike ser_get_line(), don't discard the following characters + because we have to handle multi-line responses. */ + n = 0; + while (ser_get_char(upsfd, &tmp[n], 1, 0) == 1) { + if (n >= sizeof(tmp) - 1 || tmp[n] == '\n') + break; + n++; + } + tmp[n] = '\0'; + if (n == 0) { upslogx(LOG_ERR, "no response from UPS"); return -1; } @@ -187,7 +195,6 @@ /* First command after power on returns junk - ignore it. */ ser_send(upsfd, "RI\r"); sleep(1); - ser_flush_in(upsfd, "", nut_debug_level); upsdrv_updateinfo(); @@ -201,6 +208,7 @@ int x, flags; double utility, outvolt, battvolt, loadpct; + ser_flush_in(upsfd, "", nut_debug_level); ser_send(upsfd, "RI\r"); /* identify */ x = etapro_get_response("SR"); /* manufacturer */ -- System Information: Debian Release: 3.1 APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Kernel: Linux 2.4.26 Locale: LANG=pl_PL, LC_CTYPE=pl_PL (charmap=ISO-8859-2) Versions of packages nut depends on: ii adduser 3.63 Add and remove users and groups ii debconf [debconf-2.0] 1.4.30.13 Debian configuration management sy ii libc6 2.3.2.ds1-20 GNU C Library: Shared libraries an -- debconf information: nut/major_conf_changes: nut/change_system_user: * nut/major_upstream_changes: true nut/remove_debian_conf: -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]