aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_raspi.c
diff options
context:
space:
mode:
authorvolker <volker@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2013-03-10 19:43:13 +0000
committervolker <volker@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2013-03-10 19:43:13 +0000
commit09d2a732eaca1b3ce300887d11818685e8aa42d3 (patch)
tree591532e18a322c470f0d13ab2736a98f56390a86 /plugin_raspi.c
parent4dc83784b22be02632cd5785a6ec34a6b7532e0e (diff)
downloadlcd4linux-09d2a732eaca1b3ce300887d11818685e8aa42d3.tar.gz
disable plugin sensors if not found
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1196 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'plugin_raspi.c')
-rw-r--r--plugin_raspi.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/plugin_raspi.c b/plugin_raspi.c
index bd1dea8..c6e7e45 100644
--- a/plugin_raspi.c
+++ b/plugin_raspi.c
@@ -44,6 +44,7 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include <unistd.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>
@@ -53,6 +54,7 @@
#define RASPI_FREQ_PATH "/sys/devices/system/cpu/cpu0/cpufreq/"
#define RASPI_FREQ_VALUE "cpuinfo_cur_freq"
#define RASPI_FREQ_IDFILE "scaling_driver"
+#define RASPI_FREQ_ID "BCM2835 CPUFreq"
#define RASPI_TEMP_PATH "/sys/class/thermal/thermal_zone0/"
#define RASPI_TEMP_VALUE "temp"
#define RASPI_TEMP_IDFILE "type"
@@ -132,15 +134,32 @@ int plugin_init_raspi(void)
{
char checkFile[128];
- AddFunction("raspi::cpufreq", 0, my_cpufreq);
- AddFunction("raspi::cputemp", 0, my_cputemp);
-
snprintf(checkFile, sizeof(checkFile), "%s%s", RASPI_TEMP_PATH, RASPI_TEMP_IDFILE);
if (strncmp( readStr(checkFile), RASPI_TEMP_ID, strlen(RASPI_TEMP_ID) ) != 0) {
error("Warning: no raspberry pi thermal sensor found: value of '%s' is '%s', should be '%s'",
checkFile, readStr(checkFile), RASPI_TEMP_IDFILE);
}
+ snprintf(checkFile, sizeof(checkFile), "%s%s", RASPI_TEMP_PATH, RASPI_TEMP_VALUE);
+ if (0 == access(checkFile, R_OK)) {
+ AddFunction("raspi::cputemp", 0, my_cputemp);
+ } else {
+ error("Error: File '%s' not readable, no temperature sensor found", checkFile);
+ }
+
+ snprintf(checkFile, sizeof(checkFile), "%s%s", RASPI_FREQ_PATH, RASPI_FREQ_IDFILE);
+ if (strncmp( readStr(checkFile), RASPI_FREQ_ID, strlen(RASPI_FREQ_ID) ) != 0) {
+ error("Warning: no raspberry pi frequence sensor found: value of '%s' is '%s', should be '%s'",
+ checkFile, readStr(checkFile), RASPI_FREQ_IDFILE);
+ }
+
+ snprintf(checkFile, sizeof(checkFile), "%s%s", RASPI_FREQ_PATH, RASPI_FREQ_VALUE);
+ if (0 == access(checkFile, R_OK)) {
+ AddFunction("raspi::cpufreq", 0, my_cpufreq);
+ } else {
+ error("Error: File '%s' not readable, no frequency sensor found", checkFile);
+ }
+
return 0;
}