From 4988bcd4181aa8bd363baa8506d17809064ee967 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 10 Oct 2024 22:03:46 +0200 Subject: [PATCH] luci-app-lldpd: Fix mysterious Command failed: Unknown error Executing the following command: ubus call luci.lldpd getStatus always returned 'Command failed: Unknown error', but the underlying lldpcli -f json0 show * worked fine. Fixed with a chained ?.read? Tested on 23.05.3 Signed-off-by: Paul Donald (cherry picked from commit c40253ada3d3e0257e1e3796aeab5ad46bc02f5b) --- .../root/usr/share/rpcd/ucode/luci.lldpd | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/applications/luci-app-lldpd/root/usr/share/rpcd/ucode/luci.lldpd b/applications/luci-app-lldpd/root/usr/share/rpcd/ucode/luci.lldpd index fff7ac55f3..3774e222ce 100644 --- a/applications/luci-app-lldpd/root/usr/share/rpcd/ucode/luci.lldpd +++ b/applications/luci-app-lldpd/root/usr/share/rpcd/ucode/luci.lldpd @@ -3,20 +3,20 @@ import { popen } from 'fs'; function lldpcli_json(section) { - return json(popen(`lldpcli -f json0 show ${section}`, 'r')); + return json(popen(`lldpcli -f json0 show ${section}`, 'r')?.read?.('all')); } -return { - 'luci.lldpd': { - getStatus: { - call: function() { - return { - statistics: lldpcli_json("statistics"), - neighbors: lldpcli_json("neighbors details"), - interfaces: lldpcli_json("interfaces"), - chassis: lldpcli_json("chassis") - }; - } +const methods = { + getStatus: { + call: function() { + return { + statistics: lldpcli_json("statistics"), + neighbors: lldpcli_json("neighbors details"), + interfaces: lldpcli_json("interfaces"), + chassis: lldpcli_json("chassis") + }; } } }; + +return { 'luci.lldpd': methods }; \ No newline at end of file -- 2.30.2