generic_modbus driver - handle connection errors (broken pipe), configurable modbus timeouts#1239
Conversation
…us response timeouts between requests and frame bytes
|
This pull request introduces 2 alerts when merging bbf2d51 into 5454b34 - view on LGTM.com new alerts:
|
|
LGTM errors seem right this time: you define |
|
While some CI workers complained about those comparisons, at least one other seems to have a different modbus API so there should be configure-time checks (m4) for acceptable usage respectively ifdef-ed in C code: (that's with libmodbus-3.0.5 from Ubuntu 14.04) |
|
And gotta investigate how to better handle the two different APIs, it seems ... |
The values for configuration variables |
the |
|
Well, NUT aims to be usable on a wide spread of systems, some embedded and not easily upgradeable from whatever older baseline OS they boast :\ There are already precedents of multiple-API support (e.g. libusb-0.1 vs libusb-1.0) as well as "lockpicking" suitable method argument types like in https://github.com/networkupstools/nut/blob/master/m4/nut_func_getnameinfo_argtypes.m4 (loosely modeled after cURL config code; note that |
…nection timeout handling)
…_C_PRAGMAS logic only once
…ut() and modbus_set_response_timeout()
…count and type of args used)
…val) can be used with variables from new API (uint32) set into the struct
…ed with exact macro names (not m4/shell variables)
|
Hi @dtsecon : I've posted the fix to adjust to two available libmodbus APIs, as a PR to your "nut_fork:master" (note, future development and PRing of features should better be handled in dedicated branches): dtsecon#1 If you can, please test if that still works for your builds; if all is OK, after you merge that PR this one should be automatically updated. Otherwise, I intend to merge that state of the codebase (including your and my fixes) in a few days, if NUT CI farm is okay with that - as would be seen at https://ci.networkupstools.org/job/nut/job/nut/job/dtsecon-master-PR-1239 To keep the comment in NUT for posterity: As discussed in PR #1239 there are two libmodbus API variants to consider on the build farm reflecting current and "recent" distros for NUT:
In both cases, error-check should happen at usage time and was not specifically investigated for handled in this PR. Per docs,
|
drivers/generic_modbus.c: adapt to two libmodbus timeout APIs
(original fix from master branch)
|
Some merge-conflicts cropped up between your "master" branch and the target (upstream NUT "master" branch which had some clean-up applied since original driver merge). Hopefully resolved now with minimal noise. |
tested and seems to work fine against my setup |
|
Hi @jimklimov. I noticed that mr jenkins struggles to pass this PR during the last days without success. Since my last commits against generic_modbus have been applied to my master forked nut repo (current PR), this pending merge holds me from moving on with a couple of more PR branches (a new driver for adelesystems UPS, more updates on generic_modbus, and a fix for upssched which is currently broken). Regards! |
…ints for timeval with timeouts (memset to 0 instead)
|
Hi, sorry about that delay - it also had a few complaints about the code (though did not expose them in the build verdict... recipe fixed elsewhere - so should now complain about quality regression for future NUT CI farm builds). Those complaints were fixed in the later 3 commits, and the build passed without warnings last night - so merging, finally! Thanks for the solid improvements! And for those further PRs, please remember to base them off of dedicated branches, not "master", in your forked repo :) |
generic_modbus driver now handles connection errors (broken pipe) with modbus tcp server devices. Response time out between requests and between frame bytes are now configurable via ups.conf to handle "invalid data" errors. The new code have been tested.
configuration options for modbus response and byte timeouts in ups.conf
# Modbus timeoutsmod_resp_to_s = 2mod_resp_to_us = 0mod_byte_to_s = 0mode_byte_to_us = 20000