![]() |
Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
Quote:
$ sudo gainroot # bnf You need to have rootsh package installed :-) http://wiki.maemo.org/Root Best wishes. ~~~~~~~~~~~~~~~~~ Per aspera ad astra... |
Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
Quote:
|
Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
Quote:
Like 45 for me: NAC=$( $NAC * 3570 / $RS / 1000 ) # NAC Nominal available capacity, mAh. No idea what's wrong with your file. Best wishes. |
Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
Ugh, initially I wrote: "Not bothering to look inside the script itself, but some comments which may help the next person to look zero in on the problem"... but then nooo... I just had to go digging.
Anyway, I looked at this and it looked wrong, so I figured it was a someone-wrote-out-what-they-thought-they-saw-instead-of-copy-pasting style of error. And sure enough, this is wrong, that is not what line 45 looks like: Code:
NAC=$( $NAC * 3570 / $RS / 1000 ) Looking at the line as quoted, I would imagine you meant arithmetic expansion rather than command substition? If so, it would look like this: Code:
NAC=$(($NAC * 3570 / $RS / 1000)) As a sidenote, this assumes $NAC and $RS will never have whitespace inside them (or be blank). I habitually double-quote any usage of $VAR_NAME unless I expressly know it's guaranteed to be unnecessary. So it would look like so: Code:
NAC=$(("$NAC" * 3570 / "$RS" / 1000)) However, while we're at it, the dollar signs (and thus doublequotes) are actually redundant. Since this is an arithmetic expansion we're working with, we can just write: Code:
NAC=$((NAC * 3570 / RS / 1000)) Anyway, back to the syntax error: Quote:
Here is an example test command replicating that kind of syntax error: Code:
$ A= B=1; echo $(($A * $B)) The busybox-power ash shell will instead print: Code:
-sh: arithmetic syntax error Anyway, point is, we see that $NAC is defined on line 16 (of the same file, obviously) with the command: Code:
i2cget -y 2 0x55 0x0c w So, speedonwilliam, try running the following and let us know what the result is: Code:
sudo i2cget -y 2 0x55 0x0c w |
Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
Quote:
So anyway, I would daisy-chain the VAR_NAME=$(i2cget [...]) commands with '&&', and stick them in a negated if check, so that you can abort out, like so: Code:
if ! \ # Code:
i2cget_wrapperWithError() |
Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
@speedonwilliam
Sorry, I've, somehow, missed update on this thread. Anyway, thanks for trying to solve/solving Wikiwide and Mentalist - indeed, do as Mentalist said, and we will be able to proceed after getting a meaningful output. If the "sudo i2cget" thing doesn't produce output, try issuing it without sudo, but from root shell. @Mentalist Traceur Thanks for your insights on the "code", all dully noted, I'll experiment with upgrading the script when I'll have some free time. BTW, that happens, when someone with actual knowledge inspects totally "noobishly" written code :p Well, at least I seem to *do* understand the mechanics behind your suggestions, and that is something, already... /Estel |
Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
Quote:
"But will this one-off shell script break if a user has a newline in their input?" are the kinds of questions which keep me up at night. |
Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
Woops, I made an error, right here:
Quote:
Consequently, I am less confident about my assertion that $(($SOME_VAR + 1)) would be any less efficient than $((SOME_VAR + 1)). I guess I don't remember the parsing rules with regard to arithmetic expansion as well as I thought I did. |
Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
Thank you all for your help. I really appreciate it but d truth is i'm a noob :-D so I really dont understand what you guys are saying. Anyway thanks once again.
Quote:
sudo i2cget -y 2 0x55 0x0c w nothing happens. Also follöwed your instruction and tried it without sudo but from the root shell n i get thesame message: Error: Read failed |
Re: [Announce] bnf - nifty little tool, allowing to have battery info at glance
OK, so for some reasons, your chip doesn't report nominal available capacity, at all... Now I just need to refresh my memory about what it means ;D
|
All times are GMT. The time now is 09:01. |
vBulletin® Version 3.8.8