Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ https://github.com/networkupstools/nut/milestone/12
PR #3093]
* Fixed default `unit_id`, apparently broken by changes in NUT v2.8.1.
[issue #3191, PR #3192]

- `tripplitesu` driver updates:
* Added configurable command delay to prevent read timeouts
[PR #3273]

- Introduced a new NUT driver named `nut-upower` which provides support
for monitoring UPS and battery devices managed by the UPower daemon
Expand Down
1 change: 1 addition & 0 deletions data/driver.list.in
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,7 @@
"Tripp Lite" "ups" "3" "SU3000XLCD" "USB (protocol 4004)" "usbhid-ups" # http://www.tripplite.com/en/products/model.cfm?txtSeriesID=744&txtModelID=5342
"Tripp Lite" "ups" "3" "SUINT1000RTXL2UA" "USB (protocol 4001)" "usbhid-ups" # http://www.tripplite.com/en/products/model.cfm?txtModelID=3983
"Tripp Lite" "ups" "3" "SUINT1500RTXL2UA" "USB (protocol 4001)" "usbhid-ups" # http://www.tripplite.com/en/products/model.cfm?txtSeriesID=934&txtModelID=2720
"Tripp Lite" "ups" "3" "SUINT1500RTXL2UA" "Serial" "tripplitesu" # http://www.tripplite.com/en/products/model.cfm?txtSeriesID=934&txtModelID=2720
"Tripp Lite" "ups" "3" "SUINT2200RTXL2UA" "USB (protocol 4001)" "usbhid-ups" # http://www.tripplite.com/en/products/model.cfm?txtSeriesID=934&txtModelID=3970
"Tripp Lite" "ups" "3" "SUINT3000RTXL2U" "USB (protocol 4005)" "usbhid-ups" # http://www.tripplite.com/en/products/model.cfm?txtModelID=4523

Expand Down
9 changes: 9 additions & 0 deletions docs/man/tripplitesu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ Set the low battery warning threshold in percent at which shutdown is
initiated by linkman:upsmon[8]. By default, the UPS may not report low battery
until there are only a few seconds left. Common values are around 25--30.

*command_delay*='milliseconds'::
Set a delay in milliseconds to be applied before each command sent to the UPS.
The default value is 0 (disabled). If experiencing intermittent communication
timeouts when multiple commands are sent in rapid succession, set this to
1000 (1 second) or adjust as needed.

This delay helps prevent "read timeout" errors when the hardware buffer is
not ready to accept new commands immediately after completing the previous one.

AUTHOR
------

Expand Down
33 changes: 32 additions & 1 deletion drivers/tripplitesu.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@

The following parameters (ups.conf) are supported:
lowbatt
command_delay

The following variables are supported (RW = read/write):
ambient.humidity (1)
Expand Down Expand Up @@ -126,7 +127,7 @@
#include "nut_stdint.h"

#define DRIVER_NAME "Tripp Lite SmartOnline driver"
#define DRIVER_VERSION "0.11"
#define DRIVER_VERSION "0.12"

/* driver description structure */
upsdrv_info_t upsdrv_info = {
Expand Down Expand Up @@ -163,6 +164,8 @@ static struct {
unsigned long commands_available;
} ups;

static long command_delay = 0; /* delay in milliseconds before each command, 0 = no delay by default */

/* bits in commands_available */
#define WDG_AVAILABLE (1UL << 1)

Expand Down Expand Up @@ -224,6 +227,11 @@ static ssize_t do_command(char type, const char *command, const char *parameters

ser_flush_io(upsfd);

/* Apply configurable delay if enabled (> 0) to prevent communication timeouts */
if (command_delay > 0) {
usleep((useconds_t)command_delay*1000);
}

if (response) {
*response = '\0';
}
Expand Down Expand Up @@ -890,12 +898,35 @@ void upsdrv_tweak_prognames(void)
void upsdrv_makevartable(void)
{
addvar(VAR_VALUE, "lowbatt", "Set low battery level, in percent");
addvar(VAR_VALUE, "command_delay",
"Delay in milliseconds before each command (default: 0 = no delay; "
"set to 1000ms if experiencing communication timeouts)");
}

void upsdrv_initups(void)
{
const char *val;

upsfd = ser_open(device_path);
ser_set_speed(upsfd, device_path, B2400);

/* Initialize command_delay from configuration */
val = getval("command_delay");
if (val) {
long temp = atol(val);
/* 0 (no delay) or positive values */
if (temp < 0) {
fatalx(EXIT_FAILURE, "Invalid command_delay parameter: %s (must be >= 0)", val);
}
command_delay = temp;
if (command_delay == 0) {
upsdebugx(2, "command_delay is explicitly set to 0 (no delay)");
} else {
upsdebugx(2, "Setting command_delay to %ld milliseconds", command_delay);
}
} else {
upsdebugx(2, "Using default command_delay of %ld (no delay)", command_delay);
}
}

void upsdrv_cleanup(void)
Expand Down
Loading