From 47e455e9e001d48b427bb36892858101ce607d49 Mon Sep 17 00:00:00 2001 From: tcollet Date: Mon, 10 Nov 2025 17:05:03 +0100 Subject: [PATCH 1/2] restart: update command block sequence for the restart is incorrect. Regarding https://datasheet.lcsc.com/lcsc/2412091105_Flex-Power-Modules-BMR4802112-032_C6132194.pdf it is "ERIC" and not "00000000". With this value restart is successfull for BMR456 --- src/mfr_restart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mfr_restart.c b/src/mfr_restart.c index 0ca7c37..db60a5a 100644 --- a/src/mfr_restart.c +++ b/src/mfr_restart.c @@ -5,9 +5,9 @@ int cmd_restart(int fd) { - const char *s = "00000000"; + const char *s = "ERIC"; - if (pmbus_wr_block(fd, MFR_RESTART, (const uint8_t *) s, 8) < 0) { + if (pmbus_wr_block(fd, MFR_RESTART, (const uint8_t *) s, 4) < 0) { perror("MFR_RESTART"); return 1; } From 60ab869a72b97d315658c6530de2d2b291511bae Mon Sep 17 00:00:00 2001 From: tcollet Date: Mon, 10 Nov 2025 17:08:13 +0100 Subject: [PATCH 2/2] Fix providing argument of subcommands. Call to reset optind is done too early and the whole arguments are provided to the subcommands that fails due to the unexpected value. Just move the reset of optind after settings arg/argv for the subcommand. --- src/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index d89c78b..0eb28da 100644 --- a/src/main.c +++ b/src/main.c @@ -99,7 +99,6 @@ main(int argc, char *const *argv) { } const char *cmd = argv[optind++]; - optind = 0; /* reset */ int fd = pmbus_open(opt_bus, opt_addr); if (fd < 0) { @@ -111,6 +110,8 @@ main(int argc, char *const *argv) { int sub_argc = argc - optind; char * const *sub_argv = &argv[optind]; + optind = 0; /* reset */ + if (!strcmp(cmd, "read")) { rc = cmd_read(fd, sub_argc, sub_argv, opt_pretty); goto fini;