Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions c/include/libsbp/piksi.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@
* This is a legacy message for sending and loading a satellite
* alamanac onto the Piksi's flash memory from the host.
*/
#define SBP_MSG_ALMANAC 0x0069
#define SBP_MSG_ALMANAC 0x0069


/** Send GPS time from host (host => Piksi)
*
* This message sets up timing functionality using a coarse GPS
* time estimate sent by the host.
*/
#define SBP_MSG_SET_TIME 0x0068
#define SBP_MSG_SET_TIME 0x0068


/** Reset the device (host => Piksi)
*
* This message from the host resets the Piksi back into the
* bootloader.
*/
#define SBP_MSG_RESET 0x00B2
#define SBP_MSG_RESET 0x00B2


/** Legacy message for CW interference channel (Piksi => host)
Expand All @@ -61,7 +61,7 @@
* CW interference channel on the SwiftNAP. This message will be
* removed in a future release.
*/
#define SBP_MSG_CW_RESULTS 0x00C0
#define SBP_MSG_CW_RESULTS 0x00C0


/** Legacy message for CW interference channel (host => Piksi)
Expand All @@ -70,15 +70,15 @@
* the CW interference channel on the SwiftNAP. This message will
* be removed in a future release.
*/
#define SBP_MSG_CW_START 0x00C1
#define SBP_MSG_CW_START 0x00C1


/** Reset IAR filters (host => Piksi)
*
* This message resets either the DGNSS Kalman filters or Integer
* Ambiguity Resolution (IAR) process.
*/
#define SBP_MSG_RESET_FILTERS 0x0022
#define SBP_MSG_RESET_FILTERS 0x0022
typedef struct __attribute__((packed)) {
u8 filter; /**< Filter flags */
} msg_reset_filters_t;
Expand All @@ -92,7 +92,7 @@ typedef struct __attribute__((packed)) {
* there aren't a shared minimum number (4) of satellite
* observations between the two.
*/
#define SBP_MSG_INIT_BASE 0x0023
#define SBP_MSG_INIT_BASE 0x0023


/** State of an RTOS thread
Expand All @@ -101,7 +101,7 @@ typedef struct __attribute__((packed)) {
* operating system (RTOS) thread usage statistics for the named
* thread. The reported percentage values require to be normalized.
*/
#define SBP_MSG_THREAD_STATE 0x0017
#define SBP_MSG_THREAD_STATE 0x0017
typedef struct __attribute__((packed)) {
char name[20]; /**< Thread name (NULL terminated) */
u16 cpu; /**< Percentage cpu use for this thread. Values range from 0
Expand Down Expand Up @@ -155,7 +155,7 @@ typedef struct __attribute__((packed)) {
* host access ports for embedded hosts, or other interfaces in
* future. The reported percentage values require to be normalized.
*/
#define SBP_MSG_UART_STATE 0x0018
#define SBP_MSG_UART_STATE 0x0018
typedef struct __attribute__((packed)) {
uart_channel_t uart_a; /**< State of UART A */
uart_channel_t uart_b; /**< State of UART B */
Expand All @@ -171,12 +171,24 @@ typedef struct __attribute__((packed)) {
* ambiguities from double-differenced carrier-phase measurements
* from satellite observations.
*/
#define SBP_MSG_IAR_STATE 0x0019
#define SBP_MSG_IAR_STATE 0x0019
typedef struct __attribute__((packed)) {
u32 num_hyps; /**< Number of integer ambiguity hypotheses remaining */
} msg_iar_state_t;


/** Mask a satellite from use in Piksi subsystems
*
* This message allows setting a mask to prevent a particular satellite
* from being used in various Piksi subsystems.
*/
#define SBP_MSG_MASK_SATELLITE 0x001B
typedef struct __attribute__((packed)) {
u8 mask; /**< Mask of systems that should ignore this satellite. */
u8 prn; /**< PRN for which the mask is applied */
} msg_mask_satellite_t;


/** \} */

#endif /* LIBSBP_PIKSI_MESSAGES_H */
76 changes: 76 additions & 0 deletions python/sbp/piksi.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,81 @@ def to_json_dict(self):
d.update(j)
return d

SBP_MSG_MASK_SATELLITE = 0x001B
class MsgMaskSatellite(SBP):
"""SBP class for message MSG_MASK_SATELLITE (0x001B).

You can have MSG_MASK_SATELLITE inherent its fields directly
from an inherited SBP object, or construct it inline using a dict
of its fields.


This message allows setting a mask to prevent a particular satellite
from being used in various Piksi subsystems.


Parameters
----------
sbp : SBP
SBP parent object to inherit from.
mask : int
Mask of systems that should ignore this satellite.
prn : int
PRN for which the mask is applied
sender : int
Optional sender ID, defaults to 0

"""
_parser = Struct("MsgMaskSatellite",
ULInt8('mask'),
ULInt8('prn'),)

def __init__(self, sbp=None, **kwargs):
if sbp:
self.__dict__.update(sbp.__dict__)
self.from_binary(sbp.payload)
else:
super( MsgMaskSatellite, self).__init__()
self.msg_type = SBP_MSG_MASK_SATELLITE
self.sender = kwargs.pop('sender', 0)
self.mask = kwargs.pop('mask')
self.prn = kwargs.pop('prn')

def __repr__(self):
return fmt_repr(self)

def from_binary(self, d):
"""Given a binary payload d, update the appropriate payload fields of
the message.

"""
p = MsgMaskSatellite._parser.parse(d)
self.__dict__.update(dict(p.viewitems()))

def to_binary(self):
"""Produce a framed/packed SBP message.

"""
c = containerize(exclude_fields(self))
self.payload = MsgMaskSatellite._parser.build(c)
return self.pack()

@staticmethod
def from_json(s):
"""Given a JSON-encoded string s, build a message object.

"""
d = json.loads(s)
sbp = SBP.from_json_dict(d)
return MsgMaskSatellite(sbp)

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


msg_classes = {
0x0069: MsgAlmanac,
Expand All @@ -617,4 +692,5 @@ def to_json_dict(self):
0x0017: MsgThreadState,
0x0018: MsgUartState,
0x0019: MsgIarState,
0x001B: MsgMaskSatellite,
}
2 changes: 1 addition & 1 deletion python/tests/sbp/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_table_count():
Test number of available messages to deserialize.

"""
number_of_messages = 52
number_of_messages = 53
assert len(_SBP_TABLE) == number_of_messages

def test_table_unqiue_count():
Expand Down
28 changes: 28 additions & 0 deletions spec/yaml/swiftnav/sbp/piksi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,31 @@ definitions:
- num_hyps:
type: u32
desc: Number of integer ambiguity hypotheses remaining

- MSG_MASK_SATELLITE:
id: 0x001B
short_desc: Mask a satellite from use in Piksi subsystems
desc: |
This message allows setting a mask to prevent a particular satellite
from being used in various Piksi subsystems.
fields:
- mask:
type: u8
desc: Mask of systems that should ignore this satellite.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't you actually want this to be something like:

        - mask:
            type: u8
            desc: Mask of systems that should ignore this satellite.
            fields:
                - 0:
                    desc: Acquisition channel
                    values:
                        - 0: Enabled
                        - 1: Skip this satellite on future acquisitions
                - 1:
                    desc: Tracking channels
                    values:
                        - 0: Enabled
                        - 1: Drop this PRN if currently tracking

As example:
https://github.com/gsmcmullin/libsbp/blob/mask_satellite/spec/yaml/swiftnav/sbp/navigation.yaml#L194

fields:
- 2-7:
desc: Reserved
- 1:
desc: Tracking channels
values:
- 0: Enabled
- 1: Drop this PRN if currently tracking
- 0:
desc: Acquisition channel
values:
- 0: Enabled
- 1: Skip this satellite on future acquisitions
- prn:
type: u8
desc: PRN for which the mask is applied