Skip to content

Commit

Permalink
better mode code
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Sep 13, 2021
1 parent 0d858a8 commit 38be11c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/tmtccmd/tc/service_200_mode.py
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

0 comments on commit 38be11c

Please sign in to comment.