Пример #1
0
def mk_readable_msg(msg):
  """
  Produces a unit test case from a parsed SBP message. The case
  includes the raw output, the SBP message with unparsed payload, and
  the parsed SBP message

  Parameters
  ----------
  msg : Subclass of :class: `SBP`.
    Parsed SBP message.
  keys : list
    List of keys to remove from the rendered

  Returns
  ----------
  A dict formatted for a unit test case.

  """
  f = walk_json_dict(dict([(k, getattr(msg, k)) for k in msg.__slots__]))
  # Message includes fields from the SBP message it inherits from, so
  # remove those.
  i = {'raw_packet' : base64.standard_b64encode(msg.pack()),
       'raw_json'   : msg.to_json(),
       'msg_type'   : hex(msg.msg_type),
       'sbp'        : _to_readable_dict(msg),
       'msg'        : { 'module' : msg.__class__.__module__,
                        'name' : msg.__class__.__name__,
                        'fields' : f if f else None}}
  return i
Пример #2
0
  def to_json(self):
    """Produce a JSON-encoded SBP message.

    """
    d = super( MsgIarState, self).to_json_dict()
    j = walk_json_dict(exclude_fields(self))
    d.update(j)
    return json.dumps(d)
Пример #3
0
 def _process_tracking(self, host_offset, host_time, msg):
   if type(msg) is tr.MsgTrackingState:
     m = exclude_fields(msg)
     # Flatten a bit: reindex at the top level by prn and remove the
     # 'states' field from the message.
     for s in msg.states:
       m[s.prn] = walk_json_dict(s)
       m[s.prn].update({'host_offset': host_offset,
                        'host_time': host_time})
     del m['states']
     self.rover_tracking[host_offset] = m
Пример #4
0
 def _process_uart_state(self, host_offset, host_time, msg):
   if type(msg) is piksi.MsgUartState:
     m = exclude_fields(msg)
     for i in ['uart_a', 'uart_b' ,'uart_ftdi']:
       n = walk_json_dict(m[i])
       n['host_offset'] = host_offset
       n['host_time'] = host_time
       # Normalize to percentage from 255.
       n['rx_buffer_level'] = m[i]['rx_buffer_level'] / 255.
       n['tx_buffer_level'] = m[i]['tx_buffer_level'] / 255.
       if i in self.rover_uart_state:
         self.rover_uart_state[i].update({host_offset: n})
       else:
         self.rover_uart_state[i] = {host_offset: n}
     l = walk_json_dict(m['latency'])
     l['host_offset'] = host_offset
     l['host_time'] = host_time
     if 'latency' in self.rover_uart_state:
       self.rover_uart_state['latency'].update({host_offset: l})
     else:
       self.rover_uart_state['latency'] = {host_offset: l}
Пример #5
0
 def _process_tracking(self, host_offset, host_time, msg):
   if type(msg) in [tr.MsgTrackingState, tr.MsgTrackingStateDepA]:
     m = exclude_fields(msg)
     # Flatten a bit: reindex at the top level by prn and remove the
     # 'states' field from the message.
     for s in msg.states:
       d = walk_json_dict(s)
       prn = s.sid if msg.msg_type is tr.SBP_MSG_TRACKING_STATE else s.prn
       d['host_offset'] = host_offset
       d['host_time'] = host_time
       if prn in self.rover_tracking:
         self.rover_tracking[prn].update({host_offset: d})
       else:
         self.rover_tracking[prn] = {host_offset: d}
     del m['states']
Пример #6
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgSsrPhaseBiases, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #7
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgNetworkStateResp, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #8
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgCsacTelemetryLabels, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #9
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgSsrOrbitClock, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #10
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgEphemerisDepA, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #11
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgMaskSatellite, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #12
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgTrackingStateDetailedDep, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #13
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgMaskSatellite, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #14
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgBootloaderHandshakeDepA, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #15
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgNapDeviceDnaResp, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #16
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgBootloaderJumpToApp, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #17
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgM25FlashWriteStatus, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #18
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgMeasurementState, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #19
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgBootloaderJumpToApp, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #20
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgBootloaderHandshakeDepA, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #21
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgResetFilters, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #22
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgM25FlashWriteStatus, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #23
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgFileioWriteResp, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #24
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgTrackingIq, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #25
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgAcqResultDepB, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #26
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgCsacTelemetryLabels, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #27
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgAcqSvProfileDep, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #28
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgCommandOutput, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #29
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgHeartbeat, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #30
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgDeviceMonitor, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #31
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgSolnMetaDepA, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #32
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgSsrOrbitClockDepA, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #33
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgSettingsRegister, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #34
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgDeviceMonitor, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #35
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgFileioConfigResp, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #36
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgNapDeviceDnaResp, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #37
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgStmFlashUnlockSector, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #38
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgHeartbeat, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #39
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgSsrPhaseBiases, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #40
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgAcqSvProfile, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #41
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgBaselineHeading, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #42
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgFlashReadReq, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #43
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgOrientEuler, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #44
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgStmUniqueIdResp, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #45
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgSettingsReadByIndexReq, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #46
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgResetFilters, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #47
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgSettingsRegisterResp, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #48
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgMeasurementState, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #49
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgFlashErase, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #50
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgBasePosECEF, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d
Пример #51
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgStmFlashUnlockSector, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #52
0
 def to_json_dict(self):
     self.to_binary()
     d = super(MsgStmUniqueIdResp, self).to_json_dict()
     j = walk_json_dict(exclude_fields(self))
     d.update(j)
     return d
Пример #53
0
 def to_json_dict(self):
   self.to_binary()
   d = super( MsgOrientEuler, self).to_json_dict()
   j = walk_json_dict(exclude_fields(self))
   d.update(j)
   return d