diff options
author | Vic Yang <victoryang@google.com> | 2012-01-04 16:19:21 +0800 |
---|---|---|
committer | Vic Yang <victoryang@chromium.org> | 2012-01-04 16:21:39 +0800 |
commit | 0650392f536fef6cc43259bf0440dde87785215f (patch) | |
tree | 8c22069deacb397179aef2b45709d779d23ae7d8 /util | |
parent | 6fc214c1e3803703289d62be13e887d2b581fa8e (diff) | |
download | chrome-ec-0650392f536fef6cc43259bf0440dde87785215f.tar.gz |
Add ectool option to specify single temp sensor to read data.
Add an option to read temperature from only specified temperature
sensor. With this we can prevent ectool returning error if we already
know a sensor is not connected and do not want ectool to read it.
BUG=none
TEST=ectool temps; ectool temps temp_sensor_ec_internal
Change-Id: I221f1e3390d17f4a3ae99f58eb701a99c7b566b9
Diffstat (limited to 'util')
-rw-r--r-- | util/ectool.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/util/ectool.c b/util/ectool.c index 1446c5b065..e158a9494a 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -35,8 +35,9 @@ const char help_str[] = " Serial output test for COM2\n" " version\n" " Prints EC version\n" - " temps\n" - " Print temperature\n" + " temps [sensorname]\n" + " Print temperature.\n" + " If sensorname is omitted, print temperature from all sensor.\n" " pwmgetfanrpm\n" " Prints current fan RPM\n" " pwmsetfanrpm <targetrpm>\n" @@ -445,7 +446,8 @@ int get_temperature(int sensor_id, const char* name) p.temp_sensor_id = sensor_id; printf("Reading %s...", name); - rv = ec_command(EC_LPC_COMMAND_TEMP_SENSOR_GET_READINGS, &p, sizeof(p), &r, sizeof(r)); + rv = ec_command(EC_LPC_COMMAND_TEMP_SENSOR_GET_READINGS, + &p, sizeof(p), &r, sizeof(r)); if (rv) printf("Error\n"); else @@ -453,12 +455,17 @@ int get_temperature(int sensor_id, const char* name) return rv; } -int cmd_temperature(void) +int cmd_temperature(int argc, char *argv[]) { - int rv1, rv2, rv3; - rv1 = get_temperature(TEMP_SENSOR_CASE, "TEMP_SENSOR_CASE"); - rv2 = get_temperature(TEMP_SENSOR_CASE_DIE, "TEMP_SENSOR_CASE_DIE"); - rv3 = get_temperature(TEMP_SENSOR_EC_INTERNAL, "TEMP_SENSOR_EC_INTERNAL"); + int rv1 = 0, rv2 = 0, rv3 = 0; + if (argc == 0 || strcasecmp(argv[0], "TEMP_SENSOR_CASE") == 0) + rv1 = get_temperature(TEMP_SENSOR_CASE, "TEMP_SENSOR_CASE"); + if (argc == 0 || strcasecmp(argv[0], "TEMP_SENSOR_CASE_DIE") == 0) + rv2 = get_temperature(TEMP_SENSOR_CASE_DIE, + "TEMP_SENSOR_CASE_DIE"); + if (argc == 0 || strcasecmp(argv[0], "TEMP_SENSOR_EC_INTERNAL") == 0) + rv3 = get_temperature(TEMP_SENSOR_EC_INTERNAL, + "TEMP_SENSOR_EC_INTERNAL"); if (rv1 || rv2 || rv3) return -1; return 0; @@ -536,7 +543,7 @@ int main(int argc, char *argv[]) if (!strcasecmp(argv[1], "version")) return cmd_version(); if (!strcasecmp(argv[1], "temps")) - return cmd_temperature(); + return cmd_temperature(argc - 2, argv + 2); if (!strcasecmp(argv[1], "pwmgetfanrpm")) return cmd_pwm_get_fan_rpm(); if (!strcasecmp(argv[1], "pwmsetfanrpm")) |