From fdca09e86618062d919a79993de004457bf9711b Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 31 Jul 2023 12:36:19 +0200 Subject: [PATCH 1/2] drivers/nutdrv_qx.c: improve armac subdriver for EOL support [#1978] Authored by Tomasz bla Fortuna @blaa at https://github.com/networkupstools/nut/issues/1978#issuecomment-1653259401 Signed-off-by: Jim Klimov --- drivers/nutdrv_qx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/nutdrv_qx.c b/drivers/nutdrv_qx.c index 350c555a06..70821c01f8 100644 --- a/drivers/nutdrv_qx.c +++ b/drivers/nutdrv_qx.c @@ -1838,14 +1838,20 @@ static int armac_command(const char *cmd, char *buf, size_t buflen) tmpbuf[0], tmpbuf[1], tmpbuf[2], tmpbuf[3], tmpbuf[4], tmpbuf[5], tmpbuf[1], tmpbuf[2], tmpbuf[3], tmpbuf[4], tmpbuf[5]); + /* This includes status/length byte on R/3000I/PF1 */ bytes_available = (unsigned char)tmpbuf[0] & 0x0f; if (bytes_available == 0) { /* End of transfer */ break; } - memcpy(buf + bufpos, tmpbuf + 1, bytes_available); - bufpos += bytes_available; + memcpy(buf + bufpos, tmpbuf + 1, bytes_available - 1); + bufpos += bytes_available - 1; + + if (tmpbuf[bytes_available - 1] == 0x0d) { + /* End of line is an end of the message as well */ + break; + } if (bytes_available <= 2) { /* Slow down, let the UPS buffer more bytes */ From 591c4548126714cf65ec4e613dc167da3a65b45e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 31 Jul 2023 12:43:18 +0200 Subject: [PATCH 2/2] NEWS: improve armac subdriver for EOL support [#1978] Signed-off-by: Jim Klimov --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 11385cf61d..8cf46b9413 100644 --- a/NEWS +++ b/NEWS @@ -99,6 +99,8 @@ as part of https://github.com/networkupstools/nut/issues/1410 solution. - nutdrv_qx updates: * the `voltronic_qs_protocol` should now accept both "V" (as before) and newly "H" dialects, which otherwise seem interchangeable [#1623] + * the `armac` subdriver was enhanced to support devices with a different + response pattern than previously expected per initial contribution [#1978] - usbhid-ups updates: * cps-hid subdriver now applies same report descriptor fixing logic to