-
-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nutdrv_qx: support replies not terminated by the required CR #441
Comments
@zykh is it okay if I move this to the 2.7.6 milestone? |
ahem, yes, @clepple... it turns out I completely forgot this one... |
no problem. (Hopefully the next release won't be a year from now :-) ) |
moving back to 2.7.5, since a) there is a workaround (zykh@1595a06) that apparently works as expected, and b) this is needed for #616 |
Since some devices, when communicating via USB, don't close their replies to our commands/queries with the expected (and mandated by the specs) CR, rendering the driver almost useless as protocols get one less character than they expect, update the various USB subdrivers (leaving out the ones that rely on a CR to stop reading from the device) to add the missing terminating CR in such cases (as long as we get anything usable). This is a bit of a cheat, but, at least for now, it will do -- not to mention the fact that it is way less invasive than touching all the places of the driver that expect a closing CR and all the qx2nut tables of the various protocols. Close networkupstools#441
For the record, I encountered this bug in nut 2.7.4 on Debian 11 with my UPS, model "UPSONIC IRT-3K 2U". My UPS is about 10 years old. The equivalent current model appears to be https://www.upsonic.com.au/upsonic-esart-rack-or-tower-series-ups/ https://bugs.debian.org/1019624 The fix in nut 2.8.0 (zykh@0e2372b) looks much nicer than mine. I am confident it will fix my problem, but as my UPS is back in production, I won't be able to verify this experimentally for a long time. :-( Here's my upsc output (inc. make/model):
|
As noted in the "Maintainer note" above, the solution for NUT v2.8.0 release was pin-point to certain protocol dialects. Apparently the problem is more wide-spread, so finding some way to apply the solution commonly (including to future driver contributions) would be welcome. At the very least, the several copies of same fix proposed in the PR which solved it previously seems like an invitation for refactoring into a helper method to invoke from everywhere, perhaps?.. |
Signed-off-by: Jim Klimov <[email protected]>
Signed-off-by: Jim Klimov <[email protected]>
BTW, in Armac, the final solution was different. I was forging the \r for a second when finding \0 in the datastream prematurely for Vultech. But in the end, after coercing \0 to '0' the UPS eventually sends \r at the right position and everything seems to work "fine". Just single bit is sent as \0. This \0 is weird obviously. When finishing on it though, there was not enough status bits to correctly parse response, although those lacking weren't particularly important and could be synthesized as zeroes. |
Note for future, regarding Armac subdriver approach, see: I am not convinced that devices covered by If so - then possibly this solution should be generalized to all QX reads?.. |
Apparently some devices don't close their replies to our commands/queries with the expected (and mandated by the specs) CR and, at the moment, this is not supported by nutdrv_qx:
http://lists.alioth.debian.org/pipermail/nut-upsuser/2017-June/010714.html
('krauler' USB subdriver)
As far as I can remember, this eventuality can only happen with certain USB subdrivers that only read a predetermined amount of data, read data from a given index or wait till no more data is available (if I recall correctly, serial communication and other USB subdrivers need the terminating CR in order to work properly), so, probably, the easiest fix should be to handle this situation in those USB subdrivers.
Also, this should not be considered an improvement, but a regression that needs to be solved, since blazer_* drivers, being less strict on the terminating CR of Q1 replies (3747fd5), should (sort of) support (some of) this kind of devices.
MAINTAINER NOTE: The null byte vs.
\r
at end of reads sounds reminiscent of work recently done by @blaa for thenutdrv_qx
subdriver forarmac
in #2005; maybe this part should/can be generalized somehow to help with all devices that do not use CR/LF in protocol? It seems that the 1595a06 commit which allegedly solved this issue previously added the fix for certain*_command()
methods, and so is lacking in some others that appeared afterwards.The text was updated successfully, but these errors were encountered: