Michal Soltys
2011-Mar-12 01:10 UTC
[Nut-upsdev] [RFC/PREVIEW] Move apcsmart driver to canonical processing + minor stuff
Inital tests with two apc units (2005 and pre-2000) seem to go well. See commit message for details. I'll add more detailed rationale after getting some sleep :) Michal Soltys (1): apcsmart: switch processing to ICANON + minor fixes drivers/apcsmart.c | 270 +++++++++++++++++++++++++++++++++++----------------- drivers/apcsmart.h | 127 ++++++++++++++++--------- 2 files changed, 267 insertions(+), 130 deletions(-) -- 1.7.2.1
Michal Soltys
2011-Mar-12 01:10 UTC
[Nut-upsdev] [RFC] apcsmart: switch processing to ICANON + minor fixes
1) minor fixes command '@' has been added to compat tables. All (?) APC models in smart mode should handle it ignore / alert sets have been adjusted to be more clear; lots of comments added as well upsdrv_shutdown_advanced() - fixed 'continue;' blocking certain methods to be ever used update author in comments some other comments' updates 2) heavy stuff - ICANON This patch add canonical processing mode. All reads and flushes are done now by upsread() and upsflush(); '*' which is sort-of-alert (and behaves as EOL), is handled in upsread(); upsread() behaviour is controlled by SER_* flags; code has been updated to use new functions instead of direct calls to ser_*(); Signed-off-by: Michal Soltys <soltys at ziu.info> --- drivers/apcsmart.c | 270 +++++++++++++++++++++++++++++++++++----------------- drivers/apcsmart.h | 127 ++++++++++++++++--------- 2 files changed, 267 insertions(+), 130 deletions(-) -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-apcsmart-switch-processing-to-ICANON-minor-fixes.patch Type: text/x-patch Size: 24326 bytes Desc: not available URL: <http://lists.alioth.debian.org/pipermail/nut-upsdev/attachments/20110312/87617b8e/attachment-0001.bin>
Michal Soltys
2011-Mar-13 20:33 UTC
[Nut-upsdev] [RFC/PREVIEW] Move apcsmart driver to canonical processing + minor stuff
On 11-03-12 02:10, Michal Soltys wrote:> Inital tests with two apc units (2005 and pre-2000) seem to go well. See commit > message for details. I'll add more detailed rationale after getting some sleep :) > > Michal Soltys (1): > apcsmart: switch processing to ICANON + minor fixes > > drivers/apcsmart.c | 270 +++++++++++++++++++++++++++++++++++----------------- > drivers/apcsmart.h | 127 ++++++++++++++++--------- > 2 files changed, 267 insertions(+), 130 deletions(-) >More details: While the switch to canonical mode was pretty straightforward, two small issues showed up: 1) capability check was taking near 3 seconds to complete on one of the models (and not the most advanced/newest one) - while not an issue with non-canonical mode, it was too close to the edge in the canonical mode. 2) on older models, some shutdown commands (K, @) either don't respond (on failure), or "respond" with '*' which is more like an alarm (and supposedly can happen on other times when apc powers down for other reasons ?) To resolve this gracefully: All reads are performed using upsread() now, which is based on ser_get_line_alert(). It takes few flags (see apcsmart.h) to handle different behaviour depending on our needs. Basic flags are: SER_TO - allow the read to timeout without rising error SER_AL - run with alert_handler() (and enable proper ignore/alarm sets) - when canonical mode is enabled, '*' functions as an additional EOL. It doesn't conflicit with normal operation - as '*' generally doesn't happen, and even if it did, upsread() would just skip over it continuing reading. Similary to normal LF, * won't be included in the input either - when upsread() is called in sdcmd*() functions, SER_SD flag is used. Apart from assuming SER_TO, it drops the default timeout to 1.5 seconds. This is generally used to eat responses from U or force-failed @nnn. Both commands should answer immediately with something, though for older apc stuff, failed @nnn will be silent. - when upsread() is called in sdok() functions, SER_AX flag is used. This implies SER_SD (see above) and enables handling '*'. Basically, if it's detected (remember it functions as EOL now). the buffer with just '*' is returned and sdok() actually knows if the command succeeded or not. - when we do capability check, SER_CP is used, which rises timeout to 6 seconds (and enables special ignore set). This gives plenty of margin to handle whole capability list without timing out. With canonical mode, we will use the least amount of time possible either way.