blob: c9b2680c35c50fe8148e19c850db5f4dd8cf3789 [file] [log] [blame]
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This test is overly simple right now, it'll just make sure that there are
# at least a few satellites seen (i.e. that signal can be received by the GPS).
# There are no checks to make sure that a fix can be had, nor of the precision
# or accurracy of said fix. That can either be handled by higher-level tests
# or added here later.
import logging, re
from autotest_lib.client.bin import test
from autotest_lib.client.common_lib import error, utils
class hardware_GobiGPS(test.test):
version = 1
def run_once(self):
sats_seen = {}
sats_signal = {}
got_fix = False
pos_lat = ""
pos_long = ""
nmea = utils.system_output('head -300 /tmp/gobi-nmea', timeout=60)
raise error.TestFail('GPS access failed')
for line in nmea.split('\n'):
line = line.strip()
# Satellites in view
if line.startswith('$GPGSV'):
line = line.rstrip('*0123456789ABCDEF')
fields = line.split(',')[4:]
while fields:
sat = fields[0]
if fields[3]:
sats_seen[sat] = True
sats_signal[sat] = fields[3]
sats_seen[sat] = True
fields = fields[4:]
# Recommended minimum specific GPS/Transit data
if line.startswith('$GPRMC'):
# Looks like Gobi has non-standard GPRMC with 13 fields, not 12.
match =
if match and == 'A' and not got_fix:
logging.debug('Got fix:')
logging.debug('Time = %s',
logging.debug('Status = %s',
logging.debug('Latitude = %s %s',,
logging.debug('Longitude = %s %s',,
logging.debug('Speed = %s',
logging.debug('Track Angle = %s',
logging.debug('Date = %s',
logging.debug('Magnetic Variation = %s %s',,
got_fix = True
pos_lat = '%s%s' % (,
pos_long = '%s%s' % (,
logging.debug('number of satellites seen %d: %s',
len(sats_seen), sats_seen)
logging.debug('number of satellites seen with signal strength %d: %s',
len(sats_signal), sats_signal)
if got_fix:'Got fix: %s %s' % (pos_lat, pos_long))
# Somewhat random criteria: Pass if you can see 5 at all, and at least 2
# enough to get a signal reading
if len(sats_signal) < 2 and len(sats_seen) < 5:
raise error.TestFail('Unable to find GPS signal')
else:'Saw %d GPS satellites, %d with signal strength',
len(sats_seen), len(sats_signal))