Ticket #1027: temp_sensor.patch
File temp_sensor.patch, 5.7 KB (added by , 20 years ago) |
---|
-
configure
1792 1792 fi 1793 1793 fi 1794 1794 1795 ######################################### 1796 # lmsensor probe 1797 1798 cat > $TMPC << EOF 1799 #include <sensors/sensors.h> 1800 int main( void ) { return; }; 1801 EOF 1802 1803 lmsensors=no 1804 if $cc $CFLAGS $LDFLAGS -o $TMPE $TMPC -lsensors > /dev/null 2>&1; then 1805 lmsensors=yes 1806 fi 1807 1795 1808 ########################################## 1796 1809 # SDL probe 1797 1810 … … 2442 2455 echo "FREETYPE_CFLAGS=`freetype-config --cflags`" >> $MYTH_CONFIG_MAK 2443 2456 echo "FREETYPE_LIBS=`freetype-config --libs`" >> $MYTH_CONFIG_MAK 2444 2457 fi 2458 if test "$lmsensors" = "yes" ; then 2459 CCONFIG="$CCONFIG using_lmsensors" 2460 echo "#define CONFIG_LMSENSORS 1" >> $TMPH 2461 fi 2445 2462 if test "$sunmlib" = "yes" ; then 2446 2463 echo "HAVE_MLIB=yes" >> $MYTH_CONFIG_MAK 2447 2464 echo "#define HAVE_MLIB 1" >> $TMPH -
programs/mythbackend/mythbackend.pro
24 24 using_dvb:DEFINES += USING_DVB 25 25 26 26 using_valgrind:DEFINES += USING_VALGRIND 27 28 using_lmsensors:LIBS += -lsensors -
programs/mythbackend/mainserver.cpp
45 45 #include "jobqueue.h" 46 46 #include "autoexpire.h" 47 47 #include "previewgenerator.h" 48 #ifdef CONFIG_LMSENSORS 49 #define LMSENSOR_DEFAULT_CONFIG_FILE "/etc/sensors.conf" 50 #include <sensors/sensors.h> 51 #include <sensors/chips.h> 52 #endif 48 53 49 54 /** Milliseconds to wait for an existing thread from 50 55 * process request thread pool. … … 3903 3908 QDomElement mInfo = pDoc->createElement("MachineInfo"); 3904 3909 QDomElement storage = pDoc->createElement("Storage" ); 3905 3910 QDomElement load = pDoc->createElement("Load" ); 3911 QDomElement thermal = pDoc->createElement("Thermal" ); 3906 3912 QDomElement guide = pDoc->createElement("Guide" ); 3907 3913 3908 3914 root.appendChild (mInfo ); … … 3984 3990 load.setAttribute("avg3", rgdAverages[2]); 3985 3991 } 3986 3992 3993 //temperature ----------------- 3994 // Try ACPI first, then lmsensor 2nd 3995 QDir dir("/proc/acpi/thermal_zone"); 3996 QString acpiTempDir; 3997 if (dir.exists()) 3998 { 3999 QStringList lst = dir.entryList(); 4000 QRegExp rxp = QRegExp ("TH?M?", TRUE, FALSE); 4001 QString line, temp; 4002 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it) 4003 { 4004 if ( (*it).contains(rxp)) 4005 { 4006 acpiTempDir = dir.absFilePath(*it); 4007 } 4008 } 4009 4010 QFile acpiTempFile(acpiTempDir.append("/temperature")); 4011 if (acpiTempFile.open(IO_ReadOnly)) 4012 { 4013 QTextStream stream (&acpiTempFile); 4014 line = stream.readLine(); 4015 rxp = QRegExp ("(\\d+)", TRUE, FALSE); 4016 if (rxp.search(line) != -1 ) 4017 { 4018 temp = rxp.cap(1); 4019 temp += " ℃"; // print degress Celsius 4020 mInfo.appendChild(thermal); 4021 thermal.setAttribute("temperature", temp); 4022 } 4023 } 4024 acpiTempFile.close(); 4025 } 4026 #ifdef CONFIG_LMSENSORS 4027 else 4028 { 4029 int chip_nr, a, b; 4030 char *label; 4031 double value; 4032 const sensors_chip_name *chip; 4033 const sensors_feature_data *data; 4034 const char* lmsensorConfigName = LMSENSOR_DEFAULT_CONFIG_FILE; 4035 a = b = 0; 4036 FILE *lmsensorConfigFile = fopen(lmsensorConfigName, "r"); 4037 sensors_init(lmsensorConfigFile); 4038 fclose(lmsensorConfigFile); 4039 free(lmsensorConfigFile); 4040 for (chip_nr = 0 ; (chip = sensors_get_detected_chips(&chip_nr)) ; ) 4041 { 4042 while ((data = sensors_get_all_features(*chip, &a, &b))) 4043 { 4044 if ((!sensors_get_label(*chip, data->number, &label)) && 4045 (!sensors_get_feature(*chip, data->number, &value))) 4046 { 4047 // Find label matching "CPU Temp" or "Temp/CPU" or something close to that 4048 QRegExp rxp = QRegExp ("(CPU.+Temp)|(Temp.+CPU)", FALSE, FALSE); 4049 if (rxp.search(QString(label)) != -1 && value > 0) 4050 { 4051 VERBOSE(VB_IMPORTANT, 4052 QString("Temp debug. Remove before committing: lmsensor temp label %1 value %2") 4053 .arg(label).arg(value)); 4054 QString temp = QString("%1").arg(value); 4055 temp += " ℃"; 4056 mInfo.appendChild(thermal); 4057 thermal.setAttribute("temperature", temp); 4058 } 4059 } 4060 } 4061 } 4062 } 4063 #endif 3987 4064 // Guide Data --------------------- 3988 4065 3989 4066 QDateTime GuideDataThrough; -
programs/mythbackend/httpstatus.cpp
733 733 } 734 734 } 735 735 736 // ACPI temperature ------------------ 737 738 node = info.namedItem( "Thermal" ); 739 740 if (!node.isNull()) 741 { 742 QDomElement e = node.toElement(); 743 744 if (!e.isNull()) 745 { 746 std::string temperature = e.attribute( "temperature" , "0" ); 747 748 os << " Current CPU temperature: " 749 << temperature 750 << ".<br />\r\n"; 751 } 752 } 753 736 754 // Guide Info --------------------- 737 755 738 756 node = info.namedItem( "Guide" );