summaryrefslogtreecommitdiffstats
path: root/commands/hwmon.c
diff options
context:
space:
mode:
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 0000000000..ace4503c0b
--- /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