Skip to content

drivers: add experimental APC Microlink serial driver#3406

Open
libschmudie-so wants to merge 13 commits intonetworkupstools:masterfrom
NetCube-Systems-Austria:master
Open

drivers: add experimental APC Microlink serial driver#3406
libschmudie-so wants to merge 13 commits intonetworkupstools:masterfrom
NetCube-Systems-Austria:master

Conversation

@libschmudie-so
Copy link
Copy Markdown

Implement a new apcmicrolink driver for APC Smart-UPS units that expose the Microlink serial protocol over the RJ45 serial interface.

The driver establishes a Microlink session over the serial link, reads and parses the device descriptor blob at runtime, and uses that descriptor map to publish standard NUT variables, writable settings, alarms, and supported instant commands. It also adds labeled Microlink command masks for battery tests, runtime calibration, UPS control, and outlet-group power control, including APC-style load., shutdown., and outlet.group.N.* commands.

The driver now uses the Microlink UPS status word for ups.status, exposes input.transfer.reason from the UPS status change cause enum, and avoids folding simple-signaling bits into the synthesized NUT status. The patch also adds the driver to the build and hardware lists, documents configuration and current limitations, and cleans up initial upstream review issues such as missing file headers, whitespace, and format-string warnings.

Tested against:

APC Smart-UPS 750 (SMT750RMI2UC)

Coding helper disclosure: Codex

General points

  • Described the changes in the PR submission or a separate issue, e.g.
    known published or discovered protocols, applicable hardware (expected
    compatible and actually tested/developed against), limitations, etc.

  • There may be multiple commits in the PR, aligned and commented with
    a functional change. Notably, coding style changes better belong in a
    separate PR, but certainly in a dedicated commit to simplify reviews
    of "real" changes in the other commits. Similarly for typo fixes in
    comments or text documents.

  • Use of coding helper tools and AI should be disclosed in the commit
    or PR comments (it is interesting to know which ones do a decent job).
    As with other contributions, a human is responsible and thanked for the
    quality and content of the change, and is presumed to have the right to
    post that code to be published further under the project's license terms.

  • Please star NUT on GitHub, this helps with sponsorships! ;)

Frequent "underwater rocks" for driver addition/update PRs

  • Revised existing driver families and added a sub-driver if applicable
    (nutdrv_qx, usbhid-ups...) or added a brand new driver in the other
    case.

  • Did not extend obsoleted drivers with new hardware support features
    (notably blazer and other single-device family drivers for Qx protocols,
    except the new nutdrv_qx which should cover them all).

  • For updated existing device drivers, bumped the DRIVER_VERSION macro
    or its equivalent.

  • For USB devices (HID or not), revised that the driver uses unique
    VID/PID combinations, or raised discussions when this is not the case
    (several vendors do use same interface chips for unrelated protocols).

  • For new USB devices, built and committed the changes for the
    scripts/upower/95-upower-hid.hwdb file

  • Proposed NUT data mapping is aligned with existing docs/nut-names.txt
    file. If the device exposes useful data points not listed in the file, the
    experimental.* namespace can be used as documented there, and discussion
    should be raised on the NUT Developers mailing list to standardize the new
    concept.

  • Updated data/driver.list.in if applicable (new tested device info)

Frequent "underwater rocks" for general C code PRs

  • Did not "blindly assume" default integer type sizes and value ranges,
    structure layout and alignment in memory, endianness (layout of bytes and
    bits in memory for multi-byte numeric types), or use of generic int where
    language or libraries dictate the use of size_t (or ssize_t sometimes).

  • Progress and errors are handled with upsdebugx(), upslogx(),
    fatalx() and related methods, not with direct printf() or exit().
    Similarly, NUT helpers are used for error-checked memory allocation and
    string operations (except where customized error handling is needed,
    such as unlocking device ports, etc.)

  • Coding style (including whitespace for indentations) follows precedent
    in the code of the file, and examples/guide in docs/developers.txt file.

  • For newly added files, the Makefile.am recipes were updated and the
    make distcheck target passes.

General documentation updates

  • Added a bullet point into NEWS.adoc, possibly also UPGRADING.adoc
    if there is something packagers or custom-build users should take into
    account (new driver categories, configuration options, dependencies...)

  • Updated docs/acknowledgements.txt (for vendor-backed device support)

  • Added or updated manual page information in docs/man/*.txt files
    and corresponding recipe lists in docs/man/Makefile.am for new pages

  • Passed make spellcheck, updated spell-checking dictionary in the
    docs/nut.dict file if needed (did not remove any words -- the make
    rule printout in case of changes suggests how to maintain it).

Additional work may be needed after posting this PR

  • Propose a PR for NUT DDL with detailed device data dumps from tests
    against real hardware (the more models, the better).

  • Address NUT CI farm build failures for the PR: testing on numerous
    platforms and toolkits can expose issues not seen on just one system.

  • Revise suggestions from LGTM.COM analysis about "new issues" with
    the changed codebase.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 12, 2026

A ZIP file with standard source tarball and another tarball with pre-built docs for commit 1952ef3 is temporarily available: NUT-tarballs-PR-3406.zip.

@AppVeyorBot
Copy link
Copy Markdown

@AppVeyorBot
Copy link
Copy Markdown

@jimklimov
Copy link
Copy Markdown
Member

This looks very solid, thanks!

CI disliked something about dist recipes though; while at it - the man page HTML rendering is not listed in the Makefile.am. I'm on a phone commuting now, so can't look deeper.

@AppVeyorBot
Copy link
Copy Markdown

Implement a new apcmicrolink driver for APC Smart-UPS units that expose the Microlink serial protocol.

The driver establishes a Microlink session over the serial link, reads the device descriptor blob, and uses that runtime descriptor map to publish standard NUT variables, writable settings, status bits, alarms, and supported instant commands.

Add labeled Microlink command masks for battery tests, calibration, UPS control, and outlet-group power control; wire APC-style load and shutdown commands through the static command map; publish input.transfer.reason from UPS status change cause; and stop folding simple-signaling status bits into ups.status. Also hook upsdrv_shutdown() up to the Microlink shutdown request, document the driver, and clean up initial upstream review issues such as missing file headers, whitespace, and format-string warnings.

Signed-off-by: Lukas Schmid <lukas.schmid@netcube.li>
@AppVeyorBot
Copy link
Copy Markdown

@jimklimov jimklimov added this to the 2.8.6 milestone Apr 13, 2026
@jimklimov jimklimov added serial port AI For good or bad, machine tools are upon us. Humans are still the responsible ones. labels Apr 13, 2026
Comment thread drivers/apcmicrolink.c Dismissed
Comment thread drivers/apcmicrolink.c
}

memcpy(descriptor_blob + usage->data_offset, payload, usage->size);
if (page < 256U) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@libschmudie-so : if there is potential for arch-dependent numeric type sizing, check other NUT code for use of pragmas to quiesce the warnings on specific-sized builds. Maybe a symbolic and type-specific max constraint like page <= UCHAR_MAX would be better than a number.

Comment thread drivers/apcmicrolink.c
return microlink_send_descriptor_write(path, payload, usage->size);
}

static int microlink_send_descriptor_typed_value(const microlink_desc_value_map_t *entry,
Comment thread drivers/apcmicrolink.c
return pos;
}

static size_t microlink_parse_descriptor_block(const unsigned char *blob, size_t blob_len,
Comment thread drivers/apcmicrolink.c
Comment on lines +1028 to +1223
switch (entry->type) {
case MLINK_DESC_STRING:
memset(payload, 0, usage->size);
for (i = 0; i < usage->size && val[i] != '\0'; i++) {
payload[i] = (unsigned char)val[i];
}
return microlink_send_descriptor_write(path, payload, usage->size);

case MLINK_DESC_FIXED_POINT:
{
char *endptr = NULL;
int64_t raw;

if (usage->size == 0 || usage->size > 8) {
return 0;
}

if (entry->bin_point == 0U) {
/* strict integer parsing */
long long parsed = strtoll(val, &endptr, 10);

if (endptr == val || *endptr != '\0') {
return 0;
}

raw = (int64_t)parsed;
} else {
/* fixed-point parsing */
double numeric = strtod(val, &endptr);
double scaled;

if (endptr == val || *endptr != '\0') {
return 0;
}

scaled = numeric * (double)(1U << entry->bin_point);
raw = (int64_t)((scaled >= 0.0) ? (scaled + 0.5) : (scaled - 0.5));
}

/* shared range + packing logic */

{
int64_t min_raw, max_raw;

if (entry->sign == MLINK_DESC_SIGNED) {
max_raw = ((int64_t)1 << ((usage->size * 8U) - 1U)) - 1;
min_raw = -((int64_t)1 << ((usage->size * 8U) - 1U));
} else {
min_raw = 0;
max_raw = ((int64_t)1 << (usage->size * 8U)) - 1;
}

if (raw < min_raw || raw > max_raw) {
return 0;
}
}

memset(payload, 0, usage->size);
for (i = 0; i < usage->size; i++) {
size_t shift = (usage->size - 1U - i) * 8U;
payload[i] = (unsigned char)(((uint64_t)raw >> shift) & 0xFFU);
}

return microlink_send_descriptor_write(path, payload, usage->size);
}

case MLINK_DESC_DATE:
{
int year;
int check_year;
unsigned int month, day;
unsigned int check_month, check_day;
int64_t raw;

if (usage->size == 0 || usage->size > 8) {
return 0;
}

if (sscanf(val, "%d-%u-%u", &year, &month, &day) != 3) {
return 0;
}

if (month < 1U || month > 12U || day < 1U || day > 31U) {
return 0;
}

raw = microlink_days_from_civil(year, month, day);
if (raw < 0 || (uint64_t)raw > microlink_max_unsigned_for_size(usage->size)) {
return 0;
}

microlink_civil_from_days(raw, &check_year, &check_month, &check_day);
if (check_year != year || check_month != month || check_day != day) {
return 0;
}

memset(payload, 0, usage->size);
for (i = 0; i < usage->size; i++) {
size_t shift = (usage->size - 1U - i) * 8U;
payload[i] = (unsigned char)(((uint64_t)raw >> shift) & 0xFFU);
}

return microlink_send_descriptor_write(path, payload, usage->size);
}

case MLINK_DESC_TIME:
{
unsigned int hours, minutes, seconds;
uint64_t raw;

if (usage->size == 0 || usage->size > 8) {
return 0;
}

if (sscanf(val, "%u:%u:%u", &hours, &minutes, &seconds) != 3) {
return 0;
}

if (minutes > 59U || seconds > 59U) {
return 0;
}

raw = ((uint64_t)hours * 3600U) + ((uint64_t)minutes * 60U) + (uint64_t)seconds;
if (raw > microlink_max_unsigned_for_size(usage->size)) {
return 0;
}

memset(payload, 0, usage->size);
for (i = 0; i < usage->size; i++) {
size_t shift = (usage->size - 1U - i) * 8U;
payload[i] = (unsigned char)((raw >> shift) & 0xFFU);
}

return microlink_send_descriptor_write(path, payload, usage->size);
}

case MLINK_DESC_ENUM_MAP:
case MLINK_DESC_BITFIELD_MAP:
{
char *endptr = NULL;
int64_t raw = 0;
size_t j;

if (usage->size == 0 || usage->size > 8) {
return 0;
}

if (entry->map != NULL) {
for (j = 0; entry->map[j].text != NULL; j++) {
if (!strcasecmp(entry->map[j].text, val)) {
raw = entry->map[j].value;
break;
}
}

if (entry->map[j].text == NULL) {
if (entry->type == MLINK_DESC_ENUM_MAP) {
raw = (int64_t)strtoll(val, &endptr, 0);
} else {
raw = (int64_t)strtoull(val, &endptr, 0);
}

if (endptr == val || *endptr != '\0') {
return 0;
}
}
}

{
int64_t min_raw, max_raw;

if (entry->type == MLINK_DESC_ENUM_MAP && entry->sign == MLINK_DESC_SIGNED) {
max_raw = ((int64_t)1 << ((usage->size * 8U) - 1U)) - 1;
min_raw = -((int64_t)1 << ((usage->size * 8U) - 1U));
} else {
min_raw = 0;
max_raw = ((int64_t)1 << (usage->size * 8U)) - 1;
}

if (raw < min_raw || raw > max_raw) {
return 0;
}
}

memset(payload, 0, usage->size);
for (i = 0; i < usage->size; i++) {
size_t shift = (usage->size - 1U - i) * 8U;
payload[i] = (unsigned char)(((uint64_t)raw >> shift) & 0xFFU);
}

return microlink_send_descriptor_write(path, payload, usage->size);
}

default:
return 0;
}
Comment thread drivers/apcmicrolink.c
Comment on lines +1399 to +1490
switch (token) {
case 0xF4:
pos = microlink_parse_descriptor_block(blob, blob_len, pos, data_offset, path);
if (pos == 0) {
return 0;
}
break;
case 0xF5:
skip_next = 1;
break;
case 0xF6:
case 0xFF:
return pos;
case 0xF7:
break;
case 0xF8:
{
char child[64];
if (pos >= blob_len) {
return 0;
}
if (!microlink_build_child_path(child, sizeof(child), "", blob[pos++], ":")) {
return 0;
}
pos = microlink_parse_descriptor_block(blob, blob_len, pos, data_offset, child);
if (pos == 0) {
return 0;
}
break;
}
case 0xFE:
{
char child[64];
if (pos >= blob_len) {
return 0;
}
if (!microlink_build_child_path(child, sizeof(child), path, blob[pos++], ".")) {
return 0;
}
pos = microlink_parse_descriptor_block(blob, blob_len, pos, data_offset, child);
if (pos == 0) {
return 0;
}
break;
}
case 0xFD:
{
unsigned char collection_id;
unsigned char count;
size_t block_start;
size_t block_end = 0;
unsigned int idx;

if (pos + 1 >= blob_len) {
return 0;
}

collection_id = blob[pos++];
count = blob[pos++];
block_start = pos;

for (idx = 0; idx < count; idx++) {
char child[64];
size_t sub_pos;

if (!microlink_build_collection_path(child, sizeof(child), path,
collection_id, idx)) {
return 0;
}
sub_pos = microlink_parse_descriptor_block(blob, blob_len, block_start, data_offset, child);
if (sub_pos == 0) {
return 0;
}
block_end = sub_pos;
}

pos = block_end;
break;
}
default:
if (token == 0x00 || microlink_is_descriptor_operator(token) || token > 0xDF) {
return 0;
}

pos = microlink_parse_descriptor_usage(blob, blob_len, pos, data_offset, path,
token, skip_next);
if (pos == 0) {
return 0;
}
skip_next = 0;
break;
}
@jimklimov
Copy link
Copy Markdown
Member

@libschmudie-so : Cheers, your PR is made from your master branch and not with a toggle that I can edit it as a maintainer, so I posted a couple of recipe fixes as PRs into your fork. Hopefully they should get the CI builds passing.

Is this a personal or corporate-backed contribution? Feel free to add a note in acknowledgements.txt in the latter case.

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
docs/man/Makefile.am: provide apsmicrolink.html also [networkupstools#3406]
drivers/Makefile.am: EXTRA_DIST apcmicrolink-maps.h apcmicrolink.h [networkupstools#3406]
NEWS.adoc: introduce apcmicrolink driver [networkupstools#3406]
@AppVeyorBot
Copy link
Copy Markdown

@AppVeyorBot
Copy link
Copy Markdown

@jimklimov
Copy link
Copy Markdown
Member

Yeah, now it is sad about spelling checks. Do you have aspell? Run make spellcheck-interactive-quick and it should arrange an interface to add the new words. Alternately, edit docs/nut.dict to same effect (bumping the number of entries in the top line, in the end):

FAILED : Aspell reported errors here:
----- vvv
600:& apcmicrolink 2 32: apc microlink, apc-microlink
688:& RMI 18 29: RIM, REMI, MRI, EMI, RM, MI, RI, ROM, RUM, RAMIE, RAM, REM, RMS, RBI, RSI, RIME, RAMA, ROME
----- ^^^
make[5]: *** [/home/runner/work/nut/nut/nut-2.8.5.13.7/_build/sub/docs/Makefile:1875: ../NEWS.adoc-spellchecked] Error 1
=====================================================================
FAILED automatic spellcheck for the following sources (relative to /home/runner/work/nut/nut/nut-2.8.5.13.7/_build/sub/docs) using custom dictionary file 'nut.dict':  ../../../docs/../NEWS.adoc
=====================================================================
Please 'cd /home/runner/work/nut/nut/nut-2.8.5.13.7/_build/sub && make spellcheck-interactive'
to either fix document sources or update the dictionary of accepted
words and spellings listed in the 'nut.dict' file there.
Either way, please follow up by posting a pull request or a patch
to integrate your fixes into the common NUT codebase.
=====================================================================
make[4]: *** [Makefile:1955: spellcheck] Error 1
  SUBDIR-MAKE	FAILURE: 'make spellcheck' in docs
make[3]: *** [Makefile:2119: spellcheck/docs] Error 2
  ASPELL	Spell checking on /home/runner/work/nut/nut/nut-2.8.5.13.7/docs/man/apcmicrolink.txt
FAILED : Aspell reported errors here:
----- vvv
70:& APCMICROLINK 2 1: APC MICROLINK, APC-MICROLINK
127:& apcmicrolink 2 1: apc microlink, apc-microlink
205:& apcmicrolink 2 2: apc microlink, apc-microlink
258:& apcmicrolink 2 2: apc microlink, apc-microlink
340:& apcmicrolink 2 2: apc microlink, apc-microlink
420:& apcmicrolink 2 6: apc microlink, apc-microlink
767:& apcmicrolink 2 14: apc microlink, apc-microlink
857:& showinternals 32 2: show internals, show-internals, internals, internalise, swindlers, centennials, internalize, sentinels, swindler's, bicentennials, fontanels, centennial's, vintners, swindles, Shantung's, shantung's, sentinel's, vintner's, swindle's, windfalls, wantons, tercentennials, bicentennial's, fontanel's, wanton's, wantonly, windlass, Chinatown's, winding's, windfall's, tercentennial's, Wendell's
1324:& showunmapped 9 2: show unmapped, show-unmapped, unmapped, swamped, shrimped, chomped, shampooed, wimped, champed
1628:& testinterval 6 12: test interval, test-interval, distinctively, distantly, distasteful, distastefully
1842:& Lukas 55 3: Lucas, Lucks, Lurks, Leaks, Luke's, Likes, Luck's, Lugs, Lakes, Lug's, Luges, Licks, Lula's, Lags, Lucas's, Lick's, Like's, Luaus, Lurkers, Ukase, Las, Luisa, Lacks, Larks, Leeks, Locks, Looks, Leak's, Skuas, Luna's, Lax, Lux, Loki's, Lu's, Luca, Luis, Luke, Lack's, Lake's, Lark's, Leas, Leek's, Lock's, Look's, UK's, LG's, Flukes, Lac's, Lag's, La's, Lusaka's, Lanka's, Luau's, Lea's, Fluke's
2251:& Schmid 12 9: Schmidt, Sch mid, Sch-mid, Chmod, Schmo, Schmier, Schemed, Schmo's, Schist, Chimed, Shamed, Schizoid
----- ^^^
make[6]: *** [/home/runner/work/nut/nut/nut-2.8.5.13.7/_build/sub/docs/Makefile:1875: apcmicrolink.txt-spellchecked] Error 1

@jimklimov
Copy link
Copy Markdown
Member

jimklimov commented Apr 13, 2026

There are also compiler complaints from static analysis, like:

apcmicrolink.c:335:49: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
  335 |         written = vsnprintf(buf + *pos, buflen - *pos, fmt, ap);
      |                                                        ^~~
apcmicrolink.c:453:25: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
  453 |                 snprintf(out, outlen, templ, rendered_index);
      |                                       ^~~~~
apcmicrolink.c:1028:10: error: enumeration value 'MLINK_DESC_NONE' not explicitly handled in switch [-Werror,-Wswitch-enum]
 1028 |         switch (entry->type) {
      |                 ^~~~~~~~~~~
apcmicrolink.c:1280:12: error: enumeration value 'MLINK_DESC_NONE' not explicitly handled in switch [-Werror,-Wswitch-enum]
 1280 |                         switch (entry->type) {
      |                                 ^~~~~~~~~~~
apcmicrolink.c:1999:11: error: enumeration value 'MLINK_DESC_WRITE_NONE' not explicitly handled in switch [-Werror,-Wswitch-enum]
 1999 |                 switch (entry->write_type) {
      |                         ^~~~~~~~~~~~~~~~~
5 errors generated.

For the switch, they have two conflicting requirements ("must have a default", and "do not need a default when all possible enum values were listed"), so we use a copy-paste block of pragmas to quiesce that. So list all enum values where needed, and add a default: surrounded by those pragmas, many examples in code for that. Probably the case for value(s) you did not list yet go just above that default line :)

For the formatting string, see {v,}snprintf_dynamic() etc. which validate that the actual fmt_dynamic formatting string you used matches the percent-argument template (which to compiler corresponds to the varargs passed to this fmt_reference parameter as if it were the formatting string). OTOH, something like snprintf_dynamic(out, outlen, templ, "%i", rendered_index); would be the fix.

@AppVeyorBot
Copy link
Copy Markdown

@AppVeyorBot
Copy link
Copy Markdown

libschmudie-so and others added 3 commits April 13, 2026 19:38
Signed-off-by: Lukas Schmid <lukas.schmid@netcube.li>
Signed-off-by: Lukas Schmid <lukas.schmid@netcube.li>
@libschmudie-so
Copy link
Copy Markdown
Author

How should I go about this?

apcmicrolink.c:335:49: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
  335 |         written = vsnprintf(buf + *pos, buflen - *pos, fmt, ap);
      |                                                        ^~~

fmt comes from the functions arguments and is always fixed like

microlink_path_append(buf, buflen, &pos, "%s", path)

Signed-off-by: Lukas Schmid <lukas.schmid@netcube.li>
@jimklimov
Copy link
Copy Markdown
Member

See connent above, the part about *printf_dynamic methods:)

@libschmudie-so
Copy link
Copy Markdown
Author

So i should just pass fmt twice into the _dynamic version? That semt counter-intuitive to me, that's why I am checking

@AppVeyorBot
Copy link
Copy Markdown

Build nut 2.8.5.4548-master completed (commit 17bc6789c6 by @libschmudie-so)

@AppVeyorBot
Copy link
Copy Markdown

Build nut 2.8.5.4549-master completed (commit 85cb70d261 by @libschmudie-so)

@jimklimov
Copy link
Copy Markdown
Member

jimklimov commented Apr 13, 2026

Yes, it is usually that the first "real" format is a sentence with a few percent-values, maybe dynamically constructed in a buffer or taken from some array/map, and the other is a string just with those percents, static the way compiler checks like.

Comment thread drivers/apcmicrolink.c
return 1;
}

static void microlink_publish_descriptor_exports(void)
@EchterAgo
Copy link
Copy Markdown
Contributor

Might be interesting if we could combine some things with the apc_modbus driver, it seems many of the bitfields are the same, we should probably do some consistency checks for the commands and variables.

Example output for 2 of my UPS:

battery.charge: 100.00
battery.date: 2025-07-15
battery.date.maintenance: 2030-01-13
battery.runtime: 1439
battery.temperature: 35.45
battery.voltage: 132.03
device.mfr: American Power Conversion
device.model: Smart-UPS X 2200
device.serial: AS1623536106
device.type: ups
driver.debug: 0
driver.flag.allow_killpower: 0
driver.name: apc_modbus
driver.parameter.pollinterval: 2
driver.parameter.port: 192.168.0.102:502
driver.parameter.porttype: tcp
driver.parameter.synchronous: auto
driver.state: quiet
driver.version: 2.8.5.103.9-112+gcff17f596
driver.version.internal: 0.20
driver.version.usb: libusb-1.0.29 (API: 0x0100010B)
experimental.output.energy: 3918024
experimental.ups.calibration.result: Passed, Source: Protocol
experimental.ups.mode.buzzwords: vendor:apc:HE
input.transfer.high: 265
input.transfer.low: 195
input.transfer.reason: AcceptableInput
input.voltage: 230.97
outlet.group.1.delay.reboot: 8
outlet.group.1.delay.shutdown: 90
outlet.group.1.delay.start: 0
outlet.group.1.designator: Group 1
outlet.group.1.id: SOG0
outlet.group.1.name: Outlet Group 1
outlet.group.1.status: on
outlet.group.1.timer.reboot: NotActive
outlet.group.1.timer.shutdown: NotActive
outlet.group.1.timer.start: NotActive
outlet.group.2.delay.reboot: 8
outlet.group.2.delay.shutdown: 90
outlet.group.2.delay.start: 0
outlet.group.2.designator: Group 2
outlet.group.2.id: SOG1
outlet.group.2.name: Outlet Group 2
outlet.group.2.status: on
outlet.group.2.timer.reboot: NotActive
outlet.group.2.timer.shutdown: NotActive
outlet.group.2.timer.start: NotActive
outlet.group.3.delay.reboot: 8
outlet.group.3.delay.shutdown: 90
outlet.group.3.delay.start: 0
outlet.group.3.designator: Group 3
outlet.group.3.id: SOG2
outlet.group.3.name: Outlet Group 3
outlet.group.3.status: on
outlet.group.3.timer.reboot: NotActive
outlet.group.3.timer.shutdown: NotActive
outlet.group.3.timer.start: NotActive
outlet.group.count: 3
output.current: 2.81
output.frequency: 50.00
output.voltage: 230.97
ups.delay.reboot: 0
ups.delay.shutdown: 0
ups.delay.start: 0
ups.efficiency: 95.1
ups.firmware: UPS 15.0
ups.id: Rack UPS
ups.load: 30.96
ups.mfr: American Power Conversion
ups.mfr.date: 2016-06-12
ups.model: Smart-UPS X 2200
ups.power: 652.09
ups.power.nominal: 2200
ups.realpower: 612.95
ups.realpower.nominal: 1980
ups.serial: A----------6
ups.status: OL
ups.test.result: Passed, Source: Internal
ups.timer.reboot: CountdownExpired
ups.timer.shutdown: CountdownExpired
ups.timer.start: CountdownExpired
battery.charge: 0.00
battery.date: 2021-02-15
battery.date.maintenance: 2025-08-15
battery.runtime: 0
battery.temperature: 28.80
battery.voltage: 27.12
device.mfr: American Power Conversion
device.model: Smart-UPS 1500
device.serial: 3S1545X03212
device.type: ups
driver.debug: 0
driver.flag.allow_killpower: 0
driver.name: apc_modbus
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.porttype: usb
driver.parameter.synchronous: auto
driver.parameter.vendorid: 051d
driver.state: quiet
driver.version: 2.8.5.103.9-112+gcff17f596
driver.version.internal: 0.20
driver.version.usb: libusb-1.0.29 (API: 0x0100010B)
experimental.output.energy: 9301103
experimental.ups.calibration.result: 
input.transfer.high: 253
input.transfer.low: 207
input.transfer.reason: SystemInitialization
input.voltage: 230.39
outlet.group.0.delay.reboot: 8
outlet.group.0.delay.shutdown: 0
outlet.group.0.delay.start: 0
outlet.group.0.designator: Main
outlet.group.0.id: MOG
outlet.group.0.name: UPS Outlets
outlet.group.0.status: off
outlet.group.1.delay.reboot: 8
outlet.group.1.delay.shutdown: 90
outlet.group.1.delay.start: 0
outlet.group.1.designator: Group 1
outlet.group.1.id: SOG0
outlet.group.1.name: Outlet Group 1
outlet.group.1.status: off
outlet.group.1.timer.reboot: NotActive
outlet.group.1.timer.shutdown: NotActive
outlet.group.1.timer.start: NotActive
outlet.group.count: 2
output.current: 0.00
output.frequency: 0.00
output.voltage: 0.00
ups.alarm: Battery system - Disconnected
ups.delay.reboot: 8
ups.delay.shutdown: 0
ups.delay.start: 0
ups.efficiency: OutputOff
ups.firmware: UPS 15.1
ups.id: APCUPS
ups.load: 0.00
ups.mfr: American Power Conversion
ups.mfr.date: 2015-11-06
ups.model: Smart-UPS 1500
ups.power: 0.00
ups.power.nominal: 1500
ups.productid: 0003
ups.realpower: 0.00
ups.realpower.nominal: 1000
ups.serial: 3----------2
ups.status: ALARM OFF
ups.test.result: 
ups.timer.reboot: NotActive
ups.timer.shutdown: NotActive
ups.timer.start: NotActive
ups.vendorid: 051d

@jimklimov
Copy link
Copy Markdown
Member

jimklimov commented Apr 14, 2026

apcmicrolink.c:81:44: error: missing field 'count' initializer [-Werror,-Wmissing-field-initializers]
static microlink_page0_state_t page0 = { 0 };
                                           ^
apcmicrolink.c:1896:39: error: missing field 'count' initializer [-Werror,-Wmissing-field-initializers]
        page0 = (microlink_page0_state_t){ 0 };
                                             ^
apcmicrolink.c:2109:39: error: missing field 'count' initializer [-Werror,-Wmissing-field-initializers]
        page0 = (microlink_page0_state_t){ 0 };
                                             ^
3 errors generated.
make[2]: *** [apcmicrolink.o] Error 1

Portability trouble. For the static part, zero-mem for at least simple structs is implied by C standard. For subsequent assignments, memset to 0?

Signed-off-by: Lukas Schmid <lukas.schmid@netcube.li>
@libschmudie-so
Copy link
Copy Markdown
Author

libschmudie-so commented Apr 14, 2026

@EchterAgo I've had a look and it seems microlink has more bits (or maybe they are just not documented for modbus). Do you think that maybe the CMD defines could be used as a common point between microlink and modbus?

I'll definitely have a go at changing my info names to match yours.

…mmands and values

Signed-off-by: Lukas Schmid <lukas.schmid@netcube.li>
@AppVeyorBot
Copy link
Copy Markdown

Build nut 2.8.5.4577-master completed (commit 540502e992 by @libschmudie-so)

@AppVeyorBot
Copy link
Copy Markdown

Build nut 2.8.5.4579-master completed (commit 4b9a1d92cf by @libschmudie-so)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI For good or bad, machine tools are upon us. Humans are still the responsible ones. APC feature serial port

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

5 participants