Ticket #1027: updated_temp_sensor.patch
File updated_temp_sensor.patch, 5.8 KB (added by , 18 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 bool found_acpi = false; 3997 if (dir.exists()) 3998 { 3999 QString acpiTempDir; 4000 QStringList lst = dir.entryList(); 4001 QRegExp rxp = QRegExp ("TH?M?", TRUE, FALSE); 4002 QString line, temp; 4003 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it) 4004 { 4005 if ( (*it).contains(rxp)) 4006 { 4007 acpiTempDir = dir.absFilePath(*it); 4008 } 4009 } 4010 4011 QFile acpiTempFile(acpiTempDir.append("/temperature")); 4012 if (acpiTempFile.open(IO_ReadOnly)) 4013 { 4014 QTextStream stream (&acpiTempFile); 4015 line = stream.readLine(); 4016 rxp = QRegExp ("(\\d+)", TRUE, FALSE); 4017 if (rxp.search(line) != -1 ) 4018 { 4019 temp = rxp.cap(1); 4020 temp += " ℃"; // print degress Celsius 4021 mInfo.appendChild(thermal); 4022 thermal.setAttribute("temperature", temp); 4023 found_acpi = true; 4024 } 4025 } 4026 acpiTempFile.close(); 4027 } 4028 #ifdef CONFIG_LMSENSORS 4029 if (!found_acpi) 4030 { 4031 int chip_nr, a, b; 4032 char *label; 4033 double value; 4034 const sensors_chip_name *chip; 4035 const sensors_feature_data *data; 4036 const char* lmsensorConfigName = LMSENSOR_DEFAULT_CONFIG_FILE; 4037 a = b = 0; 4038 FILE *lmsensorConfigFile = fopen(lmsensorConfigName, "r"); 4039 sensors_init(lmsensorConfigFile); 4040 fclose(lmsensorConfigFile); 4041 for (chip_nr = 0 ; (chip = sensors_get_detected_chips(&chip_nr)) ; ) 4042 { 4043 while ((data = sensors_get_all_features(*chip, &a, &b))) 4044 { 4045 if ((!sensors_get_label(*chip, data->number, &label)) && 4046 (!sensors_get_feature(*chip, data->number, &value))) 4047 { 4048 // Find label matching "CPU Temp" or "Temp/CPU" or something close to that 4049 QRegExp rxp = QRegExp ("(CPU.+Temp)|(Temp.+CPU)", FALSE, FALSE); 4050 if (rxp.search(QString(label)) != -1 && value > 0) 4051 { 4052 VERBOSE(VB_IMPORTANT, 4053 QString("Temp debug. Remove before committing: lmsensor temp label %1 value %2") 4054 .arg(label).arg(value)); 4055 QString temp = QString("%1").arg(value); 4056 temp += " ℃"; 4057 mInfo.appendChild(thermal); 4058 thermal.setAttribute("temperature", temp); 4059 } 4060 } 4061 } 4062 } 4063 } 4064 #endif 3987 4065 // Guide Data --------------------- 3988 4066 3989 4067 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" );