Skip to content

Commit 9266b35

Browse files
authored
Merge 0c8c032 into 8916ac8
2 parents 8916ac8 + 0c8c032 commit 9266b35

4 files changed

Lines changed: 31 additions & 24 deletions

File tree

NEWS.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ https://github.com/networkupstools/nut/milestone/9
168168
* Added APC BVKxxxM2 to list of devices where `lbrb_log_delay_sec=N` may be
169169
necessary to address spurious LOWBATT and REPLACEBATT events. [#2942]
170170

171+
- `pijuice` driver updates:
172+
* Converted to NUT standard use of `status_set()` with single-token values.
173+
[issue #2708]
174+
171175
- `apc_modbus` driver updates:
172176
* The time stamp and inter-frame delay accounting was fixed, alleviating
173177
one of the problems reported in issue #2609. [PR #2982]

docs/packager-guide.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ Overview of the package tree
168168
FIXME: make a dependency graph
169169

170170
- <<pkg-nut,nut>>
171+
- <<pkg-nut-common,nut-common>>
171172
- <<pkg-libupsclient1,libupsclient1>>
172173
- <<pkg-libupsclient1-dev,libupsclient1-dev>>
173174
- <<pkg-nut-cgi,nut-cgi>>
@@ -212,6 +213,16 @@ name may vary across the various systems.
212213
discussion.
213214
========================================================================
214215

216+
[[pkg-nut-common]]
217+
nut
218+
^^^
219+
- Desc:
220+
- Files: install scripts to register user/group accounts in the OS;
221+
shared data and configuration files (e.g. systemd-tmpfiles, maybe
222+
systemd-presets, in case of Linux packaging)
223+
- Size:
224+
- Deps:
225+
215226
[[pkg-nut]]
216227
nut
217228
^^^

drivers/pijuice.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "nut_stdint.h"
2424

2525
#define DRIVER_NAME "PiJuice UPS driver"
26-
#define DRIVER_VERSION "0.14"
26+
#define DRIVER_VERSION "0.15"
2727

2828
/*
2929
* Linux I2C userland is a bit of a mess until distros refresh to
@@ -340,12 +340,9 @@ static void get_charge_level_hi_res(void)
340340
static void get_status(void)
341341
{
342342
uint8_t cmd = STATUS_CMD, data, batteryStatus, powerInput, powerInput5vIo;
343-
char status_buf[ST_MAX_VALUE_LEN];
344343

345344
upsdebugx( 3, __func__ );
346345

347-
memset( status_buf, 0, ST_MAX_VALUE_LEN );
348-
349346
I2C_READ_BYTE( upsfd, cmd, __func__ )
350347

351348
batteryStatus = data >> 2 & 0x03;
@@ -422,17 +419,17 @@ static void get_status(void)
422419
if ( battery_charge_level <= LOW_BATTERY_THRESHOLD )
423420
{
424421
upsdebugx( 1, "Battery Charge Status: LOW" );
425-
snprintfcat( status_buf, ST_MAX_VALUE_LEN, "LB " );
422+
status_set("LB");
426423
}
427424
else if ( battery_charge_level > HIGH_BATTERY_THRESHOLD )
428425
{
429426
upsdebugx( 1, "Battery Charge Status: HIGH" );
430-
snprintfcat( status_buf, ST_MAX_VALUE_LEN, "HB " );
427+
status_set("HB");
431428
}
432429
}
433430
else if ( batteryStatus == BATT_NOT_PRESENT )
434431
{
435-
snprintfcat( status_buf, ST_MAX_VALUE_LEN, "RB " );
432+
status_set("RB");
436433
}
437434

438435
if ( batteryStatus <= BATT_NOT_PRESENT &&
@@ -451,10 +448,10 @@ static void get_status(void)
451448
battery_power = 0;
452449
upsdebugx( 1, "On USB power [%d:%d:%d]", usb_power, gpio_power, battery_power );
453450

454-
snprintfcat( status_buf, sizeof(status_buf), "OL" );
451+
status_set("OL");
455452
if ( batteryStatus == BATT_CHARGING_FROM_5V )
456453
{
457-
snprintfcat( status_buf, sizeof( status_buf ), " CHRG" );
454+
status_set("CHRG");
458455
upsdebugx( 1, "Battery Charger Status: charging" );
459456
dstate_setinfo( "battery.charger.status", "%s", "charging" );
460457
}
@@ -463,7 +460,6 @@ static void get_status(void)
463460
upsdebugx( 1, "Battery Charger Status: resting" );
464461
dstate_setinfo( "battery.charger.status", "%s", "resting" );
465462
}
466-
status_set( status_buf );
467463
}
468464
else if ( powerInput5vIo == POWER_NOT_PRESENT &&
469465
( powerInput != POWER_NOT_PRESENT &&
@@ -478,17 +474,15 @@ static void get_status(void)
478474
battery_power = 0;
479475
upsdebugx( 1, "On 5V_GPIO power [%d:%d:%d]", usb_power, gpio_power, battery_power );
480476

481-
snprintfcat( status_buf, sizeof(status_buf), "OL" );
477+
status_set("OL");
482478
if ( batteryStatus == BATT_CHARGING_FROM_IN )
483479
{
484-
snprintfcat( status_buf, sizeof(status_buf), " CHRG" );
485-
status_set( status_buf );
480+
status_set("CHRG");
486481
upsdebugx( 1, "Battery Charger Status: charging" );
487482
dstate_setinfo( "battery.charger.status", "%s", "charging" );
488483
}
489484
else if ( batteryStatus == BATT_NORMAL )
490485
{
491-
status_set( status_buf );
492486
upsdebugx( 1, "Battery Charger Status: resting" );
493487
dstate_setinfo( "battery.charger.status", "%s", "resting" );
494488
}
@@ -505,17 +499,15 @@ static void get_status(void)
505499
battery_power = 0;
506500
upsdebugx( 1, "On USB and 5V_GPIO power [%d:%d:%d]", usb_power, gpio_power, battery_power );
507501

508-
snprintfcat( status_buf, sizeof( status_buf ), "OL" );
502+
status_set("OL");
509503
if ( batteryStatus == BATT_CHARGING_FROM_IN )
510504
{
511-
snprintfcat( status_buf, sizeof(status_buf), " CHRG");
512-
status_set( status_buf );
505+
status_set("CHRG");
513506
upsdebugx( 1, "Battery Charger Status: charging" );
514507
dstate_setinfo("battery.charger.status", "%s", "charging");
515508
}
516509
else if ( batteryStatus == BATT_NORMAL )
517510
{
518-
status_set( status_buf );
519511
upsdebugx( 1, "Battery Charger Status: resting" );
520512
dstate_setinfo( "battery.charger.status", "%s", "resting" );
521513
}
@@ -531,8 +523,8 @@ static void get_status(void)
531523
battery_power = 1;
532524
upsdebugx( 1, "On Battery power [%d:%d:%d]", usb_power, gpio_power, battery_power );
533525

534-
snprintfcat( status_buf, sizeof(status_buf), "OB DISCHRG" );
535-
status_set( status_buf );
526+
status_set("OB");
527+
status_set("DISCHRG");
536528
}
537529
}
538530
}

drivers/powervar_cx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ void PvarCommon_Updateinfo (void)
975975
{
976976
if ((byOnBat) && (SubString[0] == '3'))
977977
{
978-
status_set ("LB");
978+
status_set("LB");
979979
}
980980
}
981981

@@ -1062,7 +1062,7 @@ void PvarCommon_Updateinfo (void)
10621062
{
10631063
if (SubString[0] == '1')
10641064
{
1065-
status_set ("RB");
1065+
status_set("RB");
10661066
}
10671067
}
10681068

@@ -1071,7 +1071,7 @@ void PvarCommon_Updateinfo (void)
10711071
{
10721072
if (SubString[0] == '1')
10731073
{
1074-
status_set ("OVER");
1074+
status_set("OVER");
10751075
}
10761076
}
10771077

@@ -1082,7 +1082,7 @@ void PvarCommon_Updateinfo (void)
10821082
if (SubString[0] == '1')
10831083
{
10841084
dstate_setinfo("ups.test.result", "Change Battery");
1085-
status_set ("RB");
1085+
status_set("RB");
10861086
}
10871087
else
10881088
{

0 commit comments

Comments
 (0)