Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Il vostro /proc/acpi/battery/BAT*/info ? [soft aggiornato]
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian)
View previous topic :: View next topic  
Author Message
federico
Advocate
Advocate


Joined: 18 Feb 2003
Posts: 3272
Location: Italy, Milano

PostPosted: Fri Jul 09, 2004 1:41 pm    Post subject: Il vostro /proc/acpi/battery/BAT*/info ? [soft aggiornato] Reply with quote

Non si tratta di un sondaggio per vedere chi ha la batteria piu' figa, ma dovrei scrivere una funzione che controlla la percentuale della batteria disponibile e volevo basarmi sulle informazioni restutuite dal proc.
Quello che non so e' quali voci sono presenti sempre, se possono cambiare e cosi' via.
Postate per favore il vostro "info" di modo che io possa fare la mia statistica :)

Code:

BAT1 # cat /proc/acpi/battery/BAT1/info
present:                 yes
design capacity:         4000 mAh
last full capacity:      4000 mAh
battery technology:      rechargeable
design voltage:          14800 mV
design capacity warning: 420 mAh
design capacity low:     156 mAh
capacity granularity 1:  264 mAh
capacity granularity 2:  3780 mAh
model number:            PA3206U
serial number:           3658Q
battery type:            Li-Ion
OEM info:                COMPAL   
altair BAT1 #


EDIT:

In aggiunta potrei vedere anche il file "state"? Nel solo info non si trova tutto quello che mi serve...

Code:

BAT1 # cat /proc/acpi/battery/BAT1/state
present:                 yes
capacity state:          ok
charging state:          discharging
present rate:            0 mA
remaining capacity:      3960 mAh
present voltage:         16431 mV
altair BAT1 #


Federico
_________________
Sideralis www.sideralis.org
Pic http://blackman.amicofigo.com/gallery
Arduino http://www.arduino.cc
Chi aveva potuto aveva spaccato
2000 pezzi buttati là
Molti saluti,qualche domanda
Semplice come musica punk


Last edited by federico on Tue Jul 13, 2004 2:49 pm; edited 1 time in total
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 31281
Location: here

PostPosted: Fri Jul 09, 2004 1:52 pm    Post subject: Reply with quote

E usare
Code:
*  sys-apps/acpi
      Latest version available: 0.06-r5
      Latest version installed: [ Not Installed ]
      Size of downloaded files: [no/bad digest]
      Homepage:    http://packages.debian.org/unstable/utils/acpi.html
      Description: Attempts to replicate the functionality of the 'old' apm command on ACPI systems, including battery and thermal information.

_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
federico
Advocate
Advocate


Joined: 18 Feb 2003
Posts: 3272
Location: Italy, Milano

PostPosted: Fri Jul 09, 2004 1:56 pm    Post subject: Reply with quote

Vorrei scriverlo proprio come alternativa, ritengo di ottenere una prestazione migliore in termini di velocita/spazio e dipendenze scrivendo la funzione per conto mio.

Sono un maniaco delle dipenze :) Mi scoccia scomodare "acpi" per valutare la percentuale di carica della batteria...
_________________
Sideralis www.sideralis.org
Pic http://blackman.amicofigo.com/gallery
Arduino http://www.arduino.cc
Chi aveva potuto aveva spaccato
2000 pezzi buttati là
Molti saluti,qualche domanda
Semplice come musica punk
Back to top
View user's profile Send private message
MyZelF
Bodhisattva
Bodhisattva


Joined: 25 Feb 2003
Posts: 2010
Location: Venice, Italy

PostPosted: Fri Jul 09, 2004 2:20 pm    Post subject: Reply with quote

Code:
$ cat /proc/acpi/battery/C11D/info
present:                 yes
design capacity:         4046 mAh
last full capacity:      4046 mAh
battery technology:      rechargeable
design voltage:          14800 mV
design capacity warning: 405 mAh
design capacity low:     0 mAh
capacity granularity 1:  100 mAh
capacity granularity 2:  100 mAh
model number:            Primary
serial number:           3952
battery type:            4E4F494C
OEM info:                 COMPAQ

$ cat /proc/acpi/battery/C11D/state
present:                 yes
capacity state:          ok
charging state:          charged
present rate:            0 mA
remaining capacity:      4046 mAh
present voltage:         16513 mV


Da notare che da me i due slot per la batteria sono visti come C11C e C11D
_________________
"Larry the Cow was a bit frustrated at the current state of Linux Distributions..."
Back to top
View user's profile Send private message
Marculin
Guru
Guru


Joined: 24 Feb 2004
Posts: 376

PostPosted: Fri Jul 09, 2004 2:24 pm    Post subject: Reply with quote

Code:

cat /proc/acpi/battery/BAT1/info
present:                 yes
design capacity:         4500 mAh
last full capacity:      4618 mAh
battery technology:      rechargeable
design voltage:          10800 mV
design capacity warning: 93 mAh
design capacity low:     0 mAh
capacity granularity 1:  1 mAh
capacity granularity 2:  1 mAh
model number:            XM2033P02   
serial number:           1700000183
battery type:            Li-ION 
OEM info:               



cat /proc/acpi/battery/BAT1/state
present:                 yes
capacity state:          ok
charging state:          charging
present rate:            1541 mA
remaining capacity:      4484 mAh
present voltage:         11330 mV

facci sapere ;)
_________________
Non capisco perchè continuavo ad avere cosi paura della shell.....è cosi bella :)
Back to top
View user's profile Send private message
.:deadhead:.
Advocate
Advocate


Joined: 25 Nov 2003
Posts: 2963
Location: Milano, Italy

PostPosted: Fri Jul 09, 2004 2:25 pm    Post subject: Reply with quote

Code:
root@INSPIRON8600 # cat /proc/acpi/battery/BAT0/info
present:                 yes
design capacity:         72000 mWh
last full capacity:      66460 mWh
battery technology:      rechargeable
design voltage:          11100 mV
design capacity warning: 3000 mWh
design capacity low:     1000 mWh
capacity granularity 1:  200 mWh
capacity granularity 2:  200 mWh
model number:            DELL 0002P6
serial number:           998
battery type:            LION
OEM info:                Sanyo

root@INSPIRON8600 # cat /proc/acpi/battery/BAT0/state
present:                 yes
capacity state:          ok
charging state:          charged
present rate:            unknown
remaining capacity:      72000 mWh
present voltage:         12522 mV

_________________
Proudly member of the Gentoo Documentation Project: the Italian Conspiracy ! ;)
Back to top
View user's profile Send private message
OKreZ
Guru
Guru


Joined: 27 Apr 2003
Posts: 372
Location: Padova (IT)

PostPosted: Fri Jul 09, 2004 2:44 pm    Post subject: Reply with quote

Code:
okrez@gloglotto okrez $ cat /proc/acpi/battery/BAT0/info
present:                 yes
design capacity:         6450 mAh
last full capacity:      4377 mAh
battery technology:      rechargeable
design voltage:          14800 mV
design capacity warning: 437 mAh
design capacity low:     132 mAh
capacity granularity 1:  5 mAh
capacity granularity 2:  5 mAh
model number:            DELL 0008T
serial number:           591
battery type:            LION
OEM info:                Sanyo

okrez@gloglotto okrez $ cat /proc/acpi/battery/BAT0/state
present:                 yes
capacity state:          ok
charging state:          charged
present rate:            unknown
remaining capacity:      6450 mAh
present voltage:         16639 mV

_________________
(HCS)OKreZ
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 31281
Location: here

PostPosted: Fri Jul 09, 2004 2:46 pm    Post subject: Reply with quote

federico wrote:
Vorrei scriverlo proprio come alternativa

Scusa non avevo capito. Purtroppo io non ho acpi quindi non posso postare niente
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
Sasdo
Guru
Guru


Joined: 18 Feb 2004
Posts: 542
Location: 44.476474,11.644446 circa.

PostPosted: Fri Jul 09, 2004 2:46 pm    Post subject: Reply with quote

Code:

info:

present:                 yes
design capacity:         4000 mAh
last full capacity:      2354 mAh
battery technology:      rechargeable
design voltage:          14800 mV
design capacity warning: 300 mAh
design capacity low:     100 mAh
capacity granularity 1:  1 mAh
capacity granularity 2:  1 mAh
model number:            G733
serial number:           1
battery type:            LION
OEM info:                ECS Cop.

state:

present:                 yes
capacity state:          ok
charging state:          charging
present rate:            625 mA
remaining capacity:      2294 mAh
present voltage:         16752 mV

_________________
LinuxUser #362518
--
Ochei lo ammetto: il mio cervello lo tengo in frigo.
Back to top
View user's profile Send private message
paperp
Guru
Guru


Joined: 27 Feb 2004
Posts: 544
Location: Toscana , Italy

PostPosted: Fri Jul 09, 2004 2:56 pm    Post subject: Reply with quote

Code:
l-(emanuele 2.6.7-gentoo)-(09 July 2004 - 16:47)-(dschg, 37%)-(pts/2)
mq-(~)-> cat /proc/acpi/battery/BAT1/info
present:                 yes
design capacity:         4500 mAh
last full capacity:      4500 mAh
battery technology:      rechargeable
design voltage:          14800 mV
design capacity warning: 420 mAh
design capacity low:     156 mAh
capacity granularity 1:  264 mAh
capacity granularity 2:  3780 mAh
model number:            PXBAS008
serial number:           3658Q
battery type:            LiIon
OEM info:                CPT

l-(emanuele 2.6.7-gentoo)-(09 July 2004 - 16:47)-(dschg, 37%)-(pts/2)
mq-(~)-> cat /proc/acpi/battery/BAT1/state
present:                 yes
capacity state:          ok
charging state:          discharging
present rate:            0 mA
remaining capacity:      1665 mAh
present voltage:         14400 mV


:wink:
Back to top
View user's profile Send private message
federico
Advocate
Advocate


Joined: 18 Feb 2003
Posts: 3272
Location: Italy, Milano

PostPosted: Fri Jul 09, 2004 3:16 pm    Post subject: Reply with quote

fedeliallalinea wrote:
Purtroppo io non ho acpi quindi non posso postare niente


Dopo magari passiamo a APM :)
_________________
Sideralis www.sideralis.org
Pic http://blackman.amicofigo.com/gallery
Arduino http://www.arduino.cc
Chi aveva potuto aveva spaccato
2000 pezzi buttati là
Molti saluti,qualche domanda
Semplice come musica punk
Back to top
View user's profile Send private message
federico
Advocate
Advocate


Joined: 18 Feb 2003
Posts: 3272
Location: Italy, Milano

PostPosted: Fri Jul 09, 2004 3:19 pm    Post subject: Reply with quote

Sono tutti simili fortunamente proprio come speravo. L'unica differenza mi pare di notarla con myzelf che non ha batX ma C11C o C11D. Chissa' che significhera' poi...

Hai due batterie? La C e' la prima e la D la seconda?
Potrei in linea di massima leggere la lista delle dir dentro /proc/acpi, sortarle in ordine alfabetico e prendere la prima e lavorare su quella... Eventualmente ricavare i dati da tutte e due ...
_________________
Sideralis www.sideralis.org
Pic http://blackman.amicofigo.com/gallery
Arduino http://www.arduino.cc
Chi aveva potuto aveva spaccato
2000 pezzi buttati là
Molti saluti,qualche domanda
Semplice come musica punk
Back to top
View user's profile Send private message
MonsterMord
Guru
Guru


Joined: 28 Apr 2004
Posts: 395
Location: Italy --> Forli'

PostPosted: Fri Jul 09, 2004 9:44 pm    Post subject: Reply with quote

Code:
cat /proc/acpi/battery/BAT0/info
present:                 yes
design capacity:         71990 mWh
last full capacity:      55300 mWh
battery technology:      rechargeable
design voltage:          11100 mV
design capacity warning: 3000 mWh
design capacity low:     1000 mWh
capacity granularity 1:  200 mWh
capacity granularity 2:  200 mWh
model number:            DELL 4P259
serial number:           294
battery type:            LION
OEM info:                Panasonic

cat /proc/acpi/battery/BAT0/state
present:                 yes
capacity state:          ok
charging state:          charged
present rate:            unknown
remaining capacity:      71990 mWh
present voltage:         12417 mV

cat /proc/acpi/battery/BAT0/alarm
alarm:                   3000 mWh

cat /proc/acpi/battery/BAT1/info
present: no
:P
_________________
Gentoo GNU/Linux on DELL Inspiron 8500
Back to top
View user's profile Send private message
MyZelF
Bodhisattva
Bodhisattva


Joined: 25 Feb 2003
Posts: 2010
Location: Venice, Italy

PostPosted: Fri Jul 09, 2004 9:48 pm    Post subject: Reply with quote

federico wrote:
Hai due batterie? La C e' la prima e la D la seconda?


Ho una sola batteria (C11D), ma nello slot multi funzione (cd) potrei piazzarne una seconda.

E' una seccatura che i nomi non siano "standard", visto che ho già dovuto mettere mano agli script invocati da acpid.
_________________
"Larry the Cow was a bit frustrated at the current state of Linux Distributions..."
Back to top
View user's profile Send private message
X-Drum
Advocate
Advocate


Joined: 24 Aug 2003
Posts: 2517
Location: ('Modica','Trieste','Ferrara') Italy

PostPosted: Fri Jul 09, 2004 10:01 pm    Post subject: Reply with quote

Code:
x-drum@Storm x-drum $ cat /proc/acpi/battery/BAT0/info
present:                 yes
design capacity:         4000 mAh
last full capacity:      4000 mAh
battery technology:      rechargeable
design voltage:          14800 mV
design capacity warning: 120 mAh
design capacity low:     120 mAh
capacity granularity 1:  10 mAh
capacity granularity 2:  4280 mAh
model number:            Bat 8Cell
serial number:           001
battery type:            Lion
OEM info:                Acer


Code:
x-drum@Storm x-drum $ cat /proc/acpi/battery/BAT0/state
present:                 yes
capacity state:          ok
charging state:          discharging
present rate:            unknown
remaining capacity:      3640 mAh
present voltage:         14800 mV

_________________
"...There are two sort of lies, lies and benchmarks..."
Back to top
View user's profile Send private message
federico
Advocate
Advocate


Joined: 18 Feb 2003
Posts: 3272
Location: Italy, Milano

PostPosted: Mon Jul 12, 2004 3:42 pm    Post subject: Reply with quote

Dunque, ho scritto un programma che vi domanderei di testare, non fa nulla di preoccupante, scrive quanta batteria e rimasta in percentuale prendendole informazioni dalla prima batteria disponibile.
Se qualcuno avesse due batterie e fosse disponibile a 10 minuti di betatesting potrebbe contattarmi in privato.

Questo e' il link al programma:

http://www.sideralis.net/blackman/bat_percent.py

potete avviarlo con "python bat_percent.py"

Ed ecco il codice:
Code:

#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
import os

try:
    batDir=os.listdir('/proc/acpi/battery')
    batDir.sort()
    batDir=batDir[0]
except OSError:
    import sys
    print >> sys.stderr, 'Could not find acpi battery directory'
    sys.exit(1)

def getValues(path,findMe):
    fp=file(path)
    text=fp.readlines()
    for line in text:
        if line.startswith(findMe):
            value=line.split()[-2]
            break
    fp.close()
    return value

startPath='/proc/acpi/battery/'+batDir
totCapacity=getValues(startPath+'/info','design capacity:')
remCapacity=getValues(startPath+'/state','remaining capacity:')

bat_percent=int(remCapacity)*100/int(totCapacity)
print 'La tua batteria è al %d%%' % bat_percent


Grazie a tutti, Federico
_________________
Sideralis www.sideralis.org
Pic http://blackman.amicofigo.com/gallery
Arduino http://www.arduino.cc
Chi aveva potuto aveva spaccato
2000 pezzi buttati là
Molti saluti,qualche domanda
Semplice come musica punk
Back to top
View user's profile Send private message
4440
Tux's lil' helper
Tux's lil' helper


Joined: 25 Jul 2002
Posts: 106

PostPosted: Mon Jul 12, 2004 4:01 pm    Post subject: Reply with quote

Quote:
present: yes
design capacity: 4400 mAh
last full capacity: 3904 mAh
battery technology: rechargeable
design voltage: 14800 mV
design capacity warning: 300 mAh
design capacity low: 200 mAh
capacity granularity 1: 32 mAh
capacity granularity 2: 32 mAh
model number: ZP02
serial number: 1
battery type: LION
OEM info: SIMPLO


boh
Back to top
View user's profile Send private message
federico
Advocate
Advocate


Joined: 18 Feb 2003
Posts: 3272
Location: Italy, Milano

PostPosted: Mon Jul 12, 2004 4:06 pm    Post subject: Reply with quote

Perfavore provate il software ora piuttosto che postare le info, il lavoro di ricerca e' completato 8)
_________________
Sideralis www.sideralis.org
Pic http://blackman.amicofigo.com/gallery
Arduino http://www.arduino.cc
Chi aveva potuto aveva spaccato
2000 pezzi buttati là
Molti saluti,qualche domanda
Semplice come musica punk
Back to top
View user's profile Send private message
MyZelF
Bodhisattva
Bodhisattva


Joined: 25 Feb 2003
Posts: 2010
Location: Venice, Italy

PostPosted: Mon Jul 12, 2004 9:43 pm    Post subject: Reply with quote

Code:
$ python bat_percent.py
Traceback (most recent call last):
  File "bat_percent.py", line 25, in ?
    totCapacity=getValues(startPath+'/info','design capacity:')
  File "bat_percent.py", line 22, in getValues
    return value
UnboundLocalError: local variable 'value' referenced before assignment

_________________
"Larry the Cow was a bit frustrated at the current state of Linux Distributions..."
Back to top
View user's profile Send private message
federico
Advocate
Advocate


Joined: 18 Feb 2003
Posts: 3272
Location: Italy, Milano

PostPosted: Mon Jul 12, 2004 9:59 pm    Post subject: Reply with quote

Mi mostreresti perfavore anche la tua altra dir della batteria? penso che il software ti abbia letto la c11c mentre probabilmente li non trova i dati che servono...
Il tuo pc e' una buona palestra per tutto questo :)
_________________
Sideralis www.sideralis.org
Pic http://blackman.amicofigo.com/gallery
Arduino http://www.arduino.cc
Chi aveva potuto aveva spaccato
2000 pezzi buttati là
Molti saluti,qualche domanda
Semplice come musica punk
Back to top
View user's profile Send private message
MyZelF
Bodhisattva
Bodhisattva


Joined: 25 Feb 2003
Posts: 2010
Location: Venice, Italy

PostPosted: Mon Jul 12, 2004 10:04 pm    Post subject: Reply with quote

Code:
$ cat /proc/acpi/battery/C11C/info
present:                 no
$ cat /proc/acpi/battery/C11C/state
present:                 no

_________________
"Larry the Cow was a bit frustrated at the current state of Linux Distributions..."
Back to top
View user's profile Send private message
OKreZ
Guru
Guru


Joined: 27 Apr 2003
Posts: 372
Location: Padova (IT)

PostPosted: Mon Jul 12, 2004 10:15 pm    Post subject: Reply with quote

federico wrote:
Perfavore provate il software ora piuttosto che postare le info, il lavoro di ricerca e' completato 8)
Code:
okrez@gloglotto okrez $ python Downloads/bat_percent.py
La tua batteria e' al 100%
okrez@gloglotto okrez $

_________________
(HCS)OKreZ
Back to top
View user's profile Send private message
federico
Advocate
Advocate


Joined: 18 Feb 2003
Posts: 3272
Location: Italy, Milano

PostPosted: Tue Jul 13, 2004 4:35 am    Post subject: Reply with quote

Grazie myzelf e okrez, sto preparando la correzione...
_________________
Sideralis www.sideralis.org
Pic http://blackman.amicofigo.com/gallery
Arduino http://www.arduino.cc
Chi aveva potuto aveva spaccato
2000 pezzi buttati là
Molti saluti,qualche domanda
Semplice come musica punk
Back to top
View user's profile Send private message
federico
Advocate
Advocate


Joined: 18 Feb 2003
Posts: 3272
Location: Italy, Milano

PostPosted: Tue Jul 13, 2004 2:56 pm    Post subject: Reply with quote

Ecco il codice aggiornato e rivisto, dovrebbe essere in grado di maneggiare uno slot vuoto e di mostrare l'utilizzo anche per piu' di una batteria

http://www.sideralis.net/blackman/acpi.py

Questa non dovrebbe avere problemi, nel caso me lo fate sapere?

Code:

#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
import os

acpibattery_path='/proc/acpi/battery'

try:
    batDir=os.listdir(acpibattery_path)
    batDir.sort()
except OSError:
    import sys
    print >> sys.stderr, 'Could not find acpi battery directory'
    sys.exit(1)

def getValues(path,findMe):
    fp=file(path)
    text=fp.readlines()
    for line in text:
        if line.startswith(findMe):
            value=line.split()
            break
    fp.close()
    return value

bat_percent=[]

for batNum in batDir:
    startPath= acpibattery_path +'/'+ batNum
    isPresent=getValues(startPath+'/info','present:')[-1]
    if isPresent.lower()=='yes':
        totCapacity=getValues(startPath+'/info','design capacity:')[-2]
        remCapacity=getValues(startPath+'/state','remaining capacity:')[-2]
        bat_percent.append(int(remCapacity)*100/int(totCapacity))
    else:
        #print "Empty Slot Found"
        pass

from output import *
for i in bat_percent:
    if i>=70 :
        print green('%d%%' % i),
    elif i<=30 :
        print red('%d%%' % i),
    else :
        print yellow('%d%%' % i),

_________________
Sideralis www.sideralis.org
Pic http://blackman.amicofigo.com/gallery
Arduino http://www.arduino.cc
Chi aveva potuto aveva spaccato
2000 pezzi buttati là
Molti saluti,qualche domanda
Semplice come musica punk
Back to top
View user's profile Send private message
MyZelF
Bodhisattva
Bodhisattva


Joined: 25 Feb 2003
Posts: 2010
Location: Venice, Italy

PostPosted: Wed Jul 14, 2004 1:04 pm    Post subject: Reply with quote

ok, ora funziona anche da me

Code:
$ python acpi.py
98%

_________________
"Larry the Cow was a bit frustrated at the current state of Linux Distributions..."
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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