Skip to content

Commit

Permalink
more Extech integration
Browse files Browse the repository at this point in the history
  • Loading branch information
fenrus75 committed Apr 27, 2011
1 parent e0b2b59 commit a051925
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
14 changes: 14 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,17 @@ Specifically PowerTOP contains code from
nl80211 userspace tool - Copyright 2007, 2008 Johannes Berg <johannes@sipsolutions.net>




Extech Power Analyzer / Datalogger support
------------------------------------------
I use, and our analysis teams use, the Extech Power Analyzer/Datalogger
(model number 380803) quite a lot, and PowerTOP supports using this
device over the serial cable. Just pass the device node on the command line
like this

powertop --extech=/dev/ttyUSB0

(where ttyUSB0 is the devicenode of the serial-to-usb adapter on my system)


5 changes: 5 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ static const struct option long_options[] =
{"help",no_argument, NULL, 'u'}, /* u for usage */
{"calibrate",no_argument, NULL, 'c'},
{"html", optional_argument, NULL, 'h'},
{"extech", optional_argument, NULL, 'e'},
{NULL, 0, NULL, 0}
};

Expand All @@ -79,6 +80,7 @@ static void print_usage()
printf(_("--debug \t run in \"debug\" mode\n"));
printf(_("--version \t print version information\n"));
printf(_("--calibrate \t runs powertop in calibration mode\n"));
printf(_("--extech=devnode \t uses an Extech Power Analyzer for measurements\n"));
printf(_("--html[=FILENAME]\t\t generate a html report\n"));
printf(_("--help \t\t print this help menu\n"));
printf("\n");
Expand Down Expand Up @@ -245,6 +247,9 @@ int main(int argc, char **argv)
exit(0);
break;

case 'e': /* Extech power analyzer support */
extech_power_meter(optarg ? optarg : "/dev/ttyUSB0");
break;
case 'u':
print_usage();
exit(0);
Expand Down
20 changes: 12 additions & 8 deletions measurement/measurement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,6 @@ void detect_power_meters(void)
DIR *dir;
struct dirent *entry;

if (0) {
class extech_power_meter *meter;

meter = new class extech_power_meter("/dev/ttyUSB0");

power_meters.push_back(meter);
}

dir = opendir("/proc/acpi/battery");
if (!dir)
return;
Expand All @@ -136,3 +128,15 @@ void detect_power_meters(void)
closedir(dir);

}

void extech_power_meter(const char *devnode)
{
DIR *dir;
struct dirent *entry;

class extech_power_meter *meter;

meter = new class extech_power_meter(devnode);

power_meters.push_back(meter);
}
2 changes: 2 additions & 0 deletions measurement/measurement.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ extern double global_joules_consumed(void);
extern double global_time_left(void);

extern void detect_power_meters(void);
extern void extech_power_meter(const char *devnode);


extern double min_power;

Expand Down

0 comments on commit a051925

Please sign in to comment.