diff options
-rw-r--r-- | argparse.c | 6 | ||||
-rw-r--r-- | cputemp2maxfreq.c | 6 | ||||
-rw-r--r-- | cputemp2maxfreq.h | 1 |
3 files changed, 12 insertions, 1 deletions
@@ -23,6 +23,7 @@ void printhelp() " Default: %s\n" "-l <logger> Logger to use, valid values: none, kmsg, stdout, syslog\n" " Default: %s\n" + "-m Log measurements (CPU temperature and frequency)\n" "-p <time> Poll interval in seconds\n" " Default: %d\n" "-s <step> Step size in Khz when increasing/decreasing CPU speed\n" @@ -45,7 +46,7 @@ void argparse(int argc, char **argv) memcpy(&userconfig,&config,sizeof(struct s_config)); // Parse options - while((opt=getopt(argc,argv,"f:g:hi:l:p:s:t:"))!=-1) + while((opt=getopt(argc,argv,"f:g:hi:l:mp:s:t:"))!=-1) { DEBUG1_ARGPARSE("Argument: %c Value: %s\n",opt,optarg); switch(opt) @@ -65,6 +66,9 @@ void argparse(int argc, char **argv) case 'l': strncpy(userconfig.logger_name,optarg,sizeof(userconfig.logger_name)); break; + case 'm': + userconfig.log_data=1; + break; case 'p': userconfig.interval=strtoll(optarg,NULL,10); break; diff --git a/cputemp2maxfreq.c b/cputemp2maxfreq.c index 88d9a5d..dd58e16 100644 --- a/cputemp2maxfreq.c +++ b/cputemp2maxfreq.c @@ -23,6 +23,7 @@ struct s_config config={ 10, // Interval "stdout", // Logger name &logger_stdout, // Logger function + 0, // Don't log measurement data }; struct s_cpudata cpudata; @@ -49,6 +50,7 @@ int main(int argc,char **argv) config.logger("Fallback frquency: %ld",config.fallback_freq); config.logger("Interval: %d",config.interval); config.logger("Logger: %s (%p)",config.logger_name,config.logger); + config.logger("Log measurement data: %d",config.log_data); if ((config.max_temp<VALID_TEMP_MIN) || (config.max_temp>VALID_TEMP_MAX)) { @@ -134,6 +136,10 @@ int main(int argc,char **argv) } DEBUG1_MAIN("Data: %ld %ld %ld %ld %ld\n",cpudata.cur_temp,config.max_temp,cpudata.max_freq,cpudata.scale_max,cpudata.cur_freq); + if (config.log_data>0) + { + config.logger("CPU Temperature: %ld, CPU Frequency: %ld",cpudata.cur_temp/1000,cpudata.cur_freq); + } // Check if we should increase if ((cpudata.cur_temp<config.max_temp) && (cpudata.scale_max<cpudata.max_freq)) diff --git a/cputemp2maxfreq.h b/cputemp2maxfreq.h index cda9d4b..0e4c424 100644 --- a/cputemp2maxfreq.h +++ b/cputemp2maxfreq.h @@ -34,6 +34,7 @@ struct s_config { unsigned int interval; // Time interval to check CPU temperature char logger_name[10]; // Name of the logging function void (*logger)(char *,...); // Pointer to the logging function + char log_data; // Option to log measurement data }; #endif |