Dear David,
you can download the source from github:
https://github.com/hans-mayer/sat_usage
if there are any questions tell me.
// hans
==================================
Hans,
Many thanks for that that, most helpful! What I actually need is a
script (or whatever) which returns the number of satellites being used
by gpsd for a fix and I'll use this as input to MRTG (likely via the
SNMP pass mechanism). Although I am completely unfamiliar with Linux
shell commands, I've been able to simplify your script down to:
________________________________________
gpspipe -r | egrep --line-buffered 'GPGSA' | stdbuf -o0 gawk '-F,' '
{
CNT=0 ;
if ( $1 ~ /GPGSA/ ) {
for (i = 1; i <= NF; i++) {
if ( $i != "" ) {
# print ( $i ) ;
CNT++ ;
} ;
} ;
print ( CNT ) ;
} ;
}'
________________________________________
which is near to what I need, with two exceptions:
1 - The script runs continuously. What I need is just to get the
current number of satellites and exit. Run once, not every second.
Something like a "break" after printing the count. My Linux knowledge
isn't up to knowing how to do this!
2 - What I would like is also the number of satellites gpsd is actually
using for a fix. Comparing the script result with "cgps -s" for
example, the value returned by the script is the total number of
satellites in the right-hand cgps column, whereas I would also like the
number of satellites with "Y" against them - satellites being used.
Perhaps this is more complex. though?
BTW: gawk isn't in the default Raspberry Pi Wheezy distribution, but
easily obtained with apt-get.
Thanks,
David