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>
This commit is contained in:
parent
914480a542
commit
0462427436
|
@ -1807,6 +1807,14 @@ config CMD_HWCLOCK
|
||||||
help
|
help
|
||||||
The hwclock command allows to query or set the hardware clock (RTC).
|
The hwclock command allows to query or set the hardware clock (RTC).
|
||||||
|
|
||||||
|
config CMD_HWMON
|
||||||
|
bool
|
||||||
|
depends on AIODEV
|
||||||
|
prompt "hwmon command"
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
The hwmon command allows to query hardware sensors.
|
||||||
|
|
||||||
config CMD_I2C
|
config CMD_I2C
|
||||||
bool
|
bool
|
||||||
depends on I2C
|
depends on I2C
|
||||||
|
|
|
@ -106,6 +106,7 @@ obj-$(CONFIG_CMD_REGULATOR) += regulator.o
|
||||||
obj-$(CONFIG_CMD_LSPCI) += lspci.o
|
obj-$(CONFIG_CMD_LSPCI) += lspci.o
|
||||||
obj-$(CONFIG_CMD_IMD) += imd.o
|
obj-$(CONFIG_CMD_IMD) += imd.o
|
||||||
obj-$(CONFIG_CMD_HWCLOCK) += hwclock.o
|
obj-$(CONFIG_CMD_HWCLOCK) += hwclock.o
|
||||||
|
obj-$(CONFIG_CMD_HWMON) += hwmon.o
|
||||||
obj-$(CONFIG_CMD_USBGADGET) += usbgadget.o
|
obj-$(CONFIG_CMD_USBGADGET) += usbgadget.o
|
||||||
obj-$(CONFIG_CMD_FIRMWARELOAD) += firmwareload.o
|
obj-$(CONFIG_CMD_FIRMWARELOAD) += firmwareload.o
|
||||||
obj-$(CONFIG_CMD_CMP) += cmp.o
|
obj-$(CONFIG_CMD_CMP) += cmp.o
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue