Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Hardware sensors on *book
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC
View previous topic :: View next topic  
Author Message
micron
Guru
Guru


Joined: 23 Jul 2003
Posts: 411
Location: Bergamo, Italy

PostPosted: Mon Feb 23, 2004 10:40 am    Post subject: Hardware sensors on *book Reply with quote

I've searched in the forum without finding an answer... :(
On my pcs I use lm-sensors + i2c to collect hardware informations (like cpu temp & voltage,fan speed,...) so I thought to use it also on my ibook G4.
I'm runnning kernel 2.6.3_rc2-benh1, after compiling "i2c support" and "Powermac Keywest I2C interface" as a module I tyred:
Code:
emerge lm-sensors

I got the following error:
Code:
!!! ERROR: sys-apps/lm-sensors-2.6.5 failed.
!!! Function src_compile, Line 28, Exitcode 2
!!! lm_sensors requires the source of a compatible kernel\nversion installed in /usr/src/linux and i2c support built as a modules

It isn't possible to use lm-sensors on ibook :?:
I've looked on lm-sensors' supported card list and I've seen apple i2c cards...
How can I get hardware infos (also without using lm-sensors) :?:
_________________
~ "Progress is merely a realisation of utopias" ~
Back to top
View user's profile Send private message
rhale314159
n00b
n00b


Joined: 14 Dec 2003
Posts: 41
Location: East US

PostPosted: Wed Feb 25, 2004 5:30 am    Post subject: ibook temperature/lm-sensors Reply with quote

I don't think lm-sensors is working for powerPC hardware.
I have a Python program here that displays CPU temp, speed, fan speed, GPU temp, and battery level on a LCD-like gui. It
requires qt.
Back to top
View user's profile Send private message
micron
Guru
Guru


Joined: 23 Jul 2003
Posts: 411
Location: Bergamo, Italy

PostPosted: Wed Feb 25, 2004 8:32 am    Post subject: Re: ibook temperature/lm-sensors Reply with quote

rhale314159 wrote:
I don't think lm-sensors is working for powerPC hardware.
I have a Python program here that displays CPU temp, speed, fan speed, GPU temp, and battery level on a LCD-like gui. It
requires qt.

Great, can you post the link? :)
_________________
~ "Progress is merely a realisation of utopias" ~
Back to top
View user's profile Send private message
rhale314159
n00b
n00b


Joined: 14 Dec 2003
Posts: 41
Location: East US

PostPosted: Wed Feb 25, 2004 7:46 pm    Post subject: cpu temperature, fan speed display Reply with quote

I'll paste the code here, it's small enough. You'll need Python, Qt and PyQt.
Copy to a file, e.g. temp.py, then do chmod +x temp.py
To run ./temp/py


---------------------Program below-------------------

#! /usr/bin/env python


import sys
from qt import *
from string import atoi


class CPUTemp:
state_dir = "/sys/devices/temperatures/"

def __init__(self):
self.cpu_temperature = 0
self.gpu_temperature = 0
self.fan_speed = 0

def getcputemp(self):
input_data = open(self.state_dir+"cpu_temperature", 'r')
data_string = input_data.readline()
self.cpu_temperature = atoi(data_string[:2])
input_data.close()
return (self.cpu_temperature)

def getgputemp(self):
input_data = open(self.state_dir+"gpu_temperature", 'r')
data_string= input_data.readline()
self.gpu_temperature = atoi(data_string[:2])
input_data.close()
return (self.gpu_temperature)

def getfanspeed(self):
input_data = open(self.state_dir+"cpu_fan_speed", 'r')
data_string = input_data.readline()
self.fan_speed = atoi(data_string)
input_data.close()
return (self.fan_speed)

def getcpuspeed(self):
input_data = open("/proc/cpuinfo", 'r')
text = input_data.readlines()
input_data.close()

#Parse file, look for clock speed
speed = 0
for i in range(len(text)):
line = text[i]
if line[:5] == "clock":
break

for j in range(len(line)):
if line[j] == ":":
speed = atoi(line[(j + 2):(j + 5)])
break
return (speed)

def getbatterystatus(self):
input_data = open("/proc/apm")
text = input_data.readline()
input_data.close()

#Parse file
text_val = " "
for i in range(len(text)):
if text[i] == "%":
text_val = text[i-3] + text[i-2] + text[i-1]
break
charge = atoi(text_val)
return(charge)


#Define a LCD display and label object
class MyLCD(QWidget):
def __init__(self, parent, x, y, width, height, label):
self.display = QLCDNumber(4, parent)
self.display.setGeometry(x, y, width, height)
self.display.setSegmentStyle(QLCDNumber.Filled)
self.display.setFrameShape(QLCDNumber.NoFrame)
self.display.setPaletteForegroundColor(QColor(8,145,29))
self.display.setPaletteBackgroundColor(QColor(0,255,255))
self.display.setMidLineWidth(1)
self.display.setLineWidth(1)
self.display.setMargin(1)
self.display.display(8)

#Create a label for the LCD display
self.display.textLabel1 = QLabel(parent,"Label")
self.display.textLabel1.setGeometry(x, y-15, width, 13)
self.display.textLabel1.setScaledContents(1)
self.display.textLabel1.setText(label)
textLabel1_font = QFont(self.display.textLabel1.font())
textLabel1_font.setFamily("New Times Roman")
textLabel1_font.setPointSize(8)
textLabel1_font.setBold(1)
self.display.textLabel1.setFont(textLabel1_font)
self.display.textLabel1.setFrameShape(QLabel.NoFrame)
self.display.textLabel1.setFrameShadow(QLabel.Plain)
self.display.textLabel1.setTextFormat(QLabel.AutoText)
self.display.textLabel1.setScaledContents(1)


def set_lcd_value(self, value):
self.display.display(value)



#Define a window object with push button and LCD displays
class MyMainWindow(QWidget):
def __init__(self, parent):
QWidget.__init__(self)
self.setGeometry(100, 100, 150, 320)

#Make some LCD displays. Pass to the constructor x,y position, width, height, a label
self.lcd1 = MyLCD(self, 10, 20, 100, 40, "CPU Temp C")
self.lcd2 = MyLCD(self, 10, 80, 100, 40, "GPU Temp C")
self.lcd3 = MyLCD(self, 10, 140, 100, 40, "Fan Speed (RPM)")
self.lcd4 = MyLCD(self, 10, 200, 100, 40, "CPU Speed (MHz)")
self.lcd5 = MyLCD(self, 10, 260, 100, 40, "Battery (%)")

#Create a timer object. When the timer reaches zero send a signal to timer_slot()
self.timer1 = QTimer()
self.connect(self.timer1, SIGNAL("timeout()"), self.timer_slot)
self.timer1.start(1000, 0) #Update once per second

self.cpudata = CPUTemp()

#Come here when timer counts down to zero
def timer_slot(self):
self.lcd1.set_lcd_value(self.cpudata.getcputemp())
self.lcd2.set_lcd_value(self.cpudata.getgputemp())
self.lcd3.set_lcd_value(self.cpudata.getfanspeed())
self.lcd4.set_lcd_value(self.cpudata.getcpuspeed())
self.lcd5.set_lcd_value(self.cpudata.getbatterystatus())



#---------------------------------------------------Main--------------------------------------------
def main(args):
app=QApplication(args)
win = MyMainWindow(app)
app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
app.setMainWidget(win)
win.show()
app.exec_loop()
#--------------------------------------------------End of Main---------------------------------------------


#Run this as a script if running stand alone
if __name__=="__main__":
main(sys.argv)
Back to top
View user's profile Send private message
rhale314159
n00b
n00b


Joined: 14 Dec 2003
Posts: 41
Location: East US

PostPosted: Wed Feb 25, 2004 7:59 pm    Post subject: Reply with quote

Sorry, I think the Gentoo emailer stripped the tab characters from the program above. The code should be indented after each 'def', 'for' and 'if' keyword.
Back to top
View user's profile Send private message
capran
n00b
n00b


Joined: 01 Apr 2003
Posts: 48

PostPosted: Sat May 15, 2004 1:21 pm    Post subject: Reply with quote

Hi, I tried to get this to work, copied/pasted, removed smileys with colon-left paren and eight-right paren, and then went and indented all for, def, class, but now it doesn't work:

All I get is a crosshair pointer when I run it that lets me drag a box, and then:
Code:

./temp.py: line 6: from: command not found
./temp.py: line 7: from: command not found
./temp.py: line 10: class: command not found
./temp.py: line 11: state_dir: command not found
./temp.py: line 13: syntax error near unexpected token `('
./temp.py: line 13: `def __init__(self):'



I emerged python, pyqt, and libexif. And here's what I have:
Code:

#! /usr/bin/env python


import sys
from qt import *
from string import atoi


class CPUTemp:
        state_dir = "/sys/devices/temperatures/"

def __init__(self):
        self.cpu_temperature = 0
        self.gpu_temperature = 0
        self.fan_speed = 0

def getcputemp(self):
        input_data = open(self.state_dir+"cpu_temperature", 'r')
        data_string = input_data.readline()
        self.cpu_temperature = atoi(data_string[:2])
        input_data.close()
        return (self.cpu_temperature)

def getgputemp(self):
        input_data = open(self.state_dir+"gpu_temperature", 'r')
        data_string= input_data.readline()
        self.gpu_temperature = atoi(data_string[:2])
        input_data.close()
        return (self.gpu_temperature)

def getfanspeed(self):
        input_data = open(self.state_dir+"cpu_fan_speed", 'r')
        data_string = input_data.readline()
        self.fan_speed = atoi(data_string)
        input_data.close()
        return (self.fan_speed)

def getcpuspeed(self):
        input_data = open("/proc/cpuinfo", 'r')
        text = input_data.readlines()
        input_data.close()

#Parse file, look for clock speed
speed = 0
for i in range(len(text)):
        line = text[i]
        if line[:5] == "clock":
                break

for j in range(len(line)):
        if line[j] == ":":
                speed = atoi(line[(j + 2):(j + 5)])
                break
                return (speed)

def getbatterystatus(self):
        input_data = open("/proc/apm")
        text = input_data.readline()
        input_data.close()

#Parse file
text_val = " "
for i in range(len(text)):
        if text[i] == "%":
                text_val = text[i-3] + text[i-2] + text[i-1]
        break
charge = atoi(text_val)
return(charge)


#Define a LCD display and label object
class MyLCD(QWidget):
        def __init__(self, parent, x, y, width, height, label):
                self.display = QLCDNumber(4, parent)
                self.display.setGeometry(x, y, width, height)
                self.display.setSegmentStyle(QLCDNumber.Filled)
                self.display.setFrameShape(QLCDNumber.NoFrame)
                self.display.setPaletteForegroundColor(QColor(8,145,29))
                self.display.setPaletteBackgroundColor(QColor(0,255,255))
                self.display.setMidLineWidth(1)
                self.display.setLineWidth(1)
                self.display.setMargin(1)
                self.display.display(8)

#Create a label for the LCD display
self.display.textLabel1 = QLabel(parent,"Label")
self.display.textLabel1.setGeometry(x, y-15, width, 13)
self.display.textLabel1.setScaledContents(1)
self.display.textLabel1.setText(label)
textLabel1_font = QFont(self.display.textLabel1.font())
textLabel1_font.setFamily("New Times Roman")
textLabel1_font.setPointSize(8)
textLabel1_font.setBold(1)
self.display.textLabel1.setFont(textLabel1_font)
self.display.textLabel1.setFrameShape(QLabel.NoFrame)
self.display.textLabel1.setFrameShadow(QLabel.Plain)
self.display.textLabel1.setTextFormat(QLabel.AutoText)
self.display.textLabel1.setScaledContents(1)


def set_lcd_value(self, value):
        self.display.display(value)



#Define a window object with push button and LCD displays
class MyMainWindow(QWidget):
        def __init__(self, parent):
                QWidget.__init__(self)
                self.setGeometry(100, 100, 150, 320)

#Make some LCD displays. Pass to the constructor x,y position, width, height, a label
self.lcd1 = MyLCD(self, 10, 20, 100, 40, "CPU Temp C")
self.lcd2 = MyLCD(self, 10, 80, 100, 40, "GPU Temp C")
self.lcd3 = MyLCD(self, 10, 140, 100, 40, "Fan Speed (RPM)")
self.lcd4 = MyLCD(self, 10, 200, 100, 40, "CPU Speed (MHz)")
self.lcd5 = MyLCD(self, 10, 260, 100, 40, "Battery (%)")

#Create a timer object. When the timer reaches zero send a signal to timer_slot()
self.timer1 = QTimer()
self.connect(self.timer1, SIGNAL("timeout()"), self.timer_slot)
self.timer1.start(1000, 0) #Update once per second

self.cpudata = CPUTemp()

#Come here when timer counts down to zero
def timer_slot(self):
        self.lcd1.set_lcd_value(self.cpudata.getcputemp())
        self.lcd2.set_lcd_value(self.cpudata.getgputemp())
        self.lcd3.set_lcd_value(self.cpudata.getfanspeed())
        self.lcd4.set_lcd_value(self.cpudata.getcpuspeed())
        self.lcd5.set_lcd_value(self.cpudata.getbatterystatus())



#---------------------------------------------------Main--------------------------------------------
def main(args):
        app=QApplication(args)
        win = MyMainWindow(app)
        app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
        app.setMainWidget(win)
        win.show()
        app.exec_loop()
#--------------------------------------------------End of Main------------------------------------------
---


#Run this as a script if running stand alone
if __name__=="__main__":
        main(sys.argv)


My motherboard is a Powermac G4 Gigabit Ethernet, and my CPU is a OWC Mercury 1 GHz G4 w/ 2MB L3. When I cd "/sys/devices/temperatures/"
bash: cd: /sys/devices/temperatures/: No such file or directory

Help?
Back to top
View user's profile Send private message
lbrtuk
l33t
l33t


Joined: 08 May 2003
Posts: 910

PostPosted: Sat May 15, 2004 2:11 pm    Post subject: Reply with quote

lmsensors isn't needed for kernel 2.6: it's included in the kernel.

Device Drivers -> I2C support -> I2C Hardware Sensors Chip support
Back to top
View user's profile Send private message
micron
Guru
Guru


Joined: 23 Jul 2003
Posts: 411
Location: Bergamo, Italy

PostPosted: Sat May 15, 2004 3:02 pm    Post subject: Reply with quote

capran wrote:
My motherboard is a Powermac G4 Gigabit Ethernet, and my CPU is a OWC Mercury 1 GHz G4 w/ 2MB L3. When I cd "/sys/devices/temperatures/"
bash: cd: /sys/devices/temperatures/: No such file or directory

Help?

On my ibook G4 I've noticed that /sys/devices/temperatures/ is provided by this kernel module:
Code:
Support for thermal mgmnt on laptops with ADT 7467 chipset

Which is under the Macintosh device drivers section.
Try to enable this or:
Code:
Support for thermal management on Windtunnel G4s

_________________
~ "Progress is merely a realisation of utopias" ~
Back to top
View user's profile Send private message
tomasino
Apprentice
Apprentice


Joined: 11 Feb 2004
Posts: 154
Location: Italy, Bologna

PostPosted: Sat May 15, 2004 11:13 pm    Post subject: Reply with quote

I've loaded module "therm_adt746x", and he give me many info such as cputemp, cpufanspeed: but when this module is loaded, the fan work too much, as it never worked before! It's safe to use this module?

Byez, tomasino
Back to top
View user's profile Send private message
rhale314159
n00b
n00b


Joined: 14 Dec 2003
Posts: 41
Location: East US

PostPosted: Sun May 16, 2004 6:14 am    Post subject: therm_adt7467 Reply with quote

Hi!
You need to enable the therm_adt7467 kernel module to get all the fan
and temperature information under the /sys directory. I think it is under
the macintosh drivers section of the kernel config.

My fan does run faster and changes speed more often, keeping the ibook
I'm using much cooler.
Back to top
View user's profile Send private message
micron
Guru
Guru


Joined: 23 Jul 2003
Posts: 411
Location: Bergamo, Italy

PostPosted: Sun May 16, 2004 8:33 am    Post subject: Reply with quote

tomasino wrote:
when this module is loaded, the fan work too much, as it never worked before! It's safe to use this module?

My fan works as under macosx, the ibook is very silence. Don't worry, be happy! :lol:
_________________
~ "Progress is merely a realisation of utopias" ~
Back to top
View user's profile Send private message
Massimo B.
Veteran
Veteran


Joined: 09 Feb 2005
Posts: 1563
Location: Germany

PostPosted: Fri Jul 22, 2005 3:20 pm    Post subject: Reply with quote

Is there a way to get to know temperature, fan speed on a G3 iBook?
I didn't find something in /sys.
Is there no way with i2c?

At the moment I only read the temperature of hddtemp. :)
_________________
ppc:PowerBook5,8 15"(1440)-G4/1.67,2G|amd64:HP EliteBook 8560w,i7-2620M,16G|Acer Z5610 (Core2QuadQ8200),8G|amd64-prefix:OpenSuse|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770
Lila-Theme
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum