summaryrefslogtreecommitdiffstats
path: root/commands/hwmon.c
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2016-05-16 09:45:57 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2016-05-18 07:47:51 +0200
commit04624274360a345ef3e4ce89d5553115d49bfd8f (patch)
treec80ce8b6477e980fb81049c05232e7451d24534f /commands/hwmon.c
parent914480a542aabd56ba5220afe0e234fd8213411e (diff)
downloadbarebox-04624274360a345ef3e4ce89d5553115d49bfd8f.tar.gz
commands: Add 'hwmon' command
Add 'hwmon' command which allows to display the readings of all hardware monitoring sensors registered with Barebox. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/hwmon.c')
-rw-r--r--commands/hwmon.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/commands/hwmon.c b/commands/hwmon.c
new file mode 100644
index 0000000..ace4503
--- /dev/null
+++ b/commands/hwmon.c
@@ -0,0 +1,35 @@
+#include <common.h>
+#include <command.h>
+#include <getopt.h>
+#include <linux/err.h>
+#include <linux/ctype.h>
+#include <string.h>
+#include <environment.h>
+#include <aiodev.h>
+
+static int do_hwmon(int argc, char *argv[])
+{
+ int i;
+ struct aiodevice *aiodev;
+
+ for_each_aiodevice(aiodev) {
+ for (i = 0; i < aiodev->num_channels; i++) {
+ struct aiochannel *chan = aiodev->channels[i];
+ int value;
+ int ret = aiochannel_get_value(chan, &value);
+
+ if (!ret)
+ printf("%s: %d %s\n", chan->name, value, chan->unit);
+ else
+ printf("%s: failed to read (%d)\n", chan->name, ret);
+ }
+ }
+
+ return 0;
+}
+
+BAREBOX_CMD_START(hwmon)
+ .cmd = do_hwmon,
+ BAREBOX_CMD_DESC("query hardware sensors (HWMON)")
+ BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
+BAREBOX_CMD_END