Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > getting resource information: battery level and more

Reply
Thread Tools

getting resource information: battery level and more

 
 
Maria
Guest
Posts: n/a
 
      02-01-2004
Hi all !

I am trying to find a way to return the battery level of a notebook or
laptop or any mobile device (but to make it simple a laptop would be
fine).
I am trying to do this because I'm building for a project a small part
of an interface for a computational grid that would accommodate in
adition to the usual devices, wireless ones too.
( So I'm trying to measure what a device will be able to offer to the
Grid ... the next step will be to measure what applications are
running on a device and so on. )
I am doing this with Java on two computers, a desktop PC with Windows
2000 and a laptop with Windows XP.
Although I have not entirely given up on Java yet, there is no command
to get me what I want so the only way to do it would be through Java
Native Interface. That is I will have to do it in C or C++.
I would be most grateful if you could suggest anyway at all to get the
battery level in Java, C or C++ or maybe using any J2ME or JINI
libraries.

Thanks !
Maria
 
Reply With Quote
 
 
 
 
Papadopoulos Giannis
Guest
Posts: n/a
 
      02-02-2004
Maria wrote:
> Although I have not entirely given up on Java yet, there is no command
> to get me what I want so the only way to do it would be through Java
> Native Interface. That is I will have to do it in C or C++.
> I would be most grateful if you could suggest anyway at all to get the
> battery level in Java, C or C++ or maybe using any J2ME or JINI
> libraries.
>
> Thanks !
> Maria

OT, you should ask in a OS-related newsgroup (btw, are u using Win or
Linux?)

--
#include <stdio.h>
#define p(s) printf(#s" endian")
int main(void){int v=1;0[(char*)&v]?p(Little)(Big);return 0;}

Giannis Papadopoulos
http://dop.users.uth.gr/
University of Thessaly
Computer & Communications Engineering dept.
 
Reply With Quote
 
 
 
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      02-02-2004
In comp.lang.c Maria <(E-Mail Removed)> wrote:

(posted only to c.l.c, crosspost ended)

> I am trying to find a way to return the battery level of a notebook or
> laptop or any mobile device (but to make it simple a laptop would be
> fine).


Your post is off-topic for comp.lang.c. Please visit

http://www.csclub.uwaterloo.ca/u/dj3...lc-welcome.txt
http://www.eskimo.com/~scs/C-faq/top.html
http://benpfaff.org/writings/clc/off-topic.html

for posting guidelines and frequently asked questions. Thank you.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
 
Reply With Quote
 
Maria
Guest
Posts: n/a
 
      02-02-2004
Thank you very very much for your reply!
I will post my message to a Windows related newsgroup. I have looked
at those newsgroups and they mostly have posts about operating system
problems instead of programming issues and this is what led me to post
here since I am looking for the c command.

> btw, are u using Win or
> Linux?
>

I am using a computer with Windows 2000 and one with XP , everything
I've done so far works perfectly well on both of them.
Also I do know the command that will do it for linux and it is
something like "cat /proc/apm" but the trick is to make it multi
platform .
What I am planning is to check the environment variable for os name
and then act accordingly. So now it is down to the windows bit I am
afraid.

Thanks a lot for all your help anyway ,
Maria
 
Reply With Quote
 
Thomas Matthews
Guest
Posts: n/a
 
      02-02-2004
Maria wrote:

> Thank you very very much for your reply!
> I will post my message to a Windows related newsgroup. I have looked
> at those newsgroups and they mostly have posts about operating system
> problems instead of programming issues and this is what led me to post
> here since I am looking for the c command.
>
>
>>btw, are u using Win or
>>Linux?
>>

>
> I am using a computer with Windows 2000 and one with XP , everything
> I've done so far works perfectly well on both of them.
> Also I do know the command that will do it for linux and it is
> something like "cat /proc/apm" but the trick is to make it multi
> platform .
> What I am planning is to check the environment variable for os name
> and then act accordingly. So now it is down to the windows bit I am
> afraid.
>
> Thanks a lot for all your help anyway ,
> Maria


I got a lot of articles by using Google and the terms
"Windows" "API" "Battery".


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

 
Reply With Quote
 
Maria Gaitani
Guest
Posts: n/a
 
      02-02-2004
Thank you but I am not looking for a command that I can get from windows
API, I have that already ... I am looking for a method or procedure ... I
don't
know c .. I am only using Java... it's just the only solution I can thing of
right now.
Thank you for taking the time to reply really ...but please don't suggest
that I don't know how to search google.
Besides I don't think there is no harm in asking ... although I do admit I
should have added an "off topic" term in my subject, which I did not think
of .. before sending the post.
Sorry..
Maria
"Thomas Matthews" <(E-Mail Removed)> wrote in
message news:K7zTb.2896$(E-Mail Removed) m...
> Maria wrote:
>
> > Thank you very very much for your reply!
> > I will post my message to a Windows related newsgroup. I have looked
> > at those newsgroups and they mostly have posts about operating system
> > problems instead of programming issues and this is what led me to post
> > here since I am looking for the c command.
> >
> >
> >>btw, are u using Win or
> >>Linux?
> >>

> >
> > I am using a computer with Windows 2000 and one with XP , everything
> > I've done so far works perfectly well on both of them.
> > Also I do know the command that will do it for linux and it is
> > something like "cat /proc/apm" but the trick is to make it multi
> > platform .
> > What I am planning is to check the environment variable for os name
> > and then act accordingly. So now it is down to the windows bit I am
> > afraid.
> >
> > Thanks a lot for all your help anyway ,
> > Maria

>
> I got a lot of articles by using Google and the terms
> "Windows" "API" "Battery".
>
>
> --
> Thomas Matthews
>
> C++ newsgroup welcome message:
> http://www.slack.net/~shiva/welcome.txt
> C++ Faq: http://www.parashift.com/c++-faq-lite
> C Faq: http://www.eskimo.com/~scs/c-faq/top.html
> alt.comp.lang.learn.c-c++ faq:
> http://www.raos.demon.uk/acllc-c++/faq.html
> Other sites:
> http://www.josuttis.com -- C++ STL Library book
>



 
Reply With Quote
 
Rob Thorpe
Guest
Posts: n/a
 
      02-03-2004
"Maria Gaitani" <(E-Mail Removed)> wrote in message news:<401ed7ce$0$18645$(E-Mail Removed)> ...
> Thank you but I am not looking for a command that I can get from windows
> API, I have that already ... I am looking for a method or procedure ... I
> don't
> know c .. I am only using Java... it's just the only solution I can thing of
> right now.
> Thank you for taking the time to reply really ...but please don't suggest
> that I don't know how to search google.
> Besides I don't think there is no harm in asking ... although I do admit I
> should have added an "off topic" term in my subject, which I did not think
> of .. before sending the post.
> Sorry..
> Maria
> "Thomas Matthews" <(E-Mail Removed)> wrote in
> message news:K7zTb.2896$(E-Mail Removed) m...
> > Maria wrote:
> >
> > > Thank you very very much for your reply!
> > > I will post my message to a Windows related newsgroup. I have looked
> > > at those newsgroups and they mostly have posts about operating system
> > > problems instead of programming issues and this is what led me to post
> > > here since I am looking for the c command.
> > >
> > >
> > >>btw, are u using Win or
> > >>Linux?
> > >>
> > >
> > > I am using a computer with Windows 2000 and one with XP , everything
> > > I've done so far works perfectly well on both of them.
> > > Also I do know the command that will do it for linux and it is
> > > something like "cat /proc/apm" but the trick is to make it multi
> > > platform .
> > > What I am planning is to check the environment variable for os name
> > > and then act accordingly. So now it is down to the windows bit I am
> > > afraid.
> > >
> > > Thanks a lot for all your help anyway ,
> > > Maria


Standard C functions can't do such things. You will need a OS
specific call each time.

Goto
comp.unix.programmer
comp.os.ms-windows.programmer.*
comp.os.linux.development.apps.*

I wouldn't test an environmental variable to get the OS, I'd write a
different makefile for each OS (or use a tool that does such things).
 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      02-04-2004
On Mon, 2 Feb 2004 23:06:31 -0000, in comp.lang.c , "Maria Gaitani"
<(E-Mail Removed)> wrote:

>Thank you but I am not looking for a command that I can get from windows
>API, I have that already ... I am looking for a method or procedure ... I
>don't know c ..


C doesn't have methods or procedures, it only has functions. But more
importantly, when it comes to system-specific stuff like you want, you
have to use the native APIs, in your case windows or linux. So you
already have your answer.

>Besides I don't think there is no harm in asking ... although I do admit I
>should have added an "off topic" term in my subject, which I did not think
>of .. before sending the post.


For your information, asking offtopic questions in Comp.lang.c and
comp.lang.c++ will get you a polite redirection (like you got) to
either google or a platform-specific group. If you continue to ask
offtopic questions, you will get much less polite answers. Adding
"offtopic" to the subject will not help.....

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
 
Reply With Quote
 
Maria Gaitani
Guest
Posts: n/a
 
      02-04-2004
Thank you very much for your reply .
I didn't quite understand the last bit. That is because I am not familiar
with c at all.

> I'd write a
> different makefile for each OS (or use a tool that does such things).


I would appreciate it if you could explain a little bit what you mean. I
don't know what a makefile is basically. Only now I'm starting to learn how
to use c and this is only due to the needs of the project.
May I also ask why you would not test the environmental variable ? Is it
just because it is not the right way to do it or is it not reliable for some
reason ?

Thanks again for your reply ,
Maria


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Low-level vs High-level Programming" and a lot more... Scorpiion VHDL 1 12-25-2008 04:27 PM
c is a low-level language or neither low level nor high level language pabbu C Programming 8 11-07-2005 03:05 PM
Resource manager problem: naming for embedded resource. Dirc Khan-Evans ASP .Net 1 10-17-2005 12:52 PM
The system cannot locate the resource specified. Error processing resource avishosh XML 2 08-08-2004 06:28 AM
getting resource information: battery level and more Maria C++ 10 02-04-2004 12:34 AM



Advertisments