コード例 #1
0
ファイル: modes_sql.py プロジェクト: chgans/gr-air-modes
  def make_insert_query(self, message):
    #assembles a SQL query tailored to our database
    #this version ignores anything that isn't Type 17 for now, because we just don't care
    [data, ecc, reference, timestamp] = message.split()

    data = modes_parse.modes_reply(long(data, 16))
    ecc = long(ecc, 16)
#   reference = float(reference)


    query = None
    msgtype = data["df"]
    if msgtype == 17:
      query = self.sql17(data)

    return query
コード例 #2
0
ファイル: modes_print.py プロジェクト: wyrdough/gr-air-modes
  def parse(self, message):
    [data, ecc, reference, timestamp] = message.split()

    ecc = long(ecc, 16)
    reference = float(reference)
    timestamp = float(timestamp)

    if reference == 0.0:
      refdb = -150.0
    else:
      refdb = 20.0*math.log10(reference)
    output = "(%.0f %.10f) " % (refdb, timestamp);

    try:
      data = modes_parse.modes_reply(long(data, 16))
      msgtype = data["df"]
      if msgtype == 0:
        output += self.print0(data, ecc)
      elif msgtype == 4:
        output += self.print4(data, ecc)
      elif msgtype == 5:
        output += self.print5(data, ecc)
      elif msgtype == 11:
        output += self.print11(data, ecc)
      elif msgtype == 17:
        output += self.print17(data)
      elif msgtype == 20 or msgtype == 21:
        output += self.print20(data, ecc)
      else:
        output += "No handler for message type %i from %x (but it's in modes_parse)" % (msgtype, ecc)
      print output
    except NoHandlerError as e:
      output += "No handler for message type %s from %x" % (e.msgtype, ecc)
      print output
    except MetricAltError:
      pass
    except CPRNoPositionError:
      pass
コード例 #3
0
ファイル: modes_sbs1.py プロジェクト: wyrdough/gr-air-modes
  def parse(self, message):
    #assembles a SBS-1-style output string from the received message

    [data, ecc, reference, timestamp] = message.split()

    data = modes_parse.modes_reply(long(data, 16))
    ecc = long(ecc, 16)
    msgtype = data["df"]
    outmsg = None

    if msgtype == 0:
      outmsg = self.pp0(data, ecc)
    elif msgtype == 4:
      outmsg = self.pp4(data, ecc)
    elif msgtype == 5:
      outmsg = self.pp5(data, ecc)
    elif msgtype == 11:
      outmsg = self.pp11(data, ecc)
    elif msgtype == 17:
      outmsg = self.pp17(data)
    else:
      raise NoHandlerError(msgtype)
    return outmsg
コード例 #4
0
  def parse(self, message):
    # Get a current timestamp. Hopefully in the future we'll have a real one even on rtl_sdr devices

    # Ok, so get the time, subtract the stored time from it, multiply by a billion, divide by 62
    # and increment the 6mhz counter by that result

    now = time.time()
    adj = round(((now - self._time) * 1000000000) / 62, 0)
    self._six += adj
    self._time = now
    fakestamp = "%012x" % self._six

    #Parse it for type so we can output the correct message type
    [rawdata, ecc, reference, timestamp] = message.split()

    data = modes_parse.modes_reply(long(rawdata, 16))
    ecc = long(ecc, 16)
    msgtype = data["df"]

    signal = "%02x" % int(round(float(reference) * 255))

    if msgtype == 17:
      # Long
      hexout = "1a33"
    else:
      # We don't deal in mode a/c (yet?), so we can ignore the third possibility
      # Short
      hexout = "1a32"

    hexout += fakestamp
    hexout += signal
    hexout += rawdata
    
#    print "At %.9f TS now %d, delta %d (%d ns)" % (self._time, self._six, adj, adj * 62)
  
    return self.HexToByte(hexout)