简体   繁体   English

gpsd和python:解释SKY数据

[英]gpsd & python: interpreting the SKY data

Having found http://www.catb.org/gpsd/client-howto.html I managed to get a bit of python (2.7) code that interprets the TPV class and handles it as desired. 找到http://www.catb.org/gpsd/client-howto.html之后,我设法获得了一些python(2.7)代码来解释TPV类并根据需要进行处理。 So far so good and kudos to the maintainer of that site. 到目前为止,一切都很好,对该站点的维护者表示敬意。 I get in trouble when I try to go a bit further and also interpret the SKY 'class', basically to know the number of satellites being used. 当我尝试进一步讲解天空“等级”时,基本上会知道所使用的卫星数量,这会给我带来麻烦。 I am however at a loss at how to decode/interpret the 'SKY' data. 但是,我对如何解码/解释“ SKY”数据不知所措。

Here is my basic code: 这是我的基本代码:

session = gps.gps(mode=gps.WATCH_ENABLE)
try:
    while True:
        report = session.next()
        ( ... )
        if report['class'] == 'SKY':
            print report

and here is sample output, with newlines inserted for readability: 这是示例输出,其中插入了换行符以提高可读性:

<dictwrapper: {u'gdop': 1.56, u'tdop': 0.66, u'vdop': 1.7, u'hdop': 1.42, u'pdop': 2.22, u'satellites':
 [<dictwrapper: {u'ss': 23, u'el': 26, u'PRN': 2, u'az': 237, u'used': True}>,
  <dictwrapper: {u'ss': 35, u'el': 55, u'PRN': 5, u'az': 293, u'used': True}>,
  <dictwrapper: {u'ss': 0, u'el': 5, u'PRN': 6, u'az': 197, u'used': False}>,
  <dictwrapper: {u'ss': 25, u'el': 63, u'PRN': 7, u'az': 76, u'used': True}>,
  <dictwrapper: {u'ss': 27, u'el': 27, u'PRN': 9, u'az': 87, u'used': True}>,
  <dictwrapper: {u'ss': 28, u'el': 24, u'PRN': 13, u'az': 267, u'used': True}>,
  <dictwrapper: {u'ss': 10, u'el': 4, u'PRN': 16, u'az': 18, u'used': False}>,
  <dictwrapper: {u'ss': 0, u'el': 3, u'PRN': 23, u'az': 89, u'used': False}>,
  <dictwrapper: {u'ss': 26, u'el': 8, u'PRN': 28, u'az': 151, u'used': True}>,
  <dictwrapper: {u'ss': 26, u'el': 68, u'PRN': 30, u'az': 173, u'used': True}>
  ],u'ydop': 0.56, u'tag': u'GSV', u'xdop': 0.64, u'device': u'/dev/ttyACM0', u'class': u'SKY'}>

What's this "dictwrapper" stuff and how can I parse it? 这是什么“ dictwrapper”的东西,我怎么解析呢? I reckon I want to count the fields with "True" to get the number of satellites being used? 我想我想用“ True”计数字段以获取正在使用的卫星数量?

Sometimes, it helps to properly word one's questions, and to look at them from a distance. 有时,它有助于正确表达一个人的问题,并能远距离查看它们。 I was able to resolve my little puzzle as follows: 我能够如下解决我的小难题:

session = gps.gps(mode=gps.WATCH_ENABLE)
    if report['class'] == 'SKY':
     #must get number of satellites from this one
     NSAT=0
     for SAT in report['satellites']:
      if SAT['used'] == True:
       NSAT += 1 
     print "Number of satellites used:",NSAT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM