Find the answer to your Linux question:
Results 1 to 8 of 8
Hi, I am working on leopard board DM355 with 2.6.10 linux kernel.I jst wanna read the status of battery. How ll i do it using a c program?? If anyone ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2011
    Posts
    68

    how to get battery status ?


    Hi,
    I am working on leopard board DM355 with 2.6.10 linux kernel.I jst wanna read the status of battery. How ll i do it using a c program??
    If anyone knows plz help me.

    Thanks

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,453
    Most of this stuff is accessible easily in the /proc directory tree, such as in the /proc/acpi/battery directory. More than that I can't say right now since I am running from a workstation/server with no battery resources.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Administrator jayd512's Avatar
    Join Date
    Feb 2008
    Location
    Kentucky
    Posts
    5,023
    For me, in Slackware:
    Code:
    $ cat /proc/acpi/battery/BAT0/state
    Code:
    $ cat /proc/acpi/battery/BAT0/info
    All battery information is found there.
    Jay

    New users, read this first.
    New Member FAQ
    Registered Linux User #463940
    I do not respond to private messages asking for Linux help. Please keep it on the public boards.

  4. #4
    Just Joined!
    Join Date
    Nov 2011
    Posts
    68
    I already checked that but in /proc/ directory there is no acpi.
    Last edited by steffi; 03-19-2012 at 07:05 AM.

  5. #5
    Administrator jayd512's Avatar
    Join Date
    Feb 2008
    Location
    Kentucky
    Posts
    5,023
    What is the output of
    Code:
    ls /proc/
    Jay

    New users, read this first.
    New Member FAQ
    Registered Linux User #463940
    I do not respond to private messages asking for Linux help. Please keep it on the public boards.

  6. #6
    Just Joined!
    Join Date
    Nov 2011
    Posts
    68
    output of
    ls proc

    1 3 buddyinfo execdomains locks stat
    10 4 bus fb meminfo swaps
    1050 5 cmdline filesystems misc sys
    1052 691 cmem fs modules sysvipc
    1092 736 config.gz gio mounts tty
    1094 754 cpu interrupts mtd uptime
    1109 94 cpuinfo iomem net version
    1111 95 crypto ioports partitions vmstat
    1114 954 devices kallsyms scsi yaffs
    19 96 diskstats kmsg self
    2 97 driver loadavg slabinfo


    Now battery is not connected to the board but it will be adding later.
    Last edited by steffi; 03-19-2012 at 07:22 AM.

  7. #7
    Administrator jayd512's Avatar
    Join Date
    Feb 2008
    Location
    Kentucky
    Posts
    5,023
    You might have to dig a bit...
    What about
    Code:
    cd /proc
    ls -l
    I'm thinking that devices might be the directory that you need to look at.
    Dig around in there... let us know what you come up with.
    Jay

    New users, read this first.
    New Member FAQ
    Registered Linux User #463940
    I do not respond to private messages asking for Linux help. Please keep it on the public boards.

  8. #8
    Just Joined!
    Join Date
    Nov 2011
    Posts
    68
    Now there is no battery connected to our board but later on will be adding .

    output of
    cd /proc
    ls -l

    # ls -l
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 1
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 10
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 1050
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 1052
    dr-xr-xr-x 3 root root 0 Jan 3 05:48 1092
    dr-xr-xr-x 3 root root 0 Jan 3 05:48 1094
    dr-xr-xr-x 3 root root 0 Jan 3 05:48 1109
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 1111
    dr-xr-xr-x 3 root root 0 Jan 3 06:02 1116
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 19
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 2
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 3
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 4
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 5
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 691
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 736
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 754
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 94
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 95
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 954
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 96
    dr-xr-xr-x 3 root root 0 Jan 3 05:47 97
    -r--r--r-- 1 root root 0 Jan 3 06:02 buddyinfo
    dr-xr-xr-x 3 root root 0 Jan 3 06:02 bus
    -r--r--r-- 1 root root 0 Jan 3 06:02 cmdline
    -r--r--r-- 1 root root 0 Jan 3 06:02 cmem
    -r--r--r-- 1 root root 6446 Jan 3 06:02 config.gz
    dr-xr-xr-x 2 root root 0 Jan 3 06:02 cpu
    -r--r--r-- 1 root root 0 Jan 3 06:02 cpuinfo
    -r--r--r-- 1 root root 0 Jan 3 06:02 crypto
    -r--r--r-- 1 root root 0 Jan 3 06:02 devices
    -r--r--r-- 1 root root 0 Jan 3 06:02 diskstats
    dr-xr-xr-x 2 root root 0 Jan 3 06:02 driver
    -r--r--r-- 1 root root 0 Jan 3 06:02 execdomains
    -r--r--r-- 1 root root 0 Jan 3 06:02 fb
    -r--r--r-- 1 root root 0 Jan 3 06:02 filesystems
    dr-xr-xr-x 3 root root 0 Jan 3 06:02 fs
    dr-xr-xr-x 2 root root 0 Jan 3 06:02 gio
    -r--r--r-- 1 root root 0 Jan 3 06:02 interrupts
    -r--r--r-- 1 root root 0 Jan 3 06:02 iomem
    -r--r--r-- 1 root root 0 Jan 3 06:02 ioports
    -r--r--r-- 1 root root 0 Jan 3 06:02 kallsyms
    -r-------- 1 root root 0 Jan 3 06:02 kmsg
    -r--r--r-- 1 root root 0 Jan 3 06:02 loadavg
    -r--r--r-- 1 root root 0 Jan 3 06:02 locks
    -r--r--r-- 1 root root 0 Jan 3 06:02 meminfo
    -r--r--r-- 1 root root 0 Jan 3 06:02 misc
    -r--r--r-- 1 root root 0 Jan 3 06:02 modules
    lrwxrwxrwx 1 root root 11 Jan 3 06:02 mounts -> self/mounts
    -r--r--r-- 1 root root 0 Jan 3 06:02 mtd
    dr-xr-xr-x 5 root root 0 Jan 3 06:02 net
    -r--r--r-- 1 root root 0 Jan 3 06:02 partitions
    dr-xr-xr-x 2 root root 0 Jan 3 06:02 scsi
    lrwxrwxrwx 1 root root 64 Jan 3 05:47 self -> 1116
    -rw-r--r-- 1 root root 0 Jan 3 06:02 slabinfo
    -r--r--r-- 1 root root 0 Jan 3 06:02 stat
    -r--r--r-- 1 root root 0 Jan 3 06:02 swaps
    dr-xr-xr-x 10 root root 0 Jan 3 06:02 sys
    dr-xr-xr-x 2 root root 0 Jan 3 06:02 sysvipc
    dr-xr-xr-x 4 root root 0 Jan 3 06:02 tty
    -r--r--r-- 1 root root 0 Jan 3 06:02 uptime
    -r--r--r-- 1 root root 0 Jan 3 06:02 version
    -r--r--r-- 1 root root 0 Jan 3 06:02 vmstat
    -r--r--r-- 1 root root 0 Jan 3 06:02 yaffs
    #

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •