-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
13 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
""" | ||
@brief Core components for mode commanding (custom PUS service) | ||
""" | ||
import enum | ||
import struct | ||
|
||
|
||
def pack_mode_data(object_id: bytearray, mode_: int, submode_: int) -> bytearray: | ||
""" | ||
Mode 0: Off, Mode 1: Mode On, Mode 2: Mode Normal, Mode 3: Mode Raw | ||
class Modes(enum.IntEnum): | ||
OFF = 0, | ||
ON = 1, | ||
NORMAL = 2, | ||
RAW = 3 | ||
|
||
|
||
def pack_mode_data(object_id: bytearray, mode: Modes, submode: int) -> bytearray: | ||
"""Mode 0: Off, Mode 1: Mode On, Mode 2: Mode Normal, Mode 3: Mode Raw | ||
""" | ||
# Normal mode | ||
mode = struct.pack(">I", mode_) | ||
mode_packed = struct.pack("!I", mode) | ||
# Submode default | ||
submode = struct.pack('B', submode_) | ||
mode_data = object_id + mode + submode | ||
submode_byte = struct.pack('B', submode) | ||
mode_data = object_id + mode_packed + submode_byte | ||
return mode_data |